sim_complete_boxgen_pions(Int_t nEvents = 100, TString pre="", Float_t mom = 6.231552, TString SimEngine ="TGeant3") { //-----User Settings:----------------------------------------------- if(pre == ""){ TString OutputFile ="sim_complete.root"; TString ParOutputfile ="simparams.root"; } else{ TString OutputFile = pre + "_sim_complete.root"; TString ParOutputfile =pre + "_simparams.root"; } TString MediaFile ="media_pnd.geo"; gDebug = 0; TString digiFile = "all.par"; //The emc run the hit producer directly // choose your event generator Bool_t UseEvtGenDirect =kFALSE; Bool_t UseDpm =kFALSE; Bool_t UseFtf =kFALSE; Bool_t UseBoxGenerator =kTRUE; TString evtPdlFile = "evt.pdl"; Double_t BeamMomentum = 0.; // beam momentum ONLY for the scaling of the dipole field. if (UseBoxGenerator) { BeamMomentum =mom; // ** change HERE if you run Box generator } else { BeamMomentum = mom; // for DPM/EvtGen BeamMomentum is always = mom } //------------------------------------------------------------------ TLorentzVector fIni(0, 0, mom, sqrt(mom*mom+9.3827203e-01*9.3827203e-01)+9.3827203e-01); TDatabasePDG::Instance()->AddParticle("pbarpSystem","pbarpSystem",fIni.M(),kFALSE,0.1,0, "",88888); //------------------------------------------------------------------ TStopwatch timer; timer.Start(); gRandom->SetSeed(); // Create the Simulation run manager-------------------------------- FairRunSim *fRun = new FairRunSim(); fRun->SetName(SimEngine.Data() ); fRun->SetOutputFile(OutputFile.Data()); fRun->SetGenerateRunInfo(kFALSE); fRun->SetBeamMom(BeamMomentum); fRun->SetMaterials(MediaFile.Data()); fRun->SetUseFairLinks(kTRUE); FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); // Set the parameters //------------------------------- TString allDigiFile = gSystem->Getenv("VMCWORKDIR"); allDigiFile += "/macro/params/"; allDigiFile += digiFile; //-------Set the parameter output -------------------- FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(allDigiFile.Data(),"in"); rtdb->setFirstInput(parIo1); //---------------------Set Parameter output ---------- Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open(ParOutputfile.Data()); rtdb->setOutput(output); // Create and add detectors //------------------------- CAVE ----------------- FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); //------------------------- Magnet ----------------- //FairModule *Magnet= new PndMagnet("MAGNET"); //Magnet->SetGeometryFileName("FullSolenoid_V842.root"); //Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root"); //fRun->AddModule(Magnet); FairModule *Dipole= new PndMagnet("MAGNET"); Dipole->SetGeometryFileName("dipole.geo"); fRun->AddModule(Dipole); //------------------------- Pipe ----------------- FairModule *Pipe= new PndPipe("PIPE"); Pipe->SetGeometryFileName("beampipe_201309.root"); fRun->AddModule(Pipe); //------------------------- STT ----------------- FairDetector *Stt= new PndStt("STT", kTRUE); Stt->SetGeometryFileName("straws_skewed_blocks_35cm_pipe.geo"); fRun->AddModule(Stt); //------------------------- MVD ----------------- FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE); Mvd->SetGeometryFileName("Mvd-2.1_FullVersion.root"); fRun->AddModule(Mvd); //------------------------- GEM ----------------- FairDetector *Gem = new PndGemDetector("GEM", kTRUE); Gem->SetGeometryFileName("gem_3Stations_Tube.root"); fRun->AddModule(Gem); //------------------------- EMC ----------------- PndEmc *Emc = new PndEmc("EMC",kTRUE); Emc->SetGeometryVersion(1); Emc->SetStorageOfData(kFALSE); fRun->AddModule(Emc); //------------------------- SCITIL ----------------- FairDetector *SciT = new PndSciT("SCIT",kTRUE); SciT->SetGeometryFileName("SciTil_201504.root"); fRun->AddModule(SciT); //------------------------- DRC ----------------- PndDrc *Drc = new PndDrc("DIRC", kTRUE); Drc->SetGeometryFileName("dirc_l0_p0_updated.root"); Drc->SetRunCherenkov(kFALSE); fRun->AddModule(Drc); //------------------------- DISC ----------------- PndDsk* Dsk = new PndDsk("DSK", kTRUE); Dsk->SetStoreCerenkovs(kFALSE); Dsk->SetStoreTrackPoints(kFALSE); fRun->AddModule(Dsk); //------------------------- MDT ----------------- PndMdt *Muo = new PndMdt("MDT",kTRUE); Muo->SetBarrel("fast"); Muo->SetEndcap("fast"); Muo->SetMuonFilter("fast"); Muo->SetForward("fast"); Muo->SetMdtMagnet(kTRUE); Muo->SetMdtCoil(kTRUE); Muo->SetMdtMFIron(kTRUE); fRun->AddModule(Muo); //------------------------- FTS ----------------- FairDetector *Fts= new PndFts("FTS", kTRUE); Fts->SetGeometryFileName("fts.geo"); fRun->AddModule(Fts); //------------------------- FTOF ----------------- FairDetector *FTof = new PndFtof("FTOF",kTRUE); FTof->SetGeometryFileName("ftofwall.root"); fRun->AddModule(FTof); //------------------------- RICH ---------------- FairDetector *Rich= new PndRich("RICH",kFALSE); Rich->SetGeometryFileName("rich_v2_shift.geo"); fRun->AddModule(Rich); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); if(UseBoxGenerator){ // Box Generator FairBoxGenerator* boxGenPiM = new FairBoxGenerator(-211, 1); // 13 = muon; 1 = multipl. boxGenPiM->SetPRange(0., 0.6); // GeV/c boxGenPiM->SetPhiRange(0., 360.); // Azimuth angle range [degree] boxGenPiM->SetThetaRange(0., 70); // Polar angle in lab system range [degree] boxGenPiM->SetXYZ(0., 0., 0.); // cm primGen->AddGenerator(boxGenPiM); FairBoxGenerator* boxGenPiP = new FairBoxGenerator(211, 1); // 13 = muon; 1 = multipl. boxGenPiP->SetPRange(0.,0.6); // GeV/c boxGenPiP->SetPhiRange(0., 360.); // Azimuth angle range [degree] boxGenPiP->SetThetaRange(0., 70); // Polar angle in lab system range [degree] boxGenPiP->SetXYZ(0., 0., 0.); // cm primGen->AddGenerator(boxGenPiP); } if(UseDpm){ PndDpmDirect *Dpm= new PndDpmDirect(mom,1); primGen->AddGenerator(Dpm); } if(UseFtf){ // TString macfile = gSystem->Getenv("VMCWORKDIR"); // macfile += "/pgenerators/FtfEvtGen/PbarP.mac"; // PndFtfDirect *Ftf = new PndFtfDirect(macfile.Data()); PndFtfDirect *Ftf = new PndFtfDirect("anti_proton", "G4_H", 1, "ftfp", mom, 123456); primGen->AddGenerator(Ftf); } if(UseEvtGenDirect){ // TString EvtInput =gSystem->Getenv("VMCWORKDIR"); // EvtInput+="/macro/run/psi2s_Jpsi2pi_Jpsi_mumu.dec"; TString EvtInput="/home/ikp1/puetz/panda/mysimulations/analysis/XiMinus_1820_lambda0_K.dec"; // PndEvtGenDirect *EvtGen = new PndEvtGenDirect("pbarpSystem", EvtInput.Data(), mom); PndEvtGenDirect * EvtGen = new PndEvtGenDirect("pbarpSystem", EvtInput.Data(), mom, -1, "", evtPdlFile.Data()); EvtGen->SetStoreTree(kTRUE); primGen->AddGenerator(EvtGen); } //---------------------Create and Set the Field(s)---------- PndMultiField *fField= new PndMultiField("AUTO"); fRun->SetField(fField); // EMC Hit producer //------------------------------- PndEmcHitProducer* emcHitProd = new PndEmcHitProducer(); fRun->AddTask(emcHitProd); //------------------------- Initialize the RUN ----------------- fRun->Init(); //------------------------- Run the Simulation ----------------- fRun->Run(nEvents); //------------------------- Save the parameters ----------------- rtdb->saveOutput(); //------------------------Print some info and exit---------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime); cout << " Test passed" << endl; cout << " All ok " << endl; exit(0); };
// Macro created 03/05/2011 by S.Spataro // It creates an evtgen simulation for the tracking TDR run_sim_stt_evt(Int_t nEvents=10, UInt_t seed=0){ gRandom->SetSeed(seed); TStopwatch timer; timer.Start(); gDebug=0; // Load basic libraries // If it does not work, please check the path of the libs and put it by hands gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); rootlogon(); TString digiFile = "all.par"; TString parFile = "evt_params_stt.root"; FairRunSim *fRun = new FairRunSim(); // set the MC version used // ------------------------ fRun->SetName("TGeant3"); //fRun->SetName("TGeant4"); fRun->SetOutputFile("evt_points_stt.root"); // Set the parameters //------------------------------- TString allDigiFile = gSystem->Getenv("VMCWORKDIR"); allDigiFile += "/macro/params/"; allDigiFile += digiFile; FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(allDigiFile.Data(),"in"); rtdb->setFirstInput(parIo1); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open(parFile); rtdb->setOutput(output); // Set Material file Name //----------------------- fRun->SetMaterials("media_pnd.geo"); // Create and add detectors //------------------------- FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); FairModule *Magnet= new PndMagnet("MAGNET"); //Magnet->SetGeometryFileName("FullSolenoid_V842.root"); Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root"); fRun->AddModule(Magnet); FairModule *Dipole= new PndMagnet("MAGNET"); Dipole->SetGeometryFileName("dipole.geo"); fRun->AddModule(Dipole); FairModule *Pipe= new PndPipe("PIPE"); fRun->AddModule(Pipe); FairDetector *Stt= new PndStt("STT", kTRUE); Stt->SetGeometryFileName("straws_skewed_blocks_35cm_pipe.geo"); fRun->AddModule(Stt); FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE); Mvd->SetGeometryFileName("Mvd-2.1_FullVersion.root"); fRun->AddModule(Mvd); PndEmc *Emc = new PndEmc("EMC",kTRUE); Emc->SetGeometryVersion(2); Emc->SetStorageOfData(kFALSE); fRun->AddModule(Emc); PndMdt *Muo = new PndMdt("MDT",kTRUE); Muo->SetBarrel("fast"); Muo->SetEndcap("fast"); Muo->SetMuonFilter("fast"); Muo->SetMdtMagnet(kTRUE); Muo->SetMdtMFIron(kTRUE); fRun->AddModule(Muo); FairDetector *Gem = new PndGemDetector("GEM", kTRUE); Gem->SetGeometryFileName("gem_3Stations.root"); fRun->AddModule(Gem); PndDsk* Dsk = new PndDsk("DSK", kTRUE); Dsk->SetGeometryFileName("dsk.root"); Dsk->SetStoreCerenkovs(kFALSE); Dsk->SetStoreTrackPoints(kFALSE); fRun->AddModule(Dsk); PndDrc *Drc = new PndDrc("DIRC", kTRUE); Drc->SetGeometryFileName("dirc_l0_p0.root"); Drc->SetRunCherenkov(kFALSE); // for fast sim Cherenkov -> kFALSE fRun->AddModule(Drc); FairDetector *Fts= new PndFts("FTS", kTRUE); Fts->SetGeometryFileName("fts.geo"); fRun->AddModule(Fts); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); primGen->SetTarget(0., 0.5/2.355); primGen->SmearVertexZ(kTRUE); primGen->SmearGausVertexZ(kTRUE); primGen->SetBeam(0., 0., 0.1, 0.1); primGen->SmearVertexXY(kTRUE); fRun->SetGenerator(primGen); // ... generate your signal on the fly PndEvtGenDirect *EvtGen = new PndEvtGenDirect("pbarpSystem","EtaCInclusive_2phi.dec",3.6772); EvtGen->SetStoreTree(kFALSE); primGen->AddGenerator(EvtGen); // Create and Set Magnetic Field //------------------------------- fRun->SetBeamMom(3.6772); PndMultiField *fField= new PndMultiField("FULL"); fRun->SetField(fField); // EMC Hit producer //------------------------------- PndEmcHitProducer* emcHitProd = new PndEmcHitProducer(); fRun->AddTask(emcHitProd); /**Initialize the session*/ fRun->Init(); rtdb->setOutput(output); rtdb->saveOutput(); rtdb->print(); // Transport nEvents // ----------------- fRun->Run(nEvents); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime); }