CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
CosmicMuonGenerator Class Reference

#include <CosmicMuonGenerator.h>

Public Member Functions

 CosmicMuonGenerator ()
 
double getRate ()
 
void initialize (CLHEP::HepRandomEngine *rng=0)
 
void nextEvent ()
 
bool nextMultiEvent ()
 
void runCMG ()
 
void setAcptAllMu (bool AllMu)
 
void setClayWidth (double ClayLaeyrWidth)
 
void setElossScaleFactor (double ElossScaleFact)
 
void setMaxEnu (double MaxEn)
 
void setMaxP (double P)
 
void setMaxPhi (double Phi)
 
void setMaxT0 (double T0)
 
void setMaxTheta (double Theta)
 
void setMinEnu (double MinEn)
 
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 setMultiMuon (bool MultiMu)
 
void setMultiMuonFileFirstEvent (int MultiMuFile1stEvt)
 
void setMultiMuonFileName (std::string MultiMuonFileName)
 
void setMultiMuonNmin (int MultiMuNmin)
 
void setNumberOfEvents (unsigned int N)
 
void setNuProdAlt (double NuPrdAlt)
 
void setPlugVx (double PlugVtx)
 
void setPlugVz (double PlugVtz)
 
void setRadiusOfTarget (double R)
 
void setRanSeed (int N)
 
void setRhoAir (double VarRhoAir)
 
void setRhoClay (double VarRhoClay)
 
void setRhoPlug (double VarRhoPlug)
 
void setRhoRock (double VarRhoRock)
 
void setRhoWall (double VarRhoSWall)
 
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

double E_at
 
std::vector< double > E_sf
 
std::vector< double > E_ug
 
double EventWeight
 
int Id_at
 
std::vector< int > Id_sf
 
std::vector< int > Id_ug
 
SingleParticleEvent OneMuoEvt
 
std::vector< double > P_mu
 
double Px_at
 
std::vector< double > Px_mu
 
std::vector< double > Px_sf
 
std::vector< double > Px_ug
 
double Py_at
 
std::vector< double > Py_mu
 
std::vector< double > Py_sf
 
std::vector< double > Py_ug
 
double Pz_at
 
std::vector< double > Pz_mu
 
std::vector< double > Pz_sf
 
std::vector< double > Pz_ug
 
double T0_at
 
std::vector< double > T0_sf
 
std::vector< double > T0_ug
 
double Theta_at
 
std::vector< double > Theta_mu
 
double Trials
 
double Vx_at
 
std::vector< double > Vx_mu
 
std::vector< double > Vx_sf
 
std::vector< double > Vx_ug
 
double Vxz_mu
 
double Vy_at
 
std::vector< double > Vy_mu
 
std::vector< double > Vy_sf
 
std::vector< double > Vy_ug
 
double Vz_at
 
std::vector< double > Vz_mu
 
std::vector< double > Vz_sf
 
std::vector< double > Vz_ug
 

Private Member Functions

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

Private Attributes

bool AcptAllMu
 
double ClayWidth
 
CMSCGENCosmics
 
bool delRanGen
 
double ElossScaleFactor
 
double EventRate
 
double MaxEnu
 
double MaxP
 
double MaxPhi
 
double MaxT0
 
double MaxTheta
 
double MinEnu
 
double MinP
 
double MinP_CMS
 
double MinPhi
 
double MinT0
 
double MinTheta
 
bool MTCCHalf
 
TFile * MultiIn
 
bool MultiMuon
 
int MultiMuonFileFirstEvent
 
std::string MultiMuonFileName
 
int MultiMuonNmin
 
TTree * MultiTree
 
int NcloseMultiMuonEvents
 
double Ndiced
 
double Ngen
 
CMSCGENnormNorm
 
bool NotInitialized
 
double Nsel
 
int NskippedMultiMuonEvents
 
unsigned int NumberOfEvents
 
double NuProdAlt
 
double PlugVx
 
double PlugVz
 
double RadiusOfTarget
 
CLHEP::HepRandomEngine * RanGen
 
int RanSeed
 
double rateErr_stat
 
double rateErr_syst
 
double RhoAir
 
double RhoClay
 
double RhoPlug
 
double RhoRock
 
double RhoWall
 
simSimTree
 
ULong64_t SimTree_jentry
 
ULong64_t SimTreeEntries
 
double SumIntegrals
 
double SurfaceRadius
 
double Target3dRadius
 
bool TIFOnly_constant
 
bool TIFOnly_linear
 
bool TrackerOnly
 
double ZCentrOfTarget
 
double ZDistOfTarget
 

Detailed Description

Definition at line 31 of file CosmicMuonGenerator.h.

Constructor & Destructor Documentation

CosmicMuonGenerator::CosmicMuonGenerator ( )
inline

Definition at line 34 of file CosmicMuonGenerator.h.

References ClayWidth, Cosmics, gather_cfg::cout, Deg2Rad, ElossScaleFactor, EventRate, MaxP, MaxPhi, MaxT0, MaxTheta, MinP, MinP_CMS, MinPhi, MinT0, MinTheta, MTCCHalf, MultiMuon, MultiMuonFileFirstEvent, MultiMuonFileName, MultiMuonNmin, Ndiced, Ngen, Norm, NotInitialized, Nsel, NumberOfEvents, PlugOnShaftVx, PlugOnShaftVz, PlugVx, PlugVz, RadiusOfTarget, RanSeed, rateErr_stat, rateErr_syst, RhoAir, RhoClay, RhoPlug, RhoRock, RhoWall, SumIntegrals, SurfaceRadius, Target3dRadius, TIFOnly_constant, TIFOnly_linear, TrackerOnly, ZCentrOfTarget, and ZDistOfTarget.

34  : delRanGen(false)
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  }
const double PlugOnShaftVz
const double PlugOnShaftVx
const double Deg2Rad
tuple cout
Definition: gather_cfg.py:121
CosmicMuonGenerator::~CosmicMuonGenerator ( )
inline

Definition at line 101 of file CosmicMuonGenerator.h.

References Cosmics, delRanGen, Norm, and RanGen.

102  {
103  if (delRanGen)
104  delete RanGen;
105  delete Norm;
106  delete Cosmics;
107  }
CLHEP::HepRandomEngine * RanGen

Member Function Documentation

void CosmicMuonGenerator::checkIn ( )
private

Definition at line 868 of file CosmicMuonGenerator.cc.

References gather_cfg::cout, ElossScaleFactor, MaxEnu, MaxP, MaxPhi, MaxT0, MaxTheta, MinEnu, MinP, MinPhi, MinT0, MinTheta, and NumberOfEvents.

Referenced by initialize().

868  {
869  if (MinP < 0.){ NumberOfEvents = 0;
870  std::cout << " CMG-ERR: min.energy is out of range (0 GeV ... inf]" << std::endl << std::endl; }
871  if (MaxP < 0.){ NumberOfEvents = 0;
872  std::cout << " CMG-ERR: max.energy is out of range (0 GeV ... inf]" << std::endl << std::endl; }
873  if (MaxP <= MinP){ NumberOfEvents = 0;
874  std::cout << " CMG-ERR: max.energy is not greater than min.energy" << std::endl << std::endl; }
875  if (MinTheta < 0.){ NumberOfEvents = 0;
876  std::cout << " CMG-ERR: min.theta is out of range [0 deg ... 90 deg)" << std::endl << std::endl; }
877  if (MaxTheta < 0.){ NumberOfEvents = 0;
878  std::cout << " CMG-ERR: max.theta is out of range [0 deg ... 90 deg)" << std::endl << std::endl; }
879  if (MaxTheta <= MinTheta){ NumberOfEvents = 0;
880  std::cout << " CMG-ERR: max.theta is not greater than min.theta" << std::endl << std::endl; }
881  if (MinPhi < 0.){ NumberOfEvents = 0;
882  std::cout << " CMG-ERR: min.phi is out of range [0 deg ... 360 deg]" << std::endl << std::endl; }
883  if (MaxPhi < 0.){ NumberOfEvents = 0;
884  std::cout << " CMG-ERR: max.phi is out of range [0 deg ... 360 deg]" << std::endl << std::endl; }
885  if (MaxPhi <= MinPhi){ NumberOfEvents = 0;
886  std::cout << " CMG-ERR: max.phi is not greater than min.phi" << std::endl << std::endl; }
887  if (MaxT0 <= MinT0){ NumberOfEvents = 0;
888  std::cout << " CMG-ERR: max.t0 is not greater than min.t0" << std::endl << std::endl; }
889  if (ElossScaleFactor < 0.){ NumberOfEvents = 0;
890  std::cout << " CMG-ERR: E-loss scale factor is out of range [0 ... inf)" << std::endl << std::endl; }
891  if (MinEnu < 0.){ NumberOfEvents = 0;
892  std::cout << " CMG-ERR: min.Enu is out of range [0 GeV ... inf]" << std::endl << std::endl; }
893  if (MaxEnu < 0.){ NumberOfEvents = 0;
894  std::cout << " CMG-ERR: max.Enu is out of range [0 GeV ... inf]" << std::endl << std::endl; }
895  if (MaxEnu <= MinEnu){ NumberOfEvents = 0;
896  std::cout << " CMG-ERR: max.Enu is not greater than min.Enu" << std::endl << std::endl; }
897 
898 }
tuple cout
Definition: gather_cfg.py:121
void CosmicMuonGenerator::displayEv ( )
private

Definition at line 979 of file CosmicMuonGenerator.cc.

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

Referenced by nextEvent().

