void emc_repack(const char* clusFile, const char* digiFile, const char* simFile, const char* outFile, Int_t events=0, const char* parFile="simparams_hc7g5kG4.root") { // Loads files with hits and digitised hits and performs reconstruction for EMC // Set runClusOnline to kFALSE to use default clustering algorithms (will use online version if set to kTRUE) // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 1; // Input file (MC events) // // Number of events to process Int_t nEvents=events; // if 0 all the events will be processed if (nEvents !=0) std::cout << "will process " << nEvents << " events" << std::endl; else std::cout << "all events will be processed" << std::endl; // Digitisation file (ascii) TString parFile_Ascii = "emc.par"; // Loading libraries // If the macro gives error messages in loading libraries, please check the path of the libs and put it by hands // gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); // gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); //rootlogon(); //basiclibs(); // ----- Timer ----------------------------------------- TStopwatch timer; timer.Start(); // --------------------------------------------------------- // ----- Reconstruction run ---------------------------- FairRunAna *fRun= new FairRunAna(); fRun->SetInputFile(clusFile); fRun->AddFriend(simFile); fRun->AddFriend(digiFile); fRun->SetOutputFile(outFile); fRun->SetUseFairLinks(kTRUE); // ----- Parameter database ----------------------------- FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(parFile_Ascii.Data(),"in"); rtdb->setFirstInput(parIo1); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile); rtdb->setSecondInput(parInput1); // --------------------------------------------------------- Bool_t storebumps = kTRUE; fRun->RunWithTimeStamps(); // no setting is needed, because this correction only makes sense for timebased sim //pack sorted clusters into "events" PndEmcPackClusters* packerTask = new PndEmcPackClusters(iVerbose); fRun->AddTask(packerTask); PndEmcMakeBump* bumperTask = new PndEmcMakeBump(iVerbose, storebumps); //fRun->AddTask(bumperTask); // ----- Before repacking, check that sorting was successful --- TFile *f = new TFile(clusFile); TTree *t1 = (TTree*)f->Get("cbmsim"); // Get the Tree from the root file int nEvents = t1->GetEntries(); std::vector tVector; double dt = 0; int faultCounter = 0; for (int i=0; iSetBranchAddress("EmcClusterSorted",&clusterArray); t1->GetEntry(i); // Get number of entries of leaf int len = clusterArray->GetEntriesFast(); for (int j=0; jAt(j); tVector.push_back(myCluster->GetTimeStamp()); } } for (int k=0; k 5) cout << "[WARNING] Sorting failed " << faultCounter << " times. " << endl; // ----- Intialise and run ----------------------------- gRandom->SetSeed(); cout << "fRun->Init()" << endl; fRun->Init(); cout << "fRun->Run()" << endl; fRun->Run(0,nEvents); // --------------------------------------------------------- // ----- Finish ---------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished successfully." << endl; cout << "Output file is " << outFile << endl; cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; cout << endl; // --------------------------------------------------------- exit(0); }