CMS 3D CMS Logo

HcalHitMaker Class Reference

#include <FastSimulation/CaloHitMakers/interface/HcalHitMaker.h>

Inheritance diagram for HcalHitMaker:

CaloHitMaker

List of all members.

Public Types

typedef ROOT::Math::Transform3DPJ Transform3D
typedef math::XYZVector XYZPoint
typedef math::XYZVector XYZVector

Public Member Functions

bool addHit (double r, double phi, unsigned layer=0)
 add the hit in the HCAL
const std::map< uint32_t, float > & getHits ()
 HcalHitMaker (EcalHitMaker &, unsigned)
bool setDepth (double)
 set the depth in X0 or Lambda0 units depending on showerType
void setSpotEnergy (double e)
 Set the spot energy.
 ~HcalHitMaker ()

Static Public Member Functions

static int getSubHcalDet (const FSimTrack *t)

Private Attributes

double currentDepth_
XYZPoint ecalEntrance_
Transform3D locToGlobal_
bool mapCalculated_
EcalHitMakermyGrid
const FSimTrackmyTrack
int onHcal
XYZVector particleDirection
double radiusFactor_


Detailed Description

Definition at line 16 of file HcalHitMaker.h.


Member Typedef Documentation

typedef ROOT::Math::Transform3DPJ HcalHitMaker::Transform3D

Definition at line 22 of file HcalHitMaker.h.

typedef math::XYZVector HcalHitMaker::XYZPoint

Reimplemented from CaloHitMaker.

Definition at line 21 of file HcalHitMaker.h.

typedef math::XYZVector HcalHitMaker::XYZVector

Reimplemented from CaloHitMaker.

Definition at line 20 of file HcalHitMaker.h.


Constructor & Destructor Documentation

HcalHitMaker::HcalHitMaker ( EcalHitMaker grid,
unsigned  shower 
)

Definition at line 10 of file HcalHitMaker.cc.

References funct::abs(), GenMuonPlsPt100GeV_cfg::cout, EcalHitMaker::ecalEntrance(), FSimTrack::ecalEntrance(), ecalEntrance_, CaloHitMaker::EMSHOWER, lat::endl(), EcalHitMaker::getFSimTrack(), CaloHitMaker::interactionLength, mapCalculated_, CaloHitMaker::moliereRadius, myGrid, myTrack, particleDirection, radiusFactor_, and CoreSimTrack::type().

00011   :CaloHitMaker(grid.getCalorimeter(),DetId::Hcal,HcalHitMaker::getSubHcalDet(grid.getFSimTrack()),
00012                 grid.getFSimTrack()->onHcal()?grid.getFSimTrack()->onHcal():grid.getFSimTrack()->onVFcal()+1,shower),
00013    myGrid(grid),  myTrack((grid.getFSimTrack()))
00014 {
00015   // normalize the direction
00016   ecalEntrance_=myGrid.ecalEntrance();
00017   particleDirection=myTrack->ecalEntrance().Vect().Unit();
00018   radiusFactor_=(EMSHOWER)? moliereRadius:interactionLength;
00019   mapCalculated_=false;
00020   //std::cout << " Famos HCAL " << grid.getTrack()->onHcal() << " " <<  grid.getTrack()->onVFcal() << " " << showerType << std::endl;
00021   if(EMSHOWER&&(abs(grid.getFSimTrack()->type())!=11 && grid.getFSimTrack()->type()!=22))
00022     {
00023       std::cout << " FamosHcalHitMaker : Strange. The following shower has EM type" << std::endl <<* grid.getFSimTrack() << std::endl;
00024     }
00025 }

HcalHitMaker::~HcalHitMaker (  )  [inline]

Definition at line 25 of file HcalHitMaker.h.

00025 {;}


Member Function Documentation

bool HcalHitMaker::addHit ( double  r,
double  phi,
unsigned  layer = 0 
) [virtual]

add the hit in the HCAL

Implements CaloHitMaker.

Definition at line 28 of file HcalHitMaker.cc.

References funct::cos(), CaloHitMaker::EMSHOWER, lat::endl(), CaloGeometryHelper::getClosestCell(), HcalForward, CaloHitMaker::hitMap_, int, locToGlobal_, CaloHitMaker::myCalorimeter, radiusFactor_, funct::sin(), and CaloHitMaker::spotEnergy.

Referenced by EMShower::compute(), HFShower::compute(), HDShower::compute(), and HDRShower::setHit().

