test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastHFShowerLibrary.cc
Go to the documentation of this file.
1 // File: FastHFShowerLibrary.cc
3 // Description: Shower library for Very forward hadron calorimeter
5 
21 
22 #include "Randomize.hh"
23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
24 #include "CLHEP/Units/GlobalPhysicalConstants.h"
25 
26 // Geant4 headers
27 #include "G4ParticleDefinition.hh"
28 #include "G4DynamicParticle.hh"
29 #include "G4DecayPhysics.hh"
30 #include "G4ParticleTable.hh"
31 #include "G4ParticleTypes.hh"
32 
33 // STL headers
34 #include <vector>
35 #include <iostream>
36 
37 //#define DebugLog
38 
40  : fast(p) {
41  edm::ParameterSet m_HS = p.getParameter<edm::ParameterSet>("HFShowerLibrary");
42  applyFidCut = m_HS.getParameter<bool>("ApplyFiducialCut");
43 }
44 
46 
47  edm::LogInfo("FastCalorimetry") << "initHFShowerLibrary::initialization";
48 
50  iSetup.get<IdealGeometryRecord>().get(cpv);
51 
53  iSetup.get<HcalSimNumberingRecord>().get(hdc);
54  hcalConstants = (HcalDDDSimConstants*)(&(*hdc));
55 
56  std::string name = "HcalHits";
58  hfshower.reset(new HFShowerLibrary(name,*cpv,fast));
59 
60  // Geant4 particles
61  G4DecayPhysics decays;
62  decays.ConstructParticle();
63  G4ParticleTable* partTable = G4ParticleTable::GetParticleTable();
64  partTable->SetReadiness();
65 
66  hfshower->initRun(partTable, hcalConstants); // init particle code
67 }
68 
70 
71 #ifdef DebugLog
72  edm::LogInfo("FastCalorimetry") << "FastHFShowerLibrary: recoHFShowerLibrary ";
73 #endif
74 
75  if(!myTrack.onVFcal()) {
76 #ifdef DebugLog
77  edm::LogInfo("FastCalorimetry") << "FastHFShowerLibrary: we should not be here ";
78 #endif
79  }
80 
81  hitMap.clear();
82  double eGen = 1000.*myTrack.vfcalEntrance().e(); // energy in [MeV]
83  double delZv = (myTrack.vfcalEntrance().vertex().Z()>0.0) ? 50.0 : -50.0;
84  G4ThreeVector vertex( 10.*myTrack.vfcalEntrance().vertex().X(),
85  10.*myTrack.vfcalEntrance().vertex().Y(),
86  10.*myTrack.vfcalEntrance().vertex().Z()+delZv); // in [mm]
87 
88  G4ThreeVector direction(myTrack.vfcalEntrance().Vect().X(),
89  myTrack.vfcalEntrance().Vect().Y(),
90  myTrack.vfcalEntrance().Vect().Z());
91 
92  bool ok;
93  double weight = 1.0; // rad. damage
94  int parCode = myTrack.type();
95  double tSlice = 0.1*vertex.mag()/29.98;
96 
97  std::vector<HFShowerLibrary::Hit> hits =
98  hfshower->fillHits(vertex,direction,parCode,eGen,ok,weight,false,tSlice);
99 
100  for (unsigned int i=0; i<hits.size(); ++i) {
101  G4ThreeVector pos = hits[i].position;
102  int depth = hits[i].depth;
103  double time = hits[i].time;
104  if (!applyFidCut || (HFFibreFiducial::PMTNumber(pos)>0) ) {
105 // if (!applyFidCut || (applyFidCut && HFFibreFiducial::PMTNumber(pos)>0)) {
106  int det = 5;
107  int lay = 1;
108  uint32_t id = 0;
109  HcalNumberingFromDDD::HcalID tmp = numberingFromDDD->unitID(det, pos, depth, lay);
110  id = numberingScheme.getUnitID(tmp);
111 
112  CaloHitID current_id(id,time,myTrack.id());
113  std::map<CaloHitID,float>::iterator cellitr;
114  cellitr = hitMap.find(current_id);
115  if(cellitr==hitMap.end()) {
116  hitMap.insert(std::pair<CaloHitID,float>(current_id,1.0));
117  } else {
118  cellitr->second += 1.0;
119  }
120  } // end of isItinFidVolume check
121  } // end loop over hits
122 
123 }
124 
126 
127  HcalDetId hid(id);
128  if (hid.subdet() == HcalForward) {
129  int eta = hid.ieta();
130  int phi = hid.iphi();
131  if (hcalConstants->maxHFDepth(eta,phi) > 2) {
132  if (hid.depth() <= 2) {
133  int dep = (G4UniformRand() > 0.5) ? (2+hid.depth()) : hid.depth();
134  id = HcalDetId(HcalForward,eta,phi,dep).rawId();
135  }
136  }
137  }
138 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
const RawParticle & vfcalEntrance() const
The particle at VFCAL entrance.
Definition: FSimTrack.h:139
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
const edm::ParameterSet fast
void recoHFShowerLibrary(const FSimTrack &myTrack)
virtual uint32_t getUnitID(const HcalNumberingFromDDD::HcalID &id)
void modifyDepth(uint32_t &id)
static int PMTNumber(const G4ThreeVector &pe_effect)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
HcalNumberingScheme numberingScheme
double Y() const
y of vertex
Definition: RawParticle.h:275
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
double Z() const
z of vertex
Definition: RawParticle.h:276
int onVFcal() const
Definition: FSimTrack.h:111
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:285
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
FastHFShowerLibrary(edm::ParameterSet const &p)
const T & get() const
Definition: EventSetup.h:56
double X() const
x of vertex
Definition: RawParticle.h:274
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:25
std::unique_ptr< HFShowerLibrary > hfshower
int id() const
the index in FBaseSimEvent and other vectors
Definition: FSimTrack.h:86
void const initHFShowerLibrary(const edm::EventSetup &)
std::map< CaloHitID, float > hitMap
HcalDDDSimConstants * hcalConstants
int maxHFDepth(int ieta, int iphi) const