CMS 3D CMS Logo

CosmicMuonGenerator.h
Go to the documentation of this file.
1 #ifndef CosmicMuonGenerator_h
2 #define CosmicMuonGenerator_h
3 //
4 // CosmicMuonGenerator by droll (04/DEC/2005)
5 // modified by P. Biallass 29.03.2006 to implement new cosmic generator (CMSCGEN.cc)
6 //
7 
8 // include files
9 
10 #include <CLHEP/Random/RandomEngine.h>
11 #include <CLHEP/Random/JamesRandom.h>
12 
13 namespace CLHEP {
14  class HepRandomEngine;
15 }
16 
17 #include <iostream>
18 #include <string>
19 #include <vector>
20 #include "TFile.h"
21 #include "TTree.h"
22 
24 
29 
30 // class definitions
32 public:
33  // constructor
34  CosmicMuonGenerator() : delRanGen(false) {
35  //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
36  Norm = new CMSCGENnorm();
37  //initialize class which produces the cosmic muons (modified by P.Biallass 29.3.2006)
38  Cosmics = new CMSCGEN();
39  // set default control parameters
40  NumberOfEvents = 100;
41  RanSeed = 135799468;
42  MinP = 3.;
43  MinP_CMS = MinP;
44  MaxP = 3000.;
45  MinTheta = 0. * Deg2Rad;
46  //MaxTheta = 84.26*Deg2Rad;
47  MaxTheta = 89.0 * Deg2Rad;
48  MinPhi = 0. * Deg2Rad;
49  MaxPhi = 360. * Deg2Rad;
50  MinT0 = -12.5;
51  MaxT0 = 12.5;
52  ElossScaleFactor = 1.0;
53  RadiusOfTarget = 8000.;
54  ZDistOfTarget = 15000.;
55  ZCentrOfTarget = 0.;
56  TrackerOnly = false;
57  MultiMuon = false;
58  MultiMuonFileName = "dummy.root";
60  MultiMuonNmin = 2;
61  TIFOnly_constant = false;
62  TIFOnly_linear = false;
63  MTCCHalf = false;
64  EventRate = 0.;
65  rateErr_stat = 0.;
66  rateErr_syst = 0.;
67 
68  SumIntegrals = 0.;
69  Ngen = 0.;
70  Nsel = 0.;
71  Ndiced = 0.;
72  NotInitialized = true;
73  Target3dRadius = 0.;
74  SurfaceRadius = 0.;
75  //set plug as default onto PX56 shaft
78  //material densities in g/cm^3
79  RhoAir = 0.001214;
80  RhoWall = 2.5;
81  RhoRock = 2.5;
82  RhoClay = 2.3;
83  RhoPlug = 2.5;
84  ClayWidth = 50000; //[mm]
85 
86  std::cout << std::endl;
87  std::cout << "*********************************************************" << std::endl;
88  std::cout << "*********************************************************" << std::endl;
89  std::cout << "*** ***" << std::endl;
90  std::cout << "*** C O S M I C M U O N G E N E R A T O R (vC++) ***" << std::endl;
91  std::cout << "*** ***" << std::endl;
92  std::cout << "*********************************************************" << std::endl;
93  std::cout << "*********************************************************" << std::endl;
94  std::cout << std::endl;
95  }
96 
97  // destructor
99  if (delRanGen)
100  delete RanGen;
101  delete Norm;
102  delete Cosmics;
103  }
104 
105  // event with one particle
106  //SingleParticleEvent OneMuoEvt;
108 
109  double EventWeight; //for multi muon events
110  double Trials; //for multi muon events
111 
112  int Id_at;
113  double Px_at;
114  double Py_at;
115  double Pz_at;
116  double E_at;
117  //double M_at;
118  double Vx_at;
119  double Vy_at;
120  double Vz_at;
121  double T0_at;
122  double Theta_at;
123 
124  std::vector<double> Px_mu;
125  std::vector<double> Py_mu;
126  std::vector<double> Pz_mu;
127  std::vector<double> P_mu;
128  std::vector<double> Vx_mu;
129  std::vector<double> Vy_mu;
130  std::vector<double> Vz_mu;
131  double Vxz_mu;
132  std::vector<double> Theta_mu;
133 
134  std::vector<int> Id_sf;
135  std::vector<double> Px_sf;
136  std::vector<double> Py_sf;
137  std::vector<double> Pz_sf;
138  std::vector<double> E_sf;
139  //std::vector<double> M_sf;
140  std::vector<double> Vx_sf;
141  std::vector<double> Vy_sf;
142  std::vector<double> Vz_sf;
143  std::vector<double> T0_sf;
144 
145  std::vector<int> Id_ug;
146  std::vector<double> Px_ug;
147  std::vector<double> Py_ug;
148  std::vector<double> Pz_ug;
149  std::vector<double> E_ug;
150  //std::vector<double> M_ug;
151  std::vector<double> Vx_ug;
152  std::vector<double> Vy_ug;
153  std::vector<double> Vz_ug;
154  std::vector<double> T0_ug;
155 
156 private:
157  TFile* MultiIn; //file to be read in
158  TTree* MultiTree; //tree of file with multi muon events
159  sim* SimTree; //class to acces tree branches
160  ULong64_t SimTreeEntries;
161  ULong64_t SimTree_jentry;
164 
165  //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
167  //initialize class which produces the cosmic muons (modified by P.Biallass 29.3.2006)
169  // default control parameters
170  unsigned int NumberOfEvents; // number of events to be generated
171  int RanSeed; // seed of random number generator
172  double MinP; // min. E [GeV]
173  double MinP_CMS; // min. E at CMS surface [GeV]; default is MinE_CMS=MinE, thus no bias from access-shaft
174  double MaxP; // max. E [GeV]
175  double MinTheta; // min. theta [rad]
176  double MaxTheta; // max. theta [rad]
177  double MinPhi; // min. phi [rad]
178  double MaxPhi; // max. phi [rad]
179  double MinT0; // min. t0 [ns]
180  double MaxT0; // max. t0 [ns]
181  double ElossScaleFactor; // scale factor for energy loss
182  double RadiusOfTarget; // Radius of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions
183  double ZDistOfTarget; // z-length of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions
184  double
185  ZCentrOfTarget; // z-position of centre of target-cylinder which cosmics HAVE to hit [mm], default is Nominal Interaction Point (=0)
186  bool TrackerOnly; //if set to "true" detector with tracker-only setup is used, so no material or B-field outside is considerd
187  bool MultiMuon; //read in multi-muon events from file instead of generating single muon events
188  std::string MultiMuonFileName; //file containing multi muon events, to be read in
189  int MultiMuonFileFirstEvent; //first multi muon event, to be read in
190  int MultiMuonNmin; //minimal number of multi muons per event reaching the cylinder surrounding CMS
191  bool TIFOnly_constant; //if set to "true" cosmics can also be generated below 2GeV with unphysical constant energy dependence
192  bool TIFOnly_linear; //if set to "true" cosmics can also be generated below 2GeV with unphysical linear energy dependence
193  bool MTCCHalf; //if set to "true" muons are sure to hit half of CMS important for MTCC,
194  //still material and B-field of whole CMS is considered
195  double EventRate; // number of muons per second [Hz]
196  double rateErr_stat; // stat. error of number of muons per second [Hz]
197  double rateErr_syst; // syst. error of number of muons per second [Hz] from error of known flux
198  // other stuff needed
199  double SumIntegrals; // sum of phase space integrals
200  double Ngen; // number of generated events
201  double Nsel; // number of selected events
202  double Ndiced; // number of diced events
203  double Target3dRadius; // radius of sphere around target (cylinder)
204  double SurfaceRadius; // radius for area on surface that has to be considered (for event generation)
205  double PlugVx; //Plug x position
206  double PlugVz; //Plug z position
207 
208  //material densities in g/cm^3
209  double RhoAir;
210  double RhoWall;
211  double RhoRock;
212  double RhoClay;
213  double RhoPlug;
214  double ClayWidth; //[mm]
215 
216  //For upgoing muon generation: Neutrino energy limits
217  double MinEnu;
218  double MaxEnu;
219  double NuProdAlt;
220 
221  bool AcptAllMu; //Accepting All Muons regardeless of direction
222 
223  // random number generator
224  CLHEP::HepRandomEngine* RanGen;
225  bool delRanGen;
226  // check user input
228  void checkIn();
229  // check, if muon is pointing into target
230  bool goodOrientation();
231  // event display: initialize + display
232  void initEvDis();
233  void displayEv();
234 
235 public:
236  // set parameters
237  void setNumberOfEvents(unsigned int N);
238  void setRanSeed(int N);
239  void setMinP(double P);
240  void setMinP_CMS(double P);
241  void setMaxP(double P);
242  void setMinTheta(double Theta);
243  void setMaxTheta(double Theta);
244  void setMinPhi(double Phi);
245  void setMaxPhi(double Phi);
246  void setMinT0(double T0);
247  void setMaxT0(double T0);
248  void setElossScaleFactor(double ElossScaleFact);
249  void setRadiusOfTarget(double R);
250  void setZDistOfTarget(double Z);
251  void setZCentrOfTarget(double Z);
252  void setTrackerOnly(bool Tracker);
253  void setMultiMuon(bool MultiMu);
254  void setMultiMuonFileName(std::string MultiMuonFileName);
255  void setMultiMuonFileFirstEvent(int MultiMuFile1stEvt);
256  void setMultiMuonNmin(int MultiMuNmin);
257  void setTIFOnly_constant(bool TIF);
258  void setTIFOnly_linear(bool TIF);
259  void setMTCCHalf(bool MTCC);
260  void setPlugVx(double PlugVtx);
261  void setPlugVz(double PlugVtz);
262  void setRhoAir(double VarRhoAir);
263  void setRhoWall(double VarRhoSWall);
264  void setRhoRock(double VarRhoRock);
265  void setRhoClay(double VarRhoClay);
266  void setRhoPlug(double VarRhoPlug);
267  void setClayWidth(double ClayLaeyrWidth);
268 
269  void setMinEnu(double MinEn);
270  void setMaxEnu(double MaxEn);
271  void setNuProdAlt(double NuPrdAlt);
272  void setAcptAllMu(bool AllMu);
273 
274  // initialize the generator
275  void setRandomEngine(CLHEP::HepRandomEngine* v);
276  void initialize(CLHEP::HepRandomEngine* rng = nullptr);
277  // prints rate + statistics
278  void terminate();
279  // initialize, generate and terminate the Cosmic Muon Generator
280  void runCMG();
281  // returns event rate
282  double getRate();
283  // generate next event/muon
284  void nextEvent();
285  // generate next multi muon event
286  bool nextMultiEvent();
287 };
288 #endif
static AlgebraicMatrix initialize()
std::vector< double > Theta_mu
const double PlugOnShaftVz
std::vector< double > Px_ug
std::vector< double > Py_mu
std::vector< int > Id_ug
std::vector< double > Py_sf
std::vector< double > E_sf
std::vector< double > Pz_mu
std::vector< double > E_ug
std::vector< double > Vz_ug
const double PlugOnShaftVx
std::vector< double > Vz_sf
std::vector< double > Vz_mu
const double Deg2Rad
std::vector< double > Vx_sf
std::vector< double > Vy_sf
CLHEP::HepRandomEngine * RanGen
std::vector< double > Vx_mu
SingleParticleEvent OneMuoEvt
std::vector< double > Vy_mu
MaxP
negative means MinP_CMS = MinP.
std::vector< double > T0_sf
std::vector< double > Px_mu
#define N
Definition: blowfish.cc:9
std::vector< double > Px_sf
std::vector< double > Vy_ug
std::pair< OmniClusterRef, TrackingParticleRef > P
std::vector< double > Pz_ug
std::vector< double > Vx_ug
std::vector< double > P_mu
std::vector< double > Py_ug
std::vector< double > T0_ug
std::vector< int > Id_sf
std::vector< double > Pz_sf