00029 {
00030     //  std::cout << " FamosHcalHitMaker::addHit - radiusFactor = " << radiusFactor
00031   //        << std::endl;
00032 
00033   XYZPoint point(r*radiusFactor_*std::cos(phi),r*radiusFactor_*std::sin(phi),0.);
00034 
00035   // Watch out !!!! (Point) is a real point in the MathCore terminology (not a redefined a XYZPoint which
00036   // is actually a XYZVector in the MatchCore terminology). Therefore, the Transform3D is correctly applied
00037   point = locToGlobal_((Point)point);
00038 
00039   // Temporary nasty hacks to avoid misbehaviour of not-intended-for-that
00040   //  getClosestCell in case of large (eta beyond HF ...)  and in EM showers 
00041   if(fabs(point.Z())>2000 || fabs(point.X())>2000 || fabs(point.Y())>2000) 
00042     { 
00043       if(EMSHOWER) 
00044         edm::LogWarning("HcalHitMaker") << "received a hit very far from the detector " << point << " coming from an electromagnetic shower. - Ignoring it" << std::endl;
00045       else
00046         edm::LogWarning("HcalHitMaker") << "received a hit very far from the detector " << point << " coming from an hadron shower. - Ignoring it" << std::endl;
00047       return false; 
00048     } 
00049 
00050 
00051   double pointeta = fabs(point.eta());
00052   if(pointeta > 5.19) return false; 
00053 
00054   DetId thecellID(myCalorimeter->getClosestCell(point,false,false));
00055   
00056   HcalDetId myDetId(thecellID);
00057                                                                                                                                       
00058 //   if ( myDetId.subdetId() == HcalForward ) {
00059 //     std::cout << "HcalHitMaker : " << point.Z() << " " << myDetId.depth()    << std::endl;
00060 //   }
00061                                                                                                                                       
00062 //   std::cout << "BEFORE" << std::endl;
00063 //   std::cout << "HcalHitMaker : subdetId : " << myDetId.subdetId() << std::endl;
00064 //   std::cout << "HcalHitMaker : depth    : " << myDetId.depth()    << std::endl;
00065 //   std::cout << "HcalHitMaker : ieta     : " << myDetId.ieta()     << std::endl;
00066 //   std::cout << "HcalHitMaker : iphi     : " << myDetId.iphi()     << std::endl;
00067 //   std::cout << "HcalHitMaker : spotE    : " << spotEnergy         << std::endl;
00068 //   std::cout << "HcalHitMaker : point.X  : " << point.X()          << std::endl;
00069 //   std::cout << "HcalHitMaker : point.Y  : " << point.Y()          << std::endl;
00070 //   std::cout << "HcalHitMaker : point.Z  : " << point.Z()          << std::endl;
00071                                                                                                                                       
00072   if ( myDetId.subdetId() == HcalForward ) {
00073     int mylayer = layer;
00074     if ( myDetId.depth()==2 ) {
00075       mylayer = (int)layer;
00076     } else {
00077       mylayer = 1;
00078     }
00079     HcalDetId myDetId2((HcalSubdetector)myDetId.subdetId(),myDetId.ieta(),myDetId.iphi(),mylayer);
00080     thecellID = myDetId2;
00081   }
00082 
00083 
00084   
00085   if(!thecellID.null())
00086     {   
00087       uint32_t cell(thecellID.rawId());
00088       
00089       //      std::cout << " FamosHcalHitMaker::addHit - the cell num " << cell
00090       //                << std::endl;
00091 
00092       std::map<uint32_t,float>::iterator cellitr;
00093       cellitr = hitMap_.find(cell);
00094       if(cellitr==hitMap_.end())
00095         {
00096           hitMap_.insert(std::pair<uint32_t,float>(cell,spotEnergy));
00097         }
00098       else
00099         {
00100           cellitr->second+=spotEnergy;
00101         }
00102       return true;
00103     }
00104   return false;
00105 }

const std::map<uint32_t,float>& HcalHitMaker::getHits (  )  [inline, virtual]

Implements CaloHitMaker.

Definition at line 34 of file HcalHitMaker.h.

References CaloHitMaker::hitMap_.

Referenced by CalorimetryManager::EMShowerSimulation(), and CalorimetryManager::HDShowerSimulation().

00034 { return hitMap_ ;} ;

static int HcalHitMaker::getSubHcalDet ( const FSimTrack t  )  [inline, static]

Definition at line 53 of file HcalHitMaker.h.

References HcalBarrel, HcalEndcap, HcalForward, FSimTrack::onHcal(), and FSimTrack::onVFcal().

00054       {
00055         //      std::cout << " getSubHcalDet " << std::endl;
00056         // According to  DataFormats/ HcalDetId/ interface/ HcalSubdetector.h
00057         //      std::cout << " onHcal " << t->onHcal() << " onVFcal " << t->onVFcal() << std::endl;
00058         if(t->onHcal()==1) return HcalBarrel;
00059         if(t->onHcal()==2) return HcalEndcap;
00060         if(t->onVFcal()==2) return HcalForward;
00061         return -1;
00062       } 

bool HcalHitMaker::setDepth ( double  depth  ) 

