CMS 3D CMS Logo

CosmicMuonGenerator Class Reference

#include <GeneratorInterface/CosmicMuonGenerator/interface/CosmicMuonGenerator.h>

List of all members.

Public Member Functions

 CosmicMuonGenerator ()
double getRate ()
void initialize ()
void nextEvent ()
void runCMG ()
void setElossScaleFactor (double ElossScaleFact)
void setMaxP (double P)
void setMaxPhi (double Phi)
void setMaxT0 (double T0)
void setMaxTheta (double Theta)
void setMinP (double P)
void setMinP_CMS (double P)
void setMinPhi (double Phi)
void setMinT0 (double T0)
void setMinTheta (double Theta)
void setMTCCHalf (bool MTCC)
void setNumberOfEvents (unsigned int N)
void setPlugVx (double PlugVtx)
void setPlugVz (double PlugVtz)
void setRadiusOfTarget (double R)
void setRanSeed (int N)
void setTIFOnly_constant (bool TIF)
void setTIFOnly_linear (bool TIF)
void setTrackerOnly (bool Tracker)
void setZCentrOfTarget (double Z)
void setZDistOfTarget (double Z)
void terminate ()
 ~CosmicMuonGenerator ()

Public Attributes

SingleParticleEvent OneMuoEvt

Private Member Functions

void checkIn ()
void displayEv ()
bool goodOrientation ()
void initEvDis ()

Private Attributes

CMSCGENCosmics
double ElossScaleFactor
double EventRate
double MaxP
double MaxPhi
double MaxT0
double MaxTheta
double MinP
double MinP_CMS
double MinPhi
double MinT0
double MinTheta
bool MTCCHalf
double Ndiced
double Ngen
CMSCGENnormNorm
bool NotInitialized
double Nsel
unsigned int NumberOfEvents
double PlugVx
double PlugVz
double RadiusOfTarget
TRandom2 RanGen
int RanSeed
double rateErr_stat
double rateErr_syst
double SumIntegrals
double SurfaceRadius
double Target3dRadius
bool TIFOnly_constant
bool TIFOnly_linear
bool TrackerOnly
double ZCentrOfTarget
double ZDistOfTarget


Detailed Description

Definition at line 19 of file CosmicMuonGenerator.h.


Constructor & Destructor Documentation

CosmicMuonGenerator::CosmicMuonGenerator (  )  [inline]

Definition at line 22 of file CosmicMuonGenerator.h.

References Cosmics, GenMuonPlsPt100GeV_cfg::cout, Deg2Rad, ElossScaleFactor, lat::endl(), EventRate, MaxP, MaxPhi, MaxT0, MaxTheta, MinP, MinP_CMS, MinPhi, MinT0, MinTheta, MTCCHalf, Ndiced, Ngen, Norm, NotInitialized, Nsel, NumberOfEvents, PlugOnShaftVx, PlugOnShaftVz, PlugVx, PlugVz, RadiusOfTarget, RanSeed, rateErr_stat, rateErr_syst, SumIntegrals, SurfaceRadius, Target3dRadius, TIFOnly_constant, TIFOnly_linear, TrackerOnly, ZCentrOfTarget, and ZDistOfTarget.

00022                        {
00023     //initialize class which normalizes flux (added by P.Biallass 29.3.2006)
00024     Norm = new CMSCGENnorm();
00025     //initialize class which produces the cosmic muons  (modified by P.Biallass 29.3.2006)
00026     Cosmics = new CMSCGEN();
00027     // set default control parameters
00028     NumberOfEvents = 100;
00029     RanSeed = 135799468;
00030     MinP =     3.;
00031     MinP_CMS =     MinP;
00032     MaxP =   3000.;
00033     MinTheta =  0.*Deg2Rad;
00034     //MaxTheta = 84.26*Deg2Rad;
00035     MaxTheta = 89.0*Deg2Rad;
00036     MinPhi =    0.*Deg2Rad;
00037     MaxPhi =  360.*Deg2Rad;
00038     MinT0  = -12.5;
00039     MaxT0  =  12.5;
00040     ElossScaleFactor = 1.0;
00041     RadiusOfTarget = 8000.;
00042     ZDistOfTarget = 15000.;
00043     ZCentrOfTarget = 0.;
00044     TrackerOnly = false;
00045     TIFOnly_constant = false;
00046     TIFOnly_linear = false;
00047     MTCCHalf = false;
00048     EventRate = 0.;
00049     rateErr_stat = 0.;
00050     rateErr_syst = 0.;
00051 
00052     SumIntegrals = 0.;
00053     Ngen = 0.;
00054     Nsel = 0.;
00055     Ndiced = 0.;
00056     NotInitialized = true;
00057     Target3dRadius = 0.;
00058     SurfaceRadius = 0.;
00059     //set plug as default onto PX56 shaft
00060     PlugVx = PlugOnShaftVx;
00061     PlugVz = PlugOnShaftVz;
00062 
00063 
00064     std::cout << std::endl;
00065     std::cout << "*********************************************************" << std::endl;
00066     std::cout << "*********************************************************" << std::endl;
00067     std::cout << "***                                                   ***" << std::endl;
00068     std::cout << "***  C O S M I C  M U O N  G E N E R A T O R  (vC++)  ***" << std::endl;
00069     std::cout << "***                                                   ***" << std::endl;
00070     std::cout << "*********************************************************" << std::endl;
00071     std::cout << "*********************************************************" << std::endl;
00072     std::cout << std::endl;
00073   }

