CMS 3D CMS Logo

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=nullptr)
 
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 setRandomEngine (CLHEP::HepRandomEngine *v)
 
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 gather_cfg::cout, Deg2Rad, source_particleGun_cfi::MaxPhi, GlobalMuonTrackMatcher_cff::MinP, source_particleGun_cfi::MinPhi, PlugOnShaftVx, and PlugOnShaftVz.

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
CosmicMuonGenerator::~CosmicMuonGenerator ( )
inline

Definition at line 101 of file CosmicMuonGenerator.h.

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 876 of file CosmicMuonGenerator.cc.

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

Referenced by initialize().

876  {
877  if (MinP < 0.){ NumberOfEvents = 0;
878  std::cout << " CMG-ERR: min.energy is out of range (0 GeV ... inf]" << std::endl << std::endl; }
879  if (MaxP < 0.){ NumberOfEvents = 0;
880  std::cout << " CMG-ERR: max.energy is out of range (0 GeV ... inf]" << std::endl << std::endl; }
881  if (MaxP <= MinP){ NumberOfEvents = 0;
882  std::cout << " CMG-ERR: max.energy is not greater than min.energy" << std::endl << std::endl; }
883  if (MinTheta < 0.){ NumberOfEvents = 0;
884  std::cout << " CMG-ERR: min.theta is out of range [0 deg ... 90 deg)" << std::endl << std::endl; }
885  if (MaxTheta < 0.){ NumberOfEvents = 0;
886  std::cout << " CMG-ERR: max.theta is out of range [0 deg ... 90 deg)" << std::endl << std::endl; }
887  if (MaxTheta <= MinTheta){ NumberOfEvents = 0;
888  std::cout << " CMG-ERR: max.theta is not greater than min.theta" << std::endl << std::endl; }
889  if (MinPhi < 0.){ NumberOfEvents = 0;
890  std::cout << " CMG-ERR: min.phi is out of range [0 deg ... 360 deg]" << std::endl << std::endl; }
891  if (MaxPhi < 0.){ NumberOfEvents = 0;
892  std::cout << " CMG-ERR: max.phi is out of range [0 deg ... 360 deg]" << std::endl << std::endl; }
893  if (MaxPhi <= MinPhi){ NumberOfEvents = 0;
894  std::cout << " CMG-ERR: max.phi is not greater than min.phi" << std::endl << std::endl; }
895  if (MaxT0 <= MinT0){ NumberOfEvents = 0;
896  std::cout << " CMG-ERR: max.t0 is not greater than min.t0" << std::endl << std::endl; }
897  if (ElossScaleFactor < 0.){ NumberOfEvents = 0;
898  std::cout << " CMG-ERR: E-loss scale factor is out of range [0 ... inf)" << std::endl << std::endl; }
899  if (MinEnu < 0.){ NumberOfEvents = 0;
900  std::cout << " CMG-ERR: min.Enu is out of range [0 GeV ... inf]" << std::endl << std::endl; }
901  if (MaxEnu < 0.){ NumberOfEvents = 0;
902  std::cout << " CMG-ERR: max.Enu is out of range [0 GeV ... inf]" << std::endl << std::endl; }
903  if (MaxEnu <= MinEnu){ NumberOfEvents = 0;
904  std::cout << " CMG-ERR: max.Enu is not greater than min.Enu" << std::endl << std::endl; }
905 
906 }
void CosmicMuonGenerator::displayEv ( )
private

Definition at line 987 of file CosmicMuonGenerator.cc.

References SingleParticleEvent::e(), objects.autophobj::float, 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().

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

Definition at line 1082 of file CosmicMuonGenerator.cc.

References EventRate.

Referenced by edm::CosMuoGenProducer::endRunProduce().

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

Definition at line 908 of file CosmicMuonGenerator.cc.

References gather_cfg::cout, Deg2Rad, 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().

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

Definition at line 944 of file CosmicMuonGenerator.cc.

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

Referenced by initialize().

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

Definition at line 26 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, particleFlowSimParticle_cfi::sim, SimTree, SimTree_jentry, SimTreeEntries, mathSSE::sqrt(), SurfaceOfEarth, SurfaceRadius, funct::tan(), Target3dRadius, TIFOnly_constant, TIFOnly_linear, TrackerOnly, Z_DistTracker, and ZDistOfTarget.

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

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

Definition at line 110 of file CosmicMuonGenerator.cc.