979  {
980 #if ROOT_INTERACTIVE
981  double RadiusDet=RadiusCMS;
982  double Z_DistDet=Z_DistCMS;
983  if(TrackerOnly==true){
984  RadiusDet = RadiusTracker;
985  Z_DistDet = Z_DistTracker;
986  }
987  disXY->Reset();
988  disZY->Reset();
989  TMarker* InteractionPoint = new TMarker(0.,0.,2);
990  TArc* r8m = new TArc(0.,0.,(RadiusDet/1000.));
991  TLatex* logEaxis = new TLatex(); logEaxis->SetTextSize(0.05);
992  float energy = float(OneMuoEvt.e());
993  float verX = float(OneMuoEvt.vx()/1000.); // [m]
994  float verY = float(OneMuoEvt.vy()/1000.); // [m]
995  float verZ = float(OneMuoEvt.vz()/1000.); // [m]
996  float dirX = float(OneMuoEvt.px())/std::fabs(OneMuoEvt.py());
997  float dirY = float(OneMuoEvt.py())/std::fabs(OneMuoEvt.py());
998  float dirZ = float(OneMuoEvt.pz())/std::fabs(OneMuoEvt.py());
999  float yStep = disXY->GetYaxis()->GetBinWidth(1);
1000  int NbinY = disXY->GetYaxis()->GetNbins();
1001  for (int iy=0; iy<NbinY; ++iy){
1002  verX += dirX*yStep;
1003  verY += dirY*yStep;
1004  verZ += dirZ*yStep;
1005  float rXY = sqrt(verX*verX + verY*verY)*1000.; // [mm]
1006  float absZ = std::fabs(verZ)*1000.; // [mm]
1007  if (rXY < RadiusDet && absZ < Z_DistDet){
1008  disXY->Fill(verX,verY,log10(energy));
1009  disZY->Fill(verZ,verY,log10(energy));
1010  disC->cd(1); disXY->Draw("COLZ"); InteractionPoint->Draw("SAME"); r8m->Draw("SAME");
1011  logEaxis->DrawLatex((0.65*RadiusDet/1000.),(1.08*RadiusDet/1000.),"log_{10}E(#mu^{#pm})");
1012  disC->cd(2); disZY->Draw("COL"); InteractionPoint->Draw("SAME");
1013  gPad->Update();
1014  }
1015  }
1016 #endif
1017 }
const double Z_DistTracker
const double RadiusCMS
T sqrt(T t)
Definition: SSEVec.h:46
const double Z_DistCMS
SingleParticleEvent OneMuoEvt
const double RadiusTracker
double CosmicMuonGenerator::getRate ( )

Definition at line 1074 of file CosmicMuonGenerator.cc.

References EventRate.

1074 { return EventRate; }
bool CosmicMuonGenerator::goodOrientation ( )
private

Definition at line 900 of file CosmicMuonGenerator.cc.

References gather_cfg::cout, Deg2Rad, dPhi(), MinTheta, OneMuoEvt, colinearityKinematic::Phi, SingleParticleEvent::phi(), Pi, PlugWidth, RadiusCMS, mathSSE::sqrt(), SurfaceOfEarth, Target3dRadius, SingleParticleEvent::theta(), TwoPi, SingleParticleEvent::vx(), and SingleParticleEvent::vz().

Referenced by nextEvent(), and nextMultiEvent().

900  {
901  // check angular range (for a sphere with Target3dRadius around the target)
902  bool goodAngles = false;
903  bool phiaccepted = false;
904  bool thetaaccepted = false;
905  double RxzV = sqrt(OneMuoEvt.vx()*OneMuoEvt.vx() + OneMuoEvt.vz()*OneMuoEvt.vz());
906 
907  double rVY;
908  if (MinTheta > 90.*Deg2Rad) //upgoing muons from neutrinos
909  rVY = -sqrt(RxzV*RxzV + RadiusCMS*RadiusCMS);
910  else
911  rVY = sqrt(RxzV*RxzV + (SurfaceOfEarth+PlugWidth)*(SurfaceOfEarth+PlugWidth));
912 
913  double Phi = OneMuoEvt.phi();
914  double PhiV = atan2(OneMuoEvt.vx(),OneMuoEvt.vz()) + Pi; if (PhiV > TwoPi) PhiV -= TwoPi;
915  double disPhi = std::fabs(PhiV - Phi); if (disPhi > Pi) disPhi = TwoPi - disPhi;
916  double dPhi = Pi; if (RxzV > Target3dRadius) dPhi = asin(Target3dRadius/RxzV);
917  if (disPhi < dPhi) phiaccepted = true;
918  double Theta = OneMuoEvt.theta();
919  double ThetaV = asin(RxzV/rVY);
920  double dTheta = Pi; if (std::fabs(rVY) > Target3dRadius) dTheta = asin(Target3dRadius/std::fabs(rVY));
921  //std::cout << " dPhi = " << dPhi << " (" << Phi << " <p|V> " << PhiV << ")" << std::endl;
922  //std::cout << " dTheta = " << dTheta << " (" << Theta << " <p|V> " << ThetaV << ")" << std::endl;
923 
924  if (!phiaccepted && RxzV < Target3dRadius)
925  //if (RxzV < Target3dRadius)
926  std::cout << "Rejected phi=" << Phi << " PhiV=" << PhiV
927  << " dPhi=" << dPhi << " disPhi=" << disPhi
928  << " RxzV=" << RxzV << " Target3dRadius=" << Target3dRadius
929  << " Theta=" << Theta << std::endl;
930 
931  if (std::fabs(Theta-ThetaV) < dTheta) thetaaccepted = true;
932  if (phiaccepted && thetaaccepted) goodAngles = true;
933  return goodAngles;
934 }
const double TwoPi
const double Pi
const double PlugWidth
const double RadiusCMS
const double SurfaceOfEarth
const double Deg2Rad
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:46
SingleParticleEvent OneMuoEvt
tuple cout
Definition: gather_cfg.py:121
void CosmicMuonGenerator::initEvDis ( )
private

Definition at line 936 of file CosmicMuonGenerator.cc.

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

Referenced by initialize().

936  {
937 #if ROOT_INTERACTIVE
938  float rCMS = RadiusCMS/1000.;
939  float zCMS = Z_DistCMS/1000.;
940  if(TrackerOnly==true){
941  rCMS = RadiusTracker/1000.;
942  zCMS = Z_DistTracker/1000.;
943 }
944  TH2F* disXY = new TH2F("disXY","X-Y view",160,-rCMS,rCMS,160,-rCMS,rCMS);
945  TH2F* disZY = new TH2F("disZY","Z-Y view",150,-zCMS,zCMS,160,-rCMS,rCMS);
946  gStyle->SetPalette(1,0);
947  gStyle->SetMarkerColor(1);
948  gStyle->SetMarkerSize(1.5);
949  TCanvas *disC = new TCanvas("disC","Cosmic Muon Event Display",0,0,800,410);
950  disC->Divide(2,1);
951  disC->cd(1);
952  gPad->SetTicks(1,1);
953  disXY->SetMinimum(log10(MinP));
954  disXY->SetMaximum(log10(MaxP));
955  disXY->GetXaxis()->SetLabelSize(0.05);
956  disXY->GetXaxis()->SetTitleSize(0.05);
957  disXY->GetXaxis()->SetTitleOffset(1.0);
958  disXY->GetXaxis()->SetTitle("X [m]");
959  disXY->GetYaxis()->SetLabelSize(0.05);
960  disXY->GetYaxis()->SetTitleSize(0.05);
961  disXY->GetYaxis()->SetTitleOffset(0.8);
962  disXY->GetYaxis()->SetTitle("Y [m]");
963  disC->cd(2);
964  gPad->SetGrid(1,1);
965  gPad->SetTicks(1,1);
966  disZY->SetMinimum(log10(MinP));
967  disZY->SetMaximum(log10(MaxP));
968  disZY->GetXaxis()->SetLabelSize(0.05);
969  disZY->GetXaxis()->SetTitleSize(0.05);
970  disZY->GetXaxis()->SetTitleOffset(1.0);
971  disZY->GetXaxis()->SetTitle("Z [m]");
972  disZY->GetYaxis()->SetLabelSize(0.05);
973  disZY->GetYaxis()->SetTitleSize(0.05);
974  disZY->GetYaxis()->SetTitleOffset(0.8);
975  disZY->GetYaxis()->SetTitle("Y [m]");
976 #endif
977 }
const double Z_DistTracker
const double RadiusCMS
const double Z_DistCMS
const double RadiusTracker
void CosmicMuonGenerator::initialize ( CLHEP::HepRandomEngine *  rng = 0)

Definition at line 18 of file CosmicMuonGenerator.cc.

References checkIn(), Cosmics, gather_cfg::cout, Debug, Deg2Rad, delRanGen, EventDisplay, sim::fChain, sim::Init(), initEvDis(), CMSCGEN::initialize(), CMSCGEN::initializeNuMu(), MaxEnu, MaxP, MaxPhi, MaxTheta, MinEnu, MinP, MinPhi, MinStepSize, MinTheta, MultiIn, MultiMuon, MultiMuonFileFirstEvent, MultiMuonFileName, MultiTree, NcloseMultiMuonEvents, NotInitialized, NskippedMultiMuonEvents, NumberOfEvents, NuProdAlt, OneMuoEvt, phi, SingleParticleEvent::PlugVx, PlugVx, SingleParticleEvent::PlugVz, PlugVz, PlugWidth, RadiusCMS, RadiusOfTarget, RadiusTracker, RanGen, RanSeed, SingleParticleEvent::RhoAir, RhoAir, SingleParticleEvent::RhoClay, RhoClay, SingleParticleEvent::RhoPlug, RhoPlug, SingleParticleEvent::RhoRock, RhoRock, SingleParticleEvent::RhoWall, RhoWall, SimTree, SimTree_jentry, SimTreeEntries, mathSSE::sqrt(), SurfaceOfEarth, SurfaceRadius, funct::tan(), Target3dRadius, TIFOnly_constant, TIFOnly_linear, TrackerOnly, Z_DistTracker, and ZDistOfTarget.

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

