CMS 3D CMS Logo

PreshowerHitMaker.cc

Go to the documentation of this file.
00001 #include "FastSimulation/CaloHitMakers/interface/PreshowerHitMaker.h"
00002 #
00003 #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h"
00004 #include "FastSimulation/Utilities/interface/LandauFluctuationGenerator.h"
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00007 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
00008 
00009 #include "Math/GenVector/Plane3D.h"
00010 
00011 #include <cmath>
00012 
00013 typedef ROOT::Math::Plane3D Plane3D;
00014 
00015 // LandauFluctuationGenerator PreshowerHitMaker::theGenerator=LandauFluctuationGenerator();
00016 
00017 PreshowerHitMaker::PreshowerHitMaker(
00018     CaloGeometryHelper * calo,
00019     const XYZPoint& layer1entrance, 
00020     const XYZVector& layer1dir, 
00021     const XYZPoint& layer2entrance, 
00022     const XYZVector& layer2dir,
00023     const LandauFluctuationGenerator* aGenerator):
00024   CaloHitMaker(calo,DetId::Ecal,EcalPreshower,2),
00025   psLayer1Entrance_(layer1entrance),
00026   psLayer1Dir_(layer1dir),
00027   psLayer2Entrance_(layer2entrance),
00028   psLayer2Dir_(layer2dir),
00029   theGenerator(aGenerator)
00030 {
00031    // Check if the entrance points are really on the wafers
00032   // Layer 1 
00033   int z=(psLayer1Entrance_.z()>0)? 1:-1;
00034   Plane3D plan1(0.,0.,1.,-z*myCalorimeter->preshowerZPosition(1));
00035   double dummyt;
00036   psLayer1Entrance_ = intersect(plan1,layer1entrance,layer1entrance+layer1dir,dummyt,false);
00037   x1=psLayer1Entrance_.x();
00038   y1=psLayer1Entrance_.y();
00039   z1=psLayer1Entrance_.z();
00040   XYZVector dirx(psLayer1Entrance_.x(),0,psLayer1Entrance_.z());
00041   XYZVector diry(0,psLayer1Entrance_.y(),psLayer1Entrance_.z());
00042   dirx=dirx.Unit();
00043   diry=diry.Unit();
00044   invcostheta1x = 1./fabs(dirx.Dot(XYZVector(0,0,1.)));
00045   invcostheta1y = 1./fabs(diry.Dot(XYZVector(0,0,1.)));      
00046 
00047   // Layer 2
00048   z=(psLayer2Entrance_.z()>0) ? 1:-1;
00049   Plane3D plan2(0.,0.,1.,-z*myCalorimeter->preshowerZPosition(2));
00050   
00051   psLayer2Entrance_ = intersect(plan2,layer2entrance,layer2entrance+layer2dir,dummyt,false);
00052   x2=psLayer2Entrance_.x();
00053   y2=psLayer2Entrance_.y();
00054   z2=psLayer2Entrance_.z();
00055   dirx = XYZVector(psLayer2Entrance_.x(),0,psLayer2Entrance_.z());
00056   diry = XYZVector(0,psLayer2Entrance_.y(),psLayer2Entrance_.z());
00057   dirx=dirx.Unit();
00058   diry=diry.Unit();
00059   invcostheta2x = 1./fabs(dirx.Dot(XYZVector(0,0,1.)));
00060   invcostheta2y = 1./fabs(diry.Dot(XYZVector(0,0,1.)));
00061 
00062   //  theGenerator=LandauFluctuationGenerator();
00063 }
00064 
00065 
00066 bool 
00067 PreshowerHitMaker::addHit(double r,double phi,unsigned layer)
00068 {
00069   r*=moliereRadius;
00070   XYZPoint point = (layer==1) ? 
00071     XYZPoint(x1+r*invcostheta1x*std::cos(phi),y1+r*invcostheta1y*std::sin(phi),z1) : 
00072     XYZPoint(x2+r*invcostheta2x*std::cos(phi),y2+r*invcostheta2y*std::sin(phi),z2);
00073   
00074   //  std::cout << " Layer " << layer << " " << point << std::endl;
00075   DetId strip = myCalorimeter->getEcalPreshowerGeometry()->getClosestCellInPlane(GlobalPoint(point.x(),point.y(),point.z()),layer);
00076 
00077   float spote=0.000095+0.000021*theGenerator->landau();
00078 
00079   if(!strip.null())
00080     {
00081       uint stripNumber=strip.rawId();
00082       std::map<uint32_t,float>::iterator cellitr;
00083       cellitr = hitMap_.find(stripNumber);
00084       if( cellitr==hitMap_.end())
00085         {
00086           hitMap_.insert(std::pair<uint32_t,float>(stripNumber,spote));
00087         }
00088       else
00089         {
00090           cellitr->second+=spotEnergy;
00091         }  
00092       return true;
00093     }
00094   return false;
00095 }

Generated on Tue Jun 9 17:35:02 2009 for CMSSW by  doxygen 1.5.4