// C/C++ headers // #include #include #include #include #include // // ROOT headers // #include #include #include #include #include #include #include #include #include #include #include #include #include #include // // RunInfo header // #include #include #include //PamVMC headers #include "PamVMCDigMgr.h" #include "PamVMCTrkHit.h" #include "PamVMCTrkF77GpsSpe.h" #include "PamVMCPrimaryGenerator.h" using namespace std; //This program is standalone Digitizer for PamVMC void Usage (); TClonesArray* FindColl(TTree*t, TString brname, TString type = "PamVMCDetectorHit"); void RegisterPDG(); //Here user should define all nuclei and particles that are not in PDG tabe of ROOT //otherwise application will crash on TOF digitization whrer charge information needed; void UnCompressCalo(TClonesArray* cal_comp, TClonesArray & cal_u); int main(int argc, char * argv[] ){ if(argc!=3){ Usage(); return 0; } TString DataPATH = gSystem->Getenv("PWD"); TString inputfilename(argv[1]); if(!inputfilename.Contains(".root")){ cerr<<"Error! Not root file on input!"<Get("hits"); if(!hits_tree){ cerr<<"Tree hits are not found in file "<GetName()<GetName(); treename.Replace(treename.Index(".root",5),5,""); hits_tree = (TTree*)rfin->Get(treename); if(!hits_tree) return 0; } TObjArray * frndArr = new TObjArray(); hits_tree->SetBranchAddress("RNDM",&frndArr); PamVMCRndMgr* rnd_mgr = PamVMCRndMgr::Instance_ext(); cout<<"dmdr"<RegisterCollections("C1D1", FindColl(hits_tree,"C1D1")); ac->RegisterCollections("C2D1", FindColl(hits_tree,"C2D1")); ac->RegisterCollections("TOP1", FindColl(hits_tree,"TOP1")); ac->RegisterCollections("SID1", FindColl(hits_tree,"SID1")); //TOF: S11Y, S12X, S21X, S22Y, S31Y, S32X PamVMCTofDig* tof = new PamVMCTofDig(); tof->RegisterCollections("S11Y", FindColl(hits_tree,"S11Y")); tof->RegisterCollections("S12X", FindColl(hits_tree,"S12X")); tof->RegisterCollections("S21X", FindColl(hits_tree,"S21X")); tof->RegisterCollections("S22Y", FindColl(hits_tree,"S22Y")); tof->RegisterCollections("S31Y", FindColl(hits_tree,"S31Y")); tof->RegisterCollections("S32X", FindColl(hits_tree,"S32X")); //Calorimeter CAST #define NSTRIPS 4224 PamVMCCaloDig* cal = new PamVMCCaloDig(); TClonesArray *cal_u = new TClonesArray("PamVMCDetectorHit",NSTRIPS); //uncompressed array TClonesArray* cal_comp = FindColl(hits_tree,"CAST"); // compressed array from file cal->RegisterCollections("CAST", cal_u); //Tracker GPSSPE PamVMCTrkDig* trk = new PamVMCTrkDig(); TBranch *gps = hits_tree->GetBranch("GPSSPE"); trk->RegisterCollections("TSPA", FindColl(hits_tree,"TSPA")); pGPSSPEHits * hits = new pGPSSPEHits(); if(gps){ hits_tree->SetBranchAddress("GPSSPE",&hits); hits_tree->SetBranchStatus("GPSSPE",1); cout<<"TRKCOLL="<RegisterTrkData(hits); } //S4 PamVMCS4Dig* s4 = new PamVMCS4Dig(); s4->RegisterCollections("S4", FindColl(hits_tree,"S4")); //ND: NDTI PamVMCNDDig* nd = new PamVMCNDDig(); nd->RegisterCollections("NDTI", FindColl(hits_tree,"NDTI")); //Primaries TClonesArray *prims = FindColl(hits_tree,"PRIM","PamVMCPrimary"); //Initialization d_mgr->SetDIG("Tof",tof); d_mgr->SetDIG("AC",ac); d_mgr->SetDIG("CAST",cal); d_mgr->SetDIG("TSPA",trk); d_mgr->SetDIG("S4",s4); d_mgr->SetDIG("NDTI",nd); d_mgr->Initialize( new TRandom3(0)); //Load Calibrations and set dummy random PamVMCRawMgr* r_mgr = PamVMCRawMgr::Instance(); r_mgr->CreateOutFile(outputfilename.Data()); r_mgr->WriteToFile(); Int_t nev = hits_tree->GetEntries(); cout<<"TOTAL NUMBER OF EVENTS:"<PrintCollections(); for(Int_t i = 0; iGetEntry(i); cout<<"--> Setting Random"<GetEntries(); j++){ TRandom3 * rnd = (TRandom3*)frndArr->At(j); TString nm = rnd->GetName(); if ( nm=="AC" ) ac->SetRandom(rnd); if ( nm=="Calo" ) cal->SetRandom(rnd); if ( nm=="Tracker" ) trk->SetRandom(rnd); if ( nm=="S4" ) s4->SetRandom(rnd); if ( nm=="Tof" ) tof->SetRandom(rnd); if ( nm=="ND" ) nd->SetRandom(rnd); } cout<<"--> Digitizing evnt"<Digitize(((PamVMCPrimary*)prims->At(0))->fID,((PamVMCPrimary*)prims->At(0))->fPDG); cout<<"--> Writing evnt"<WriteEvent(); rnd_mgr->ClearColl(); } r_mgr->FinishRun(); d_mgr->PrintCollections(); timer.Stop(); gDirectory->Delete("tmp.root"); rfin->Close(); return 0; } TClonesArray* FindColl(TTree*t, TString brname, TString type){ if(t->GetBranch(brname)){ TClonesArray* coll = 0;//new TClonesArray(type,4224); t->GetBranch(brname)->SetAddress(&coll); cout<<"coll="<AddParticle("H-2","H-2",1.875613,kTRUE,0., 3. /* |e|/3 charge*/,"Ion",1000010020); TDatabasePDG::Instance()->AddParticle("H-3","H-3",2.808921,kTRUE,0., 3. /* |e|/3 charge*/,"Ion",1000010030); TDatabasePDG::Instance()->AddParticle("He-4","He-4",3.727379,kTRUE,0., 6. /* |e|/3 charge*/,"Ion",1000020040); TDatabasePDG::Instance()->AddParticle("He-3","He-3",2.808391,kTRUE,0., 6. /* |e|/3 charge*/,"Ion",1000020030); Double_t gev = 0.93146;// conversion a.m.u. to gev; //nuclei and other stuff TDatabasePDG::Instance()->AddParticle("Li-6","Li-6",6.015122*gev,kTRUE,0., 9. /* |e|/3 charge*/,"Ion",1000030060); TDatabasePDG::Instance()->AddParticle("Li-7","Li-7",7.016004*gev,kTRUE,0., 9. /* |e|/3 charge*/,"Ion",1000030070); TDatabasePDG::Instance()->AddParticle("Be-7","Be-7",7.01692983*gev,kTRUE,0., 12. /* |e|/3 charge*/,"Ion",1000040070); TDatabasePDG::Instance()->AddParticle("Be-9","Be-9",9.0121822*gev,kTRUE,0., 12. /* |e|/3 charge*/,"Ion",1000040090); TDatabasePDG::Instance()->AddParticle("Be-10","Be-10",10.013533818*gev,kTRUE,0., 12. /* |e|/3 charge*/,"Ion",1000040100); TDatabasePDG::Instance()->AddParticle("B-10","B-10",10.0129370*gev,kTRUE,0., 15. /* |e|/3 charge*/,"Ion",1000050100); TDatabasePDG::Instance()->AddParticle("B-11","B-11",11.0093054*gev,kTRUE,0., 15. /* |e|/3 charge*/,"Ion",1000050110); TDatabasePDG::Instance()->AddParticle("C-12","C-12",12.*gev,kTRUE,0., 18. /* |e|/3 charge*/,"Ion",1000060120); TDatabasePDG::Instance()->AddParticle("N-14","N-14",14.0030740048*gev,kTRUE,0., 21. /* |e|/3 charge*/,"Ion",1000070140); TDatabasePDG::Instance()->AddParticle("O-16","O-16",15.99491461956*gev,kTRUE,0., 23. /* |e|/3 charge*/,"Ion",1000080160); } void UnCompressCalo(TClonesArray* cal_comp, TClonesArray & cal_u){ if(!cal_comp) return; PamVMCDetectorHit* hit = NULL; PamVMCDetectorHit* newhit = NULL; cal_u.Clear("C"); for(Int_t j = 0; jGetEntries(); j++){ hit=((PamVMCDetectorHit*)cal_comp->At(j)); newhit = (PamVMCDetectorHit*)cal_u.New(hit->GetPOS()); *newhit = *hit; } } void Usage(){ cout<<"NAME"< option in section )"<