CosmicMuonGenerator::~CosmicMuonGenerator (  )  [inline]

Definition at line 75 of file CosmicMuonGenerator.h.

References Cosmics, and Norm.

00075                         {
00076     delete Norm; 
00077     delete Cosmics;
00078   }


Member Function Documentation

void CosmicMuonGenerator::checkIn (  )  [private]

Definition at line 196 of file CosmicMuonGenerator.cc.

References GenMuonPlsPt100GeV_cfg::cout, ElossScaleFactor, lat::endl(), MaxP, MaxPhi, MaxT0, MaxTheta, MinP, MinPhi, MinT0, MinTheta, and NumberOfEvents.

Referenced by initialize().

00196                                  {
00197   if (MinP < 0.){ NumberOfEvents = 0;
00198     std::cout << "  CMG-ERR: min.energy is out of range (0 GeV ... inf]" << std::endl << std::endl; }
00199   if (MaxP < 0.){ NumberOfEvents = 0;
00200     std::cout << "  CMG-ERR: max.energy is out of range (0 GeV ... inf]" << std::endl << std::endl; }
00201   if (MaxP <= MinP){ NumberOfEvents = 0;
00202     std::cout << "  CMG-ERR: max.energy is not greater than min.energy" << std::endl << std::endl; }
00203   if (MinTheta < 0.){ NumberOfEvents = 0;
00204     std::cout << "  CMG-ERR: min.theta is out of range [0 deg ... 90 deg)" << std::endl << std::endl; }
00205   if (MaxTheta < 0.){ NumberOfEvents = 0;
00206     std::cout << "  CMG-ERR: max.theta is out of range [0 deg ... 90 deg)" << std::endl << std::endl; }
00207   if (MaxTheta <= MinTheta){ NumberOfEvents = 0;
00208     std::cout << "  CMG-ERR: max.theta is not greater than min.theta" << std::endl << std::endl; }
00209   if (MinPhi < 0.){ NumberOfEvents = 0;
00210     std::cout << "  CMG-ERR: min.phi is out of range [0 deg ... 360 deg]" << std::endl << std::endl; }
00211   if (MaxPhi < 0.){ NumberOfEvents = 0;
00212     std::cout << "  CMG-ERR: max.phi is out of range [0 deg ... 360 deg]" << std::endl << std::endl; }
00213   if (MaxPhi <= MinPhi){ NumberOfEvents = 0;
00214     std::cout << "  CMG-ERR: max.phi is not greater than min.phi" << std::endl << std::endl; }
00215   if (MaxT0 <= MinT0){ NumberOfEvents = 0;
00216     std::cout << "  CMG-ERR: max.t0 is not greater than min.t0" << std::endl << std::endl; }
00217   if (ElossScaleFactor < 0.){ NumberOfEvents = 0;
00218     std::cout << "  CMG-ERR: E-loss scale factor is out of range [0 ... inf)" << std::endl << std::endl; }
00219 }

void CosmicMuonGenerator::displayEv (  )  [private]

Definition at line 294 of file CosmicMuonGenerator.cc.

References SingleParticleEvent::e(), relval_parameters_module::energy, OneMuoEvt, SingleParticleEvent::px(), SingleParticleEvent::py(), SingleParticleEvent::pz(), RadiusCMS, RadiusTracker, funct::sqrt(), TrackerOnly, SingleParticleEvent::vx(), SingleParticleEvent::vy(), SingleParticleEvent::vz(), Z_DistCMS, and Z_DistTracker.

Referenced by nextEvent().

00294                                    {
00295 #if ROOT_INTERACTIVE
00296   double RadiusDet=RadiusCMS;
00297   double Z_DistDet=Z_DistCMS;
00298   if(TrackerOnly==true){
00299     RadiusDet = RadiusTracker;
00300     Z_DistDet = Z_DistTracker;
00301   }
00302   disXY->Reset();
00303   disZY->Reset();
00304   TMarker* InteractionPoint = new TMarker(0.,0.,2);
00305   TArc* r8m = new TArc(0.,0.,(RadiusDet/1000.));
00306   TLatex* logEaxis = new TLatex(); logEaxis->SetTextSize(0.05);
00307   float energy = float(OneMuoEvt.e());
00308   float verX = float(OneMuoEvt.vx()/1000.); // [m]
00309   float verY = float(OneMuoEvt.vy()/1000.); // [m]
00310   float verZ = float(OneMuoEvt.vz()/1000.); // [m]
00311   float dirX = float(OneMuoEvt.px())/fabs(OneMuoEvt.py());
00312   float dirY = float(OneMuoEvt.py())/fabs(OneMuoEvt.py());
00313   float dirZ = float(OneMuoEvt.pz())/fabs(OneMuoEvt.py());
00314   float yStep = disXY->GetYaxis()->GetBinWidth(1);
00315   int   NbinY = disXY->GetYaxis()->GetNbins();
00316   for (int iy=0; iy<NbinY; ++iy){
00317     verX += dirX*yStep;
00318     verY += dirY*yStep;
00319     verZ += dirZ*yStep;
00320     float rXY = sqrt(verX*verX + verY*verY)*1000.; // [mm]
00321     float absZ = fabs(verZ)*1000.;                 // [mm]
00322     if (rXY < RadiusDet && absZ < Z_DistDet){
00323       disXY->Fill(verX,verY,log10(energy));
00324       disZY->Fill(verZ,verY,log10(energy));
00325       disC->cd(1); disXY->Draw("COLZ"); InteractionPoint->Draw("SAME"); r8m->Draw("SAME");
00326       logEaxis->DrawLatex((0.65*RadiusDet/1000.),(1.08*RadiusDet/1000.),"log_{10}E(#mu^{#pm})");
00327       disC->cd(2); disZY->Draw("COL"); InteractionPoint->Draw("SAME");
00328       gPad->Update();
00329     }
00330   }
00331 #endif
00332 }

