CMS 3D CMS Logo

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