18  {
19  if (delRanGen)
20  delete RanGen;
21  if (!rng) {
22  RanGen = new CLHEP::HepJamesRandom;
23  RanGen->setSeed(RanSeed, 0); //set seed for Random Generator (seed can be controled by config-file)
24  delRanGen = true;
25  } else {
26  RanGen = rng;
27  delRanGen = false;
28  }
29  checkIn();
30  if (NumberOfEvents > 0){
31  // set up "surface geometry" dimensions
32  double RadiusTargetEff = RadiusOfTarget; //get this from cfg-file
33  double Z_DistTargetEff = ZDistOfTarget; //get this from cfg-file
34  //double Z_CentrTargetEff = ZCentrOfTarget; //get this from cfg-file
35  if(TrackerOnly==true){
36  RadiusTargetEff = RadiusTracker;
37  Z_DistTargetEff = Z_DistTracker;
38  }
39  Target3dRadius = sqrt(RadiusTargetEff*RadiusTargetEff + Z_DistTargetEff*Z_DistTargetEff) + MinStepSize;
40  if (Debug) std::cout << " radius of sphere around target = " << Target3dRadius << " mm" << std::endl;
41 
42  if (MinTheta > 90.*Deg2Rad) //upgoing muons from neutrinos
44  else
46  if (Debug) std::cout << " starting point radius at Surface + PlugWidth = " << SurfaceRadius << " mm" << std::endl;
47 
55  //set energy and angle limits for CMSCGEN, give same seed as above
56  if (MinTheta >= 90.*Deg2Rad) //upgoing muons from neutrinos
59  else
61 
62 #if ROOT_INTERACTIVE
63  // book histos
64  TH1D* ene = new TH1D("ene","generated energy",210,0.,1050.);
65  TH1D* the = new TH1D("the","generated theta",90,0.,90.);
66  TH1D* phi = new TH1D("phi","generated phi",120,0.,360.);
67  TH3F* ver = new TH3F("ver","Z-X-Y coordinates",100,-25.,25.,20,-10.,10.,40,-10.,10.);
68 #endif
69  if (EventDisplay) initEvDis();
70  std::cout << std::endl;
71 
72  if (MultiMuon) {
73  MultiIn = 0;
74 
75  std::cout << "MultiMuonFileName.c_str()=" << MultiMuonFileName.c_str() << std::endl;
76  MultiIn = new TFile( MultiMuonFileName.c_str() );
77 
78  if (!MultiIn) std::cout << "MultiMuon=True: MultiMuonFileName='"
79  << MultiMuonFileName.c_str() << "' does not exist" << std::endl;
80  else std::cout << "MultiMuonFile: " << MultiMuonFileName.c_str() << " opened!" << std::endl;
81  //MultiTree = (TTree*) gDirectory->Get("sim");
82  MultiTree = (TTree*) MultiIn->Get("sim");
83  SimTree = new sim(MultiTree);
85  SimTreeEntries = SimTree->fChain->GetEntriesFast();
86  std::cout << "SimTreeEntries=" << SimTreeEntries << std::endl;
87 
88  if (MultiMuonFileFirstEvent <= 0)
89  SimTree_jentry = 0;
90  else
91  SimTree_jentry = MultiMuonFileFirstEvent - 1; //1=1st evt (SimTree_jentry=0)
92 
95  }
96 
97  if (!MultiMuon || (MultiMuon && MultiIn)) NotInitialized = false;
98 
99  }
100 }
const double Z_DistTracker
TTree * fChain
Definition: sim.h:21
int initialize(double, double, double, double, CLHEP::HepRandomEngine *, bool, bool)
Definition: CMSCGEN.cc:23
virtual void Init(TTree *tree)
Definition: sim.h:19
const double PlugWidth
const double RadiusCMS
const double SurfaceOfEarth
const double Deg2Rad
T sqrt(T t)
Definition: SSEVec.h:46
CLHEP::HepRandomEngine * RanGen
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
SingleParticleEvent OneMuoEvt
const double MinStepSize
const bool EventDisplay
const double RadiusTracker
tuple cout
Definition: gather_cfg.py:121
int initializeNuMu(double, double, double, double, double, double, double, double, double, CLHEP::HepRandomEngine *)
Definition: CMSCGEN.cc:495
const bool Debug
Definition: DDAxes.h:10
void CosmicMuonGenerator::nextEvent ( )

Definition at line 102 of file CosmicMuonGenerator.cc.

References AcptAllMu, funct::cos(), CMSCGEN::cos_theta(), Cosmics, gather_cfg::cout, SingleParticleEvent::create(), Debug, Deg2Rad, displayEv(), dPhi(), SingleParticleEvent::e(), E_at, E_sf, E_ug, ElossScaleFactor, EventDisplay, CMSCGENnorm::events_n100cos(), EventWeight, CMSCGEN::generate(), CMSCGEN::generateNuMu(), goodOrientation(), SingleParticleEvent::hitTarget(), SingleParticleEvent::id(), errorMatrix2Lands_multiChannel::id, Id_at, Id_sf, Id_ug, SingleParticleEvent::m(), MaxPhi, MaxT0, MinP_CMS, MinPhi, MinT0, MinTheta, CMSCGEN::momentum_times_charge(), MTCCHalf, MuonMass, Ndiced, Ngen, Norm, Nsel, OneMuoEvt, phi, colinearityKinematic::Phi, SingleParticleEvent::phi(), Pi, PlugWidth, SingleParticleEvent::propagate(), SingleParticleEvent::px(), Px_at, Px_sf, Px_ug, SingleParticleEvent::py(), Py_at, Py_sf, Py_ug, SingleParticleEvent::pz(), Pz_at, Pz_sf, Pz_ug, Rad2Deg, RadiusCMS, RadiusOfTarget, RanGen, funct::sin(), SpeedOfLight, mathSSE::sqrt(), SurfaceOfEarth, SurfaceRadius, SingleParticleEvent::t0(), T0_at, T0_sf, T0_ug, Target3dRadius, SingleParticleEvent::theta(), TrackerOnly, TwoPi, SingleParticleEvent::vx(), Vx_at, Vx_sf, Vx_ug, SingleParticleEvent::vy(), Vy_at, Vy_sf, Vy_ug, SingleParticleEvent::vz(), Vz_at, Vz_sf, Vz_ug, ZCentrOfTarget, and ZDistOfTarget.

Referenced by runCMG().

102  {
103 
104  double E = 0.; double Theta = 0.; double Phi = 0.; double RxzV = 0.; double PhiV = 0.;
105  if (int(Nsel)%100 == 0) std::cout << " generated " << int(Nsel) << " events" << std::endl;
106  // generate cosmic (E,theta,phi)
107  bool notSelected = true;
108  while (notSelected){
109  bool badMomentumGenerated = true;
110  while (badMomentumGenerated){
111 
112  if (MinTheta > 90.*Deg2Rad) //upgoing muons from neutrinos
114  else
115  Cosmics->generate(); //dice one event now
116 
118  Theta = TMath::ACos( Cosmics->cos_theta() ) ; //angle has to be in RAD here
119  Ngen+=1.; //count number of initial cosmic events (in surface area), vertices will be added later
120  badMomentumGenerated = false;
121  Phi = RanGen->flat()*(MaxPhi-MinPhi) + MinPhi;
122  }
123  Norm->events_n100cos(E, Theta); //test if this muon is in normalization range
124  Ndiced += 1; //one more cosmic is diced
125 
126  // generate vertex
127  double Nver = 0.;
128  bool badVertexGenerated = true;
129  while (badVertexGenerated){
130  RxzV = sqrt(RanGen->flat())*SurfaceRadius;
131  PhiV = RanGen->flat()*TwoPi;
132  // check phi range (for a sphere with Target3dRadius around the target)
133  double dPhi = Pi; if (RxzV > Target3dRadius) dPhi = asin(Target3dRadius/RxzV);
134  double rotPhi = PhiV + Pi; if (rotPhi > TwoPi) rotPhi -= TwoPi;
135  double disPhi = std::fabs(rotPhi - Phi); if (disPhi > Pi) disPhi = TwoPi - disPhi;
136  if (disPhi < dPhi || AcptAllMu) badVertexGenerated = false;
137  Nver+=1.;
138  }
139  Ngen += (Nver-1.); //add number of generated vertices to initial cosmic events
140 
141  // complete event at surface
142  int id = 13; // mu-
143  if (Cosmics->momentum_times_charge() >0.) id = -13; // mu+
144  double absMom = sqrt(E*E - MuonMass*MuonMass);
145  double verMom = absMom*cos(Theta);
146  double horMom = absMom*sin(Theta);
147  double Px = horMom*sin(Phi); // [GeV/c]
148  double Py = -verMom; // [GeV/c]
149  double Pz = horMom*cos(Phi); // [GeV/c]
150  double Vx = RxzV*sin(PhiV); // [mm]
151 
152  double Vy;
153  if (MinTheta > 90.*Deg2Rad) //upgoing muons from neutrinos
154  Vy = -RadiusCMS;
155  else
156  Vy = SurfaceOfEarth + PlugWidth; // [mm]
157 
158  double Vz = RxzV*cos(PhiV); // [mm]
159  double T0 = (RanGen->flat()*(MaxT0-MinT0) + MinT0)*SpeedOfLight; // [mm/c];
160 
161  Id_at = id;
162  Px_at = Px; Py_at = Py; Pz_at = Pz; E_at = E; //M_at = MuonMass;
163  Vx_at = Vx; Vy_at = Vy; Vz_at = Vz; T0_at = T0;
164 
165  OneMuoEvt.create(id, Px, Py, Pz, E, MuonMass, Vx, Vy, Vz, T0);
166  // if angles are ok, propagate to target
167  if (goodOrientation()) {
168  if (MinTheta > 90.*Deg2Rad) //upgoing muons from neutrinos
170  else
172  }
173 
175  || AcptAllMu==true){
176  Nsel+=1.; //count number of generated and accepted events
177  notSelected = false;
178  }
179  }
180 
181  EventWeight = 1.;
182 
183  //just one outgoing particle at SurFace
184  Id_sf.resize(1);
185  Px_sf.resize(1);
186  Py_sf.resize(1);
187  Pz_sf.resize(1);
188  E_sf.resize(1);
189  //M_sf.resize(1);
190  Vx_sf.resize(1);
191  Vy_sf.resize(1);
192  Vz_sf.resize(1);
193  T0_sf.resize(1);
194 
195  Id_sf[0] = Id_at;
196  Px_sf[0] = Px_at; Py_sf[0] = Py_at; Pz_sf[0] = Pz_at; E_sf[0] = E_at; //M_fs[0] = MuonMass;
197  Vx_sf[0] = Vx_at; Vy_sf[0] = Vy_at; Vz_sf[0] = Vz_at; T0_sf[0] = T0_at;
198 
199 
200  //just one particle at UnderGround
201  Id_ug.resize(1);
202  Px_ug.resize(1);
203  Py_ug.resize(1);
204  Pz_ug.resize(1);
205  E_ug.resize(1);
206  //M_ug.resize(1);
207  Vx_ug.resize(1);
208  Vy_ug.resize(1);
209  Vz_ug.resize(1);
210  T0_ug.resize(1);
211 
212  Id_ug[0] = OneMuoEvt.id();
213  Px_ug[0] = OneMuoEvt.px();
214  Py_ug[0] = OneMuoEvt.py();
215  Pz_ug[0] = OneMuoEvt.pz();
216  E_ug[0] = OneMuoEvt.e();
217  //M_ug[0] = OneMuoEvt.m();
218  Vx_ug[0] = OneMuoEvt.vx();
219  Vy_ug[0] = OneMuoEvt.vy();
220  Vz_ug[0] = OneMuoEvt.vz();
221  T0_ug[0] = OneMuoEvt.t0();
222 
223  // plot variables of selected events
224 #if ROOT_INTERACTIVE
225  ene->Fill(OneMuoEvt.e());
226  the->Fill((OneMuoEvt.theta()*Rad2Deg));
227  phi->Fill((OneMuoEvt.phi()*Rad2Deg));
228  ver->Fill((OneMuoEvt.vz()/1000.),(OneMuoEvt.vx()/1000.),(OneMuoEvt.vy()/1000.));
229 #endif
230  if (Debug){
231  std::cout << "new event" << std::endl;
232  std::cout << " Px,Py,Pz,E,m = " << OneMuoEvt.px() << ", " << OneMuoEvt.py() << ", "
233  << OneMuoEvt.pz() << ", " << OneMuoEvt.e() << ", " << OneMuoEvt.m() << " GeV" << std::endl;
234  std::cout << " Vx,Vy,Vz,t0 = " << OneMuoEvt.vx() << ", " << OneMuoEvt.vy() << ", "
235  << OneMuoEvt.vz() << ", " << OneMuoEvt.t0() << " mm" << std::endl;
236  }
237  if (EventDisplay) displayEv();
238 
239 }
const double TwoPi
const double Pi
void propagate(double ElossScaleFac, double RadiusTarget, double Z_DistTarget, double Z_CentrTarget, bool TrackerOnly, bool MTCCHalf)
int events_n100cos(double energy, double theta)
Definition: CMSCGENnorm.cc:15
std::vector< double > Px_ug
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< int > Id_ug
std::vector< double > Py_sf
std::vector< double > E_sf
const double SpeedOfLight
std::vector< double > E_ug
double cos_theta()
Definition: CMSCGEN.cc:462
const double PlugWidth
std::vector< double > Vz_ug
int generate()
Definition: CMSCGEN.cc:256
const double RadiusCMS
const double SurfaceOfEarth
std::vector< double > Vz_sf
const double Deg2Rad
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< double > Vx_sf
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< double > Vy_sf
CLHEP::HepRandomEngine * RanGen
SingleParticleEvent OneMuoEvt
std::vector< double > T0_sf
std::vector< double > Px_sf
std::vector< double > Vy_ug
double momentum_times_charge()
Definition: CMSCGEN.cc:447
std::vector< double > Pz_ug
void create(int id, double px, double py, double pz, double e, double m, double vx, double vy, double vz, double t0)
const bool EventDisplay
const double MuonMass
tuple cout
Definition: gather_cfg.py:121
const double Rad2Deg
std::vector< double > Vx_ug
int generateNuMu()
Definition: CMSCGEN.cc:588
std::vector< double > Py_ug
const bool Debug
std::vector< double > T0_ug
std::vector< int > Id_sf
std::vector< double > Pz_sf
Definition: DDAxes.h:10
bool CosmicMuonGenerator::nextMultiEvent ( )

