Go to the documentation of this file.00001 #ifndef FastSimulation_CaloHitMakers_EcalHitMaker_h
00002 #define FastSimulation_CaloHitMakers_EcalHitMaker_h
00003
00004 #include "Geometry/CaloTopology/interface/CaloDirection.h"
00005
00006
00007 #include "FastSimulation/CaloHitMakers/interface/CaloHitMaker.h"
00008 #include "FastSimulation/CaloGeometryTools/interface/CaloPoint.h"
00009 #include "FastSimulation/CaloGeometryTools/interface/CaloSegment.h"
00010 #include "FastSimulation/CaloGeometryTools/interface/CrystalPad.h"
00011 #include "FastSimulation/CaloGeometryTools/interface/Crystal.h"
00012 #include "FastSimulation/Utilities/interface/FamosDebug.h"
00013
00014
00015
00016 #include <vector>
00017
00018 class CaloGeometryHelper;
00019 class CrystalWindowMap;
00020 class Histos;
00021 class RandomEngine;
00022 class FSimTrack;
00023
00024 class EcalHitMaker: public CaloHitMaker
00025 {
00026 public:
00027
00028 typedef math::XYZVector XYZVector;
00029 typedef math::XYZVector XYZPoint;
00030 typedef math::XYZVector XYZNormal;
00031 typedef ROOT::Math::Plane3D Plane3D;
00032
00033 EcalHitMaker(CaloGeometryHelper * calo,
00034 const XYZPoint& ecalentrance,
00035 const DetId& cell,
00036 int onEcal,
00037 unsigned size,
00038 unsigned showertype,
00039 const RandomEngine* engine);
00040
00041 ~EcalHitMaker();
00042
00043
00044 void setTrackParameters(const XYZNormal& normal,
00045 double X0depthoffset,
00046 const FSimTrack& theTrack);
00047
00048
00049
00050
00051
00052
00053 inline double totalX0() const {return totalX0_;};
00054
00056 inline double totalL0() const {return totalL0_;};
00057
00059 inline double x0DepthOffset() const {return X0depthoffset_;}
00060
00061
00062 inline double ps1TotalX0() const {return X0PS1_;}
00063
00065 inline double ps2TotalX0() const {return X0PS2_;}
00066
00067
00068 inline double ps2eeTotalX0() const {return X0PS2EE_;}
00069
00071 inline double ecalTotalX0() const {return X0ECAL_;}
00072
00074 inline double ecalHcalGapTotalX0() const { return X0EHGAP_;}
00075
00077 inline double hcalTotalX0() const {return X0HCAL_;}
00078
00080 inline double ps1TotalL0() const {return L0PS1_;}
00081
00083 inline double ps2TotalL0() const {return L0PS2_;}
00084
00085
00086 inline double ps2eeTotalL0() const {return L0PS2EE_;}
00087
00089 inline double ecalTotalL0() const {return L0ECAL_;}
00090
00092 inline double hcalTotalL0() const {return L0HCAL_;}
00093
00095 inline double ecalHcalGapTotalL0() const { return L0EHGAP_;}
00096
00099 inline const std::vector<CaloSegment>& getSegments() const {return segments_;};
00100
00101
00102
00103
00107 bool getPads(double depth,bool inCm=false) ;
00108
00109 inline double getX0back() const {return maxX0_;}
00110
00111 bool addHitDepth(double r,double phi,double depth=-1);
00112
00113 bool addHit(double r,double phi,unsigned layer=0) ;
00114
00115 unsigned fastInsideCell(const CLHEP::Hep2Vector & point,double & sp,bool debug=false) ;
00116
00117 inline void setSpotEnergy(double e) { spotEnergy=e;}
00118
00121
00122 const std::map<CaloHitID,float>& getHits() ;
00123
00125 const FSimTrack* getFSimTrack() const {return myTrack_;}
00126
00128 inline const XYZPoint& ecalEntrance() const {return EcalEntrance_;};
00129
00130 inline void setRadiusFactor(double r) {radiusCorrectionFactor_ = r;}
00131
00132 inline void setPulledPadSurvivalProbability(double val) {pulledPadProbability_ = val;};
00133
00134 inline void setCrackPadSurvivalProbability(double val ) {crackPadProbability_ = val ;};
00135
00136
00137 inline void setPreshowerPresent(bool ps) {simulatePreshower_=ps;};
00138
00140 inline const std::vector<Crystal>& getCrystals() const {return regionOfInterest_;}
00141
00142
00143
00144 private:
00145
00146
00147
00148
00149 void cellLine(std::vector<CaloPoint>& cp) ;
00150
00151 void preshowerCellLine(std::vector<CaloPoint>& cp) const;
00152
00153 void hcalCellLine(std::vector<CaloPoint>& cp) const;
00154
00155 void ecalCellLine(const XYZPoint&, const XYZPoint&,std::vector<CaloPoint>& cp);
00156
00157 void buildSegments(const std::vector<CaloPoint>& cp);
00158
00159
00160 void buildGeometry();
00161
00162
00163 void configureGeometry();
00164
00165
00166 bool pulled(const XYZPoint & origin, const XYZNormal& normal, XYZPoint & fPoint) const ;
00167
00168
00169 void prepareCrystalNumberArray();
00170
00171
00172 void convertIntegerCoordinates(double x, double y,unsigned &ix,unsigned &iy) const ;
00173
00174
00175 void reorganizePads();
00176
00177
00178 typedef std::pair<CaloDirection,unsigned > neighbour;
00179 CLHEP::Hep2Vector & correspondingEdge(neighbour& myneighbour,CaloDirection dir2 ) ;
00180
00181
00182 bool diagonalEdge(unsigned myPad, CaloDirection dir,CLHEP::Hep2Vector & point);
00183
00184
00185
00186 bool unbalancedDirection(const std::vector<neighbour>& dirs,unsigned & unb,unsigned & dir1, unsigned & dir2);
00187
00188
00189 void gapsLifting(std::vector<neighbour>& gaps,unsigned iq);
00190
00191
00192 void cracksPads(std::vector<neighbour> & cracks, unsigned iq);
00193
00194
00195 private:
00196
00197 bool inside3D(const std::vector<XYZPoint>&, const XYZPoint& p) const;
00198
00199
00200 std::vector<std::vector<unsigned > > myCrystalNumberArray_;
00201
00202
00203 double totalX0_;
00204 double totalL0_;
00205 double X0depthoffset_;
00206 double X0PS1_;
00207 double X0PS2_;
00208 double X0PS2EE_;
00209 double X0ECAL_;
00210 double X0EHGAP_;
00211 double X0HCAL_;
00212 double L0PS1_;
00213 double L0PS2_;
00214 double L0PS2EE_;
00215 double L0ECAL_;
00216 double L0HCAL_;
00217 double L0EHGAP_;
00218
00219 double maxX0_;
00220 double rearleakage_ ;
00221 double outsideWindowEnergy_;
00222
00223
00224 Crystal pivot_;
00225 XYZPoint EcalEntrance_;
00226 XYZNormal normal_;
00227 int central_;
00228 int onEcal_;
00229
00230 bool configuredGeometry_ ;
00231 unsigned ncrystals_ ;
00232
00233 unsigned nx_,ny_;
00234 double xmin_,xmax_,ymin_,ymax_;
00235
00236 std::vector<DetId> CellsWindow_;
00237 std::vector<Crystal> regionOfInterest_;
00238 std::vector<float> hits_;
00239
00240 std::vector<bool> validPads_;
00241
00242
00243 std::map<DetId,unsigned> DetIdMap_;
00244
00245 CrystalWindowMap * myCrystalWindowMap_;
00246
00247
00248 int ecalFirstSegment_;
00249
00250
00251 unsigned etasize_;
00252 unsigned phisize_;
00253
00254 bool truncatedGrid_ ;
00255
00256
00257
00258
00259 double radiusCorrectionFactor_;
00260
00261 double radiusFactor_ ;
00262
00263 bool detailedShowerTail_;
00264
00265 double currentdepth_;
00266
00267 double bfactor_;
00268
00269 bool simulatePreshower_;
00270
00271
00272 unsigned ncrackpadsatdepth_;
00273 unsigned npadsatdepth_;
00274 Plane3D plan_;
00275
00276
00277 double pulledPadProbability_;
00278
00279 double crackPadProbability_;
00280
00281 double sizex_,sizey_;
00282
00283
00284 const FSimTrack* myTrack_;
00285
00286
00287 std::vector<CaloPoint> intersections_;
00288
00289 std::vector<CaloSegment> segments_;
00290
00291 bool doreorg_;
00292
00293
00294 std::vector<CrystalPad> padsatdepth_;
00295 std::vector<CrystalPad> crackpadsatdepth_;
00296
00297 bool hitmaphasbeencalculated_ ;
00298
00299
00300 std::vector<CLHEP::Hep2Vector> mycorners;
00301 std::vector<XYZPoint> corners;
00302
00303
00304 const RandomEngine* random;
00305
00306
00307 #ifdef FAMOSDEBUG
00308 Histos * myHistos;
00309 #endif
00310
00311
00312 };
00313
00314 #endif