References AcptAllMu, funct::cos(), CMSCGEN::cos_theta(), Cosmics, gather_cfg::cout, SingleParticleEvent::create(), Debug, Deg2Rad, displayEv(), SingleParticleEvent::e(), E_at, E_sf, E_ug, ElossScaleFactor, EventDisplay, CMSCGENnorm::events_n100cos(), EventWeight, CMSCGEN::generate(), CMSCGEN::generateNuMu(), goodOrientation(), SingleParticleEvent::hitTarget(), triggerObjects_cff::id, SingleParticleEvent::id(), Id_at, Id_sf, Id_ug, createfilelist::int, 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 edm::CosMuoGenProducer::produce(), and runCMG().

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

Definition at line 251 of file CosmicMuonGenerator.cc.

References AcptAllMu, funct::cos(), gather_cfg::cout, SingleParticleEvent::create(), Debug, SingleParticleEvent::e(), E_at, E_sf, E_ug, ElossScaleFactor, EventWeight, sim::GetEntry(), goodOrientation(), SingleParticleEvent::hitTarget(), SingleParticleEvent::id(), Id_at, Id_sf, Id_ug, SiStripPI::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.

Referenced by edm::CosMuoGenProducer::produce().

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

Definition at line 1076 of file CosmicMuonGenerator.cc.

References ClayWidth, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1076 { if (NotInitialized) ClayWidth = ClayLayerWidth; }
void CosmicMuonGenerator::setElossScaleFactor ( double  ElossScaleFact)

Definition at line 1049 of file CosmicMuonGenerator.cc.

References ElossScaleFactor, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1049 { if (NotInitialized) ElossScaleFactor = ElossScaleFact; }
void CosmicMuonGenerator::setMaxEnu ( double  MaxEn)

Definition at line 1079 of file CosmicMuonGenerator.cc.

References MaxEnu, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

void CosmicMuonGenerator::setMaxP ( double  P)

Definition at line 1035 of file CosmicMuonGenerator.cc.

References MaxP, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1035 { if (NotInitialized) MaxP = P; }
std::pair< OmniClusterRef, TrackingParticleRef > P
void CosmicMuonGenerator::setMaxPhi ( double  Phi)
void CosmicMuonGenerator::setMaxT0 ( double  T0)
void CosmicMuonGenerator::setMaxTheta ( double  Theta)

Definition at line 1039 of file CosmicMuonGenerator.cc.

References Deg2Rad, MaxTheta, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1039 { if (NotInitialized) MaxTheta = Theta*Deg2Rad; }
const double Deg2Rad
void CosmicMuonGenerator::setMinEnu ( double  MinEn)

Definition at line 1078 of file CosmicMuonGenerator.cc.

References MinEnu, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

void CosmicMuonGenerator::setMinP ( double  P)

Definition at line 1031 of file CosmicMuonGenerator.cc.

References MinP, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1031 { if (NotInitialized) MinP = P; }
std::pair< OmniClusterRef, TrackingParticleRef > P
void CosmicMuonGenerator::setMinP_CMS ( double  P)

Definition at line 1033 of file CosmicMuonGenerator.cc.

References MinP_CMS, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1033 { if (NotInitialized) MinP_CMS = P; }
std::pair< OmniClusterRef, TrackingParticleRef > P
void CosmicMuonGenerator::setMinPhi ( double  Phi)
void CosmicMuonGenerator::setMinT0 ( double  T0)
void CosmicMuonGenerator::setMinTheta ( double  Theta)

Definition at line 1037 of file CosmicMuonGenerator.cc.

References Deg2Rad, MinTheta, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1037 { if (NotInitialized) MinTheta = Theta*Deg2Rad; }
const double Deg2Rad
void CosmicMuonGenerator::setMTCCHalf ( bool  MTCC)
void CosmicMuonGenerator::setMultiMuon ( bool  MultiMu)
void CosmicMuonGenerator::setMultiMuonFileFirstEvent ( int  MultiMuFile1stEvt)
void CosmicMuonGenerator::setMultiMuonFileName ( std::string  MultiMuonFileName)

Definition at line 1060 of file CosmicMuonGenerator.cc.

References MultiMuonFileName, and NotInitialized.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1060 { if (NotInitialized) MultiMuonFileName = MultiMuFile; }
void CosmicMuonGenerator::setMultiMuonNmin ( int  MultiMuNmin)
void CosmicMuonGenerator::setNumberOfEvents ( unsigned int  N)

Definition at line 1027 of file CosmicMuonGenerator.cc.

References N, NotInitialized, and NumberOfEvents.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1027 { if (NotInitialized) NumberOfEvents = N; }
#define N
Definition: blowfish.cc:9
void CosmicMuonGenerator::setNuProdAlt ( double  NuPrdAlt)

Definition at line 1080 of file CosmicMuonGenerator.cc.

References NotInitialized, and NuProdAlt.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