set the depth in X0 or Lambda0 units depending on showerType

Definition at line 108 of file HcalHitMaker.cc.

References GenMuonPlsPt100GeV_cfg::cout, currentDepth_, CaloHitMaker::EMSHOWER, lat::endl(), EcalHitMaker::getFSimTrack(), EcalHitMaker::getSegments(), CaloHitMaker::HADSHOWER, locToGlobal_, myGrid, origin, and particleDirection.

Referenced by EMShower::compute(), HFShower::compute(), HDShower::compute(), and HDRShower::setHit().

00109 {
00110   currentDepth_=depth;
00111   std::vector<CaloSegment>::const_iterator segiterator;
00112   if(EMSHOWER)
00113     segiterator = find_if(myGrid.getSegments().begin(),myGrid.getSegments().end(),CaloSegment::inX0Segment(currentDepth_));
00114   
00115   //Hadron shower 
00116   if(HADSHOWER)
00117     segiterator = find_if(myGrid.getSegments().begin(),myGrid.getSegments().end(),CaloSegment::inL0Segment(currentDepth_));
00118   if(segiterator==myGrid.getSegments().end()) 
00119     {
00120       // Special trick  - As advised by Salavat, no leakage should be simulated
00121       if(depth > myGrid.getSegments().back().sL0Exit())
00122         {
00123           segiterator= find_if(myGrid.getSegments().begin(),myGrid.getSegments().end(),CaloSegment::inL0Segment(myGrid.getSegments().back().sL0Exit()-1.));
00124           depth=segiterator->sL0Exit()-1.;
00125           currentDepth_=depth;
00126           if(segiterator==myGrid.getSegments().end())
00127             {
00128               std::cout << " Could not go at such depth " << EMSHOWER << "  " << currentDepth_ << std::endl;
00129               std::cout << " Track " << *(myGrid.getFSimTrack()) << std::endl;
00130               return false;
00131             }
00132         }
00133       else
00134         {
00135           std::cout << " Could not go at such depth " << EMSHOWER << "  " << currentDepth_ << " " << myGrid.getSegments().back().sL0Exit() << std::endl; 
00136           std::cout << " Track " << *(myGrid.getFSimTrack()) << std::endl; 
00137           return false; 
00138         }
00139     }
00140 
00141 
00142   XYZPoint origin;
00143   if(EMSHOWER)
00144     origin=segiterator->positionAtDepthinX0(currentDepth_);
00145   if(HADSHOWER)
00146     origin=segiterator->positionAtDepthinL0(currentDepth_);
00147 
00148   XYZVector zaxis(0,0,1);
00149   XYZVector planeVec1=(zaxis.Cross(particleDirection)).Unit();
00150   locToGlobal_=Transform3D(Point(0,0,0),
00151                            Point(0,0,1),
00152                            Point(1,0,0),
00153                            (Point)origin,
00154                            (Point)(origin+particleDirection),
00155                            (Point)(origin+planeVec1));
00156   return true;
00157 }

void HcalHitMaker::setSpotEnergy ( double  e  )  [inline, virtual]

Set the spot energy.

Implements CaloHitMaker.

Definition at line 28 of file HcalHitMaker.h.

References CaloHitMaker::spotEnergy.

Referenced by EMShower::compute(), HFShower::compute(), HDShower::compute(), and HDRShower::setHit().

00028 { spotEnergy=e;} 


Member Data Documentation

double HcalHitMaker::currentDepth_ [private]

Definition at line 47 of file HcalHitMaker.h.

Referenced by setDepth().

XYZPoint HcalHitMaker::ecalEntrance_ [private]

Definition at line 43 of file HcalHitMaker.h.

Referenced by HcalHitMaker().

Transform3D HcalHitMaker::locToGlobal_ [private]

Definition at line 48 of file HcalHitMaker.h.

Referenced by addHit(), and setDepth().

bool HcalHitMaker::mapCalculated_ [private]

Definition at line 50 of file HcalHitMaker.h.

Referenced by HcalHitMaker().

EcalHitMaker& HcalHitMaker::myGrid [private]

Definition at line 40 of file HcalHitMaker.h.

Referenced by HcalHitMaker(), and setDepth().

const FSimTrack* HcalHitMaker::myTrack [private]

Definition at line 42 of file HcalHitMaker.h.

Referenced by HcalHitMaker().

int HcalHitMaker::onHcal [private]

Definition at line 45 of file HcalHitMaker.h.

XYZVector HcalHitMaker::particleDirection [private]

Definition at line 44 of file HcalHitMaker.h.

Referenced by HcalHitMaker(), and setDepth().

double HcalHitMaker::radiusFactor_ [private]

Definition at line 49 of file HcalHitMaker.h.

Referenced by addHit(), and HcalHitMaker().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:23:42 2009 for CMSSW by  doxygen 1.5.4