Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:16

0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003 #include <string>
0004 #include <sstream>
0005 #include <vector>
0006 #include <utility>
0007 #include <fun4all/Fun4AllBase.h>
0008 #include <fun4all/Fun4AllServer.h>
0009 #include <fun4all/Fun4AllInputManager.h>
0010 #include <fun4all/Fun4AllDstInputManager.h>
0011 #include <fun4all/SubsysReco.h>
0012 #include <calorimetertowerenc/CalorimeterTowerENC.h>
0013 
0014 R__LOAD_LIBRARY(libfun4all.so)
0015 R__LOAD_LIBRARY(libcalo_io.so)
0016 R__LOAD_LIBRARY(libffamodules.so)
0017 R__LOAD_LIBRARY(libCalorimeterTowerENC.so)
0018 
0019 int CompareParticlesToTowers(std::string truthjetfile, std::string calotowersfile, std::string truthrecofile, std::string globalrecofile, std::string truthhitfile, std::string segments, std::string n_evt)
0020 {
0021     std::cout<<"Input truth jet: " <<truthjetfile <<"\n Input calo towers: " <<calotowersfile <<"\n Input truth reco: " <<truthrecofile <<"\n Input Global reco: " 
0022             <<globalrecofile <<" Input truth hit file: " <<truthhitfile <<"\n Run for " <<n_evt <<" events" <<std::endl;
0023 //  Global_Reco(); 
0024     Fun4AllServer* se=Fun4AllServer::instance();
0025     Fun4AllDstInputManager *truthjet   = new Fun4AllDstInputManager("truthjet");
0026     Fun4AllDstInputManager *calotower  = new Fun4AllDstInputManager("calotower");
0027     Fun4AllDstInputManager *globalreco = new Fun4AllDstInputManager("globalreco");
0028     Fun4AllDstInputManager *truthreco  = new Fun4AllDstInputManager("truthreco");
0029     Fun4AllDstInputManager *truthhit  = new Fun4AllDstInputManager("truthhit");
0030     std::vector<std::pair<std::string, Fun4AllDstInputManager*>> inputdst {{truthjetfile, truthjet}, {calotowersfile, calotower}, {truthrecofile, truthreco}, {globalrecofile, globalreco}, {truthhitfile, truthhit}};
0031     int n_evts=std::stoi(n_evt), run_number=15, DST_Segment=std::stoi(segments);
0032     for(auto input:inputdst)
0033     {
0034         std::stringstream filename (input.first);
0035         std::string runf="", segnf="", substr;
0036         if(run_number == 0){
0037             while(std::getline(filename, substr, '-')){
0038                 if(run_number >= 0){
0039                     runf=substr;
0040                     try{
0041                         run_number=std::stoi(runf);
0042                     }
0043                     catch(std::exception& e){ run_number = -1; }
0044                 }
0045                 else if(DST_Segment >= 0){
0046                     segnf=substr;
0047                     try{
0048                         DST_Segment=std::stoi(segnf);
0049                     }
0050                     catch(std::exception& e ) { DST_Segment = -1; }
0051                 }
0052             }
0053         }
0054         if(run_number < 0 || DST_Segment < 0 ){
0055             run_number = 0;
0056             DST_Segment = 0;
0057         }
0058         try{
0059             input.second->AddFile(input.first);
0060             se->registerInputManager(input.second);
0061         }
0062         catch(std::exception& e) {}
0063     }
0064     CalorimeterTowerENC* CalEval=new CalorimeterTowerENC(run_number, DST_Segment);
0065     std::cout<<"The Calorimeter tower has output file name " <<CalEval->outfilename <<std::endl;
0066     se->registerSubsystem(CalEval);
0067     se->run(n_evts);
0068     CalEval->Print();
0069     return 0;
0070 }
0071 #endif