void CosmicMuonGenerator::setPlugVx ( double  PlugVtx)

Definition at line 1069 of file CosmicMuonGenerator.cc.

References NotInitialized, and PlugVx.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

void CosmicMuonGenerator::setPlugVz ( double  PlugVtz)

Definition at line 1070 of file CosmicMuonGenerator.cc.

References NotInitialized, and PlugVz.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

void CosmicMuonGenerator::setRadiusOfTarget ( double  R)
void CosmicMuonGenerator::setRandomEngine ( CLHEP::HepRandomEngine *  v)

Definition at line 18 of file CosmicMuonGenerator.cc.

References Cosmics, delRanGen, RanGen, CMSCGEN::setRandomEngine(), and findQualityFiles::v.

18  {
19  if (delRanGen)
20  delete RanGen;
21  RanGen = v;
22  delRanGen = false;
24 }
void setRandomEngine(CLHEP::HepRandomEngine *v)
Definition: CMSCGEN.cc:23
CLHEP::HepRandomEngine * RanGen
void CosmicMuonGenerator::setRanSeed ( int  N)

Definition at line 1029 of file CosmicMuonGenerator.cc.

References N, NotInitialized, and RanSeed.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

void CosmicMuonGenerator::setRhoAir ( double  VarRhoAir)

Definition at line 1071 of file CosmicMuonGenerator.cc.

References NotInitialized, and RhoAir.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1071 { if (NotInitialized) RhoAir = VarRhoAir; }
void CosmicMuonGenerator::setRhoClay ( double  VarRhoClay)

Definition at line 1074 of file CosmicMuonGenerator.cc.

References NotInitialized, and RhoClay.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1074 { if (NotInitialized) RhoClay = VarRhoClay; }
void CosmicMuonGenerator::setRhoPlug ( double  VarRhoPlug)

Definition at line 1075 of file CosmicMuonGenerator.cc.

References NotInitialized, and RhoPlug.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1075 { if (NotInitialized) RhoPlug = VarRhoPlug; }
void CosmicMuonGenerator::setRhoRock ( double  VarRhoRock)

Definition at line 1073 of file CosmicMuonGenerator.cc.

References NotInitialized, and RhoRock.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1073 { if (NotInitialized) RhoRock = VarRhoRock; }
void CosmicMuonGenerator::setRhoWall ( double  VarRhoSWall)

Definition at line 1072 of file CosmicMuonGenerator.cc.

References NotInitialized, and RhoWall.

Referenced by edm::CosMuoGenProducer::CosMuoGenProducer().

1072 { if (NotInitialized) RhoWall = VarRhoWall; }
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 786 of file CosmicMuonGenerator.cc.

References jets_cff::area, funct::cos(), gather_cfg::cout, Deg2Rad, MillePedeFileConverter_cfg::e, ElossScaleFactor, EventRate, CMSCGENnorm::events_n100cos(), createfilelist::int, 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 edm::CosMuoGenProducer::endRunProduce(), and runCMG().

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

CMSCGEN* CosmicMuonGenerator::Cosmics
private

Definition at line 161 of file CosmicMuonGenerator.h.

Referenced by initialize(), nextEvent(), and setRandomEngine().

bool CosmicMuonGenerator::delRanGen
private

Definition at line 219 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setRandomEngine().

double CosmicMuonGenerator::E_at
std::vector<double> CosmicMuonGenerator::E_sf
std::vector<double> CosmicMuonGenerator::E_ug
double CosmicMuonGenerator::ElossScaleFactor
private
double CosmicMuonGenerator::EventRate
private

Definition at line 187 of file CosmicMuonGenerator.h.

Referenced by getRate(), and terminate().

double CosmicMuonGenerator::EventWeight
int CosmicMuonGenerator::Id_at
std::vector<int> CosmicMuonGenerator::Id_sf
std::vector<int> CosmicMuonGenerator::Id_ug
double CosmicMuonGenerator::MaxEnu
private

Definition at line 211 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MaxP
private

Definition at line 167 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MaxPhi
private

Definition at line 171 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MaxT0
private

Definition at line 173 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MaxTheta
private

Definition at line 169 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinEnu
private

Definition at line 210 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinP
private

Definition at line 165 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinP_CMS
private

Definition at line 166 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinPhi
private

Definition at line 170 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinT0
private

Definition at line 172 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::MinTheta
private
bool CosmicMuonGenerator::MTCCHalf
private

Definition at line 185 of file CosmicMuonGenerator.h.

Referenced by 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 initialize(), and setMultiMuon().

int CosmicMuonGenerator::MultiMuonFileFirstEvent
private