double CosmicMuonGenerator::getRate (  ) 

Definition at line 376 of file CosmicMuonGenerator.cc.

References EventRate.

00376 { return EventRate; }

bool CosmicMuonGenerator::goodOrientation (  )  [private]

Definition at line 221 of file CosmicMuonGenerator.cc.

References GenMuonPlsPt100GeV_cfg::cout, dPhi(), lat::endl(), OneMuoEvt, SingleParticleEvent::phi(), Pi, PlugWidth, funct::sqrt(), SurfaceOfEarth, Target3dRadius, SingleParticleEvent::theta(), TwoPi, SingleParticleEvent::vx(), and SingleParticleEvent::vz().

Referenced by nextEvent().

00221                                          {
00222   // check angular range (for a sphere with Target3dRadius around the target)
00223   bool goodAngles = false;
00224   bool phiaccepted = false;
00225   bool thetaaccepted = false;
00226   double RxzV = sqrt(OneMuoEvt.vx()*OneMuoEvt.vx() + OneMuoEvt.vz()*OneMuoEvt.vz());
00227   double rVY = sqrt(RxzV*RxzV + (SurfaceOfEarth+PlugWidth)*(SurfaceOfEarth+PlugWidth));
00228   double Phi = OneMuoEvt.phi();
00229   double PhiV = atan2(OneMuoEvt.vx(),OneMuoEvt.vz()) + Pi; if (PhiV > TwoPi) PhiV -= TwoPi;
00230   double disPhi = fabs(PhiV - Phi); if (disPhi > Pi) disPhi = TwoPi - disPhi;
00231   double dPhi = Pi; if (RxzV > Target3dRadius) dPhi = asin(Target3dRadius/RxzV);
00232   if (disPhi < dPhi) phiaccepted = true;
00233   double Theta = OneMuoEvt.theta();
00234   double ThetaV = asin(RxzV/rVY);
00235   double dTheta = Pi; if (rVY > Target3dRadius) dTheta = asin(Target3dRadius/rVY);
00236   //std::cout << "    dPhi = " <<   dPhi << "  (" <<   Phi << " <p|V> " <<   PhiV << ")" << std::endl;
00237   //std::cout << "  dTheta = " << dTheta << "  (" << Theta << " <p|V> " << ThetaV << ")" << std::endl;
00238 
00239   if (!phiaccepted && RxzV < Target3dRadius)
00240   //if (RxzV < Target3dRadius)
00241     std::cout << "Rejected phi=" << Phi << "  PhiV="  << PhiV 
00242          << "  dPhi=" << dPhi << "  disPhi=" << disPhi
00243          << "  RxzV=" << RxzV << "  Target3dRadius=" << Target3dRadius 
00244          << "  Theta=" << Theta << std::endl;
00245 
00246   if (fabs(Theta-ThetaV) < dTheta) thetaaccepted = true;
00247   if (phiaccepted && thetaaccepted) goodAngles = true;
00248   return goodAngles;
00249 }

void CosmicMuonGenerator::initEvDis (  )  [private]

Definition at line 251 of file CosmicMuonGenerator.cc.

References MaxP, MinP, RadiusCMS, RadiusTracker, TrackerOnly, Z_DistCMS, and Z_DistTracker.

Referenced by initialize().

00251                                    {
00252 #if ROOT_INTERACTIVE
00253   float rCMS = RadiusCMS/1000.;
00254   float zCMS = Z_DistCMS/1000.;
00255   if(TrackerOnly==true){
00256     rCMS = RadiusTracker/1000.;
00257     zCMS = Z_DistTracker/1000.;
00258 }
00259   TH2F* disXY = new TH2F("disXY","X-Y view",160,-rCMS,rCMS,160,-rCMS,rCMS);
00260   TH2F* disZY = new TH2F("disZY","Z-Y view",150,-zCMS,zCMS,160,-rCMS,rCMS);
00261   gStyle->SetPalette(1,0);
00262   gStyle->SetMarkerColor(1);
00263   gStyle->SetMarkerSize(1.5);
00264   TCanvas *disC = new TCanvas("disC","Cosmic Muon Event Display",0,0,800,410);
00265   disC->Divide(2,1);
00266   disC->cd(1);
00267   gPad->SetTicks(1,1);
00268   disXY->SetMinimum(log10(MinP));
00269   disXY->SetMaximum(log10(MaxP));
00270   disXY->GetXaxis()->SetLabelSize(0.05);
00271   disXY->GetXaxis()->SetTitleSize(0.05);
00272   disXY->GetXaxis()->SetTitleOffset(1.0);
00273   disXY->GetXaxis()->SetTitle("X [m]");
00274   disXY->GetYaxis()->SetLabelSize(0.05);
00275   disXY->GetYaxis()->SetTitleSize(0.05);
00276   disXY->GetYaxis()->SetTitleOffset(0.8);
00277   disXY->GetYaxis()->SetTitle("Y [m]");
00278   disC->cd(2);
00279   gPad->SetGrid(1,1);
00280   gPad->SetTicks(1,1);
00281   disZY->SetMinimum(log10(MinP));
00282   disZY->SetMaximum(log10(MaxP));
00283   disZY->GetXaxis()->SetLabelSize(0.05);
00284   disZY->GetXaxis()->SetTitleSize(0.05);
00285   disZY->GetXaxis()->SetTitleOffset(1.0);
00286   disZY->GetXaxis()->SetTitle("Z [m]");
00287   disZY->GetYaxis()->SetLabelSize(0.05);
00288   disZY->GetYaxis()->SetTitleSize(0.05);
00289   disZY->GetYaxis()->SetTitleOffset(0.8);
00290   disZY->GetYaxis()->SetTitle("Y [m]");
00291 #endif
00292 }