Definition at line 243 of file CosmicMuonGenerator.cc.

References AcptAllMu, funct::cos(), gather_cfg::cout, SingleParticleEvent::create(), Debug, dPhi(), SingleParticleEvent::e(), E_at, E_sf, E_ug, ElossScaleFactor, EventWeight, sim::GetEntry(), goodOrientation(), SingleParticleEvent::hitTarget(), SingleParticleEvent::id(), Id_at, Id_sf, Id_ug, max(), max_Trials, MaxT0, min, MinP_CMS, MinT0, MTCCHalf, MultiMuonNmin, MuonMass, NcloseMultiMuonEvents, Ngen, NorthCMSzDeltaPhi, Nsel, NskippedMultiMuonEvents, OneMuoEvt, P_mu, sim::particle__ParticleID, sim::particle__Px, sim::particle__Py, sim::particle__Pz, sim::particle__Time, sim::particle__x, sim::particle__y, Pi, PlugWidth, funct::pow(), SingleParticleEvent::propagate(), SingleParticleEvent::px(), Px_at, Px_mu, Px_sf, Px_ug, SingleParticleEvent::py(), Py_at, Py_mu, Py_sf, Py_ug, SingleParticleEvent::pz(), Pz_at, Pz_mu, Pz_sf, Pz_ug, RadiusOfTarget, RanGen, sim::shower_Energy, sim::shower_EventID, sim::shower_GH_t0, sim::shower_nParticlesWritten, sim::shower_Phi, sim::shower_Theta, SimTree, SimTree_jentry, SimTreeEntries, funct::sin(), SpeedOfLight, mathSSE::sqrt(), SurfaceOfEarth, SurfaceRadius, SingleParticleEvent::t0(), T0_at, T0_sf, T0_ug, funct::tan(), Target3dRadius, Theta_at, Theta_mu, TrackerOnly, Trials, funct::true, TwoPi, SingleParticleEvent::vx(), Vx_at, Vx_mu, Vx_sf, Vx_ug, Vxz_mu, SingleParticleEvent::vy(), Vy_at, Vy_mu, Vy_sf, Vy_ug, SingleParticleEvent::vz(), Vz_at, Vz_mu, Vz_sf, Vz_ug, ZCentrOfTarget, and ZDistOfTarget.