Definition at line 181 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setMultiMuonFileFirstEvent().

std::string CosmicMuonGenerator::MultiMuonFileName
private

Definition at line 180 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setMultiMuonFileName().

int CosmicMuonGenerator::MultiMuonNmin
private

Definition at line 182 of file CosmicMuonGenerator.h.

Referenced by 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 nextEvent(), and terminate().

double CosmicMuonGenerator::Ngen
private

Definition at line 192 of file CosmicMuonGenerator.h.

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

CMSCGENnorm* CosmicMuonGenerator::Norm
private

Definition at line 159 of file CosmicMuonGenerator.h.

Referenced by nextEvent(), and terminate().

bool CosmicMuonGenerator::NotInitialized
private
double CosmicMuonGenerator::Nsel
private

Definition at line 193 of file CosmicMuonGenerator.h.

Referenced by 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

Definition at line 163 of file CosmicMuonGenerator.h.

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

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 initialize(), and setPlugVx().

double CosmicMuonGenerator::PlugVz
private

Definition at line 198 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setPlugVz().

double CosmicMuonGenerator::Px_at
std::vector<double> CosmicMuonGenerator::Px_mu

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Px_sf
std::vector<double> CosmicMuonGenerator::Px_ug
double CosmicMuonGenerator::Py_at
std::vector<double> CosmicMuonGenerator::Py_mu

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Py_sf
std::vector<double> CosmicMuonGenerator::Py_ug
double CosmicMuonGenerator::Pz_at
std::vector<double> CosmicMuonGenerator::Pz_mu

Definition at line 125 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Pz_sf
std::vector<double> CosmicMuonGenerator::Pz_ug
double CosmicMuonGenerator::RadiusOfTarget
private
CLHEP::HepRandomEngine* CosmicMuonGenerator::RanGen
private

Definition at line 218 of file CosmicMuonGenerator.h.

Referenced by initialize(), nextEvent(), nextMultiEvent(), and setRandomEngine().

int CosmicMuonGenerator::RanSeed
private

Definition at line 164 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setRanSeed().

double CosmicMuonGenerator::rateErr_stat
private

Definition at line 188 of file CosmicMuonGenerator.h.

Referenced by terminate().

double CosmicMuonGenerator::rateErr_syst
private

Definition at line 189 of file CosmicMuonGenerator.h.

Referenced by terminate().

double CosmicMuonGenerator::RhoAir
private

Definition at line 201 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setRhoAir().

double CosmicMuonGenerator::RhoClay
private

Definition at line 204 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setRhoClay().

double CosmicMuonGenerator::RhoPlug
private

Definition at line 205 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setRhoPlug().

double CosmicMuonGenerator::RhoRock
private

Definition at line 203 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setRhoRock().

double CosmicMuonGenerator::RhoWall
private

Definition at line 202 of file CosmicMuonGenerator.h.

Referenced by 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.

double CosmicMuonGenerator::SurfaceRadius
private

Definition at line 196 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::T0_at
std::vector<double> CosmicMuonGenerator::T0_sf
std::vector<double> CosmicMuonGenerator::T0_ug
double CosmicMuonGenerator::Target3dRadius
private

Definition at line 195 of file CosmicMuonGenerator.h.

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

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 initialize(), and setTIFOnly_constant().

bool CosmicMuonGenerator::TIFOnly_linear
private

Definition at line 184 of file CosmicMuonGenerator.h.

Referenced by initialize(), and setTIFOnly_linear().

bool CosmicMuonGenerator::TrackerOnly
private
double CosmicMuonGenerator::Trials

Definition at line 114 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent(), and edm::CosMuoGenProducer::produce().

double CosmicMuonGenerator::Vx_at
std::vector<double> CosmicMuonGenerator::Vx_mu

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vx_sf
std::vector<double> CosmicMuonGenerator::Vx_ug
double CosmicMuonGenerator::Vxz_mu

Definition at line 128 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

double CosmicMuonGenerator::Vy_at
std::vector<double> CosmicMuonGenerator::Vy_mu

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vy_sf
std::vector<double> CosmicMuonGenerator::Vy_ug
double CosmicMuonGenerator::Vz_at
std::vector<double> CosmicMuonGenerator::Vz_mu

Definition at line 127 of file CosmicMuonGenerator.h.

Referenced by nextMultiEvent().

std::vector<double> CosmicMuonGenerator::Vz_sf
std::vector<double> CosmicMuonGenerator::Vz_ug
double CosmicMuonGenerator::ZCentrOfTarget
private

Definition at line 177 of file CosmicMuonGenerator.h.

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

double CosmicMuonGenerator::ZDistOfTarget
private