CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FastSimulation/CaloGeometryTools/src/CaloSegment.cc

Go to the documentation of this file.
00001 //FAMOS headers
00002 #include "FastSimulation/CaloGeometryTools/interface/CaloSegment.h"
00003 #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h"
00004 #include "FastSimulation/CalorimeterProperties/interface/PreshowerLayer1Properties.h"
00005 #include "FastSimulation/CalorimeterProperties/interface/PreshowerLayer2Properties.h"
00006 #include "FastSimulation/CalorimeterProperties/interface/HCALProperties.h"
00007 #include "FastSimulation/CalorimeterProperties/interface/ECALProperties.h"
00008 
00009 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00010 
00011 CaloSegment::CaloSegment(const CaloPoint& in,
00012                          const CaloPoint& out,
00013                          double si,
00014                          double siX0, 
00015                          double siL0,
00016                          Material mat,
00017                          const CaloGeometryHelper* myCalorimeter):
00018   entrance_(in),
00019   exit_(out),
00020   sentrance_(si),
00021   sX0entrance_(siX0),
00022   sL0entrance_(siL0),
00023   material_(mat)
00024 
00025 {
00026 
00027   sexit_= sentrance_+std::sqrt((exit_-entrance_).mag2());
00028   // Change this. CaloProperties from FamosShower should be used instead 
00029   double radLenIncm=999999;
00030   double intLenIncm=999999;
00031   detector_=in.whichDetector();
00032   if(detector_!=out.whichDetector()&&mat!=CRACK&&mat!=GAP&&mat!=ECALHCALGAP) 
00033     {
00034       std::cout << " Problem in the segments " << detector_ << " " << out.whichDetector() <<std::endl;
00035     }
00036   switch (mat)
00037     {
00038     case PbWO4:
00039       {
00040 
00041         int det = 0;
00042         if (in.whichSubDetector()==EcalBarrel) det = 1;
00043         if (in.whichSubDetector()==EcalEndcap) det = 2;
00044 
00045         radLenIncm =
00046           myCalorimeter->ecalProperties(det)->radLenIncm();
00047         intLenIncm =
00048           myCalorimeter->ecalProperties(det)->interactionLength();
00049       }
00050       break;
00051     case CRACK:
00052       {
00053         radLenIncm=8.9;//cracks : Al
00054         intLenIncm=35.4;
00055       }
00056       break;
00057     case PS:
00058       {
00059         radLenIncm = 
00060           myCalorimeter->layer1Properties(1)->radLenIncm();
00061         intLenIncm = 
00062           myCalorimeter->layer1Properties(1)->interactionLength();
00063       }
00064       break;
00065     case HCAL:
00066       {
00067         radLenIncm = 
00068           myCalorimeter->hcalProperties(1)->radLenIncm();
00069         intLenIncm = 
00070           myCalorimeter->hcalProperties(1)->interactionLength();
00071       }
00072       break;
00073     case ECALHCALGAP:
00074       {
00075         // From Olga's & Patrick's talk PRS/JetMET 21 Sept 2004 
00076         radLenIncm = 22.3;
00077         intLenIncm = 140;
00078       }
00079       break;
00080     case PSEEGAP:
00081       {
00082         // according to Sunanda 0.19 X0 (0.08X0 of polyethylene), support (0.06X0 of aluminium)  + other stuff
00083         // in the geometry 12 cm between layer and entrance of EE. Polyethylene is rather 48 and Al 8.9 (PDG)
00084         // for the inLen, just rescale according to PDG (85cm)
00085         radLenIncm = myCalorimeter->layer2Properties(1)->pseeRadLenIncm();
00086         intLenIncm = myCalorimeter->layer2Properties(1)->pseeIntLenIncm();
00087       }
00088       break;
00089     default:
00090       radLenIncm=999999;
00091     }
00092   sX0exit_ = sX0entrance_+(sexit_-sentrance_)/radLenIncm;
00093   sL0exit_ = sL0entrance_+(sexit_-sentrance_)/intLenIncm;
00094   if(mat==GAP) 
00095     {
00096       sX0exit_=sX0entrance_;
00097       sL0exit_=sL0entrance_;
00098     }
00099   length_ = sexit_-sentrance_;
00100   X0length_ = sX0exit_-sX0entrance_;
00101   L0length_ = sL0exit_-sL0entrance_;
00102 }
00103 
00104 CaloSegment::XYZPoint 
00105 CaloSegment::positionAtDepthincm(double depth) const
00106 {
00107   if (depth<sentrance_||depth>sexit_) return XYZPoint();
00108   return XYZPoint(entrance_+((depth-sentrance_)/(sexit_-sentrance_)*(exit_-entrance_)));
00109 }
00110 
00111 CaloSegment::XYZPoint 
00112 CaloSegment::positionAtDepthinX0(double depth) const
00113 {
00114   if (depth<sX0entrance_||depth>sX0exit_) return XYZPoint();
00115   return XYZPoint(entrance_+((depth-sX0entrance_)/(sX0exit_-sX0entrance_)*(exit_-entrance_)));
00116 }
00117 
00118 CaloSegment::XYZPoint 
00119 CaloSegment::positionAtDepthinL0(double depth) const
00120 {
00121   if (depth<sL0entrance_||depth>sL0exit_) return XYZPoint();
00122   return XYZPoint(entrance_+((depth-sL0entrance_)/(sL0exit_-sL0entrance_)*(exit_-entrance_)));
00123 }
00124 
00125 double 
00126 CaloSegment::x0FromCm(double cm) const{
00127   return sX0entrance_+cm/length_*X0length_;
00128 }
00129 
00130 std::ostream & operator<<(std::ostream& ost ,const CaloSegment& seg)
00131 {
00132   ost << " DetId " ;
00133   if(!seg.entrance().getDetId().null()) 
00134     ost << seg.entrance().getDetId()() ;
00135   else 
00136     {
00137       ost << seg.entrance().whichDetector() ;
00138       //  ost<< " Entrance side " << seg.entrance().getSide()
00139       ost << " Point " << (math::XYZVector)seg.entrance() << std::endl;
00140     }
00141   ost  << "DetId " ;
00142   if(!seg.exit().getDetId().null()) 
00143     ost << seg.exit().getDetId()() ;
00144   else
00145     ost << seg.exit().whichDetector() ;
00146 
00147   //  ost << " Exit side " << seg.exit().getSide() 
00148   ost << " Point " << (math::XYZVector)seg.exit() << " " 
00149       << seg.length() << " cm " 
00150       << seg.X0length() << " X0 " 
00151       <<  seg.L0length() << " Lambda0 " ;
00152   switch (seg.material())
00153     {
00154     case CaloSegment::PbWO4:
00155       ost << "PbWO4 " ;
00156       break;
00157     case CaloSegment::CRACK:
00158       ost << "CRACK ";
00159       break;
00160     case CaloSegment::PS:
00161       ost << "PS ";
00162       break;
00163     case CaloSegment::HCAL:
00164       ost << "HCAL ";
00165       break;
00166     case CaloSegment::ECALHCALGAP:
00167       ost << "ECAL-HCAL GAP ";
00168       break;
00169     case CaloSegment::PSEEGAP:
00170       ost  << "PS-ECAL GAP";
00171       break;
00172     default:
00173       ost << "GAP " ;
00174     }
00175   return ost;
00176 }
00177