void CosmicMuonGenerator::initialize (  ) 

Definition at line 14 of file CosmicMuonGenerator.cc.

References checkIn(), Cosmics, GenMuonPlsPt100GeV_cfg::cout, Debug, lat::endl(), EventDisplay, initEvDis(), CMSCGEN::initialize(), MaxP, MaxTheta, MinP, MinStepSize, MinTheta, NotInitialized, NumberOfEvents, OneMuoEvt, phi, PlugVx, SingleParticleEvent::PlugVx, PlugVz, SingleParticleEvent::PlugVz, PlugWidth, RadiusOfTarget, RadiusTracker, RanGen, RanSeed, funct::sqrt(), SurfaceOfEarth, SurfaceRadius, funct::tan(), Target3dRadius, TIFOnly_constant, TIFOnly_linear, TrackerOnly, mergeAndRegister_online::ver, Z_DistTracker, ZCentrOfTarget, and ZDistOfTarget.

Referenced by edm::CosMuoGenSource::CosMuoGenSource(), and runCMG().

00014                                     {
00015   checkIn();
00016   if (NumberOfEvents > 0){
00017     RanGen.SetSeed(RanSeed); //set seed for Random Generator (seed can be controled by config-file)
00018     // set up "surface geometry" dimensions
00019     double RadiusTargetEff = RadiusOfTarget; //get this from cfg-file
00020     double Z_DistTargetEff = ZDistOfTarget;  //get this from cfg-file
00021     double Z_CentrTargetEff = ZCentrOfTarget;  //get this from cfg-file
00022     if(TrackerOnly==true){
00023     RadiusTargetEff = RadiusTracker;
00024     Z_DistTargetEff = Z_DistTracker;
00025     }
00026     Target3dRadius = sqrt(RadiusTargetEff*RadiusTargetEff + Z_DistTargetEff*Z_DistTargetEff) + MinStepSize;
00027     if (Debug) std::cout << "  radius of sphere  around  target = " << Target3dRadius << " mm" << std::endl;
00028     SurfaceRadius = (SurfaceOfEarth+PlugWidth+RadiusTargetEff)*tan(MaxTheta) + Target3dRadius;  
00029     if (Debug) std::cout << "  starting point radius at Surface + PlugWidth = " << SurfaceRadius << " mm" << std::endl;
00030 
00031     OneMuoEvt.PlugVx = PlugVx;
00032     OneMuoEvt.PlugVz = PlugVz;
00033     //set energy and angle limits for CMSCGEN, give same seed as above 
00034     Cosmics->initialize(MinP, MaxP, MinTheta, MaxTheta, RanSeed, TIFOnly_constant, TIFOnly_linear);
00035    
00036 #if ROOT_INTERACTIVE
00037   // book histos
00038   TH1D* ene = new TH1D("ene","generated energy",210,0.,1050.);
00039   TH1D* the = new TH1D("the","generated theta",90,0.,90.);
00040   TH1D* phi = new TH1D("phi","generated phi",120,0.,360.);
00041   TH3F* ver = new TH3F("ver","Z-X-Y coordinates",50,-25.,25.,20,-10.,10.,20,-10.,10.);
00042 #endif
00043     if (EventDisplay) initEvDis();
00044     std::cout << std::endl;
00045     std::cout << "  generating " << NumberOfEvents << " events with random seed " << RanSeed << std::endl;
00046     NotInitialized = false;
00047   }
00048 }

void CosmicMuonGenerator::nextEvent (  ) 

Definition at line 50 of file CosmicMuonGenerator.cc.

References funct::cos(), CMSCGEN::cos_theta(), Cosmics, GenMuonPlsPt100GeV_cfg::cout, SingleParticleEvent::create(), Debug, displayEv(), dPhi(), SingleParticleEvent::e(), ElossScaleFactor, lat::endl(), EventDisplay, CMSCGENnorm::events_n100cos(), CMSCGEN::generate(), goodOrientation(), SingleParticleEvent::hitTarget(), int, SingleParticleEvent::m(), MaxPhi, MaxT0, MinP_CMS, MinPhi, MinT0, CMSCGEN::momentum_times_charge(), MTCCHalf, MuonMass, Ndiced, Ngen, Norm, Nsel, OneMuoEvt, phi, SingleParticleEvent::phi(), Pi, PlugWidth, SingleParticleEvent::propagate(), SingleParticleEvent::px(), SingleParticleEvent::py(), SingleParticleEvent::pz(), Rad2Deg, RadiusOfTarget, RanGen, funct::sin(), SpeedOfLight, funct::sqrt(), SurfaceOfEarth, SurfaceRadius, SingleParticleEvent::t0(), Target3dRadius, SingleParticleEvent::theta(), TrackerOnly, TwoPi, mergeAndRegister_online::ver, SingleParticleEvent::vx(), SingleParticleEvent::vy(), SingleParticleEvent::vz(), ZCentrOfTarget, and ZDistOfTarget.

