CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/FastSimulation/CaloHitMakers/src/CaloHitMaker.cc

Go to the documentation of this file.
00001 #include "FastSimulation/CaloHitMakers/interface/CaloHitMaker.h"
00002 #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h"
00003 #include "FastSimulation/CalorimeterProperties/interface/CalorimeterProperties.h"
00004 #include "FastSimulation/CalorimeterProperties/interface/PreshowerProperties.h"
00005 #include "FastSimulation/CalorimeterProperties/interface/HCALProperties.h"
00006 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00007 
00008 typedef ROOT::Math::Plane3D::Point Point;
00009 
00010 CaloHitMaker::CaloHitMaker(const CaloGeometryHelper * theCalo,DetId::Detector basedet,int subdetn,int cal,unsigned sht)
00011   :myCalorimeter(theCalo),theCaloProperties(NULL),base_(basedet),subdetn_(subdetn),onCal_(cal),showerType_(sht)
00012 {
00013   //  std::cout << " FamosCalorimeter " << basedet << " " << cal << std::endl;
00014   EMSHOWER=(sht==0);
00015   HADSHOWER=(sht==1);
00016   MIP=(sht==2);
00017   if(base_==DetId::Ecal&&(subdetn_==EcalBarrel||subdetn==EcalEndcap)&&onCal_)
00018     theCaloProperties = (CalorimeterProperties*)myCalorimeter->ecalProperties(onCal_);
00019   // is it really necessary to cast here ? 
00020   if(base_==DetId::Ecal&&subdetn_==EcalPreshower&&onCal_)
00021     theCaloProperties = (PreshowerProperties*)myCalorimeter->layer1Properties(onCal_);
00022   if(base_==DetId::Hcal&&cal) theCaloProperties = myCalorimeter->hcalProperties(onCal_);
00023 
00024   if(theCaloProperties)
00025     {
00026       moliereRadius=theCaloProperties->moliereRadius();
00027       interactionLength=theCaloProperties->interactionLength();
00028     }
00029   else
00030     {
00031       moliereRadius=999;
00032       interactionLength=999;
00033     }
00034 }
00035 
00036 
00037 CaloHitMaker::XYZPoint 
00038 CaloHitMaker::intersect(const Plane3D& p,const XYZPoint& a,const XYZPoint& b, 
00039                         double& t,bool segment, bool debug) 
00040 {
00041   t=-9999.;
00042   // En Attendant //
00043   XYZVector normal = p.Normal();
00044   double AAA = normal.X();
00045   double BBB = normal.Y();
00046   double CCC = normal.Z();
00047   //  double DDD = p.Distance(Point(0.,0.,0.));
00048   double DDD = p.HesseDistance();
00049   //  double denom = p.A()*(b.X()-a.X()) + p.B()*(b.Y()-a.Y()) + p.C()*(b.Z()-a.Z());
00050   double denom = AAA*(b.X()-a.X()) + BBB*(b.Y()-a.Y()) + CCC*(b.Z()-a.Z());
00051   if(denom!=0.)
00052     {
00053       // t=-(p.A()*a.X()+p.B()*a.Y()+p.C()*a.Z()+p.D());
00054       t=-(AAA*a.X()+BBB*a.Y()+CCC*a.Z()+DDD);
00055       t/=denom;
00056       if(debug) std::cout << " T = " << t <<std::endl; 
00057       if(segment)
00058         {
00059           if(t>=0&&t<=1)
00060             return XYZPoint(a.X()+(b.X()-a.X())*t,
00061                             a.Y()+(b.Y()-a.Y())*t,
00062                             a.Z()+(b.Z()-a.Z())*t);      
00063         }
00064       else
00065         {
00066           return XYZPoint(a.X()+(b.X()-a.X())*t,
00067                           a.Y()+(b.Y()-a.Y())*t,
00068                           a.Z()+(b.Z()-a.Z())*t);      
00069         }
00070           
00071      
00072     }
00073 
00074   return XYZPoint(0.,0.,0.);
00075 }