243  {
244 
245  if (Debug) std::cout << "\nEntered CosmicMuonGenerator::nextMultiEvent()" << std::endl;
246  bool EvtRejected = true;
247  bool MuInMaxDist = false;
248  double MinDist; //[mm]
249 
250  while (EvtRejected) {
251 
252  //read in event from SimTree
253  //ULong64_t ientry = SimTree->LoadTree(SimTree_jentry);
254  Long64_t ientry = SimTree->GetEntry(SimTree_jentry);
255  std::cout << "CosmicMuonGenerator::nextMultiEvent(): SimTree_jentry=" << SimTree_jentry
256  //<< " ientry=" << ientry
257  << " SimTreeEntries=" << SimTreeEntries << std::endl;
258  if (ientry < 0) return false; //stop run
260  SimTree_jentry++;
261  }
262  else {
263  std::cout << "CosmicMuonGenerator.cc::nextMultiEvent: No more events in file!" << std::endl;
264  return false; //stop run
265  }
266 
267 
268 
269  int nmuons = SimTree->shower_nParticlesWritten;
270  if (nmuons<MultiMuonNmin) {
271  std::cout << "CosmicMuonGenerator.cc: Warning! Less than " << MultiMuonNmin <<
272  " muons in event!" << std::endl;
273  std::cout << "trying next event from file" << std::endl;
275  continue; //EvtRejected while loop: get next event from file
276  }
277 
278 
279 
280  Px_mu.resize(nmuons); Py_mu.resize(nmuons); Pz_mu.resize(nmuons);
281  P_mu.resize(nmuons);
282 
283  MinDist = 99999.e9; //[mm]
284  double MuMuDist;
285  MuInMaxDist = false;
286  //check if at least one muon pair closer than 30m at surface
287  int NmuPmin = 0;
288  for (int imu=0; imu<nmuons; ++imu) {
289 
294  Py_mu[imu] = -SimTree->particle__Pz[imu]; //Corsika down going particles defined in -z direction!
295  P_mu[imu] = sqrt(Px_mu[imu]*Px_mu[imu] + Py_mu[imu]*Py_mu[imu] + Pz_mu[imu]*Pz_mu[imu]);
296 
297  if (P_mu[imu] < MinP_CMS && AcptAllMu==false) continue;
298  else if (SimTree->particle__ParticleID[imu] != 5 &&
299  SimTree->particle__ParticleID[imu] != 6) continue;
300  else NmuPmin++;
301 
302  for (int jmu=0; jmu<imu; ++jmu) {
303  if (P_mu[jmu] < MinP_CMS && AcptAllMu==false) continue;
304  if (SimTree->particle__ParticleID[imu] != 5 &&
305  SimTree->particle__ParticleID[imu] != 6) continue;
306  MuMuDist = sqrt( (SimTree->particle__x[imu]-SimTree->particle__x[jmu])*
307  (SimTree->particle__x[imu]-SimTree->particle__x[jmu])
308  +(SimTree->particle__y[imu]-SimTree->particle__y[jmu])*
309  (SimTree->particle__y[imu]-SimTree->particle__y[jmu])
310  )*10.; //CORSIKA [cm] to CMSCGEN [mm]
311  if (MuMuDist < MinDist) MinDist = MuMuDist;
312  if (MuMuDist < 2.*Target3dRadius) MuInMaxDist = true;
313  }
314  }
315  if (MultiMuonNmin>=2) {
316  if (MuInMaxDist) {
318  }
319  else {
320  std::cout << "CosmicMuonGenerator.cc: Warning! No muon pair closer than "
321  << 2.*Target3dRadius/1000. << "m MinDist=" << MinDist/1000. << "m at surface" << std::endl;
322  std::cout << "Fraction of too wide opening angle multi muon events: "
323  << 1 - double(NcloseMultiMuonEvents)/SimTree_jentry << std::endl;
324  std::cout << "NcloseMultiMuonEvents=" << NcloseMultiMuonEvents << std::endl;
325  std::cout << "trying next event from file" << std::endl;
327  continue; //EvtRejected while loop: get next event from file
328  }
329  }
330 
331  if (NmuPmin < MultiMuonNmin && AcptAllMu==false) { //take single muon events consistently into account
333  continue; //EvtRejected while loop: get next event from file
334  }
335 
336  if (Debug)
337  if (MultiMuonNmin>=2)
338  std::cout << "start trial do loop: MuMuDist=" << MinDist/1000. << "[m] Nmuons="
339  << nmuons << " NcloseMultiMuonEvents=" << NcloseMultiMuonEvents
340  << " NskippedMultiMuonEvents=" << NskippedMultiMuonEvents << std::endl;
341 
342 
343  //int primary_id = SimTree->run_ParticleID;
345 
346  double M_at = 0.;
347  //if (Id_at == 13) {
348  Id_at = 2212; //convert from Corsika to HepPDT
349  M_at = 938.272e-3; //[GeV] mass
350  //}
351 
354  double phi_at = SimTree->shower_Phi - NorthCMSzDeltaPhi; //rotate by almost 90 degrees
355  if (phi_at < -Pi) phi_at +=TwoPi; //bring into interval (-Pi,Pi]
356  else if (phi_at > Pi) phi_at -= TwoPi;
357  double P_at = sqrt(E_at*E_at - M_at*M_at);
358  //need to rotate about 90degrees around x->N axis => y<=>z,
359  //then rotate new x-z-plane from x->North to x->LHC centre
360  Px_at = P_at*sin(Theta_at)*sin(phi_at);
361  Py_at = -P_at*cos(Theta_at);
362  Pz_at = P_at*sin(Theta_at)*cos(phi_at);
363 
364  //compute maximal theta of secondary muons
365  double theta_mu_max = Theta_at;
366  double theta_mu_min = Theta_at;
367 
368  double phi_rel_min = 0.; //phi_mu_min - phi_at
369  double phi_rel_max = 0.; //phi_mu_max - phi_at
370 
371  //std::cout << "SimTree->shower_Energy=" << SimTree->shower_Energy <<std::endl;
372 
373  Theta_mu.resize(nmuons);
374  for (int imu=0; imu<nmuons; ++imu) {
375  Theta_mu[imu] = acos(-Py_mu[imu]/P_mu[imu]);
376  if (Theta_mu[imu]>theta_mu_max) theta_mu_max = Theta_mu[imu];
377  if (Theta_mu[imu]<theta_mu_min) theta_mu_min = Theta_mu[imu];
378 
379  double phi_mu = atan2(Px_mu[imu],Pz_mu[imu]); // in (-Pi,Pi]
380  double phi_rel = phi_mu - phi_at;
381  if (phi_rel < -Pi) phi_rel += TwoPi; //bring into interval (-Pi,Pi]
382  else if (phi_rel > Pi) phi_rel -= TwoPi;
383  if (phi_rel < phi_rel_min) phi_rel_min = phi_rel;
384  else if (phi_rel > phi_rel_max) phi_rel_max =phi_rel;
385 
386 
387  }
388 
389 
390  double h_sf = SurfaceOfEarth + PlugWidth; //[mm]
391 
392  double R_at = h_sf*tan(Theta_at);
393 
394  double JdRxzV_dR_trans = 1.;
395  double JdPhiV_dPhi_trans = 1.;
396  double JdR_trans_sqrt = 1.;
397 
398  //chose random vertex Phi and Rxz weighted to speed up and smoothen
399  double R_mu_max = (h_sf+Target3dRadius)*tan(theta_mu_max);
400  double R_max = std::min(SurfaceRadius, R_mu_max);
401  double R_mu_min = (h_sf-Target3dRadius)*tan(theta_mu_min);
402  double R_min = std::max(0., R_mu_min);
403 
404  if (R_at>SurfaceRadius) {
405  std::cout << "CosmicMuonGenerator.cc: Warning! R_at=" << R_at
406  << " > SurfaceRadius=" << SurfaceRadius <<std::endl;
407  }
408 
409  //do phase space transformation for horizontal radius R
410 
411  //determine first phase space limits
412 
413  double psR1min = R_min + 0.25*(R_max-R_min);
414  double psR1max = std::min(SurfaceRadius,R_max-0.25*(R_max-R_min)); //no R's beyond R_max
415  double psR1 = psR1max - psR1min;
416 
417  double psR2min = R_min;
418  double psR2max = R_max;
419  double psR2 = psR2max - psR2min;
420 
421  double psR3min = 0.;
422  double psR3max = SurfaceRadius;
423  double psR3 = psR3max - psR3min;
424 
425  //double psall = psR1+psR2+psR3;
426  double psRall = psR3;
427 
428  double fR1=psR1/psRall, fR2=psR2/psRall, fR3=psR3/psRall; //f1+f2+f3=130%
429  double pR1=0.25, pR2=0.7, pR3=0.05;
430 
431 
432  //do phase space transformation for azimuthal angle phi
433  double psPh1 = 0.5*(phi_rel_max - phi_rel_min);
434  double psPh2 = phi_rel_max - phi_rel_min;
435  double psPh3 = TwoPi;
436  double psPhall = psPh3;
437 
438  double fPh1=psPh1/psPhall, fPh2=psPh2/psPhall, fPh3=psPh3/psPhall; //(f1+f2+f3=TwoPi+f1+f2)/(TwoPi+f1+f2)
439 
440  double pPh1=0.25, pPh2=0.7, pPh3=0.05;
441 
442  Trials = 0; //global int trials
443  double trials = 0.; //local weighted trials
444  Vx_mu.resize(nmuons); Vy_mu.resize(nmuons); Vz_mu.resize(nmuons);
445  int NmuHitTarget = 0;
446  while (NmuHitTarget < MultiMuonNmin) {
447 
448  NmuHitTarget = 0; //re-initialize every loop iteration
449  double Nver = 0.;
450 
451 
452  //chose phase space class
453  double RxzV;
454  double which_R_class = RanGen->flat();
455  if (which_R_class < pR1) { //pR1% in psR1
456  RxzV = psR1min + psR1 * RanGen->flat();
457  JdRxzV_dR_trans = fR1/pR1 * SurfaceRadius/psR1;
458  }
459  else if (which_R_class < pR1+pR2) { //further pR2% in psR2
460  RxzV = psR2min + psR2 * RanGen->flat();
461  JdRxzV_dR_trans = fR2/pR2 * SurfaceRadius/psR2;
462  }
463  else { //remaining pR3% in psR3=[0., R_max]
464  RxzV = psR3min + psR3 * RanGen->flat();
465  JdRxzV_dR_trans = fR3/pR3 * SurfaceRadius/psR3;
466  }
467 
468  JdR_trans_sqrt = 2.*RxzV/SurfaceRadius; //flat in sqrt(r) space
469 
470  //chose phase space class
471  double PhiV;
472  double which_phi_class = RanGen->flat();
473  if (which_phi_class < pPh1) { //pPh1% in psPh1
474  PhiV = phi_at + phi_rel_min + psPh1 * RanGen->flat();
475  JdPhiV_dPhi_trans = fPh1/pPh1 * TwoPi/psPh1;
476  }
477  else if (which_phi_class < pPh1+pPh2) { //further pPh2% in psPh2
478  PhiV = phi_at + phi_rel_min + psPh2 * RanGen->flat();
479  JdPhiV_dPhi_trans = fPh2/pPh2 * TwoPi/psPh2;
480  }
481  else { //remaining pPh3% in psPh3=[-Pi,Pi]
482  PhiV = phi_at + phi_rel_min + psPh3 * RanGen->flat();
483  JdPhiV_dPhi_trans = fPh3/pPh3 * TwoPi/psPh3;
484  }
485 
486  //shuffle PhiV into [-Pi,+Pi] interval
487  if (PhiV < -Pi) PhiV+=TwoPi;
488  else if (PhiV > Pi) PhiV-=TwoPi;
489 
490 
491  Nver++;
492  trials += JdR_trans_sqrt * JdRxzV_dR_trans * JdPhiV_dPhi_trans;
493  Trials++;
494  if (trials > max_Trials) break; //while (Id_sf.size() < 2) loop
495  Ngen += (Nver-1.); //add number of generated vertices to initial cosmic events
496 
497 
498  Vx_at = RxzV*sin(PhiV); // [mm]
499 
500  Vy_at = h_sf; // [mm] (SurfaceOfEarth + PlugWidth; Determine primary particle height below)
501  //Vy_at = SimTree->shower_StartingAltitude*10. + h_sf; // [mm]
502  //std::cout << "SimTree->shower_StartingAltitude*10=" << SimTree->shower_StartingAltitude*10 <<std::endl;
503  Vz_at = RxzV*cos(PhiV); // [mm]
504 
505  int NmuHitTargetSphere = 0;
506  for (int imu=0; imu<nmuons; ++imu) {
507 
509  +SimTree->particle__y[imu]*cos(NorthCMSzDeltaPhi) )*10; //[mm] (Corsika cm to CMSCGEN mm)
510  Vy_mu[imu] = h_sf; //[mm] fixed at surface + PlugWidth
512  +SimTree->particle__y[imu]*sin(NorthCMSzDeltaPhi) )*10; //[mm] (Corsika cm to CMSCGEN mm)
513 
514 
515  //add atmospheric height to primary particle (default SimTree->shower_StartingAltitude = 0.)
516  double pt_sec = sqrt(Px_mu[imu]*Px_mu[imu]+Pz_mu[imu]*Pz_mu[imu]);
517  double theta_sec = atan2(std::fabs(Py_mu[imu]),pt_sec);
518  double r_sec = sqrt((Vx_mu[imu]-Vx_at)*(Vx_mu[imu]-Vx_at)
519  +(Vz_mu[imu]-Vz_at)*(Vz_mu[imu]-Vz_at));
520  double h_prod = r_sec * tan(theta_sec);
521  if (h_prod + h_sf > Vy_at) Vy_at = h_prod + h_sf;
522 
523  //only muons
524  if (SimTree->particle__ParticleID[imu] != 5 &&
525  SimTree->particle__ParticleID[imu] != 6) continue;
526 
527  if (P_mu[imu] < MinP_CMS && AcptAllMu==false) continue;
528 
529  //check here if at least 2 muons make it to the target sphere
530  double Vxz_mu = sqrt(Vx_mu[imu]*Vx_mu[imu] + Vz_mu[imu]*Vz_mu[imu]);
531  theta_mu_max = atan((Vxz_mu+Target3dRadius)/(h_sf-Target3dRadius));
532  theta_mu_min = atan((Vxz_mu-Target3dRadius)/(h_sf+Target3dRadius));
533  if (Theta_mu[imu] > theta_mu_min && Theta_mu[imu] < theta_mu_max) {
534 
535  // check phi range (for a sphere with Target3dRadius around the target)
536  double dPhi = Pi; if (Vxz_mu > Target3dRadius) dPhi = asin(Target3dRadius/Vxz_mu);
537  double PhiPmu = atan2(Px_mu[imu],Pz_mu[imu]); //muon phi
538  double PhiVmu = atan2(Vx_mu[imu],Vz_mu[imu]); //muon phi
539  double rotPhi = PhiVmu + Pi; if (rotPhi > Pi) rotPhi -= TwoPi;
540  double disPhi = std::fabs(rotPhi - PhiPmu); if (disPhi > Pi) disPhi = TwoPi - disPhi;
541  if (disPhi < dPhi) {
542  NmuHitTargetSphere++;
543  }
544 
545  }
546 
547  } //end imu for loop
548 
549 
550 
551 
552  if (NmuHitTargetSphere < MultiMuonNmin) continue; //while (Id_sf.size() < 2) loop
553 
554  //nmuons outgoing particle at SurFace
555  Id_sf.clear();
556  Px_sf.clear();
557  Py_sf.clear();
558  Pz_sf.clear();
559  E_sf.clear();
560  //M_sf_out.clear();
561  Vx_sf.clear();
562  Vy_sf.clear();
563  Vz_sf.clear();
564  T0_sf.clear();
565 
566  //nmuons particles at UnderGround
567  Id_ug.clear();
568  Px_ug.clear();
569  Py_ug.clear();
570  Pz_ug.clear();
571  E_ug.clear();
572  //M_ug.clear();
573  Vx_ug.clear();
574  Vy_ug.clear();
575  Vz_ug.clear();
576  T0_ug.clear();
577 
578  int Id_sf_this =0;
579  double Px_sf_this =0., Py_sf_this=0., Pz_sf_this=0.;
580  double E_sf_this=0.;
581  //double M_sf_this=0.;
582  double Vx_sf_this=0., Vy_sf_this=0., Vz_sf_this=0.;
583  double T0_sf_this=0.;
584 
585  T0_at = SimTree->shower_GH_t0 * SpeedOfLight; // [mm]
586 
587  for (int imu=0; imu<nmuons; ++imu) {
588 
589  if (P_mu[imu] < MinP_CMS && AcptAllMu==false) continue;
590  //for the time being only muons
591  if (SimTree->particle__ParticleID[imu] != 5 &&
592  SimTree->particle__ParticleID[imu] != 6) continue;
593 
594  Id_sf_this = SimTree->particle__ParticleID[imu];
595  if (Id_sf_this == 5) Id_sf_this = -13; //mu+
596  else if (Id_sf_this == 6) Id_sf_this = 13; //mu-
597 
598  else if (Id_sf_this == 1) Id_sf_this = 22; //gamma
599  else if (Id_sf_this == 2) Id_sf_this = -11; //e+
600  else if (Id_sf_this == 3) Id_sf_this = 11; //e-
601  else if (Id_sf_this == 7) Id_sf_this = 111; //pi0
602  else if (Id_sf_this == 8) Id_sf_this = 211; //pi+
603  else if (Id_sf_this == 9) Id_sf_this = -211; //pi-
604  else if (Id_sf_this == 10) Id_sf_this = 130; //KL0
605  else if (Id_sf_this == 11) Id_sf_this = 321; //K+
606  else if (Id_sf_this == 12) Id_sf_this = -321; //K-
607  else if (Id_sf_this == 13) Id_sf_this = 2112; //n
608  else if (Id_sf_this == 14) Id_sf_this = 2212; //p
609  else if (Id_sf_this == 15) Id_sf_this = -2212; //pbar
610  else if (Id_sf_this == 16) Id_sf_this = 310; //Ks0
611  else if (Id_sf_this == 17) Id_sf_this = 221; //eta
612  else if (Id_sf_this == 18) Id_sf_this = 3122; //Lambda
613 
614  else {
615  std::cout << "CosmicMuonGenerator.cc: Warning! Muon Id=" << Id_sf_this
616  << " from file read in" <<std::endl;
617  Id_sf_this = 99999; //trouble
618  }
619 
620  T0_sf_this = SimTree->particle__Time[imu] * SpeedOfLight; //in [mm]
621 
622  Px_sf_this = Px_mu[imu];
623  Py_sf_this = Py_mu[imu]; //Corsika down going particles defined in -z direction!
624  Pz_sf_this = Pz_mu[imu];
625  E_sf_this = sqrt(P_mu[imu]*P_mu[imu] + MuonMass*MuonMass);
626  Vx_sf_this = Vx_mu[imu];
627  Vy_sf_this = Vy_mu[imu]; //[mm] fixed at surface + PlugWidth
628  Vz_sf_this = Vz_mu[imu];
629 
630 
631  OneMuoEvt.create(Id_sf_this, Px_sf_this, Py_sf_this, Pz_sf_this, E_sf_this, MuonMass, Vx_sf_this, Vy_sf_this, Vz_sf_this, T0_sf_this);
632  // if angles are ok, propagate to target
633  if (goodOrientation()) {
635  }
636 
637  if ( (OneMuoEvt.hitTarget()
639  || AcptAllMu==true ) {
640 
641  Id_sf.push_back(Id_sf_this);
642  Px_sf.push_back(Px_sf_this);
643  Py_sf.push_back(Py_sf_this);
644  Pz_sf.push_back(Pz_sf_this);
645  E_sf.push_back(E_sf_this);
646  //M_sf.push_back(M_sf_this);
647  Vx_sf.push_back(Vx_sf_this);
648  Vy_sf.push_back(Vy_sf_this);
649  Vz_sf.push_back(Vz_sf_this);
650  T0_sf.push_back(T0_sf_this);
651  //T0_sf.push_back(0.); //synchronised arrival for 100% efficient full simulation tests
652 
653  Id_ug.push_back(OneMuoEvt.id());
654  Px_ug.push_back(OneMuoEvt.px());
655  Py_ug.push_back(OneMuoEvt.py());
656  Pz_ug.push_back(OneMuoEvt.pz());
657  E_ug.push_back(OneMuoEvt.e());
658  //M_sf.push_back(OneMuoEvt.m());
659  Vx_ug.push_back(OneMuoEvt.vx());
660  Vy_ug.push_back(OneMuoEvt.vy());
661  Vz_ug.push_back(OneMuoEvt.vz());
662  T0_ug.push_back(OneMuoEvt.t0());
663 
664  NmuHitTarget++;
665  }
666  }
667 
668 
669  } // while (Id_sf.size() < 2); //end of do loop
670 
671 
672  if (trials > max_Trials) {
673  std::cout << "CosmicMuonGenerator.cc: Warning! trials reach max_trials=" << max_Trials
674  << " without accepting event!" << std::endl;
675  if (Debug) {
676  std::cout << " N(mu)=" << Id_ug.size();
677  if (Id_ug.size()>=1)
678  std::cout << " E[0]=" << E_ug[0] << " theta="
679  << acos(-Py_ug[0]/sqrt(Px_ug[0]*Px_ug[0]+Py_ug[0]*Py_ug[0]+Pz_ug[0]*Pz_ug[0]))
680  << " R_xz=" << sqrt(Vx_sf[0]*Vx_sf[0]+Vy_sf[0]*Vy_sf[0]);
681  std::cout << " Theta_at=" << Theta_at << std::endl;
682  }
683  std::cout << "Unweighted int num of Trials = " << Trials << std::endl;
684  std::cout << "trying next event (" << SimTree_jentry << ") from file" << std::endl;
686  continue; //EvtRejected while loop: get next event from file
687  }
688  else {
689  if (NmuHitTarget < MultiMuonNmin) {
690  std::cout << "CosmicMuonGenerator.cc: Warning! less than " << MultiMuonNmin <<
691  " muons hit target: N(mu=)" << NmuHitTarget << std::endl;
692  std::cout << "trying next event (" << SimTree_jentry << ") from file" << std::endl;
694  continue; //EvtRejected while loop: get next event from file
695  }
696  else { //if (MuInMaxDist) {
697 
698  //re-adjust T0's of surviving muons shifted to trigger time box
699  //(possible T0 increase due to propagation (loss of energy/speed + travelled distance))
700  double T0_ug_min, T0_ug_max;
701  T0_ug_min = T0_ug_max = T0_ug[0];
702  double Tbox = (MaxT0 - MinT0) * SpeedOfLight; // [mm]
703  double minDeltaT0 = 2*Tbox;
704  for (unsigned int imu=0; imu<Id_ug.size(); ++imu) {
705  double T0_this = T0_ug[imu];
706  if (T0_this < T0_ug_min) T0_ug_min = T0_this;
707  if (T0_this > T0_ug_max) T0_ug_max = T0_this;
708  if (Debug) std::cout << "imu=" << imu << " T0_this=" << T0_this
709  << " P=" << sqrt(pow(Px_ug[imu],2) + pow(Py_ug[imu],2) + pow(Pz_ug[imu],2))
710  << std::endl;
711  for (unsigned int jmu=0; jmu<imu; ++jmu) {
712  if (std::fabs(T0_ug[imu]-T0_ug[jmu]) < minDeltaT0) minDeltaT0 = std::fabs(T0_ug[imu]-T0_ug[jmu]);
713  }
714  }
715 
716  if (int(Id_ug.size()) >= MultiMuonNmin && MultiMuonNmin>=2 && minDeltaT0 > Tbox)
717  continue; //EvtRejected while loop: get next event from file
718 
719  double T0_min = T0_ug_min +MinT0*SpeedOfLight; //-12.5ns * c [mm]
720  double T0_max = T0_ug_max +MaxT0*SpeedOfLight; //+12.5ns * c [mm]
721 
722  //ckeck if >= NmuMin in time box, else throw new random number + augment evt weight
723  int TboxTrials = 0;
724  int NmuInTbox;
725  double T0_offset, T0diff;
726  for (int tboxtrial=0; tboxtrial<1000; ++tboxtrial) { //max 1000 trials
727  T0_offset = RanGen->flat()*(T0_max -T0_min); // [mm]
728  TboxTrials++;
729  T0diff = T0_offset - T0_max; // [mm]
730  NmuInTbox = 0;
731  for (unsigned int imu=0; imu<Id_ug.size(); ++imu) {
732  if (T0_ug[imu]+T0diff > MinT0*SpeedOfLight && T0_ug[imu]+T0diff < MaxT0*SpeedOfLight)
733  NmuInTbox++;
734  }
735  if (NmuInTbox >= MultiMuonNmin) break;
736 
737  }
738  if (NmuInTbox < MultiMuonNmin) continue; //EvtRejected while loop: get next event from file
739 
740 
741  if (Debug) std::cout << "initial T0_at=" << T0_at << " T0_min=" << T0_min << " T0_max=" << T0_max
742  << " T0_offset=" << T0_offset;
743  T0_at += T0diff; //[mm]
744  if (Debug) std::cout << " T0diff=" << T0diff << std::endl;
745  for (unsigned int imu=0; imu<Id_ug.size(); ++imu) { //adjust @ surface + underground
746  if (Debug) std::cout << "before: T0_sf[" << imu << "]=" << T0_sf[imu] << " T0_ug=" << T0_ug[imu];
747  T0_sf[imu] += T0diff;
748  T0_ug[imu] += T0diff;
749  if (Debug)
750  std::cout << " after: T0_sf[" << imu << "]=" << T0_sf[imu] << " T0_ug=" << T0_ug[imu] << std::endl;
751  }
752  if (Debug) std::cout << "T0diff=" << T0diff << " T0_at=" << T0_at << std::endl;
753 
754 
755 
756  Nsel += 1;
757  EventWeight = JdR_trans_sqrt * JdRxzV_dR_trans * JdPhiV_dPhi_trans
758  / (trials * TboxTrials);
759  EvtRejected = false;
760  if (Debug) std::cout << "CosmicMuonGenerator.cc: Theta_at=" << Theta_at << " phi_at=" << phi_at
761  << " Px_at=" << Px_at << " Py_at=" << Py_at << " Pz_at=" << Pz_at
762  << " T0_at=" << T0_at
763  << " Vx_at=" << Vx_at << " Vy_at=" << Vy_at << " Vz_at=" << Vz_at
764  << " EventWeight=" << EventWeight << " Nmuons=" << Id_sf.size() << std::endl;
765  }
766  }
767 
768 
769  } //while loop EvtRejected
770 
771 
772  return true; //write event to HepMC;
773 
774 }
Int_t shower_nParticlesWritten
Definition: sim.h:41
const double TwoPi
const double Pi
void propagate(double ElossScaleFac, double RadiusTarget, double Z_DistTarget, double Z_CentrTarget, bool TrackerOnly, bool MTCCHalf)
std::vector< double > Theta_mu
std::vector< double > Px_ug
Double_t particle__Py[kMaxparticle_]
Definition: sim.h:62
std::vector< double > Py_mu
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< int > Id_ug
Double_t particle__Time[kMaxparticle_]
Definition: sim.h:66
std::vector< double > Py_sf
#define min(a, b)
Definition: mlp_lapack.h:161
std::vector< double > E_sf
Double_t particle__Px[kMaxparticle_]
Definition: sim.h:61
Int_t shower_EventID
Definition: sim.h:28
std::vector< double > Pz_mu
const double SpeedOfLight
Double_t particle__Pz[kMaxparticle_]
Definition: sim.h:63
std::vector< double > E_ug
const double NorthCMSzDeltaPhi
virtual Int_t GetEntry(Long64_t entry)
const double PlugWidth
Float_t shower_Energy
Definition: sim.h:29
std::vector< double > Vz_ug
const double SurfaceOfEarth
std::vector< double > Vz_sf
std::vector< double > Vz_mu
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< double > Vx_sf
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Float_t shower_Phi
Definition: sim.h:34
std::vector< double > Vy_sf
CLHEP::HepRandomEngine * RanGen
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< double > Vx_mu
SingleParticleEvent OneMuoEvt
std::vector< double > Vy_mu
std::vector< double > T0_sf
std::vector< double > Px_mu
std::vector< double > Px_sf
std::vector< double > Vy_ug
Int_t particle__ParticleID[kMaxparticle_]
Definition: sim.h:58
std::vector< double > Pz_ug
Double_t particle__x[kMaxparticle_]
Definition: sim.h:64
void create(int id, double px, double py, double pz, double e, double m, double vx, double vy, double vz, double t0)
const int max_Trials
const double MuonMass
tuple cout
Definition: gather_cfg.py:121
Float_t shower_GH_t0
Definition: sim.h:47
std::vector< double > Vx_ug
std::vector< double > P_mu
std::vector< double > Py_ug
const bool Debug
Float_t shower_Theta
Definition: sim.h:33
std::vector< double > T0_ug
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< int > Id_sf
std::vector< double > Pz_sf
Double_t particle__y[kMaxparticle_]
Definition: sim.h:65
void CosmicMuonGenerator::runCMG ( )

