CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/GeneratorInterface/CosmicMuonGenerator/interface/CosmicMuonGenerator.h

Go to the documentation of this file.
00001 #ifndef CosmicMuonGenerator_h
00002 #define CosmicMuonGenerator_h
00003 //
00004 // CosmicMuonGenerator by droll (04/DEC/2005)
00005 // modified by P. Biallass 29.03.2006 to implement new cosmic generator (CMSCGEN.cc) 
00006 //
00007 
00008 // include files
00009 
00010 #include <CLHEP/Random/RandomEngine.h>
00011 #include <CLHEP/Random/JamesRandom.h>
00012 
00013 namespace CLHEP {
00014   class HepRandomEngine;
00015 }
00016 
00017 #include <iostream>
00018 #include <string>
00019 #include <vector>
00020 #include "TFile.h"
00021 #include "TTree.h"
00022 
00023 #include "GeneratorInterface/CosmicMuonGenerator/interface/sim.h"
00024 
00025 #include "GeneratorInterface/CosmicMuonGenerator/interface/CMSCGENnorm.h"
00026 #include "GeneratorInterface/CosmicMuonGenerator/interface/CMSCGEN.h"
00027 #include "GeneratorInterface/CosmicMuonGenerator/interface/CosmicMuonParameters.h"
00028 #include "GeneratorInterface/CosmicMuonGenerator/interface/SingleParticleEvent.h"
00029 
00030 // class definitions
00031 class CosmicMuonGenerator{
00032 public:
00033   // constructor
00034   CosmicMuonGenerator() : delRanGen(false)
00035     {
00036       //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
00037       Norm = new CMSCGENnorm();
00038       //initialize class which produces the cosmic muons  (modified by P.Biallass 29.3.2006)
00039       Cosmics = new CMSCGEN();
00040       // set default control parameters
00041       NumberOfEvents = 100;
00042       RanSeed = 135799468;
00043       MinP =     3.;
00044       MinP_CMS =     MinP;
00045       MaxP =   3000.;
00046       MinTheta =  0.*Deg2Rad;
00047       //MaxTheta = 84.26*Deg2Rad;
00048       MaxTheta = 89.0*Deg2Rad;
00049       MinPhi =    0.*Deg2Rad;
00050       MaxPhi =  360.*Deg2Rad;
00051       MinT0  = -12.5;
00052       MaxT0  =  12.5;
00053       ElossScaleFactor = 1.0;
00054       RadiusOfTarget = 8000.;
00055       ZDistOfTarget = 15000.;
00056       ZCentrOfTarget = 0.;
00057       TrackerOnly = false;
00058       MultiMuon = false;
00059       MultiMuonFileName = "dummy.root";
00060       MultiMuonFileFirstEvent = 0;
00061       MultiMuonNmin = 2;
00062       TIFOnly_constant = false;
00063       TIFOnly_linear = false;
00064       MTCCHalf = false;
00065       EventRate = 0.;
00066       rateErr_stat = 0.;
00067       rateErr_syst = 0.;
00068       
00069       SumIntegrals = 0.;
00070       Ngen = 0.;
00071       Nsel = 0.;
00072       Ndiced = 0.;
00073       NotInitialized = true;
00074       Target3dRadius = 0.;
00075       SurfaceRadius = 0.;
00076       //set plug as default onto PX56 shaft
00077       PlugVx = PlugOnShaftVx;
00078       PlugVz = PlugOnShaftVz;
00079       //material densities in g/cm^3
00080       RhoAir = 0.001214;
00081       RhoWall = 2.5;
00082       RhoRock = 2.5;
00083       RhoClay = 2.3;
00084       RhoPlug = 2.5;
00085       ClayWidth = 50000; //[mm]
00086 
00087 
00088       
00089       std::cout << std::endl;
00090       std::cout << "*********************************************************" << std::endl;
00091       std::cout << "*********************************************************" << std::endl;
00092       std::cout << "***                                                   ***" << std::endl;
00093       std::cout << "***  C O S M I C  M U O N  G E N E R A T O R  (vC++)  ***" << std::endl;
00094       std::cout << "***                                                   ***" << std::endl;
00095       std::cout << "*********************************************************" << std::endl;
00096       std::cout << "*********************************************************" << std::endl;
00097       std::cout << std::endl;
00098     }
00099   
00100   // destructor
00101   ~CosmicMuonGenerator()
00102     {
00103       if (delRanGen)
00104         delete RanGen;
00105       delete Norm; 
00106       delete Cosmics;
00107     }
00108   
00109   // event with one particle
00110   //SingleParticleEvent OneMuoEvt;
00111   SingleParticleEvent OneMuoEvt;
00112 
00113   double EventWeight; //for multi muon events
00114   double Trials; //for multi muon events
00115 
00116   int Id_at;
00117   double Px_at; double Py_at; double Pz_at; 
00118   double E_at; 
00119   //double M_at;
00120   double Vx_at; double Vy_at; double Vz_at; 
00121   double T0_at;
00122   double Theta_at;
00123 
00124 
00125   std::vector<double> Px_mu; std::vector<double> Py_mu; std::vector<double> Pz_mu;
00126   std::vector<double> P_mu;
00127   std::vector<double> Vx_mu; std::vector<double> Vy_mu; std::vector<double> Vz_mu;
00128   double Vxz_mu;
00129   std::vector<double> Theta_mu;
00130 
00131   std::vector<int> Id_sf;
00132   std::vector<double> Px_sf; std::vector<double> Py_sf; std::vector<double> Pz_sf; 
00133   std::vector<double> E_sf; 
00134   //std::vector<double> M_sf;
00135   std::vector<double> Vx_sf; std::vector<double> Vy_sf; std::vector<double> Vz_sf; 
00136   std::vector<double> T0_sf;
00137   
00138   std::vector<int> Id_ug;
00139   std::vector<double> Px_ug; std::vector<double> Py_ug; std::vector<double> Pz_ug;
00140   std::vector<double> E_ug; 
00141   //std::vector<double> M_ug;
00142   std::vector<double> Vx_ug; std::vector<double> Vy_ug; std::vector<double> Vz_ug;
00143   std::vector<double> T0_ug;
00144  
00145  
00146 
00147 private:
00148 
00149   TFile* MultiIn; //file to be read in
00150   TTree* MultiTree; //tree of file with multi muon events
00151   sim* SimTree; //class to acces tree branches
00152   ULong64_t SimTreeEntries;
00153   ULong64_t SimTree_jentry;
00154   int NcloseMultiMuonEvents;
00155   int NskippedMultiMuonEvents;
00156 
00157 
00158   //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
00159   CMSCGENnorm*  Norm ;
00160   //initialize class which produces the cosmic muons  (modified by P.Biallass 29.3.2006)
00161   CMSCGEN* Cosmics ; 
00162   // default control parameters
00163   unsigned int NumberOfEvents; // number of events to be generated
00164   int    RanSeed; // seed of random number generator
00165   double MinP;     // min. E     [GeV]
00166   double MinP_CMS; // min. E at CMS surface    [GeV]; default is MinE_CMS=MinE, thus no bias from access-shaft
00167   double MaxP;     // max. E     [GeV]
00168   double MinTheta; // min. theta [rad]
00169   double MaxTheta; // max. theta [rad]
00170   double MinPhi;   // min. phi   [rad]
00171   double MaxPhi;   // max. phi   [rad]
00172   double MinT0;    // min. t0   [ns]
00173   double MaxT0;    // max. t0   [ns]
00174   double ElossScaleFactor; // scale factor for energy loss
00175   double RadiusOfTarget; // Radius of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions
00176   double ZDistOfTarget; // z-length of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions
00177   double ZCentrOfTarget; // z-position of centre of target-cylinder which cosmics HAVE to hit [mm], default is Nominal Interaction Point (=0)
00178   bool   TrackerOnly; //if set to "true" detector with tracker-only setup is used, so no material or B-field outside is considerd
00179   bool   MultiMuon; //read in multi-muon events from file instead of generating single muon events
00180   std::string MultiMuonFileName; //file containing multi muon events, to be read in
00181   int MultiMuonFileFirstEvent; //first multi muon event, to be read in
00182   int MultiMuonNmin; //minimal number of multi muons per event reaching the cylinder surrounding CMS
00183   bool   TIFOnly_constant; //if set to "true" cosmics can also be generated below 2GeV with unphysical constant energy dependence
00184   bool   TIFOnly_linear; //if set to "true" cosmics can also be generated below 2GeV with unphysical linear energy dependence
00185   bool   MTCCHalf; //if set to "true" muons are sure to hit half of CMS important for MTCC, 
00186                    //still material and B-field of whole CMS is considered
00187   double EventRate; // number of muons per second [Hz]
00188   double rateErr_stat; // stat. error of number of muons per second [Hz]
00189   double rateErr_syst; // syst. error of number of muons per second [Hz] from error of known flux
00190   // other stuff needed
00191   double SumIntegrals; // sum of phase space integrals
00192   double Ngen; // number of generated events
00193   double Nsel; // number of selected events
00194   double Ndiced; // number of diced events
00195   double Target3dRadius; // radius of sphere around target (cylinder)
00196   double SurfaceRadius; // radius for area on surface that has to be considered (for event generation)
00197   double PlugVx; //Plug x position
00198   double PlugVz; //Plug z position
00199 
00200   //material densities in g/cm^3
00201   double RhoAir;
00202   double RhoWall;
00203   double RhoRock;
00204   double RhoClay;
00205   double RhoPlug;
00206   double ClayWidth; //[mm]
00207 
00208 
00209   //For upgoing muon generation: Neutrino energy limits
00210   double MinEnu;
00211   double MaxEnu;
00212   double NuProdAlt;
00213 
00214   bool AcptAllMu; //Accepting All Muons regardeless of direction
00215 
00216 
00217   // random number generator
00218   CLHEP::HepRandomEngine *RanGen;
00219   bool delRanGen;
00220   // check user input
00221   bool NotInitialized;
00222   void checkIn();
00223   // check, if muon is pointing into target
00224   bool goodOrientation();
00225   // event display: initialize + display
00226   void initEvDis();
00227   void displayEv();
00228 
00229 public:
00230   // set parameters
00231   void setNumberOfEvents(unsigned int N);
00232   void setRanSeed(int N);
00233   void setMinP(double P);
00234   void setMinP_CMS(double P);
00235   void setMaxP(double P);
00236   void setMinTheta(double Theta);
00237   void setMaxTheta(double Theta);
00238   void setMinPhi(double Phi);
00239   void setMaxPhi(double Phi);
00240   void setMinT0(double T0);
00241   void setMaxT0(double T0);
00242   void setElossScaleFactor(double ElossScaleFact);
00243   void setRadiusOfTarget(double R);
00244   void setZDistOfTarget(double Z);
00245   void setZCentrOfTarget(double Z);
00246   void setTrackerOnly(bool Tracker);
00247   void setMultiMuon(bool MultiMu);
00248   void setMultiMuonFileName(std::string MultiMuonFileName);
00249   void setMultiMuonFileFirstEvent(int MultiMuFile1stEvt);
00250   void setMultiMuonNmin(int MultiMuNmin);
00251   void setTIFOnly_constant(bool TIF);
00252   void setTIFOnly_linear(bool TIF);
00253   void setMTCCHalf(bool MTCC);
00254   void setPlugVx(double PlugVtx);
00255   void setPlugVz(double PlugVtz);
00256   void setRhoAir(double VarRhoAir);
00257   void setRhoWall(double VarRhoSWall);
00258   void setRhoRock(double VarRhoRock);
00259   void setRhoClay(double VarRhoClay);
00260   void setRhoPlug(double VarRhoPlug);
00261   void setClayWidth(double ClayLaeyrWidth);
00262 
00263   void setMinEnu(double MinEn);
00264   void setMaxEnu(double MaxEn);
00265   void setNuProdAlt(double NuPrdAlt);
00266   void setAcptAllMu(bool AllMu);
00267 
00268 
00269   // initialize the generator
00270   void initialize(CLHEP::HepRandomEngine *rng = 0);
00271    // prints rate + statistics
00272   void terminate();
00273   // initialize, generate and terminate the Cosmic Muon Generator
00274   void runCMG();
00275   // returns event rate
00276   double getRate();
00277   // generate next event/muon
00278   void nextEvent();
00279   // generate next multi muon event
00280   bool nextMultiEvent();
00281 };
00282 #endif