CMS 3D CMS Logo

EcalHitMaker.h
Go to the documentation of this file.
1 #ifndef FastSimulation_CaloHitMakers_EcalHitMaker_h
2 #define FastSimulation_CaloHitMakers_EcalHitMaker_h
3 
5 
6 //#include "FastSimulation/Event/interface/FSimTrack.h"
13 
14 //#include <boost/cstdint.hpp>
15 
16 #include <vector>
17 
18 class CaloGeometryHelper;
19 class CrystalWindowMap;
20 class Histos;
22 class FSimTrack;
23 
24 class EcalHitMaker : public CaloHitMaker {
25 public:
30 
32  const XYZPoint& ecalentrance,
33  const DetId& cell,
34  int onEcal,
35  unsigned size,
36  unsigned showertype,
37  const RandomEngineAndDistribution* engine);
38 
39  ~EcalHitMaker() override;
40 
41  // This is not part of the constructor but it has to be called very early
42  void setTrackParameters(const XYZNormal& normal, double X0depthoffset, const FSimTrack& theTrack);
43 
44  // The following methods are related to the path of the particle
45  // through the detector.
46 
47  // Number of X0 "seen" by the track
48  // inline double totalX0() const {return totalX0_-X0depthoffset_;};
49  inline double totalX0() const { return totalX0_; };
50 
52  inline double totalL0() const { return totalL0_; };
53 
55  inline double x0DepthOffset() const { return X0depthoffset_; }
56 
57  // total number of X0 in the PS (Layer1).
58  inline double ps1TotalX0() const { return X0PS1_; }
59 
61  inline double ps2TotalX0() const { return X0PS2_; }
62 
63  // number of X0 between PS2 and EE
64  inline double ps2eeTotalX0() const { return X0PS2EE_; }
65 
67  inline double ecalTotalX0() const { return X0ECAL_; }
68 
70  inline double ecalHcalGapTotalX0() const { return X0EHGAP_; }
71 
73  inline double hcalTotalX0() const { return X0HCAL_; }
74 
76  inline double ps1TotalL0() const { return L0PS1_; }
77 
79  inline double ps2TotalL0() const { return L0PS2_; }
80 
81  // number of X0 between PS2 and EE
82  inline double ps2eeTotalL0() const { return L0PS2EE_; }
83 
85  inline double ecalTotalL0() const { return L0ECAL_; }
86 
88  inline double hcalTotalL0() const { return L0HCAL_; }
89 
91  inline double ecalHcalGapTotalL0() const { return L0EHGAP_; }
92 
95  inline const std::vector<CaloSegment>& getSegments() const { return segments_; };
96 
97  // The following methods are EM showers specific
98 
102  bool getPads(double depth, bool inCm = false);
103 
104  inline double getX0back() const { return maxX0_; }
105 
106  bool addHitDepth(double r, double phi, double depth = -1);
107 
108  bool addHit(double r, double phi, unsigned layer = 0) override;
109 
110  unsigned fastInsideCell(const CLHEP::Hep2Vector& point, double& sp, bool debug = false);
111 
112  inline void setSpotEnergy(double e) override { spotEnergy = e; }
113 
116 
117  const std::map<CaloHitID, float>& getHits() override;
118 
120  const FSimTrack* getFSimTrack() const { return myTrack_; }
121 
123  inline const XYZPoint& ecalEntrance() const { return EcalEntrance_; };
124 
125  inline void setRadiusFactor(double r) { radiusCorrectionFactor_ = r; }
126 
128 
130 
131  // set preshower
132  inline void setPreshowerPresent(bool ps) { simulatePreshower_ = ps; };
133 
135  inline const std::vector<Crystal>& getCrystals() const { return regionOfInterest_; }
136 
137 private:
138  // Computes the intersections of a track with the different calorimeters
139  void cellLine(std::vector<CaloPoint>& cp);
140 
141  void preshowerCellLine(std::vector<CaloPoint>& cp) const;
142 
143  void hcalCellLine(std::vector<CaloPoint>& cp) const;
144 
145  void ecalCellLine(const XYZPoint&, const XYZPoint&, std::vector<CaloPoint>& cp);
146 
147  void buildSegments(const std::vector<CaloPoint>& cp);
148 
149  // retrieves the 7x7 crystals and builds the map of neighbours
150  void buildGeometry();
151 
152  // depth-dependent geometry operations
153  void configureGeometry();
154 
155  // project fPoint on the plane (origin,normal)
156  bool pulled(const XYZPoint& origin, const XYZNormal& normal, XYZPoint& fPoint) const;
157 
158  // the numbering within the grid
160 
161  // find approximately the pad corresponding to (x,y)
162  void convertIntegerCoordinates(double x, double y, unsigned& ix, unsigned& iy) const;
163 
164  // pads reorganization (to lift the gaps)
165  void reorganizePads();
166 
167  // retrieves the coordinates of a corner belonging to the neighbour
168  typedef std::pair<CaloDirection, unsigned> neighbour;
169  CLHEP::Hep2Vector& correspondingEdge(neighbour& myneighbour, CaloDirection dir2);
170 
171  // almost the same
172  bool diagonalEdge(unsigned myPad, CaloDirection dir, CLHEP::Hep2Vector& point);
173 
174  // check if there is an unbalanced direction in the input vertor. If the result is true,
175  // the cooresponding directions are returned dir1+dir2=unb
176  bool unbalancedDirection(const std::vector<neighbour>& dirs, unsigned& unb, unsigned& dir1, unsigned& dir2);
177 
178  // glue the pads together if there is no crack between them
179  void gapsLifting(std::vector<neighbour>& gaps, unsigned iq);
180 
181  // creates a crack
182  void cracksPads(std::vector<neighbour>& cracks, unsigned iq);
183 
184 private:
185  bool inside3D(const std::vector<XYZPoint>&, const XYZPoint& p) const;
186 
187  // the numbering of the pads
188  std::vector<std::vector<unsigned> > myCrystalNumberArray_;
189 
190  // The following quantities are related to the path of the track through the detector
191  double totalX0_;
192  double totalL0_;
194  double X0PS1_;
195  double X0PS2_;
196  double X0PS2EE_;
197  double X0ECAL_;
198  double X0EHGAP_;
199  double X0HCAL_;
200  double L0PS1_;
201  double L0PS2_;
202  double L0PS2EE_;
203  double L0ECAL_;
204  double L0HCAL_;
205  double L0EHGAP_;
206 
207  double maxX0_;
208  double rearleakage_;
210 
211  // Grid construction
215  int central_;
216  int onEcal_;
217 
219  unsigned ncrystals_;
220  // size of the grid in the(x,y) plane
221  unsigned nx_, ny_;
222  double xmin_, xmax_, ymin_, ymax_;
223 
224  std::vector<DetId> CellsWindow_;
225  std::vector<Crystal> regionOfInterest_;
226  std::vector<float> hits_;
227  // Validity of the pads. To be valid, the intersection of the crytal with the plane should have 4 corners
228  std::vector<bool> validPads_;
229  // Get the index of the crystal (in hits_ or regionOfInterest_) when its CellID is known
230  // Needed because the navigation uses DetIds.
231  std::map<DetId, unsigned> DetIdMap_;
232 
234 
235  // First segment in ECAL
237 
238  // Properties of the crystal window
239  unsigned etasize_;
240  unsigned phisize_;
241  // is the grid complete ?
243 
244  // shower simulation quantities
245  // This one is the shower enlargment wrt Grindhammer
247  // moliere radius * radiuscorrectionfactor OR interactionlength
249  // is it necessary to trigger the detailed simulation of the shower tail ?
251  // current depth
253  // magnetic field correction factor
254  double bfactor_;
255  // simulate preshower
257 
258  // pads-depth specific quantities
260  unsigned npadsatdepth_;
262  // spot survival probability for a pulled pad - corresponding to the front face of a crystal
263  // on the plan located in front of the crystal - Front leaking
265  // spot survival probability for the craks
267  // size of the grid in the plane
268  double sizex_, sizey_;
269 
270  // int fsimtrack_;
272 
273  // vector of the intersection of the track with the dectectors (PS,ECAL,HCAL)
274  std::vector<CaloPoint> intersections_;
275  // segments obtained from the intersections
276  std::vector<CaloSegment> segments_;
277  // should the pads be reorganized (most of the time YES! )
278  bool doreorg_;
279 
280  // the geometrical objects
281  std::vector<CrystalPad> padsatdepth_;
282  std::vector<CrystalPad> crackpadsatdepth_;
283 
285 
286  // A local vector of corners, to avoid reserving, newing and mallocing
287  std::vector<CLHEP::Hep2Vector> mycorners;
288  std::vector<XYZPoint> corners;
289 
291 
292 #ifdef FAMOSDEBUG
293  Histos* myHistos;
294 #endif
295 };
296 
297 #endif
size
Write out results.
double ecalHcalGapTotalL0() const
ECAL-HCAL transition.
Definition: EcalHitMaker.h:91
XYZNormal normal_
Definition: EcalHitMaker.h:214
void ecalCellLine(const XYZPoint &, const XYZPoint &, std::vector< CaloPoint > &cp)
double pulledPadProbability_
Definition: EcalHitMaker.h:264
bool addHit(double r, double phi, unsigned layer=0) override
bool detailedShowerTail_
Definition: EcalHitMaker.h:250
unsigned ny_
Definition: EcalHitMaker.h:221
CrystalWindowMap * myCrystalWindowMap_
Definition: EcalHitMaker.h:233
void convertIntegerCoordinates(double x, double y, unsigned &ix, unsigned &iy) const
std::map< DetId, unsigned > DetIdMap_
Definition: EcalHitMaker.h:231
std::vector< CrystalPad > crackpadsatdepth_
Definition: EcalHitMaker.h:282
double totalX0() const
Definition: EcalHitMaker.h:49
static const char * normal
Definition: DMRtrends.cc:35
const std::vector< Crystal > & getCrystals() const
for debugging
Definition: EcalHitMaker.h:135
double ps2TotalL0() const
total number of L0 in the PS (Layer2).
Definition: EcalHitMaker.h:79
EcalHitMaker(CaloGeometryHelper *calo, const XYZPoint &ecalentrance, const DetId &cell, int onEcal, unsigned size, unsigned showertype, const RandomEngineAndDistribution *engine)
Definition: EcalHitMaker.cc:33
void reorganizePads()
const std::vector< CaloSegment > & getSegments() const
Definition: EcalHitMaker.h:95
bool unbalancedDirection(const std::vector< neighbour > &dirs, unsigned &unb, unsigned &dir1, unsigned &dir2)
double ps1TotalX0() const
Definition: EcalHitMaker.h:58
double ecalTotalL0() const
in the ECAL
Definition: EcalHitMaker.h:85
void setCrackPadSurvivalProbability(double val)
Definition: EcalHitMaker.h:129
std::vector< CrystalPad > padsatdepth_
Definition: EcalHitMaker.h:281
math::XYZVector XYZPoint
Definition: CaloHitMaker.h:23
double L0HCAL_
Definition: EcalHitMaker.h:204
Plane3D plan_
Definition: EcalHitMaker.h:261
std::vector< CLHEP::Hep2Vector > mycorners
Definition: EcalHitMaker.h:287
const RandomEngineAndDistribution * random
Definition: EcalHitMaker.h:290
double x0DepthOffset() const
get the offset (e.g the number of X0 after which the shower starts)
Definition: EcalHitMaker.h:55
math::XYZVector XYZPoint
Definition: EcalHitMaker.h:27
void prepareCrystalNumberArray()
double currentdepth_
Definition: EcalHitMaker.h:252
bool simulatePreshower_
Definition: EcalHitMaker.h:256
unsigned ncrystals_
Definition: EcalHitMaker.h:219
double X0HCAL_
Definition: EcalHitMaker.h:199
double hcalTotalX0() const
in the HCAL
Definition: EcalHitMaker.h:73
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
bool inside3D(const std::vector< XYZPoint > &, const XYZPoint &p) const
bool pulled(const XYZPoint &origin, const XYZNormal &normal, XYZPoint &fPoint) const
unsigned etasize_
Definition: EcalHitMaker.h:239
void setRadiusFactor(double r)
Definition: EcalHitMaker.h:125
bool truncatedGrid_
Definition: EcalHitMaker.h:242
unsigned fastInsideCell(const CLHEP::Hep2Vector &point, double &sp, bool debug=false)
bool configuredGeometry_
Definition: EcalHitMaker.h:218
double crackPadProbability_
Definition: EcalHitMaker.h:266
bool addHitDepth(double r, double phi, double depth=-1)
double L0PS2EE_
Definition: EcalHitMaker.h:202
const std::map< CaloHitID, float > & getHits() override
double radiusCorrectionFactor_
Definition: EcalHitMaker.h:246
double radiusFactor_
Definition: EcalHitMaker.h:248
double L0ECAL_
Definition: EcalHitMaker.h:203
void setTrackParameters(const XYZNormal &normal, double X0depthoffset, const FSimTrack &theTrack)
double X0EHGAP_
Definition: EcalHitMaker.h:198
const FSimTrack * myTrack_
Definition: EcalHitMaker.h:271
double ecalTotalX0() const
in the ECAL
Definition: EcalHitMaker.h:67
double getX0back() const
Definition: EcalHitMaker.h:104
void cracksPads(std::vector< neighbour > &cracks, unsigned iq)
double totalL0_
Definition: EcalHitMaker.h:192
double L0EHGAP_
Definition: EcalHitMaker.h:205
std::vector< CaloPoint > intersections_
Definition: EcalHitMaker.h:274
math::XYZVector XYZVector
Definition: EcalHitMaker.h:26
unsigned phisize_
Definition: EcalHitMaker.h:240
double ecalHcalGapTotalX0() const
ECAL-HCAL transition.
Definition: EcalHitMaker.h:70
double outsideWindowEnergy_
Definition: EcalHitMaker.h:209
void gapsLifting(std::vector< neighbour > &gaps, unsigned iq)
CLHEP::Hep2Vector & correspondingEdge(neighbour &myneighbour, CaloDirection dir2)
ROOT::Math::Plane3D Plane3D
Definition: EcalHitMaker.h:29
double ps1TotalL0() const
total number of L0 in the PS (Layer1).
Definition: EcalHitMaker.h:76
std::pair< CaloDirection, unsigned > neighbour
Definition: EcalHitMaker.h:168
double ps2eeTotalX0() const
Definition: EcalHitMaker.h:64
Definition: DetId.h:17
unsigned ncrackpadsatdepth_
Definition: EcalHitMaker.h:259
std::vector< XYZPoint > corners
Definition: EcalHitMaker.h:288
#define debug
Definition: HDRShower.cc:19
double X0PS2EE_
Definition: EcalHitMaker.h:196
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double bfactor_
Definition: EcalHitMaker.h:254
void preshowerCellLine(std::vector< CaloPoint > &cp) const
Crystal pivot_
Definition: EcalHitMaker.h:212
ROOT::Math::Plane3D Plane3D
Definition: CaloHitMaker.h:24
void configureGeometry()
double totalL0() const
Number of interaction length "seen" by the track.
Definition: EcalHitMaker.h:52
XYZPoint EcalEntrance_
Definition: EcalHitMaker.h:213
const FSimTrack * getFSimTrack() const
To retrieve the track.
Definition: EcalHitMaker.h:120
double X0ECAL_
Definition: EcalHitMaker.h:197
bool getPads(double depth, bool inCm=false)
void cellLine(std::vector< CaloPoint > &cp)
int ecalFirstSegment_
Definition: EcalHitMaker.h:236
double hcalTotalL0() const
in the HCAL
Definition: EcalHitMaker.h:88
std::vector< std::vector< unsigned > > myCrystalNumberArray_
Definition: EcalHitMaker.h:188
std::vector< float > hits_
Definition: EcalHitMaker.h:226
std::vector< Crystal > regionOfInterest_
Definition: EcalHitMaker.h:225
math::XYZVector XYZPoint
void buildSegments(const std::vector< CaloPoint > &cp)
void hcalCellLine(std::vector< CaloPoint > &cp) const
double ps2TotalX0() const
total number of X0 in the PS (Layer2).
Definition: EcalHitMaker.h:61
void setPulledPadSurvivalProbability(double val)
Definition: EcalHitMaker.h:127
~EcalHitMaker() override
Definition: Histos.h:19
void buildGeometry()
void setPreshowerPresent(bool ps)
Definition: EcalHitMaker.h:132
double X0depthoffset_
Definition: EcalHitMaker.h:193
std::vector< bool > validPads_
Definition: EcalHitMaker.h:228
double ps2eeTotalL0() const
Definition: EcalHitMaker.h:82
std::vector< DetId > CellsWindow_
Definition: EcalHitMaker.h:224
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
const XYZPoint & ecalEntrance() const
used in FamosHcalHitMaker
Definition: EcalHitMaker.h:123
bool hitmaphasbeencalculated_
Definition: EcalHitMaker.h:284
unsigned npadsatdepth_
Definition: EcalHitMaker.h:260
math::XYZVector XYZNormal
Definition: EcalHitMaker.h:28
double rearleakage_
Definition: EcalHitMaker.h:208
double spotEnergy
Definition: CaloHitMaker.h:48
ROOT::Math::Plane3D Plane3D
Definition: Common.h:9
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void setSpotEnergy(double e) override
Definition: EcalHitMaker.h:112
bool diagonalEdge(unsigned myPad, CaloDirection dir, CLHEP::Hep2Vector &point)
double totalX0_
Definition: EcalHitMaker.h:191
std::vector< CaloSegment > segments_
Definition: EcalHitMaker.h:276
unsigned nx_
Definition: EcalHitMaker.h:221