#include <CaloGeometryHelper.h>
Public Types | |
typedef math::XYZVector | XYZPoint |
typedef math::XYZVector | XYZVector |
Public Member Functions | |
bool | borderCrossing (const DetId &, const DetId &) const |
void | buildCrystal (const DetId &id, Crystal &) const |
CaloGeometryHelper (const edm::ParameterSet &fastCalo) | |
CaloGeometryHelper () | |
DetId | getClosestCell (const XYZPoint &point, bool ecal, bool central) const |
const std::vector< DetId > & | getNeighbours (const DetId &det) const |
void | getWindow (const DetId &pivot, int s1, int s2, std::vector< DetId > &) const |
void | initialize (double bField) |
double | magneticField () const |
bool | move (DetId &cell, const CaloDirection &dir, bool fast=true) const |
bool | preshowerPresent () const |
double | preshowerZPosition (int layer) const |
~CaloGeometryHelper () | |
Private Member Functions | |
void | buildCrystalArray () |
void | buildNeighbourArray () |
bool | diagonalmove (DetId &cell, const CaloDirection &dir) const |
bool | simplemove (DetId &cell, const CaloDirection &dir) const |
Private Attributes | |
std::vector< BaseCrystal > | barrelCrystals_ |
std::vector< std::vector< DetId > > | barrelNeighbours_ |
double | bfield_ |
std::vector< BaseCrystal > | endcapCrystals_ |
std::vector< std::vector< DetId > > | endcapNeighbours_ |
bool | neighbourmapcalculated_ |
bool | preshowerPresent_ |
double | psLayer1Z_ |
double | psLayer2Z_ |
Definition at line 17 of file CaloGeometryHelper.h.
Definition at line 23 of file CaloGeometryHelper.h.
Definition at line 22 of file CaloGeometryHelper.h.
CaloGeometryHelper::CaloGeometryHelper | ( | ) |
Definition at line 25 of file CaloGeometryHelper.cc.
References neighbourmapcalculated_, psLayer1Z_, and psLayer2Z_.
:Calorimeter() { neighbourmapcalculated_= false; psLayer1Z_ = 303; psLayer2Z_ = 307; }
CaloGeometryHelper::CaloGeometryHelper | ( | const edm::ParameterSet & | fastCalo | ) |
Definition at line 32 of file CaloGeometryHelper.cc.
References psLayer1Z_, and psLayer2Z_.
:Calorimeter(fastCalo) { // std::cout << " In the constructor with ParameterSet " << std::endl; psLayer1Z_ = 303; psLayer2Z_ = 307; }
CaloGeometryHelper::~CaloGeometryHelper | ( | ) |
Definition at line 61 of file CaloGeometryHelper.cc.
{; }
Definition at line 427 of file CaloGeometryHelper.cc.
References EcalBarrel, EcalEndcap, EBDetId::im(), EEDetId::isc(), EBDetId::ism(), and DetId::subdetId().
Referenced by EcalHitMaker::buildSegments(), and EcalHitMaker::configureGeometry().
{ if(c1.subdetId()!=c2.subdetId()) return false; if(c1.subdetId()==EcalBarrel) { // there is a crack if the two cells don't belong to the same // module EBDetId cc1(c1); EBDetId cc2(c2); return (cc1.im()!=cc2.im()||cc1.ism()!=cc2.ism() ); } if(c1.subdetId()==EcalEndcap) { // there is a crack if the two cells don't belong to the same // module return (EEDetId(c1).isc()!=EEDetId(c2).isc()); } return false; }
Definition at line 172 of file CaloGeometryHelper.cc.
References barrelCrystals_, EcalBarrel, EcalEndcap, endcapCrystals_, ecalpyutils::hashedIndex(), and DetId::subdetId().
Referenced by EcalHitMaker::buildGeometry(), and EcalHitMaker::EcalHitMaker().
{ if(cell.subdetId()==EcalBarrel) { xtal=Crystal(cell,&barrelCrystals_[EBDetId(cell).hashedIndex()]); return; } if(cell.subdetId()==EcalEndcap) { xtal=Crystal(cell,&endcapCrystals_[EEDetId(cell).hashedIndex()]); return; } }
void CaloGeometryHelper::buildCrystalArray | ( | ) | [private] |
Definition at line 449 of file CaloGeometryHelper.cc.
References barrelCrystals_, DetId::Ecal, EcalBarrel, Calorimeter::EcalBarrelGeometry_, EcalEndcap, Calorimeter::EcalEndcapGeometry_, endcapCrystals_, relativeConstraints::geom, CaloCellGeometry::getCorners(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloSubdetectorGeometry::getValidDetIds(), EEDetId::hashedIndex(), EBDetId::hashedIndex(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, BaseCrystal::setCorners(), and findQualityFiles::size.
Referenced by initialize().
{ const unsigned nbarrel = EBDetId::kSizeForDenseIndexing; // Barrel first. The hashed index runs from 0 to 61199 barrelCrystals_.resize(nbarrel,BaseCrystal()); //std::cout << " Building the array of crystals (barrel) " ; const std::vector<DetId>& vec(EcalBarrelGeometry_->getValidDetIds(DetId::Ecal,EcalBarrel)); unsigned size=vec.size(); const CaloCellGeometry * geom=0; for(unsigned ic=0; ic<size; ++ic) { unsigned hashedindex=EBDetId(vec[ic]).hashedIndex(); geom = EcalBarrelGeometry_->getGeometry(vec[ic]); BaseCrystal xtal(vec[ic]); xtal.setCorners(geom->getCorners(),geom->getPosition()); barrelCrystals_[hashedindex]=xtal; } // std::cout << " done " << size << std::endl; // std::cout << " Building the array of crystals (endcap) " ; const std::vector<DetId>& vece(EcalEndcapGeometry_->getValidDetIds(DetId::Ecal,EcalEndcap)); size=vece.size(); // There are some holes in the hashedIndex for the EE. Hence the array is bigger than the number // of crystals const unsigned nendcap=EEDetId::kSizeForDenseIndexing; endcapCrystals_.resize(nendcap,BaseCrystal()); for(unsigned ic=0; ic<size; ++ic) { unsigned hashedindex=EEDetId(vece[ic]).hashedIndex(); geom = EcalEndcapGeometry_->getGeometry(vece[ic]); BaseCrystal xtal(vece[ic]); xtal.setCorners(geom->getCorners(),geom->getPosition()); endcapCrystals_[hashedindex]=xtal; } // std::cout << " done " << size << std::endl; }
void CaloGeometryHelper::buildNeighbourArray | ( | ) | [private] |
Definition at line 187 of file CaloGeometryHelper.cc.
References barrelNeighbours_, EAST, DetId::Ecal, EcalBarrel, Calorimeter::EcalBarrelGeometry_, Calorimeter::EcalBarrelTopology_, EcalEndcap, Calorimeter::EcalEndcapGeometry_, Calorimeter::EcalEndcapTopology_, endcapNeighbours_, CaloSubdetectorGeometry::getValidDetIds(), CaloSubdetectorTopology::getWindow(), EEDetId::hashedIndex(), EBDetId::hashedIndex(), recoMuon::in, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, LogDebug, move(), neighbourmapcalculated_, NORTH, NORTHEAST, NORTHWEST, findQualityFiles::size, SOUTH, SOUTHEAST, SOUTHWEST, ntuplemaker::status, and WEST.
Referenced by initialize().
{ static const CaloDirection orderedDir[8]={SOUTHWEST,SOUTH,SOUTHEAST,WEST,EAST,NORTHWEST,NORTH, NORTHEAST}; const unsigned nbarrel = EBDetId::kSizeForDenseIndexing; // Barrel first. The hashed index runs from 0 to 61199 barrelNeighbours_.resize(nbarrel); //std::cout << " Building the array of neighbours (barrel) " ; const std::vector<DetId>& vec(EcalBarrelGeometry_->getValidDetIds(DetId::Ecal,EcalBarrel)); unsigned size=vec.size(); for(unsigned ic=0; ic<size; ++ic) { // We get the 9 cells in a square. std::vector<DetId> neighbours(EcalBarrelTopology_->getWindow(vec[ic],3,3)); // std::cout << " Cell " << EBDetId(vec[ic]) << std::endl; unsigned nneighbours=neighbours.size(); unsigned hashedindex=EBDetId(vec[ic]).hashedIndex(); if(hashedindex>=nbarrel) { LogDebug("CaloGeometryTools") << " Array overflow " << std::endl; } // If there are 9 cells, it is easy, and this order is know: // 6 7 8 // 3 4 5 // 0 1 2 (0 = SOUTHWEST) if(nneighbours==9) { barrelNeighbours_[hashedindex].reserve(8); for(unsigned in=0;in<nneighbours;++in) { // remove the centre if(neighbours[in]!=vec[ic]) { barrelNeighbours_[hashedindex].push_back(neighbours[in]); // std::cout << " Neighbour " << in << " " << EBDetId(neighbours[in]) << std::endl; } } } else { DetId central(vec[ic]); barrelNeighbours_[hashedindex].resize(8,DetId(0)); for(unsigned idir=0;idir<8;++idir) { DetId testid=central; bool status=move(testid,orderedDir[idir],false); if(status) barrelNeighbours_[hashedindex][idir]=testid; } } } // Moved to the endcap // std::cout << " done " << size << std::endl; // std::cout << " Building the array of neighbours (endcap) " ; const std::vector<DetId> & vece(EcalEndcapGeometry_->getValidDetIds(DetId::Ecal,EcalEndcap)); size=vece.size(); // There are some holes in the hashedIndex for the EE. Hence the array is bigger than the number // of crystals const unsigned nendcap=EEDetId::kSizeForDenseIndexing; endcapNeighbours_.resize(nendcap); for(unsigned ic=0; ic<size; ++ic) { // We get the 9 cells in a square. std::vector<DetId> neighbours(EcalEndcapTopology_->getWindow(vece[ic],3,3)); unsigned nneighbours=neighbours.size(); // remove the centre unsigned hashedindex=EEDetId(vece[ic]).hashedIndex(); if(hashedindex>=nendcap) { LogDebug("CaloGeometryTools") << " Array overflow " << std::endl; } if(nneighbours==9) { endcapNeighbours_[hashedindex].reserve(8); for(unsigned in=0;in<nneighbours;++in) { // remove the centre if(neighbours[in]!=vece[ic]) { endcapNeighbours_[hashedindex].push_back(neighbours[in]); } } } else { DetId central(vece[ic]); endcapNeighbours_[hashedindex].resize(8,DetId(0)); for(unsigned idir=0;idir<8;++idir) { DetId testid=central; bool status=move(testid,orderedDir[idir],false); if(status) endcapNeighbours_[hashedindex][idir]=testid; } } } // std::cout << " done " << size <<std::endl; neighbourmapcalculated_ = true; }
bool CaloGeometryHelper::diagonalmove | ( | DetId & | cell, |
const CaloDirection & | dir | ||
) | const [private] |
Definition at line 363 of file CaloGeometryHelper.cc.
References EAST, NORTH, NORTHEAST, NORTHWEST, query::result, simplemove(), SOUTH, SOUTHEAST, SOUTHWEST, and WEST.
Referenced by move().
{ bool result; // One has to try both paths if(dir==NORTHEAST) { result = simplemove(cell,NORTH); if(result) return simplemove(cell,EAST); else { result = simplemove(cell,EAST); if(result) return simplemove(cell,NORTH); else return false; } } else if(dir==NORTHWEST) { result = simplemove(cell,NORTH); if(result) return simplemove(cell,WEST); else { result = simplemove(cell,WEST); if(result) return simplemove(cell,NORTH); else return false; } } else if(dir == SOUTHEAST) { result = simplemove(cell,SOUTH); if(result) return simplemove(cell,EAST); else { result = simplemove(cell,EAST); if(result) return simplemove(cell,SOUTH); else return false; } } else if(dir == SOUTHWEST) { result = simplemove(cell,SOUTH); if(result) return simplemove(cell,WEST); else { result = simplemove(cell,SOUTH); if(result) return simplemove(cell,WEST); else return false; } } cell = DetId(0); return false; }
in sync with BaseParticlePropagator
Definition at line 65 of file CaloGeometryHelper.cc.
References funct::cos(), HcalDetId::depth(), Calorimeter::EcalBarrelGeometry_, Calorimeter::EcalEndcapGeometry_, PV3DBase< T, PVType, FrameType >::eta(), Histos::fill(), first, CaloSubdetectorGeometry::getClosestCell(), EcalBarrelGeometry::getClosestCell(), EcalEndcapGeometry::getClosestCell(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), HcalEndcap, HcalForward, Calorimeter::HcalGeometry_, HcalDetId::ieta(), HcalDetId::ietaAbs(), Histos::instance(), HcalDetId::iphi(), DetId::null(), perp(), PV3DBase< T, PVType, FrameType >::phi(), query::result, edm::second(), mathSSE::sqrt(), and DetId::subdetId().
Referenced by HcalHitMaker::addHit(), EcalHitMaker::EcalHitMaker(), CalorimetryManager::EMShowerSimulation(), CalorimetryManager::HDShowerSimulation(), CalorimetryManager::MuonMipSimulation(), CalorimetryManager::reconstructECAL(), and CalorimetryManager::reconstructHCAL().
{ DetId result; if(ecal) { if(central) { // std::cout << "EcalBarrelGeometry_" << " " << EcalBarrelGeometry_ << std::endl; result = EcalBarrelGeometry_->getClosestCell(GlobalPoint(point.X(),point.Y(),point.Z())); #ifdef DEBUGGCC if(result.null()) return result; GlobalPoint ip=GlobalPoint(point.X(),point.Y(),point.Z()); GlobalPoint cc=EcalBarrelGeometry_->getGeometry(result)->getPosition(); float deltaeta2 = ip.eta()-cc.eta(); deltaeta2 *= deltaeta2; float deltaphi2 = acos(cos(ip.phi()-cc.phi())); deltaphi2 *= deltaphi2; Histos::instance()->fill("h100",point.eta(),sqrt(deltaeta2+deltaphi2)); #endif } else { result = EcalEndcapGeometry_->getClosestCell(GlobalPoint(point.X(),point.Y(),point.Z())); #ifdef DEBUGGCC if(result.null()) { return result; } GlobalPoint ip=GlobalPoint(point.X(),point.Y(),point.Z()); GlobalPoint cc=EcalEndcapGeometry_->getGeometry(result)->getPosition(); Histos::instance()->fill("h110",point.eta(),(ip-cc).perp()); #endif } } else { result=HcalGeometry_->getClosestCell(GlobalPoint(point.X(),point.Y(),point.Z())); HcalDetId myDetId(result); // special patch for HF if ( myDetId.subdetId() == HcalForward ) { int mylayer; if ( fabs(point.Z()) > 1132. ) { mylayer = 2; } else { mylayer = 1; } HcalDetId myDetId2((HcalSubdetector)myDetId.subdetId(),myDetId.ieta(),myDetId.iphi(),mylayer); result = myDetId2; return result; } if(result.subdetId()!=HcalEndcap) return result; // Special patch to correct the HCAL geometry if(myDetId.depth()==3) return result; int ieta=myDetId.ietaAbs(); float azmin=400.458; if(ieta<=17) return result; else if(ieta>=18 && ieta<=26) azmin += 35.0; // don't consider ieta=18 nose separately else if(ieta>=27) azmin += 21.0; HcalDetId first(HcalEndcap,myDetId.ieta(),myDetId.iphi(),1); bool layer2=(fabs(point.Z())>azmin); if(!layer2) { return first; } else { HcalDetId second(HcalEndcap,myDetId.ieta(),myDetId.iphi(),2); if(second!=HcalDetId()) result=second; } #ifdef DEBUGGCC if(result.null()) { return result; } GlobalPoint ip=GlobalPoint(point.x(),point.y(),point.z()); GlobalPoint cc=HcalGeometry_->getGeometry(result)->getPosition(); float deltaeta2 = ip.eta()-cc.eta(); deltaeta2 *= deltaeta2; float deltaphi2 = acos(cos(ip.phi()-cc.phi())); deltaphi2 *= deltaphi2; Histos::instance()->fill("h120",point.eta(),sqrt(deltaeta2+deltaphi2)); #endif } return result; }
Definition at line 302 of file CaloGeometryHelper.cc.
References barrelNeighbours_, EcalBarrel, endcapNeighbours_, EEDetId::hashedIndex(), EBDetId::hashedIndex(), and DetId::subdetId().
Referenced by CrystalWindowMap::CrystalWindowMap().
{ return (detid.subdetId()==EcalBarrel)?barrelNeighbours_[EBDetId(detid).hashedIndex()]: endcapNeighbours_[EEDetId(detid).hashedIndex()]; }
void CaloGeometryHelper::getWindow | ( | const DetId & | pivot, |
int | s1, | ||
int | s2, | ||
std::vector< DetId > & | vec | ||
) | const |
Definition at line 162 of file CaloGeometryHelper.cc.
References Calorimeter::getEcalGeometry(), Calorimeter::getEcalTopology(), python::multivaluedict::sort(), and DetId::subdetId().
Referenced by EcalHitMaker::EcalHitMaker().
{ // currently the getWindow method is the same for EcalBarrelTopology and EndcapTopology // (implemented in CaloSubDetectorTopology) // optimized versions are foreseen vec=getEcalTopology(pivot.subdetId())->getWindow(pivot,s1,s2); DistanceToCell distance(getEcalGeometry(pivot.subdetId()),pivot); sort(vec.begin(),vec.end(),distance); }
void CaloGeometryHelper::initialize | ( | double | bField | ) |
Definition at line 39 of file CaloGeometryHelper.cc.
References ecalTB2006H4_GenSimDigiReco_cfg::bField, bfield_, buildCrystalArray(), buildNeighbourArray(), Calorimeter::getEcalPreshowerGeometry(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), LogDebug, preshowerPresent_, psLayer1Z_, psLayer2Z_, and PV3DBase< T, PVType, FrameType >::z().
Referenced by FamosManager::setupGeometryAndField().
{ buildCrystalArray(); buildNeighbourArray(); bfield_ = bField; preshowerPresent_=(getEcalPreshowerGeometry()!=0); if(preshowerPresent_) { ESDetId cps1(getEcalPreshowerGeometry()->getClosestCellInPlane(GlobalPoint(80.,80.,303.),1)); psLayer1Z_ = getEcalPreshowerGeometry()->getGeometry(cps1)->getPosition().z(); ESDetId cps2(getEcalPreshowerGeometry()->getClosestCellInPlane(GlobalPoint(80.,80.,307.),2)); psLayer2Z_ = getEcalPreshowerGeometry()->getGeometry(cps2)->getPosition().z(); LogDebug("CaloGeometryTools") << " Preshower layer positions " << psLayer1Z_ << " " << psLayer2Z_ << std::endl; } else LogDebug("CaloGeometryTools") << " No preshower present" << std::endl; // std::cout << " Preshower layer positions " << psLayer1Z_ << " " << psLayer2Z_ << std::endl; }
double CaloGeometryHelper::magneticField | ( | ) | const [inline] |
Definition at line 50 of file CaloGeometryHelper.h.
References bfield_.
Referenced by EcalHitMaker::configureGeometry().
{return bfield_;}
bool CaloGeometryHelper::move | ( | DetId & | cell, |
const CaloDirection & | dir, | ||
bool | fast = true |
||
) | const |
Definition at line 308 of file CaloGeometryHelper.cc.
References barrelNeighbours_, diagonalmove(), dir, EAST, EcalBarrel, endcapNeighbours_, EEDetId::hashedIndex(), EBDetId::hashedIndex(), neighbourmapcalculated_, NONE, NORTH, NORTHEAST, NORTHWEST, DetId::null(), query::result, simplemove(), SOUTH, SOUTHEAST, SOUTHWEST, ntuplemaker::status, DetId::subdetId(), and WEST.
Referenced by buildNeighbourArray(), and EcalHitMaker::configureGeometry().
{ DetId originalcell = cell; if(dir==NONE || cell==DetId(0)) return false; // Conversion CaloDirection and index in the table // CaloDirection :NONE,SOUTH,SOUTHEAST,SOUTHWEST,EAST,WEST, NORTHEAST,NORTHWEST,NORTH // Table : SOUTHWEST,SOUTH,SOUTHEAST,WEST,EAST,NORTHWEST,NORTH, NORTHEAST static const int calodirections[9]={-1,1,2,0,4,3,7,5,6}; if(fast&&neighbourmapcalculated_) { DetId result = (originalcell.subdetId()==EcalBarrel) ? barrelNeighbours_[EBDetId(originalcell).hashedIndex()][calodirections[dir]]: endcapNeighbours_[EEDetId(originalcell).hashedIndex()][calodirections[dir]]; bool status = !result.null(); cell = result; return status; } if(dir==NORTH || dir ==SOUTH || dir==EAST || dir==WEST) { return simplemove(cell,dir); } else { if(dir == NORTHEAST || dir==NORTHWEST || dir==SOUTHEAST || dir==SOUTHWEST) return diagonalmove(cell,dir); } cell = DetId(0); return false; }
bool CaloGeometryHelper::preshowerPresent | ( | ) | const [inline] |
Definition at line 57 of file CaloGeometryHelper.h.
References preshowerPresent_.
Referenced by CalorimetryManager::reconstruct().
{return preshowerPresent_;};
double CaloGeometryHelper::preshowerZPosition | ( | int | layer | ) | const [inline] |
Definition at line 37 of file CaloGeometryHelper.h.
References psLayer1Z_, and psLayer2Z_.
Referenced by PreshowerHitMaker::addHit(), and PreshowerHitMaker::PreshowerHitMaker().
{ return (layer==1) ? psLayer1Z_: psLayer2Z_ ; }
bool CaloGeometryHelper::simplemove | ( | DetId & | cell, |
const CaloDirection & | dir | ||
) | const [private] |
Definition at line 343 of file CaloGeometryHelper.cc.
References EcalBarrel, Calorimeter::EcalBarrelTopology_, EcalEndcap, Calorimeter::EcalEndcapTopology_, CaloSubdetectorTopology::getNeighbours(), and DetId::subdetId().
Referenced by diagonalmove(), and move().
{ std::vector<DetId> neighbours; if(cell.subdetId()==EcalBarrel) neighbours = EcalBarrelTopology_->getNeighbours(cell,dir); else if(cell.subdetId()==EcalEndcap) neighbours= EcalEndcapTopology_->getNeighbours(cell,dir); if(neighbours.size()>0 && !neighbours[0].null()) { cell = neighbours[0]; return true; } else { cell = DetId(0); return false; } }
std::vector<BaseCrystal> CaloGeometryHelper::barrelCrystals_ [private] |
Definition at line 73 of file CaloGeometryHelper.h.
Referenced by buildCrystal(), and buildCrystalArray().
std::vector<std::vector<DetId> > CaloGeometryHelper::barrelNeighbours_ [private] |
Definition at line 70 of file CaloGeometryHelper.h.
Referenced by buildNeighbourArray(), getNeighbours(), and move().
double CaloGeometryHelper::bfield_ [private] |
Definition at line 79 of file CaloGeometryHelper.h.
Referenced by initialize(), and magneticField().
std::vector<BaseCrystal> CaloGeometryHelper::endcapCrystals_ [private] |
Definition at line 74 of file CaloGeometryHelper.h.
Referenced by buildCrystal(), and buildCrystalArray().
std::vector<std::vector<DetId> > CaloGeometryHelper::endcapNeighbours_ [private] |
Definition at line 71 of file CaloGeometryHelper.h.
Referenced by buildNeighbourArray(), getNeighbours(), and move().
bool CaloGeometryHelper::neighbourmapcalculated_ [private] |
Definition at line 76 of file CaloGeometryHelper.h.
Referenced by buildNeighbourArray(), CaloGeometryHelper(), and move().
bool CaloGeometryHelper::preshowerPresent_ [private] |
Definition at line 80 of file CaloGeometryHelper.h.
Referenced by initialize(), and preshowerPresent().
double CaloGeometryHelper::psLayer1Z_ [private] |
Definition at line 67 of file CaloGeometryHelper.h.
Referenced by CaloGeometryHelper(), initialize(), and preshowerZPosition().
double CaloGeometryHelper::psLayer2Z_ [private] |
Definition at line 67 of file CaloGeometryHelper.h.
Referenced by CaloGeometryHelper(), initialize(), and preshowerZPosition().