// Macro created 5/04/2007 by A.Sanchez // It creates a geant simulation file for hypGe // 16.09.13: steinen: added sec target (air version) to use PndVolGenerator without material void sim_Gamma(Int_t nEvents = 1000, Int_t WhichDetector = 36,Double_t Energy = 0.001,Bool_t addSecTar = 1) { // Load basic libraries // If it does not work, please check the path of the libs and put it by hands gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C"); gSystem->Load("libHypGe"); gSystem->Load("libHyp"); FairRunSim *fRun = new FairRunSim(); TStopwatch timer; timer.Start(); gDebug=0; TDatime now; gRandom->SetSeed(now.Convert()); cout << now.Convert() << endl; //Choose geometry TString outFile="$SIMDATADIR/Gamma/"; // If no SIMDATADIR, same folder as the macro TString GeoFile; if (WhichDetector == 3) { GeoFile ="hypGe_GeoMarcell.root"; outFile += "TripleV2_"; } else if (WhichDetector == 31) { GeoFile = "hypGeGeoTripleCluster_V3.root"; outFile += "TripleBall30_"; } else if (WhichDetector == 32) { GeoFile = "hypGeGeoTripleCluster_Straight.root"; outFile += "TripleStraight_"; } else if (WhichDetector == 33) { GeoFile = "hypGeGeoTripleCluster_Ball40_Offset10.root"; outFile += "TripleBall40Offset10_"; } else if (WhichDetector == 34) { GeoFile = "hypGeGeoTripleCluster_Ball40_Offset20.root"; outFile += "TripleBall40Offset20_"; } else if (WhichDetector == 35) { GeoFile = "hypGeGeoTripleCluster_Ball40_Offset10_STTFitting.root"; outFile += "TripleBall40Offset10STT_"; } else if (WhichDetector == 36) { GeoFile = "hypGeGeoTripleCluster_Ball40_Offset20_STTFitting.root"; outFile += "TripleBall40Offset20STT_"; } else if (WhichDetector == 2) { GeoFile = "hypGe_GeoMarcell_2er.root"; outFile += "DoubleV2_"; } else if (WhichDetector == 21) { GeoFile = "hypGeGeoDoubleCluster_V3.root"; outFile += "DoubleV3_"; } // choose Co60 bool isCo60 = false; //compose the name of the output file and the simparams file if (!isCo60) { outFile += Energy*1000; outFile += "MeV_"; } else { outFile += "Co60_"; } outFile += nEvents; outFile += "Evts"; if (addSecTar) { outFile += "withSecTar"; } TString SimparamsFile; SimparamsFile=outFile; outFile +=".root"; SimparamsFile += "__Simparams.root"; //TString inFile="/d/panda02/urqmd_smm/pbarC_3_GeV.root"; //TString inFile="/u/asanchez/razhyp_gt12.dat"; // set the MC version used // ------------------------ fRun->SetName("TGeant4"); fRun->SetOutputFile(outFile); // Set Material file Name //----------------------- fRun->SetMaterials("media_pnd_hypGe.geo"); // Create and add detectors //------------------------- FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); if (addSecTar) { //acc sec. target PndHyp *Hyp= new PndHyp("HYP",kFALSE); Hyp->SetAbsorberVol("Absorber"); // absorber layer Hyp->SetSensorVol("Sensor"); // silicon sensor Hyp->SetGeometryFileName("../macro/hyp/Sebastian/SekTarget_open_varAbs4Si5_3Q_HYPbe_1mm_MVD.root"); fRun->AddModule(Hyp); //add MVD outer barrel FairDetector *Mvd = new PndMvdDetector("MVD", kFALSE); Mvd->SetGeometryFileName("../macro/hyp/Sebastian/Mvd-2.2_Simplified_onlyStrip5_z-verschoben550.root"); fRun->AddModule(Mvd); } else { PndHyp *Hyp= new PndHyp("HYP",kFALSE); Hyp->SetAbsorberVol("Absorber"); // absorber layer Hyp->SetSensorVol("Sensor"); // silicon sensor Hyp->SetGeometryFileName("../macro/hyp/Sebastian/SekTarget_open_varAbs4Si5_3Q_HYPbe_1mm_MVD_air.root"); fRun->AddModule(Hyp); } PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE); TString nam = gSystem->Getenv("VMCWORKDIR"); HypGe->SetPathGeo(nam.Data()); HypGe->SetGeometryFileName(GeoFile); fRun->AddModule(HypGe); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); // Box Generator: // FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1); // 13 = muon; 1 = multipl. // 211 = pi+ // first number: PDG particle code: 2nd number: particle multiplicity per event bool boxgen = false; bool volgen = true; if(boxgen) { PndBoxGenerator* boxGen = new PndBoxGenerator(22, 1); boxGen->SetXYZ(0., 0., -55.); // vertex coordinates [cm] if (!isCo60) boxGen->SetPRange(Energy,Energy); // GeV/c else boxGen->SetPRange(0.001172,0.001172); //set first line of Co60 in GeV/c if (isCo60) { PndBoxGenerator* boxGen2 = new PndBoxGenerator(22, 1); boxGen2->SetPRange(0.001332,0.001332); // GeV/c //boxGen2->SetPtRange(1.,1.); // GeV/c boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree] boxGen2->SetThetaRange(90., 180.); // Polar angle in lab system range [degree] //boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta) boxGen2->SetXYZ(0., 0., -55.); // vertex coordinates [cm] primGen->AddGenerator(boxGen2); } } if (volgen) { PndVolGenerator* boxGen = new PndVolGenerator(22, 1); TF1 *f1 = new TF1("f1","0.427842106*exp(-x/3.35703)", 4.5, 8.4999); // Factor makes no difference! //double r = f1->GetRandom(); boxGen->SetVolTgFc(2, f1); // 2=Setting quadrant 2 boxGen->SetPRange(Energy,Energy); // GeV/c } // boxGen->SetPtRange(1.,1.); // GeV/c boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree] boxGen->SetThetaRange(90., 180.); // Polar angle in lab system range [degree] //boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta) primGen->AddGenerator(boxGen); fRun->SetStoreTraj(kTRUE); // to store particle trajectories //magnetic field: no field when commented put //FairFieldConst *fMagField=new FairFieldConst(); //fMagField->SetField(0.,0.,20.); // values are in kG //fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax) //fRun->SetField(fMagField); fRun->Init(); // Fill the Parameter containers for this run //------------------------------------------- FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open(SimparamsFile); 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); }