Referenced by edm::CosMuoGenSource::produce(), and runCMG().

00050                                    {
00051 
00052   double E = 0.; double Theta = 0.; double Phi = 0.; double RxzV = 0.; double PhiV = 0.;
00053   if (int(Nsel)%100 == 0) std::cout << "    generated " << int(Nsel) << " events" << std::endl;
00054   // generate cosmic (E,theta,phi)
00055   bool   notSelected = true;
00056   while (notSelected){
00057         bool   badMomentumGenerated = true;
00058         while (badMomentumGenerated){
00059           Cosmics->generate(); //dice one event now
00060           E = sqrt(Cosmics->momentum_times_charge()*Cosmics->momentum_times_charge() + MuonMass*MuonMass);
00061           Theta = TMath::ACos( Cosmics->cos_theta() ) ; //angle has to be in RAD here
00062           Ngen+=1.;   //count number of initial cosmic events (in surface area), vertices will be added later
00063             badMomentumGenerated = false;
00064             Phi = RanGen.Rndm()*(MaxPhi-MinPhi) + MinPhi;
00065         }
00066         Norm->events_n100cos(E, Theta); //test if this muon is in normalization range
00067         Ndiced += 1; //one more cosmic is diced
00068   
00069     // generate vertex
00070     double Nver = 0.;
00071     bool   badVertexGenerated = true;
00072     while (badVertexGenerated){
00073       RxzV = sqrt(RanGen.Rndm())*SurfaceRadius;
00074       PhiV = RanGen.Rndm()*TwoPi;
00075       // check phi range (for a sphere with Target3dRadius around the target)
00076       double dPhi = Pi; if (RxzV > Target3dRadius) dPhi = asin(Target3dRadius/RxzV);
00077       double rotPhi = PhiV + Pi; if (rotPhi > TwoPi) rotPhi -= TwoPi;
00078       double disPhi = fabs(rotPhi - Phi); if (disPhi > Pi) disPhi = TwoPi - disPhi;
00079       if (disPhi < dPhi) badVertexGenerated = false;
00080       Nver+=1.;
00081     }
00082     Ngen += (Nver-1.); //add number of generated vertices to initial cosmic events
00083     
00084     // complete event at surface
00085     int                             id =  13; // mu-
00086     if (Cosmics->momentum_times_charge() >0.) id = -13; // mu+
00087     double absMom = sqrt(E*E - MuonMass*MuonMass);
00088     double verMom = absMom*cos(Theta);
00089     double horMom = absMom*sin(Theta);
00090     double Px = horMom*sin(Phi); // [GeV/c]
00091     double Py = -verMom;         // [GeV/c]
00092     double Pz = horMom*cos(Phi); // [GeV/c]
00093     double Vx = RxzV*sin(PhiV);  // [mm]
00094     double Vy = SurfaceOfEarth + PlugWidth;  // [mm]
00095     double Vz = RxzV*cos(PhiV);  // [mm]
00096     double T0 = (RanGen.Rndm()*(MaxT0-MinT0) + MinT0)*SpeedOfLight; // [mm/c];
00097     OneMuoEvt.create(id, Px, Py, Pz, E, MuonMass, Vx, Vy, Vz, T0); 
00098     // if angles are ok, propagate to target
00099     if (goodOrientation()) OneMuoEvt.propagate(ElossScaleFactor, RadiusOfTarget, ZDistOfTarget, ZCentrOfTarget, TrackerOnly, MTCCHalf);
00100     // if cosmic hits target test also if P>Pmin_CMS; the default is MinP_surface=MinP_CMS, thus no bias from access shaft
00101     if (OneMuoEvt.hitTarget() && sqrt(OneMuoEvt.e()*OneMuoEvt.e() - MuonMass*MuonMass) > MinP_CMS){
00102       Nsel+=1.; //count number of generated and accepted events  
00103       notSelected = false;
00104       }
00105   }
00106   // plot variables of selected events
00107 #if ROOT_INTERACTIVE
00108   ene->Fill(OneMuoEvt.e());
00109   the->Fill((OneMuoEvt.theta()*Rad2Deg));
00110   phi->Fill((OneMuoEvt.phi()*Rad2Deg));
00111   ver->Fill((OneMuoEvt.vz()/1000.),(OneMuoEvt.vx()/1000.),(OneMuoEvt.vy()/1000.));
00112 #endif
00113   if (Debug){
00114     std::cout << "new event" << std::endl;
00115     std::cout << "  Px,Py,Pz,E,m = " << OneMuoEvt.px() << ", " << OneMuoEvt.py() << ", "
00116          << OneMuoEvt.pz() << ", " << OneMuoEvt.e() << ", " << OneMuoEvt.m() << " GeV" << std::endl;
00117     std::cout << "  Vx,Vy,Vz,t0  = " << OneMuoEvt.vx() << ", " << OneMuoEvt.vy() << ", " 
00118          << OneMuoEvt.vz() << ", " << OneMuoEvt.t0() << " mm" << std::endl;
00119   }
00120   if (EventDisplay) displayEv();
00121   
00122 }

void CosmicMuonGenerator::runCMG (  ) 

Definition at line 8 of file CosmicMuonGenerator.cc.

References initialize(), nextEvent(), NumberOfEvents, and terminate().

00008                                 {
00009   initialize();
00010   for (unsigned int iGen=0; iGen<NumberOfEvents; ++iGen){ nextEvent(); }
00011   terminate();
00012 }

