CMS 3D CMS Logo

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