File indexing completed on 2024-04-06 12:11:12
0001 #ifndef FastSimulation_CaloHitMakers_EcalHitMaker_h
0002 #define FastSimulation_CaloHitMakers_EcalHitMaker_h
0003
0004 #include "Geometry/CaloTopology/interface/CaloDirection.h"
0005
0006
0007 #include "FastSimulation/CaloHitMakers/interface/CaloHitMaker.h"
0008 #include "FastSimulation/CaloGeometryTools/interface/CaloPoint.h"
0009 #include "FastSimulation/CaloGeometryTools/interface/CaloSegment.h"
0010 #include "FastSimulation/CaloGeometryTools/interface/CrystalPad.h"
0011 #include "FastSimulation/CaloGeometryTools/interface/Crystal.h"
0012 #include "FastSimulation/Utilities/interface/FamosDebug.h"
0013
0014
0015
0016 #include <vector>
0017
0018 class CaloGeometryHelper;
0019 class CrystalWindowMap;
0020 class Histos;
0021 class RandomEngineAndDistribution;
0022 class FSimTrack;
0023
0024 class EcalHitMaker : public CaloHitMaker {
0025 public:
0026 typedef math::XYZVector XYZVector;
0027 typedef math::XYZVector XYZPoint;
0028 typedef math::XYZVector XYZNormal;
0029 typedef ROOT::Math::Plane3D Plane3D;
0030
0031 EcalHitMaker(CaloGeometryHelper* calo,
0032 const XYZPoint& ecalentrance,
0033 const DetId& cell,
0034 int onEcal,
0035 unsigned size,
0036 unsigned showertype,
0037 const RandomEngineAndDistribution* engine);
0038
0039 ~EcalHitMaker() override;
0040
0041
0042 void setTrackParameters(const XYZNormal& normal, double X0depthoffset, const FSimTrack& theTrack);
0043
0044
0045
0046
0047
0048
0049 inline double totalX0() const { return totalX0_; };
0050
0051
0052 inline double totalL0() const { return totalL0_; };
0053
0054
0055 inline double x0DepthOffset() const { return X0depthoffset_; }
0056
0057
0058 inline double ps1TotalX0() const { return X0PS1_; }
0059
0060
0061 inline double ps2TotalX0() const { return X0PS2_; }
0062
0063
0064 inline double ps2eeTotalX0() const { return X0PS2EE_; }
0065
0066
0067 inline double ecalTotalX0() const { return X0ECAL_; }
0068
0069
0070 inline double ecalHcalGapTotalX0() const { return X0EHGAP_; }
0071
0072
0073 inline double hcalTotalX0() const { return X0HCAL_; }
0074
0075
0076 inline double ps1TotalL0() const { return L0PS1_; }
0077
0078
0079 inline double ps2TotalL0() const { return L0PS2_; }
0080
0081
0082 inline double ps2eeTotalL0() const { return L0PS2EE_; }
0083
0084
0085 inline double ecalTotalL0() const { return L0ECAL_; }
0086
0087
0088 inline double hcalTotalL0() const { return L0HCAL_; }
0089
0090
0091 inline double ecalHcalGapTotalL0() const { return L0EHGAP_; }
0092
0093
0094
0095 inline const std::vector<CaloSegment>& getSegments() const { return segments_; };
0096
0097
0098
0099
0100
0101
0102 bool getPads(double depth, bool inCm = false);
0103
0104 inline double getX0back() const { return maxX0_; }
0105
0106 bool addHitDepth(double r, double phi, double depth = -1);
0107
0108 bool addHit(double r, double phi, unsigned layer = 0) override;
0109
0110 unsigned fastInsideCell(const CLHEP::Hep2Vector& point, double& sp, bool debug = false);
0111
0112 inline void setSpotEnergy(double e) override { spotEnergy = e; }
0113
0114
0115
0116
0117 const std::map<CaloHitID, float>& getHits() override;
0118
0119
0120 const FSimTrack* getFSimTrack() const { return myTrack_; }
0121
0122
0123 inline const XYZPoint& ecalEntrance() const { return EcalEntrance_; };
0124
0125 inline void setRadiusFactor(double r) { radiusCorrectionFactor_ = r; }
0126
0127 inline void setPulledPadSurvivalProbability(double val) { pulledPadProbability_ = val; };
0128
0129 inline void setCrackPadSurvivalProbability(double val) { crackPadProbability_ = val; };
0130
0131
0132 inline void setPreshowerPresent(bool ps) { simulatePreshower_ = ps; };
0133
0134
0135 inline const std::vector<Crystal>& getCrystals() const { return regionOfInterest_; }
0136
0137 private:
0138
0139 void cellLine(std::vector<CaloPoint>& cp);
0140
0141 void preshowerCellLine(std::vector<CaloPoint>& cp) const;
0142
0143 void hcalCellLine(std::vector<CaloPoint>& cp) const;
0144
0145 void ecalCellLine(const XYZPoint&, const XYZPoint&, std::vector<CaloPoint>& cp);
0146
0147 void buildSegments(const std::vector<CaloPoint>& cp);
0148
0149
0150 void buildGeometry();
0151
0152
0153 void configureGeometry();
0154
0155
0156 bool pulled(const XYZPoint& origin, const XYZNormal& normal, XYZPoint& fPoint) const;
0157
0158
0159 void prepareCrystalNumberArray();
0160
0161
0162 void convertIntegerCoordinates(double x, double y, unsigned& ix, unsigned& iy) const;
0163
0164
0165 void reorganizePads();
0166
0167
0168 typedef std::pair<CaloDirection, unsigned> neighbour;
0169 CLHEP::Hep2Vector& correspondingEdge(neighbour& myneighbour, CaloDirection dir2);
0170
0171
0172 bool diagonalEdge(unsigned myPad, CaloDirection dir, CLHEP::Hep2Vector& point);
0173
0174
0175
0176 bool unbalancedDirection(const std::vector<neighbour>& dirs, unsigned& unb, unsigned& dir1, unsigned& dir2);
0177
0178
0179 void gapsLifting(std::vector<neighbour>& gaps, unsigned iq);
0180
0181
0182 void cracksPads(std::vector<neighbour>& cracks, unsigned iq);
0183
0184 private:
0185 bool inside3D(const std::vector<XYZPoint>&, const XYZPoint& p) const;
0186
0187
0188 std::vector<std::vector<unsigned> > myCrystalNumberArray_;
0189
0190
0191 double totalX0_;
0192 double totalL0_;
0193 double X0depthoffset_;
0194 double X0PS1_;
0195 double X0PS2_;
0196 double X0PS2EE_;
0197 double X0ECAL_;
0198 double X0EHGAP_;
0199 double X0HCAL_;
0200 double L0PS1_;
0201 double L0PS2_;
0202 double L0PS2EE_;
0203 double L0ECAL_;
0204 double L0HCAL_;
0205 double L0EHGAP_;
0206
0207 double maxX0_;
0208 double rearleakage_;
0209 double outsideWindowEnergy_;
0210
0211
0212 Crystal pivot_;
0213 XYZPoint EcalEntrance_;
0214 XYZNormal normal_;
0215 int central_;
0216 int onEcal_;
0217
0218 bool configuredGeometry_;
0219 unsigned ncrystals_;
0220
0221 unsigned nx_, ny_;
0222 double xmin_, xmax_, ymin_, ymax_;
0223
0224 std::vector<DetId> CellsWindow_;
0225 std::vector<Crystal> regionOfInterest_;
0226 std::vector<float> hits_;
0227
0228 std::vector<bool> validPads_;
0229
0230
0231 std::map<DetId, unsigned> DetIdMap_;
0232
0233 CrystalWindowMap* myCrystalWindowMap_;
0234
0235
0236 int ecalFirstSegment_;
0237
0238
0239 unsigned etasize_;
0240 unsigned phisize_;
0241
0242 bool truncatedGrid_;
0243
0244
0245
0246 double radiusCorrectionFactor_;
0247
0248 double radiusFactor_;
0249
0250 bool detailedShowerTail_;
0251
0252 double currentdepth_;
0253
0254 double bfactor_;
0255
0256 bool simulatePreshower_;
0257
0258
0259 unsigned ncrackpadsatdepth_;
0260 unsigned npadsatdepth_;
0261 Plane3D plan_;
0262
0263
0264 double pulledPadProbability_;
0265
0266 double crackPadProbability_;
0267
0268 double sizex_, sizey_;
0269
0270
0271 const FSimTrack* myTrack_;
0272
0273
0274 std::vector<CaloPoint> intersections_;
0275
0276 std::vector<CaloSegment> segments_;
0277
0278 bool doreorg_;
0279
0280
0281 std::vector<CrystalPad> padsatdepth_;
0282 std::vector<CrystalPad> crackpadsatdepth_;
0283
0284 bool hitmaphasbeencalculated_;
0285
0286
0287 std::vector<CLHEP::Hep2Vector> mycorners;
0288 std::vector<XYZPoint> corners;
0289
0290 const RandomEngineAndDistribution* random;
0291
0292 #ifdef FAMOSDEBUG
0293 Histos* myHistos;
0294 #endif
0295 };
0296
0297 #endif