void CosmicMuonGenerator::setElossScaleFactor ( double  ElossScaleFact  ) 

Definition at line 356 of file CosmicMuonGenerator.cc.

References ElossScaleFactor, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00356 { if (NotInitialized) ElossScaleFactor = ElossScaleFact; }

void CosmicMuonGenerator::setMaxP ( double  P  ) 

Definition at line 342 of file CosmicMuonGenerator.cc.

References MaxP, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00342 { if (NotInitialized) MaxP = P; }

void CosmicMuonGenerator::setMaxPhi ( double  Phi  ) 

Definition at line 350 of file CosmicMuonGenerator.cc.

References Deg2Rad, MaxPhi, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00350 { if (NotInitialized) MaxPhi = Phi*Deg2Rad; }

void CosmicMuonGenerator::setMaxT0 ( double  T0  ) 

Definition at line 354 of file CosmicMuonGenerator.cc.

References MaxT0, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00354 { if (NotInitialized) MaxT0 = T0; }

void CosmicMuonGenerator::setMaxTheta ( double  Theta  ) 

Definition at line 346 of file CosmicMuonGenerator.cc.

References Deg2Rad, MaxTheta, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00346 { if (NotInitialized) MaxTheta = Theta*Deg2Rad; } 

void CosmicMuonGenerator::setMinP ( double  P  ) 

Definition at line 338 of file CosmicMuonGenerator.cc.

References MinP, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00338 { if (NotInitialized) MinP = P; }

void CosmicMuonGenerator::setMinP_CMS ( double  P  ) 

Definition at line 340 of file CosmicMuonGenerator.cc.

References MinP_CMS, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00340 { if (NotInitialized) MinP_CMS = P; }

void CosmicMuonGenerator::setMinPhi ( double  Phi  ) 

Definition at line 348 of file CosmicMuonGenerator.cc.

References Deg2Rad, MinPhi, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00348 { if (NotInitialized) MinPhi = Phi*Deg2Rad; }

void CosmicMuonGenerator::setMinT0 ( double  T0  ) 

Definition at line 352 of file CosmicMuonGenerator.cc.

References MinT0, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00352 { if (NotInitialized) MinT0 = T0; }

void CosmicMuonGenerator::setMinTheta ( double  Theta  ) 

Definition at line 344 of file CosmicMuonGenerator.cc.

References Deg2Rad, MinTheta, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00344 { if (NotInitialized) MinTheta = Theta*Deg2Rad; }

void CosmicMuonGenerator::setMTCCHalf ( bool  MTCC  ) 

Definition at line 370 of file CosmicMuonGenerator.cc.

References MTCCHalf, and NotInitialized.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00370 { if (NotInitialized) MTCCHalf = MTCC; }

void CosmicMuonGenerator::setNumberOfEvents ( unsigned int  N  ) 

Definition at line 334 of file CosmicMuonGenerator.cc.

References NotInitialized, and NumberOfEvents.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00334 { if (NotInitialized) NumberOfEvents = N; }

void CosmicMuonGenerator::setPlugVx ( double  PlugVtx  ) 

Definition at line 372 of file CosmicMuonGenerator.cc.

References NotInitialized, and PlugVx.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00372 { if (NotInitialized) PlugVx = PlugVtx; }

void CosmicMuonGenerator::setPlugVz ( double  PlugVtz  ) 

Definition at line 373 of file CosmicMuonGenerator.cc.

References NotInitialized, and PlugVz.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00373 { if (NotInitialized) PlugVz = PlugVtz; }

void CosmicMuonGenerator::setRadiusOfTarget ( double  R  ) 

Definition at line 358 of file CosmicMuonGenerator.cc.

References NotInitialized, and RadiusOfTarget.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00358 { if (NotInitialized) RadiusOfTarget = R; }

void CosmicMuonGenerator::setRanSeed ( int  N  ) 

Definition at line 336 of file CosmicMuonGenerator.cc.

References NotInitialized, and RanSeed.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00336 { if (NotInitialized) RanSeed = N; }

void CosmicMuonGenerator::setTIFOnly_constant ( bool  TIF  ) 

Definition at line 366 of file CosmicMuonGenerator.cc.

References NotInitialized, and TIFOnly_constant.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00366 { if (NotInitialized) TIFOnly_constant = TIF; }

void CosmicMuonGenerator::setTIFOnly_linear ( bool  TIF  ) 

Definition at line 368 of file CosmicMuonGenerator.cc.

References NotInitialized, and TIFOnly_linear.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00368 { if (NotInitialized) TIFOnly_linear = TIF; }

void CosmicMuonGenerator::setTrackerOnly ( bool  Tracker  ) 

Definition at line 364 of file CosmicMuonGenerator.cc.

References NotInitialized, and TrackerOnly.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

void CosmicMuonGenerator::setZCentrOfTarget ( double  Z  ) 

Definition at line 362 of file CosmicMuonGenerator.cc.

References NotInitialized, and ZCentrOfTarget.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00362 { if (NotInitialized) ZCentrOfTarget = Z; }

void CosmicMuonGenerator::setZDistOfTarget ( double  Z  ) 

Definition at line 360 of file CosmicMuonGenerator.cc.

References NotInitialized, and ZDistOfTarget.

Referenced by edm::CosMuoGenSource::CosMuoGenSource().

00360 { if (NotInitialized) ZDistOfTarget = Z; }

void CosmicMuonGenerator::terminate ( void   ) 

Definition at line 124 of file CosmicMuonGenerator.cc.