Definition at line 12 of file CosmicMuonGenerator.cc.

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

12  {
13  initialize();
14  for (unsigned int iGen=0; iGen<NumberOfEvents; ++iGen){ nextEvent(); }
15  terminate();
16 }
void initialize(CLHEP::HepRandomEngine *rng=0)
void CosmicMuonGenerator::setAcptAllMu ( bool  AllMu)
void CosmicMuonGenerator::setClayWidth ( double  ClayLaeyrWidth)
void CosmicMuonGenerator::setElossScaleFactor ( double  ElossScaleFact)
void CosmicMuonGenerator::setMaxEnu ( double  MaxEn)
void CosmicMuonGenerator::setMaxP ( double  P)
void CosmicMuonGenerator::setMaxPhi ( double  Phi)
void CosmicMuonGenerator::setMaxT0 ( double  T0)
void CosmicMuonGenerator::setMaxTheta ( double  Theta)
void CosmicMuonGenerator::setMinEnu ( double  MinEn)
void CosmicMuonGenerator::setMinP ( double  P)
void CosmicMuonGenerator::setMinP_CMS ( double  P)
void CosmicMuonGenerator::setMinPhi ( double  Phi)
void CosmicMuonGenerator::setMinT0 ( double  T0)
void CosmicMuonGenerator::setMinTheta ( double  Theta)
void CosmicMuonGenerator::setMTCCHalf ( bool  MTCC)
void CosmicMuonGenerator::setMultiMuon ( bool  MultiMu)
void CosmicMuonGenerator::setMultiMuonFileFirstEvent ( int  MultiMuFile1stEvt)
void CosmicMuonGenerator::setMultiMuonFileName ( std::string  MultiMuonFileName)
void CosmicMuonGenerator::setMultiMuonNmin ( int  MultiMuNmin)
void CosmicMuonGenerator::setNumberOfEvents ( unsigned int  N)
void CosmicMuonGenerator::setNuProdAlt ( double  NuPrdAlt)
void CosmicMuonGenerator::setPlugVx ( double  PlugVtx)
void CosmicMuonGenerator::setPlugVz ( double  PlugVtz)
void CosmicMuonGenerator::setRadiusOfTarget ( double  R)
void CosmicMuonGenerator::setRanSeed ( int  N)
void CosmicMuonGenerator::setRhoAir ( double  VarRhoAir)
void CosmicMuonGenerator::setRhoClay ( double  VarRhoClay)
void CosmicMuonGenerator::setRhoPlug ( double  VarRhoPlug)
void CosmicMuonGenerator::setRhoRock ( double  VarRhoRock)
void CosmicMuonGenerator::setRhoWall ( double  VarRhoSWall)
void CosmicMuonGenerator::setTIFOnly_constant ( bool  TIF)
void CosmicMuonGenerator::setTIFOnly_linear ( bool  TIF)
void CosmicMuonGenerator::setTrackerOnly ( bool  Tracker)
void CosmicMuonGenerator::setZCentrOfTarget ( double  Z)
void CosmicMuonGenerator::setZDistOfTarget ( double  Z)
void CosmicMuonGenerator::terminate ( void  )

