FairRoot/PandaRoot
runLumiPixel0SimFTF.C
Go to the documentation of this file.
1 // Lmd FTF Sim macro
2 int runLumiPixel0SimFTF(const int nEvents = 10, const int startEvent = 0,
3  const double mom = 15, TString input, TString storePath = "tmpOutputDPM",
4  const double beam_X0 = 0.0, const double beam_Y0 = 0.0,
5  const double target_Z0 = 0.0, const double beam_width_sigma_X = 0.0,
6  const double beam_width_sigma_Y = 0.0,
7  const double target_width_Z = 0.0, // beam offset and smearing parameters
8  const double beam_grad_X = 0.0, const double beam_grad_Y = 0.0,
9  const double beam_grad_sigma_X = 0.0, const double beam_grad_sigma_Y = 0.0, // beam gradiant parameters
10  const int verboseLevel = 0) {
11  // gRandom->SetSeed(seed);
12  Int_t mode = 1;
13  TStopwatch timer;
14  timer.Start();
15  gDebug = 0;
16 
17  //output1
18  TString simOutput = storePath + "/Lumi_MC_";
19  simOutput += startEvent;
20  simOutput += ".root";
21  TString parOutput = storePath + "/Lumi_Params_";
22  parOutput += startEvent;
23  parOutput += ".root";
24  //Load basic libraries
25  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
26  gSystem->Load("libSds");
27  gSystem->Load("libLmd");
28  FairRunSim *fRun = new FairRunSim();
29  cout << "All libraries succsesfully loaded!" << endl;
30 
31  //set the MC version used
32  fRun->SetName("TGeant4");
33 
34  fRun->SetOutputFile(simOutput);
35 
36  //set material
37  fRun->SetMaterials("media_pnd.geo");
38 
39  // //create and add detectors
40 // //------------------------- CAVE -----------------
41 
42  FairModule *Cave = new PndCave("CAVE");
43  // Cave->SetGeometryFileName("pndcave.geo");
44  Cave->SetGeometryFileName("pndcaveVAC.geo"); //vac cave is not really necessary
45  fRun->AddModule(Cave);
46  //------------------------- Magnet -----------------
47  FairModule *Magnet = new PndMagnet("MAGNET");
48  Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root");
49  fRun->AddModule(Magnet);
50  FairModule *Dipole = new PndMagnet("MAGNET");
51  Dipole->SetGeometryFileName("dipole.geo");
52  fRun->AddModule(Dipole);
53  //------------------------- Pipe -----------------
54  FairModule *Pipe = new PndPipe("PIPE");
55  Pipe->SetGeometryFileName("beampipe_201309.root");
56  fRun->AddModule(Pipe);
57 
58 
59  PndLmdDetector *Lum = new PndLmdDetector("LUM", kTRUE);
60  Lum->SetExclusiveSensorType("LumActive"); //ignore MVD
61  Lum->SetGeometryFileName("Luminosity-Detector.root"); // new sensors
63  fRun->AddModule(Lum);
64 
65  //particle generator
66  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
67  if (beam_X0 != 0.0 || beam_Y0 != 0.0 || beam_width_sigma_X > 0.0 || beam_width_sigma_Y > 0.0) {
68  primGen->SmearGausVertexXY(true);
69  primGen->SetBeam(beam_X0, beam_Y0, beam_width_sigma_X, beam_width_sigma_Y);
70  }
71  if(target_Z0 != 0.0 || target_width_Z > 0.0) {
72  primGen->SmearGausVertexZ(true);
73  primGen->SetTarget(target_Z0, target_width_Z);
74  }
75  if (beam_grad_X != 0.0 || beam_grad_Y != 0.0 || beam_grad_sigma_X > 0.0 || beam_grad_sigma_Y > 0.0) {
76  primGen->SetBeamAngle(beam_grad_X, beam_grad_Y, beam_grad_sigma_X,
77  beam_grad_sigma_Y);
78  }
79 
80  fRun->SetGenerator(primGen);
81 
82  // FTF Generator
83  PndFtfGenerator* ftfGen = new PndFtfGenerator(input);
84  primGen->AddGenerator(ftfGen);
85 
86 
87 //reading the new field map in the old format
88  fRun->SetBeamMom(mom);
89  PndMultiField *fField= new PndMultiField("AUTO");
90  fRun->SetField(fField);
91 
92  fRun->SetField(fField);
93 
94  if (nEvents < 450)
95  fRun->SetStoreTraj(kTRUE); // toggle this for use with EVE
96  else
97  fRun->SetStoreTraj(kFALSE);
98 
99 // //FairLogger
100 // // get handle
101 // FairLogger *logger = FairLogger::GetLogger();
102 // //
103 // // log to screen and to file
104 // logger->SetLogToScreen(kTRUE);
105 // logger->SetLogToFile(kFALSE);
106 
107 // logger->SetLogVerbosityLevel("LOW");
108 
109 // // Set different levels of verbosity. In the example everything >=INFO goes to the
110 // // file and everything >= ERROR is printed on the screen
111 // // LogLevels are (FATAL, ERROR, WARNING, INFO, DEBUG, DEBUG1, DEBUG2, DEBUG3, DEBUG4)
112 // logger->SetLogScreenLevel("ERROR"); //Only FATAL and ERROR to screen
113 
114  fRun->Init();
115  // ((TGeant4*)gMC)->ProcessGeantCommand("/mcVerbose/eventAction 0");
116 
117 // // Fill the Parameter containers for this run
118 // //-------------------------------------------
119  FairRuntimeDb *rtdb = fRun->GetRuntimeDb();
120  Bool_t kParameterMerged = kTRUE;
121  FairParRootFileIo* output = new FairParRootFileIo(kParameterMerged);
122  output->open(parOutput.Data(), "RECREATE");
123  rtdb->setOutput(output);
124 
125 // PndMultiFieldPar* Par = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
126 // if (fField) { Par->SetParameters(fField); }
127 // Par->setInputVersion(fRun->GetRunId(),1);
128 // Par->setChanged();
129 
130 // Transport nEvents
131 // -----------------
132 
133  fRun->Run(nEvents);
134 
135  rtdb->saveOutput();
136  rtdb->print();
137 
138  timer.Stop();
139  Double_t rtime = timer.RealTime();
140  Double_t ctime = timer.CpuTime();
141  printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
142  return 0;
143 }
PndMultiField * fField
Definition: sim_emc_apd.C:97
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
int verboseLevel
Definition: Lars/runMvdSim.C:7
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
void SetExclusiveSensorType(const TString sens)
Int_t startEvent
TString storePath
Double_t mom
Definition: plot_dirc.C:14
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
TString parOutput
FairRunAna * fRun
Definition: hit_dirc.C:58
Int_t mode
Definition: autocutx.C:47
Double_t
FairModule * Dipole
Definition: sim_emc_apd.C:40
FairModule * Cave
Definition: sim_emc_apd.C:32
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
gDebug
Definition: sim_emc_apd.C:6
int runLumiPixel0SimFTF(const int nEvents=10, const int startEvent=0, const double mom=15, TString input, TString storePath="tmpOutputDPM", const double beam_X0=0.0, const double beam_Y0=0.0, const double target_Z0=0.0, const double beam_width_sigma_X=0.0, const double beam_width_sigma_Y=0.0, const double target_width_Z=0.0, const double beam_grad_X=0.0, const double beam_grad_Y=0.0, const double beam_grad_sigma_X=0.0, const double beam_grad_sigma_Y=0.0, const int verboseLevel=0)
Double_t ctime
Definition: hit_dirc.C:114
TString simOutput
void SetVerboseLevel(Int_t level)
FairModule * Pipe
Definition: sim_emc_apd.C:44
Double_t rtime
Definition: hit_dirc.C:113
FairModule * Magnet
Definition: sim_emc_apd.C:36
Definition: PndCave.h:8