References funct::cos(), GenMuonPlsPt100GeV_cfg::cout, Deg2Rad, ElossScaleFactor, lat::endl(), EventRate, CMSCGENnorm::events_n100cos(), int, MaxP, MaxPhi, MaxT0, MaxTheta, MinP, MinPhi, MinT0, MinTheta, Ndiced, Ngen, CMSCGENnorm::norm(), Norm, Nsel, NumberOfEvents, Pi, Rad2Deg, rateErr_stat, rateErr_syst, funct::sqrt(), SurfaceOfEarth, and SurfaceRadius.

Referenced by runCMG(), and edm::CosMuoGenSource::~CosMuoGenSource().

00124                                    {
00125   if (NumberOfEvents > 0){
00126     std::cout << std::endl;
00127     std::cout << "*********************************************************" << std::endl;
00128     std::cout << "*********************************************************" << std::endl;
00129     std::cout << "***                                                   ***" << std::endl;
00130     std::cout << "***    C O S M I C   M U O N   S T A T I S T I C S    ***" << std::endl;
00131     std::cout << "***                                                   ***" << std::endl;
00132     std::cout << "*********************************************************" << std::endl;
00133     std::cout << "*********************************************************" << std::endl;
00134     std::cout << std::endl;  
00135     std::cout << "       number of initial cosmic events:  " << int(Ngen) << std::endl;
00136     std::cout << "       number of actually diced events:  " << int(Ndiced) << std::endl;
00137     std::cout << "       number of generated and accepted events:  " << int(Nsel) << std::endl;
00138     double selEff = Nsel/Ngen; // selection efficiency
00139     std::cout << "       event selection efficiency:  " << selEff*100. << "%" << std::endl;
00140     int n100cos =  Norm->events_n100cos(0., 0.); //get final amount of cosmics in defined range for normalisation of flux
00141     std::cout << "       events with ~100 GeV and 1 - cos(theta) < 1/2pi: " << n100cos << std::endl;
00142     std::cout << std::endl;
00143     std::cout << "       momentum range: " << MinP             << " ... " << MaxP << " GeV" << std::endl;
00144     std::cout << "       theta  range:   " << MinTheta*Rad2Deg << " ... " << MaxTheta*Rad2Deg << " deg" << std::endl; 
00145     std::cout << "       phi    range:   " << MinPhi*Rad2Deg   << " ... " << MaxPhi*Rad2Deg << " deg" << std::endl;
00146     std::cout << "       time   range:   " << MinT0            << " ... " << MaxT0 << " ns" << std::endl;
00147     std::cout << "       energy  loss:   " << ElossScaleFactor*100. << "%" << std::endl;
00148     std::cout << std::endl;
00149     double area = 1.e-6*Pi*SurfaceRadius*SurfaceRadius; // area on surface [m^2] 
00150     std::cout << "       area of initial cosmics on Surface + PlugWidth:   " << area << " m^2" << std::endl;
00151     std::cout << "       depth of CMS detector (from Surface, without PlugWidth)):   " << SurfaceOfEarth/1000 << " m" << std::endl;
00152     //OneMuoEvt.theta()*Rad2Deg
00153     if(n100cos>0 && MaxTheta<84.26*Deg2Rad){
00154       // rate: corrected for area and selection-Eff. and normalized to known flux, integration over solid angle (dOmega) is implicit
00155       // flux is normalised with respect to known flux of vertical 100GeV muons in area at suface level 
00156       // rate seen by detector is lower than rate at surface area, so has to be corrected for selection-Eff.
00157       // normalisation factor has unit [1/s/m^2] 
00158       // rate = N/time --> normalization factor gives 1/runtime/area 
00159       // normalization with respect to number of actually diced events (Ndiced)
00160       EventRate= (Ndiced * Norm->norm(n100cos)) * area * selEff;
00161       rateErr_stat = EventRate/sqrt( (double) n100cos);  // stat. rate error 
00162       rateErr_syst = EventRate/2.63e-3 * 0.06e-3;  // syst. rate error, from error of known flux 
00163 
00164       // normalisation in region 1.-cos(theta) < 1./(2.*Pi), if MaxTheta even lower correct for this
00165       if(MaxTheta<0.572){
00166         double spacean = 2.*Pi*(1.-cos(MaxTheta));
00167         EventRate= (Ndiced * Norm->norm(n100cos)) * area * selEff * spacean;
00168         rateErr_stat = EventRate/sqrt( (double) n100cos);  // rate error 
00169         rateErr_syst = EventRate/2.63e-3 * 0.06e-3;  // syst. rate error, from error of known flux 
00170       }
00171 
00172     }else{
00173       EventRate=Nsel; //no info as no muons at 100 GeV
00174       rateErr_stat =Nsel;
00175       rateErr_syst =Nsel;
00176       std::cout << std::endl;
00177       if (MinP > 100.)
00178         std::cout << " !!! MinP > 100 GeV. Cannot apply normalisation!" << std::endl;
00179       else if (MaxTheta > 84.26*Deg2Rad)
00180         std::cout << " !!! Note: generated cosmics exceed parameterisation. No flux calculated!" << std::endl;
00181       else 
00182         std::cout << " !!! Not enough statistics to apply normalisation (rate=1 +- 1) !!!" << std::endl;
00183     } 
00184     
00185     std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
00186     std::cout << "       rate is " << EventRate << " +-" << rateErr_stat <<" (stat) " << "+-" << 
00187       rateErr_syst << " (syst) " <<" muons per second" << std::endl;
00188     if(EventRate!=0) std::cout << "       number of events corresponds to " << Nsel/EventRate << " s" << std::endl;  //runtime at CMS = Nsel/rate
00189     std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
00190     std::cout << std::endl;
00191     std::cout << "*********************************************************" << std::endl;
00192     std::cout << "*********************************************************" << std::endl;
00193   }
00194 }