Definition at line 778 of file CosmicMuonGenerator.cc.

References funct::cos(), gather_cfg::cout, Deg2Rad, alignCSCRings::e, ElossScaleFactor, EventRate, CMSCGENnorm::events_n100cos(), MaxP, MaxPhi, MaxT0, MaxTheta, MinP, MinPhi, MinT0, MinTheta, Ndiced, Ngen, CMSCGENnorm::norm(), Norm, Nsel, NumberOfEvents, Pi, Rad2Deg, RadiusOfTarget, rateErr_stat, rateErr_syst, mathSSE::sqrt(), SurfaceOfEarth, SurfaceRadius, and ZDistOfTarget.

Referenced by runCMG().

778  {
779  if (NumberOfEvents > 0){
780  std::cout << std::endl;
781  std::cout << "*********************************************************" << std::endl;
782  std::cout << "*********************************************************" << std::endl;
783  std::cout << "*** ***" << std::endl;
784  std::cout << "*** C O S M I C M U O N S T A T I S T I C S ***" << std::endl;
785  std::cout << "*** ***" << std::endl;
786  std::cout << "*********************************************************" << std::endl;
787  std::cout << "*********************************************************" << std::endl;
788  std::cout << std::endl;
789  std::cout << " number of initial cosmic events: " << int(Ngen) << std::endl;
790  std::cout << " number of actually diced events: " << int(Ndiced) << std::endl;
791  std::cout << " number of generated and accepted events: " << int(Nsel) << std::endl;
792  double selEff = Nsel/Ngen; // selection efficiency
793  std::cout << " event selection efficiency: " << selEff*100. << "%" << std::endl;
794  int n100cos = Norm->events_n100cos(0., 0.); //get final amount of cosmics in defined range for normalisation of flux
795  std::cout << " events with ~100 GeV and 1 - cos(theta) < 1/2pi: " << n100cos << std::endl;
796  std::cout << std::endl;
797  std::cout << " momentum range: " << MinP << " ... " << MaxP << " GeV" << std::endl;
798  std::cout << " theta range: " << MinTheta*Rad2Deg << " ... " << MaxTheta*Rad2Deg << " deg" << std::endl;
799  std::cout << " phi range: " << MinPhi*Rad2Deg << " ... " << MaxPhi*Rad2Deg << " deg" << std::endl;
800  std::cout << " time range: " << MinT0 << " ... " << MaxT0 << " ns" << std::endl;
801  std::cout << " energy loss: " << ElossScaleFactor*100. << "%" << std::endl;
802  std::cout << std::endl;
803  double area = 1.e-6*Pi*SurfaceRadius*SurfaceRadius; // area on surface [m^2]
804  if (MinTheta > 90.*Deg2Rad) //upgoing muons from neutrinos)
805  std::cout << " area of initial cosmics at CMS detector bottom surface: " << area << " m^2" << std::endl;
806  else
807  std::cout << " area of initial cosmics on Surface + PlugWidth: " << area << " m^2" << std::endl;
808  std::cout << " depth of CMS detector (from Surface): " << SurfaceOfEarth/1000 << " m" << std::endl;
809 
810  //at least 100 evts., and
811  //downgoing inside theta parametersisation range
812  //or upgoing neutrino muons
813  if( (n100cos>0 && MaxTheta<84.26*Deg2Rad)
814  || MinTheta>90.*Deg2Rad) {
815  // rate: corrected for area and selection-Eff. and normalized to known flux, integration over solid angle (dOmega) is implicit
816  // flux is normalised with respect to known flux of vertical 100GeV muons in area at suface level
817  // rate seen by detector is lower than rate at surface area, so has to be corrected for selection-Eff.
818  // normalisation factor has unit [1/s/m^2]
819  // rate = N/time --> normalization factor gives 1/runtime/area
820  // normalization with respect to number of actually diced events (Ndiced)
821 
822  if (MinTheta > 90.*Deg2Rad) {//upgoing muons from neutrinos)
823  double Omega = (cos(MinTheta)-cos(MaxTheta)) * (MaxPhi-MinPhi);
824  //EventRate = (Ndiced * 3.e-13) * Omega * area*1.e4 * selEff;//area in cm, flux=3.e-13cm^-2s^-1sr^-1
825  EventRate = (Ndiced * 3.e-13) * Omega * 4.*RadiusOfTarget*ZDistOfTarget*1.e-2 * selEff;//area in cm, flux=3.e-13cm^-2s^-1sr^-1
826  rateErr_stat = EventRate/sqrt( (double) Ndiced); // stat. rate error
827  rateErr_syst = EventRate/3.e-13 * 1.0e-13; // syst. rate error, from error of known flux
828  }
829  else {
830  EventRate= (Ndiced * Norm->norm(n100cos)) * area * selEff;
831  rateErr_stat = EventRate/sqrt( (double) n100cos); // stat. rate error
832  rateErr_syst = EventRate/2.63e-3 * 0.06e-3; // syst. rate error, from error of known flux
833  }
834 
835  // normalisation in region 1.-cos(theta) < 1./(2.*Pi), if MaxTheta even lower correct for this
836  if(MaxTheta<0.572){
837  double spacean = 2.*Pi*(1.-cos(MaxTheta));
838  EventRate= (Ndiced * Norm->norm(n100cos)) * area * selEff * spacean;
839  rateErr_stat = EventRate/sqrt( (double) n100cos); // rate error
840  rateErr_syst = EventRate/2.63e-3 * 0.06e-3; // syst. rate error, from error of known flux
841  }
842 
843  }else{
844  EventRate=Nsel; //no info as no muons at 100 GeV
847  std::cout << std::endl;
848  if (MinP > 100.)
849  std::cout << " !!! MinP > 100 GeV. Cannot apply normalisation!" << std::endl;
850  else if (MaxTheta > 84.26*Deg2Rad)
851  std::cout << " !!! Note: generated cosmics exceed parameterisation. No flux calculated!" << std::endl;
852 
853  else
854  std::cout << " !!! Not enough statistics to apply normalisation (rate=1 +- 1) !!!" << std::endl;
855  }
856 
857  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
858  std::cout << " rate is " << EventRate << " +-" << rateErr_stat <<" (stat) " << "+-" <<
859  rateErr_syst << " (syst) " <<" muons per second" << std::endl;
860  if(EventRate!=0) std::cout << " number of events corresponds to " << Nsel/EventRate << " s" << std::endl; //runtime at CMS = Nsel/rate
861  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
862  std::cout << std::endl;
863  std::cout << "*********************************************************" << std::endl;
864  std::cout << "*********************************************************" << std::endl;
865  }
866 }
const double Pi
float norm(int n100cos)
Definition: CMSCGENnorm.cc:31
int events_n100cos(double energy, double theta)
Definition: CMSCGENnorm.cc:15
const double SurfaceOfEarth
const double Deg2Rad
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tuple cout
Definition: gather_cfg.py:121
const double Rad2Deg

