Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:23

0001 #ifndef FUN4ALL_YEAR1_C
0002 #define FUN4ALL_YEAR1_C
0003 
0004 #include <caloreco/CaloTowerBuilder.h>
0005 #include <caloreco/CaloTowerCalib.h>
0006 #include <caloreco/CaloTowerStatus.h>
0007 #include <caloreco/CaloWaveformProcessing.h>
0008 
0009 #include <ffamodules/CDBInterface.h>
0010 #include <ffamodules/FlagHandler.h>
0011 #include <ffamodules/HeadReco.h>
0012 #include <ffamodules/SyncReco.h>
0013 
0014 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0015 
0016 #include <fun4all/Fun4AllDstInputManager.h>
0017 #include <fun4all/Fun4AllDstOutputManager.h>
0018 #include <fun4all/Fun4AllInputManager.h>
0019 #include <fun4all/Fun4AllRunNodeInputManager.h>
0020 #include <fun4all/Fun4AllServer.h>
0021 #include <fun4all/Fun4AllUtils.h>
0022 #include <fun4all/SubsysReco.h>
0023 
0024 #include <phool/recoConsts.h>
0025 
0026 #include <calovalid/CaloValid.h>
0027 
0028 #include <litecaloeval/HCalCosmics.h>
0029 
0030 R__LOAD_LIBRARY(libfun4all.so)
0031 R__LOAD_LIBRARY(libfun4allraw.so)
0032 R__LOAD_LIBRARY(libcalo_reco.so)
0033 R__LOAD_LIBRARY(libcentrality.so)
0034 R__LOAD_LIBRARY(libffamodules.so)
0035 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
0036 
0037 void Fun4All_HCalCosmics(int nEvents = 100, 
0038                    const std::string &fname = "DST_TRIGGERED_EVENT_run2pp_new_2024p003-00048185-0000.root",
0039                    const std::string &outfile = "DST_CALOFITTING-00000000-000000.root",
0040                    const std::string& outfile_hist1= "HIST_HCALOUT-00000000-000000.root",
0041                    const std::string& outfile_hist2= "HIST_HCALIN-00000000-000000.root",                   
0042                    const std::string &dbtag = "ProdA_2024")
0043 {
0044   bool useDSTRAW = true;
0045   // v1 uncomment:
0046   // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs:::kPRDFTowerv1;
0047   // v2 uncomment:
0048   CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2;
0049   // v3 uncomment:
0050   // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform;
0051 
0052   Fun4AllServer *se = Fun4AllServer::instance();
0053   se->Verbosity(0);
0054 
0055   recoConsts *rc = recoConsts::instance();
0056 
0057   pair<int, int> runseg = Fun4AllUtils::GetRunSegment(fname);
0058   int runnumber = runseg.first;
0059 
0060   // conditions DB flags and timestamp
0061   rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0062   rc->set_uint64Flag("TIMESTAMP", runnumber);
0063   CDBInterface::instance()->Verbosity(1);
0064 
0065   FlagHandler *flag = new FlagHandler();
0066   se->registerSubsystem(flag);
0067 
0068   /////////////////
0069   // build towers
0070   CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0071   ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0072   ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0073   ctbIHCal->set_builder_type(buildertype);
0074   ctbIHCal->set_nsamples(12);
0075   if (useDSTRAW) ctbIHCal->set_offlineflag();
0076   ctbIHCal->set_softwarezerosuppression(true, 200);
0077   se->registerSubsystem(ctbIHCal);
0078 
0079   CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0080   ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0081   ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0082   ctbOHCal->set_builder_type(buildertype);
0083   ctbOHCal->set_nsamples(12);
0084   if (useDSTRAW) ctbOHCal->set_offlineflag();
0085   ctbOHCal->set_softwarezerosuppression(true, 200);
0086   se->registerSubsystem(ctbOHCal);
0087 
0088   CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
0089   statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN);
0090   statusHCalIn->set_time_cut(10);
0091   se->registerSubsystem(statusHCalIn);
0092 
0093   CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
0094   statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT);
0095   statusHCALOUT->set_time_cut(10);
0096   se->registerSubsystem(statusHCALOUT);
0097 
0098   ////////////////////
0099   // Calibrate towers
0100   std::cout << "Calibrating OHcal" << std::endl;
0101   CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
0102   calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0103   se->registerSubsystem(calibOHCal);
0104 
0105   std::cout << "Calibrating IHcal" << std::endl;
0106   CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
0107   calibIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0108   se->registerSubsystem(calibIHCal);
0109 
0110   std::cout << "Adding Geometry file" << std::endl;
0111   Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0112   std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0113   intrue2->AddFile(geoLocation);
0114   se->registerInputManager(intrue2);
0115 
0116   ///////////////////////////////////////////
0117   // Cosmics histMaker 
0118   HCalCosmics *wt2 = new HCalCosmics("HCalCalib_HCALIN",outfile_hist2);
0119   wt2->set_tower_threshold(0.2498); //500*0.0004996=0.2498
0120   wt2->set_vert_threshold(0.2498); //500*0.0004996=0.2498
0121   wt2->set_veto_threshold(0.17486); //350*0.0004996=0.17486
0122   wt2->HistBinWidth(0.01);
0123   wt2->Detector("HCALIN");
0124   wt2->TowerPrefix("TOWERINFO_CALIB_");
0125   se->registerSubsystem(wt2);
0126 
0127   HCalCosmics *wt3 = new HCalCosmics("HCalCosmics_HCALOUT",outfile_hist1);
0128   wt3->set_tower_threshold(1.665); //500*0.00333=1.665 
0129   wt3->set_vert_threshold(1.665); //500*0.00333=1.665
0130   wt3->set_veto_threshold(1.1655); //350*0.00333=1.1655
0131   wt3->HistBinWidth(0.05);
0132   wt3->Detector("HCALOUT");
0133   wt3->TowerPrefix("TOWERINFO_CALIB_");
0134   se->registerSubsystem(wt3);
0135 /*
0136   ///////////////////////////////////
0137   // Validation 
0138   CaloValid *ca = new CaloValid("calomodulename",fulloutfile_hist);
0139   ca->set_timing_cut_width(200);  //integers for timing width, > 1 : wider cut around max peak time
0140   ca->apply_vertex_cut(false);
0141   ca->set_vertex_cut(20.);
0142   se->registerSubsystem(ca);
0143 */
0144 
0145   Fun4AllInputManager *In;
0146   if(!useDSTRAW) In = new Fun4AllPrdfInputManager("in");
0147   if(useDSTRAW)  In = new Fun4AllDstInputManager("in");
0148   In->AddFile(fname);
0149   se->registerInputManager(In);
0150 
0151   Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile);
0152   out->StripNode("CEMCPackets");
0153   out->StripNode("HCALPackets");
0154   out->StripNode("ZDCPackets");
0155   out->StripNode("SEPDPackets");
0156   out->StripNode("MBDPackets");
0157   se->registerOutputManager(out);
0158 
0159   se->run(nEvents);
0160   se->End();
0161   CDBInterface::instance()->Print();  // print used DB files
0162   se->PrintTimer();
0163   delete se;
0164 
0165   std::cout << "All done!" << std::endl;
0166   gSystem->Exit(0);
0167 }
0168 
0169 #endif