Member Data Documentation

CMSCGEN* CosmicMuonGenerator::Cosmics [private]

Definition at line 89 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), nextEvent(), and ~CosmicMuonGenerator().

double CosmicMuonGenerator::ElossScaleFactor [private]

Definition at line 102 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), nextEvent(), setElossScaleFactor(), and terminate().

double CosmicMuonGenerator::EventRate [private]

Definition at line 111 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), getRate(), and terminate().

double CosmicMuonGenerator::MaxP [private]

Definition at line 95 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), initEvDis(), initialize(), setMaxP(), and terminate().

double CosmicMuonGenerator::MaxPhi [private]

Definition at line 99 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), nextEvent(), setMaxPhi(), and terminate().

double CosmicMuonGenerator::MaxT0 [private]

Definition at line 101 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), nextEvent(), setMaxT0(), and terminate().

double CosmicMuonGenerator::MaxTheta [private]

Definition at line 97 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), initialize(), setMaxTheta(), and terminate().

double CosmicMuonGenerator::MinP [private]

Definition at line 93 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), initEvDis(), initialize(), setMinP(), and terminate().

double CosmicMuonGenerator::MinP_CMS [private]

Definition at line 94 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextEvent(), and setMinP_CMS().

double CosmicMuonGenerator::MinPhi [private]

Definition at line 98 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), nextEvent(), setMinPhi(), and terminate().

double CosmicMuonGenerator::MinT0 [private]

Definition at line 100 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), nextEvent(), setMinT0(), and terminate().

double CosmicMuonGenerator::MinTheta [private]

Definition at line 96 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), initialize(), setMinTheta(), and terminate().

bool CosmicMuonGenerator::MTCCHalf [private]

Definition at line 109 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextEvent(), and setMTCCHalf().

double CosmicMuonGenerator::Ndiced [private]

Definition at line 118 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextEvent(), and terminate().

double CosmicMuonGenerator::Ngen [private]

Definition at line 116 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextEvent(), and terminate().

CMSCGENnorm* CosmicMuonGenerator::Norm [private]

Definition at line 87 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextEvent(), terminate(), and ~CosmicMuonGenerator().

bool CosmicMuonGenerator::NotInitialized [private]

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), setElossScaleFactor(), setMaxP(), setMaxPhi(), setMaxT0(), setMaxTheta(), setMinP(), setMinP_CMS(), setMinPhi(), setMinT0(), setMinTheta(), setMTCCHalf(), setNumberOfEvents(), setPlugVx(), setPlugVz(), setRadiusOfTarget(), setRanSeed(), setTIFOnly_constant(), setTIFOnly_linear(), setTrackerOnly(), setZCentrOfTarget(), and setZDistOfTarget().

double CosmicMuonGenerator::Nsel [private]

Definition at line 117 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextEvent(), and terminate().

unsigned int CosmicMuonGenerator::NumberOfEvents [private]

Definition at line 91 of file CosmicMuonGenerator.h.

Referenced by checkIn(), CosmicMuonGenerator(), initialize(), runCMG(), setNumberOfEvents(), and terminate().

SingleParticleEvent CosmicMuonGenerator::OneMuoEvt

Definition at line 81 of file CosmicMuonGenerator.h.

Referenced by displayEv(), goodOrientation(), initialize(), nextEvent(), and edm::CosMuoGenSource::produce().

double CosmicMuonGenerator::PlugVx [private]

Definition at line 121 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), and setPlugVx().

double CosmicMuonGenerator::PlugVz [private]

Definition at line 122 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), and setPlugVz().

double CosmicMuonGenerator::RadiusOfTarget [private]

Definition at line 103 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), nextEvent(), and setRadiusOfTarget().

TRandom2 CosmicMuonGenerator::RanGen [private]

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by initialize(), and nextEvent().

int CosmicMuonGenerator::RanSeed [private]

Definition at line 92 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), and setRanSeed().

double CosmicMuonGenerator::rateErr_stat [private]

Definition at line 112 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), and terminate().

double CosmicMuonGenerator::rateErr_syst [private]

Definition at line 113 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), and terminate().

double CosmicMuonGenerator::SumIntegrals [private]

Definition at line 115 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator().

double CosmicMuonGenerator::SurfaceRadius [private]

Definition at line 120 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), nextEvent(), and terminate().

double CosmicMuonGenerator::Target3dRadius [private]

Definition at line 119 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), goodOrientation(), initialize(), and nextEvent().

bool CosmicMuonGenerator::TIFOnly_constant [private]

Definition at line 107 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), and setTIFOnly_constant().

bool CosmicMuonGenerator::TIFOnly_linear [private]

Definition at line 108 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), and setTIFOnly_linear().

bool CosmicMuonGenerator::TrackerOnly [private]

Definition at line 106 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), displayEv(), initEvDis(), initialize(), nextEvent(), and setTrackerOnly().

double CosmicMuonGenerator::ZCentrOfTarget [private]

Definition at line 105 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), nextEvent(), and setZCentrOfTarget().

double CosmicMuonGenerator::ZDistOfTarget [private]

Definition at line 104 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), initialize(), nextEvent(), and setZDistOfTarget().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:16:53 2009 for CMSSW by  doxygen 1.5.4