Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:39

0001 #ifndef CosmicMuonGenerator_h
0002 #define CosmicMuonGenerator_h
0003 //
0004 // CosmicMuonGenerator by droll (04/DEC/2005)
0005 // modified by P. Biallass 29.03.2006 to implement new cosmic generator (CMSCGEN.cc)
0006 //
0007 
0008 // include files
0009 
0010 #include <CLHEP/Random/RandomEngine.h>
0011 #include <CLHEP/Random/JamesRandom.h>
0012 
0013 namespace CLHEP {
0014   class HepRandomEngine;
0015 }
0016 
0017 #include <iostream>
0018 #include <string>
0019 #include <vector>
0020 #include "TFile.h"
0021 #include "TTree.h"
0022 
0023 #include "GeneratorInterface/CosmicMuonGenerator/interface/sim.h"
0024 
0025 #include "GeneratorInterface/CosmicMuonGenerator/interface/CMSCGENnorm.h"
0026 #include "GeneratorInterface/CosmicMuonGenerator/interface/CMSCGEN.h"
0027 #include "GeneratorInterface/CosmicMuonGenerator/interface/CosmicMuonParameters.h"
0028 #include "GeneratorInterface/CosmicMuonGenerator/interface/SingleParticleEvent.h"
0029 
0030 // class definitions
0031 class CosmicMuonGenerator {
0032 public:
0033   // constructor
0034   CosmicMuonGenerator() : delRanGen(false) {
0035     //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
0036     Norm = new CMSCGENnorm();
0037     //initialize class which produces the cosmic muons  (modified by P.Biallass 29.3.2006)
0038     Cosmics = new CMSCGEN();
0039     // set default control parameters
0040     NumberOfEvents = 100;
0041     RanSeed = 135799468;
0042     MinP = 3.;
0043     MinP_CMS = MinP;
0044     MaxP = 3000.;
0045     MinTheta = 0. * Deg2Rad;
0046     //MaxTheta = 84.26*Deg2Rad;
0047     MaxTheta = 89.0 * Deg2Rad;
0048     MinPhi = 0. * Deg2Rad;
0049     MaxPhi = 360. * Deg2Rad;
0050     MinT0 = -12.5;
0051     MaxT0 = 12.5;
0052     ElossScaleFactor = 1.0;
0053     RadiusOfTarget = 8000.;
0054     ZDistOfTarget = 15000.;
0055     ZCentrOfTarget = 0.;
0056     TrackerOnly = false;
0057     MultiMuon = false;
0058     MultiMuonFileName = "dummy.root";
0059     MultiMuonFileFirstEvent = 0;
0060     MultiMuonNmin = 2;
0061     TIFOnly_constant = false;
0062     TIFOnly_linear = false;
0063     MTCCHalf = false;
0064     EventRate = 0.;
0065     rateErr_stat = 0.;
0066     rateErr_syst = 0.;
0067 
0068     SumIntegrals = 0.;
0069     Ngen = 0.;
0070     Nsel = 0.;
0071     Ndiced = 0.;
0072     NotInitialized = true;
0073     Target3dRadius = 0.;
0074     SurfaceRadius = 0.;
0075     //set plug as default onto PX56 shaft
0076     PlugVx = PlugOnShaftVx;
0077     PlugVz = PlugOnShaftVz;
0078     //material densities in g/cm^3
0079     RhoAir = 0.001214;
0080     RhoWall = 2.5;
0081     RhoRock = 2.5;
0082     RhoClay = 2.3;
0083     RhoPlug = 2.5;
0084     ClayWidth = 50000;  //[mm]
0085 
0086     std::cout << std::endl;
0087     std::cout << "*********************************************************" << std::endl;
0088     std::cout << "*********************************************************" << std::endl;
0089     std::cout << "***                                                   ***" << std::endl;
0090     std::cout << "***  C O S M I C  M U O N  G E N E R A T O R  (vC++)  ***" << std::endl;
0091     std::cout << "***                                                   ***" << std::endl;
0092     std::cout << "*********************************************************" << std::endl;
0093     std::cout << "*********************************************************" << std::endl;
0094     std::cout << std::endl;
0095   }
0096 
0097   // destructor
0098   ~CosmicMuonGenerator() {
0099     if (delRanGen)
0100       delete RanGen;
0101     delete Norm;
0102     delete Cosmics;
0103   }
0104 
0105   // event with one particle
0106   //SingleParticleEvent OneMuoEvt;
0107   SingleParticleEvent OneMuoEvt;
0108 
0109   double EventWeight;  //for multi muon events
0110   double Trials;       //for multi muon events
0111 
0112   int Id_at;
0113   double Px_at;
0114   double Py_at;
0115   double Pz_at;
0116   double E_at;
0117   //double M_at;
0118   double Vx_at;
0119   double Vy_at;
0120   double Vz_at;
0121   double T0_at;
0122   double Theta_at;
0123 
0124   std::vector<double> Px_mu;
0125   std::vector<double> Py_mu;
0126   std::vector<double> Pz_mu;
0127   std::vector<double> P_mu;
0128   std::vector<double> Vx_mu;
0129   std::vector<double> Vy_mu;
0130   std::vector<double> Vz_mu;
0131   double Vxz_mu;
0132   std::vector<double> Theta_mu;
0133 
0134   std::vector<int> Id_sf;
0135   std::vector<double> Px_sf;
0136   std::vector<double> Py_sf;
0137   std::vector<double> Pz_sf;
0138   std::vector<double> E_sf;
0139   //std::vector<double> M_sf;
0140   std::vector<double> Vx_sf;
0141   std::vector<double> Vy_sf;
0142   std::vector<double> Vz_sf;
0143   std::vector<double> T0_sf;
0144 
0145   std::vector<int> Id_ug;
0146   std::vector<double> Px_ug;
0147   std::vector<double> Py_ug;
0148   std::vector<double> Pz_ug;
0149   std::vector<double> E_ug;
0150   //std::vector<double> M_ug;
0151   std::vector<double> Vx_ug;
0152   std::vector<double> Vy_ug;
0153   std::vector<double> Vz_ug;
0154   std::vector<double> T0_ug;
0155 
0156 private:
0157   TFile* MultiIn;    //file to be read in
0158   TTree* MultiTree;  //tree of file with multi muon events
0159   sim* SimTree;      //class to acces tree branches
0160   ULong64_t SimTreeEntries;
0161   ULong64_t SimTree_jentry;
0162   int NcloseMultiMuonEvents;
0163   int NskippedMultiMuonEvents;
0164 
0165   //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
0166   CMSCGENnorm* Norm;
0167   //initialize class which produces the cosmic muons  (modified by P.Biallass 29.3.2006)
0168   CMSCGEN* Cosmics;
0169   // default control parameters
0170   unsigned int NumberOfEvents;  // number of events to be generated
0171   int RanSeed;                  // seed of random number generator
0172   double MinP;                  // min. E     [GeV]
0173   double MinP_CMS;          // min. E at CMS surface    [GeV]; default is MinE_CMS=MinE, thus no bias from access-shaft
0174   double MaxP;              // max. E     [GeV]
0175   double MinTheta;          // min. theta [rad]
0176   double MaxTheta;          // max. theta [rad]
0177   double MinPhi;            // min. phi   [rad]
0178   double MaxPhi;            // max. phi   [rad]
0179   double MinT0;             // min. t0   [ns]
0180   double MaxT0;             // max. t0   [ns]
0181   double ElossScaleFactor;  // scale factor for energy loss
0182   double RadiusOfTarget;    // Radius of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions
0183   double ZDistOfTarget;     // z-length of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions
0184   double
0185       ZCentrOfTarget;  // z-position of centre of target-cylinder which cosmics HAVE to hit [mm], default is Nominal Interaction Point (=0)
0186   bool TrackerOnly;  //if set to "true" detector with tracker-only setup is used, so no material or B-field outside is considerd
0187   bool MultiMuon;                 //read in multi-muon events from file instead of generating single muon events
0188   std::string MultiMuonFileName;  //file containing multi muon events, to be read in
0189   int MultiMuonFileFirstEvent;    //first multi muon event, to be read in
0190   int MultiMuonNmin;              //minimal number of multi muons per event reaching the cylinder surrounding CMS
0191   bool TIFOnly_constant;  //if set to "true" cosmics can also be generated below 2GeV with unphysical constant energy dependence
0192   bool TIFOnly_linear;  //if set to "true" cosmics can also be generated below 2GeV with unphysical linear energy dependence
0193   bool MTCCHalf;        //if set to "true" muons are sure to hit half of CMS important for MTCC,
0194                         //still material and B-field of whole CMS is considered
0195   double EventRate;     // number of muons per second [Hz]
0196   double rateErr_stat;  // stat. error of number of muons per second [Hz]
0197   double rateErr_syst;  // syst. error of number of muons per second [Hz] from error of known flux
0198   // other stuff needed
0199   double SumIntegrals;    // sum of phase space integrals
0200   double Ngen;            // number of generated events
0201   double Nsel;            // number of selected events
0202   double Ndiced;          // number of diced events
0203   double Target3dRadius;  // radius of sphere around target (cylinder)
0204   double SurfaceRadius;   // radius for area on surface that has to be considered (for event generation)
0205   double PlugVx;          //Plug x position
0206   double PlugVz;          //Plug z position
0207 
0208   //material densities in g/cm^3
0209   double RhoAir;
0210   double RhoWall;
0211   double RhoRock;
0212   double RhoClay;
0213   double RhoPlug;
0214   double ClayWidth;  //[mm]
0215 
0216   //For upgoing muon generation: Neutrino energy limits
0217   double MinEnu;
0218   double MaxEnu;
0219   double NuProdAlt;
0220 
0221   bool AcptAllMu;  //Accepting All Muons regardeless of direction
0222 
0223   // random number generator
0224   CLHEP::HepRandomEngine* RanGen;
0225   bool delRanGen;
0226   // check user input
0227   bool NotInitialized;
0228   void checkIn();
0229   // check, if muon is pointing into target
0230   bool goodOrientation();
0231   // event display: initialize + display
0232   void initEvDis();
0233   void displayEv();
0234 
0235 public:
0236   // set parameters
0237   void setNumberOfEvents(unsigned int N);
0238   void setRanSeed(int N);
0239   void setMinP(double P);
0240   void setMinP_CMS(double P);
0241   void setMaxP(double P);
0242   void setMinTheta(double Theta);
0243   void setMaxTheta(double Theta);
0244   void setMinPhi(double Phi);
0245   void setMaxPhi(double Phi);
0246   void setMinT0(double T0);
0247   void setMaxT0(double T0);
0248   void setElossScaleFactor(double ElossScaleFact);
0249   void setRadiusOfTarget(double R);
0250   void setZDistOfTarget(double Z);
0251   void setZCentrOfTarget(double Z);
0252   void setTrackerOnly(bool Tracker);
0253   void setMultiMuon(bool MultiMu);
0254   void setMultiMuonFileName(std::string MultiMuonFileName);
0255   void setMultiMuonFileFirstEvent(int MultiMuFile1stEvt);
0256   void setMultiMuonNmin(int MultiMuNmin);
0257   void setTIFOnly_constant(bool TIF);
0258   void setTIFOnly_linear(bool TIF);
0259   void setMTCCHalf(bool MTCC);
0260   void setPlugVx(double PlugVtx);
0261   void setPlugVz(double PlugVtz);
0262   void setRhoAir(double VarRhoAir);
0263   void setRhoWall(double VarRhoSWall);
0264   void setRhoRock(double VarRhoRock);
0265   void setRhoClay(double VarRhoClay);
0266   void setRhoPlug(double VarRhoPlug);
0267   void setClayWidth(double ClayLaeyrWidth);
0268 
0269   void setMinEnu(double MinEn);
0270   void setMaxEnu(double MaxEn);
0271   void setNuProdAlt(double NuPrdAlt);
0272   void setAcptAllMu(bool AllMu);
0273 
0274   // initialize the generator
0275   void setRandomEngine(CLHEP::HepRandomEngine* v);
0276   void initialize(CLHEP::HepRandomEngine* rng = nullptr);
0277   // prints rate + statistics
0278   void terminate();
0279   // initialize, generate and terminate the Cosmic Muon Generator
0280   void runCMG();
0281   // returns event rate
0282   double getRate();
0283   // generate next event/muon
0284   void nextEvent();
0285   // generate next multi muon event
0286   bool nextMultiEvent();
0287 };
0288 #endif