Member Data Documentation

bool CosmicMuonGenerator::AcptAllMu
private

Definition at line 214 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), nextMultiEvent(), and setAcptAllMu().

double CosmicMuonGenerator::ClayWidth
private

Definition at line 206 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), and setClayWidth().

CMSCGEN* CosmicMuonGenerator::Cosmics
private
bool CosmicMuonGenerator::delRanGen
private

Definition at line 219 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::E_at

Definition at line 118 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::E_sf

Definition at line 133 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::E_ug

Definition at line 140 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::ElossScaleFactor
private
double CosmicMuonGenerator::EventRate
private

Definition at line 187 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::EventWeight

Definition at line 113 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

int CosmicMuonGenerator::Id_at

Definition at line 116 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<int> CosmicMuonGenerator::Id_sf

Definition at line 131 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<int> CosmicMuonGenerator::Id_ug

Definition at line 138 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::MaxEnu
private

Definition at line 211 of file CosmicMuonGenerator.h.

Referenced by checkIn(), initialize(), and setMaxEnu().

double CosmicMuonGenerator::MaxP
private
double CosmicMuonGenerator::MaxPhi
private
double CosmicMuonGenerator::MaxT0
private
double CosmicMuonGenerator::MaxTheta
private
double CosmicMuonGenerator::MinEnu
private

Definition at line 210 of file CosmicMuonGenerator.h.

Referenced by checkIn(), initialize(), and setMinEnu().

double CosmicMuonGenerator::MinP
private
double CosmicMuonGenerator::MinP_CMS
private

Definition at line 166 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinPhi
private
double CosmicMuonGenerator::MinT0
private
double CosmicMuonGenerator::MinTheta
private
bool CosmicMuonGenerator::MTCCHalf
private

Definition at line 185 of file CosmicMuonGenerator.h.

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

TFile* CosmicMuonGenerator::MultiIn
private

Definition at line 149 of file CosmicMuonGenerator.h.

Referenced by initialize().

bool CosmicMuonGenerator::MultiMuon
private

Definition at line 179 of file CosmicMuonGenerator.h.

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

int CosmicMuonGenerator::MultiMuonFileFirstEvent
private
std::string CosmicMuonGenerator::MultiMuonFileName
private

Definition at line 180 of file CosmicMuonGenerator.h.

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

int CosmicMuonGenerator::MultiMuonNmin
private

Definition at line 182 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), nextMultiEvent(), and setMultiMuonNmin().

TTree* CosmicMuonGenerator::MultiTree
private

Definition at line 150 of file CosmicMuonGenerator.h.

Referenced by initialize().

int CosmicMuonGenerator::NcloseMultiMuonEvents
private

Definition at line 154 of file CosmicMuonGenerator.h.

Referenced by initialize(), and nextMultiEvent().

double CosmicMuonGenerator::Ndiced
private

Definition at line 194 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::Ngen
private

Definition at line 192 of file CosmicMuonGenerator.h.

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

CMSCGENnorm* CosmicMuonGenerator::Norm
private
bool CosmicMuonGenerator::NotInitialized
private
double CosmicMuonGenerator::Nsel
private

Definition at line 193 of file CosmicMuonGenerator.h.

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

int CosmicMuonGenerator::NskippedMultiMuonEvents
private

Definition at line 155 of file CosmicMuonGenerator.h.

Referenced by initialize(), and nextMultiEvent().

unsigned int CosmicMuonGenerator::NumberOfEvents
private
double CosmicMuonGenerator::NuProdAlt
private

Definition at line 212 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setNuProdAlt().

SingleParticleEvent CosmicMuonGenerator::OneMuoEvt
std::vector<double> CosmicMuonGenerator::P_mu

Definition at line 126 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

double CosmicMuonGenerator::PlugVx
private

Definition at line 197 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::PlugVz
private

Definition at line 198 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::Px_at

Definition at line 117 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Px_mu

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Px_sf

Definition at line 132 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Px_ug

Definition at line 139 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::Py_at

Definition at line 117 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Py_mu

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Py_sf

Definition at line 132 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Py_ug

Definition at line 139 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::Pz_at

Definition at line 117 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Pz_mu

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Pz_sf

Definition at line 132 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Pz_ug

Definition at line 139 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::RadiusOfTarget
private
CLHEP::HepRandomEngine* CosmicMuonGenerator::RanGen
private

Definition at line 218 of file CosmicMuonGenerator.h.

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

int CosmicMuonGenerator::RanSeed
private

Definition at line 164 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::rateErr_stat
private

Definition at line 188 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), and terminate().

double CosmicMuonGenerator::rateErr_syst
private

Definition at line 189 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator(), and terminate().

double CosmicMuonGenerator::RhoAir
private

Definition at line 201 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::RhoClay
private

Definition at line 204 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::RhoPlug
private

Definition at line 205 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::RhoRock
private

Definition at line 203 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::RhoWall
private

Definition at line 202 of file CosmicMuonGenerator.h.

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

sim* CosmicMuonGenerator::SimTree
private

Definition at line 151 of file CosmicMuonGenerator.h.

Referenced by initialize(), and nextMultiEvent().

ULong64_t CosmicMuonGenerator::SimTree_jentry
private

Definition at line 153 of file CosmicMuonGenerator.h.

Referenced by initialize(), and nextMultiEvent().

ULong64_t CosmicMuonGenerator::SimTreeEntries
private

Definition at line 152 of file CosmicMuonGenerator.h.

Referenced by initialize(), and nextMultiEvent().

double CosmicMuonGenerator::SumIntegrals
private

Definition at line 191 of file CosmicMuonGenerator.h.

Referenced by CosmicMuonGenerator().

double CosmicMuonGenerator::SurfaceRadius
private
double CosmicMuonGenerator::T0_at

Definition at line 121 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::T0_sf

Definition at line 136 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::T0_ug

Definition at line 143 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::Target3dRadius
private
double CosmicMuonGenerator::Theta_at

Definition at line 122 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Theta_mu

Definition at line 129 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

bool CosmicMuonGenerator::TIFOnly_constant
private

Definition at line 183 of file CosmicMuonGenerator.h.

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

bool CosmicMuonGenerator::TIFOnly_linear
private

Definition at line 184 of file CosmicMuonGenerator.h.

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

bool CosmicMuonGenerator::TrackerOnly
private
double CosmicMuonGenerator::Trials

Definition at line 114 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

double CosmicMuonGenerator::Vx_at

Definition at line 120 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vx_mu

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vx_sf

Definition at line 135 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vx_ug

Definition at line 142 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::Vxz_mu

Definition at line 128 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

double CosmicMuonGenerator::Vy_at

Definition at line 120 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vy_mu

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vy_sf

Definition at line 135 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vy_ug

Definition at line 142 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::Vz_at

Definition at line 120 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vz_mu

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vz_sf

Definition at line 135 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vz_ug

Definition at line 142 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and nextMultiEvent().

double CosmicMuonGenerator::ZCentrOfTarget
private
double CosmicMuonGenerator::ZDistOfTarget
private