CMS 3D CMS Logo

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