CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFRecHitProducerECAL Class Reference

Producer for particle flow rechits (PFRecHit) in ECAL. More...

#include <PFRecHitProducerECAL.h>

Inheritance diagram for PFRecHitProducerECAL:
PFRecHitProducer edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFRecHitProducerECAL (const edm::ParameterSet &)
 
 ~PFRecHitProducerECAL ()
 
- Public Member Functions inherited from PFRecHitProducer
virtual void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
 PFRecHitProducer (const edm::ParameterSet &)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PFRecHitProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

reco::PFRecHitcreateEcalRecHit (const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom)
 
void createRecHits (std::vector< reco::PFRecHit > &rechits, std::vector< reco::PFRecHit > &rechitsCleaned, edm::Event &, const edm::EventSetup &)
 
void ecalNeighbArray (const EcalBarrelGeometry &barrelGeom, const CaloSubdetectorTopology &barrelTopo, const EcalEndcapGeometry &endcapGeom, const CaloSubdetectorTopology &endcapTopo)
 
bool findEcalRecHitGeometry (const DetId &detid, const CaloSubdetectorGeometry *geom, math::XYZVector &position, math::XYZVector &axis)
 find the position and the axis of the cell for a given rechit More...
 
void findRecHitNeighboursECAL (reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits)
 find rechit neighbours, using the hashed index More...
 
DetId move (DetId cell, const CaloDirection &dir) const
 
bool stdmove (DetId &cell, const CaloDirection &dir, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorTopology &endcapTopo, const EcalBarrelGeometry &barrelGeom, const EcalEndcapGeometry &endcapGeom) const
 
bool stdsimplemove (DetId &cell, const CaloDirection &dir, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorTopology &endcapTopo, const EcalBarrelGeometry &barrelGeom, const EcalEndcapGeometry &endcapGeom) const
 

Private Attributes

bool crossBarrelEndcapBorder_
 if true, navigation will cross the barrel-endcap border More...
 
edm::InputTag inputTagEcalRecHitsEB_
 
edm::InputTag inputTagEcalRecHitsEE_
 
bool neighbourmapcalculated_
 set to true in ecalNeighbArray More...
 
std::vector< std::vector< DetId > > neighboursEB_
 for each ecal barrel rechit, keep track of the neighbours More...
 
std::vector< std::vector< DetId > > neighboursEE_
 for each ecal endcap rechit, keep track of the neighbours More...
 
double threshCleaningEB_
 
double threshCleaningEE_
 
bool timingCleaning_
 
bool topologicalCleaning_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Types inherited from PFRecHitProducer
typedef std::map< unsigned,
unsigned >::const_iterator 
IDH
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from PFRecHitProducer
const HcalPFCorrsmyPFCorr
 
const EcalChannelStatustheEcalChStatus
 
const HcalChannelQualitytheHcalChStatus
 
const CaloTowerConstituentsMaptheTowerConstituentsMap
 
double thresh_Barrel_
 rechits with E < threshold will not give rise to a PFRecHit More...
 
double thresh_Endcap_
 
bool verbose_
 verbose ? More...
 

Detailed Description

Producer for particle flow rechits (PFRecHit) in ECAL.

Author
Colin Bernet
Date
february 2008

Definition at line 41 of file PFRecHitProducerECAL.h.

Constructor & Destructor Documentation

PFRecHitProducerECAL::PFRecHitProducerECAL ( const edm::ParameterSet iConfig)
explicit

Definition at line 36 of file PFRecHitProducerECAL.cc.

References crossBarrelEndcapBorder_, edm::ParameterSet::getParameter(), inputTagEcalRecHitsEB_, inputTagEcalRecHitsEE_, neighbourmapcalculated_, threshCleaningEB_, threshCleaningEE_, timingCleaning_, and topologicalCleaning_.

37  : PFRecHitProducer(iConfig) {
38 
39  // access to the collections of rechits
40 
41 
43  iConfig.getParameter<InputTag>("ecalRecHitsEB");
44 
46  iConfig.getParameter<InputTag>("ecalRecHitsEE");
47 
48 
50  iConfig.getParameter<bool>("crossBarrelEndcapBorder");
51 
53  iConfig.getParameter<bool>("timing_Cleaning");
54 
56  iConfig.getParameter<bool>("topological_Cleaning");
57 
59  iConfig.getParameter<double>("thresh_Cleaning_EB");
60 
62  iConfig.getParameter<double>("thresh_Cleaning_EE");
63 
65 }
T getParameter(std::string const &) const
edm::InputTag inputTagEcalRecHitsEE_
PFRecHitProducer(const edm::ParameterSet &)
edm::InputTag inputTagEcalRecHitsEB_
bool crossBarrelEndcapBorder_
if true, navigation will cross the barrel-endcap border
bool neighbourmapcalculated_
set to true in ecalNeighbArray
PFRecHitProducerECAL::~PFRecHitProducerECAL ( )

Definition at line 69 of file PFRecHitProducerECAL.cc.

69 {}

Member Function Documentation

reco::PFRecHit * PFRecHitProducerECAL::createEcalRecHit ( const DetId detid,
double  energy,
PFLayer::Layer  layer,
const CaloSubdetectorGeometry geom 
)
private

Definition at line 284 of file PFRecHitProducerECAL.cc.

References relval_parameters_module::energy, CaloCellGeometry::getCorners(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), position, DetId::rawId(), reco::PFRecHit::setNECorner(), reco::PFRecHit::setNWCorner(), reco::PFRecHit::setSECorner(), reco::PFRecHit::setSWCorner(), x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by createRecHits().

287  {
288 
290  math::XYZVector axis;
291 
292  const CaloCellGeometry *thisCell
293  = geom->getGeometry(detid);
294 
295  // find rechit geometry
296  if(!thisCell) {
297  LogError("PFRecHitProducerECAL")
298  <<"warning detid "<<detid.rawId()
299  <<" not found in geometry"<<endl;
300  return 0;
301  }
302 
303  position.SetCoordinates ( thisCell->getPosition().x(),
304  thisCell->getPosition().y(),
305  thisCell->getPosition().z() );
306 
307 
308 
309  // the axis vector is the difference
310  const TruncatedPyramid* pyr
311  = dynamic_cast< const TruncatedPyramid* > (thisCell);
312  if( pyr ) {
313  axis.SetCoordinates( pyr->getPosition(1).x(),
314  pyr->getPosition(1).y(),
315  pyr->getPosition(1).z() );
316 
317  math::XYZVector axis0( pyr->getPosition(0).x(),
318  pyr->getPosition(0).y(),
319  pyr->getPosition(0).z() );
320 
321  axis -= axis0;
322  }
323  else return 0;
324 
325 // if( !geomfound ) {
326 // LogError("PFRecHitProducerECAL")<<"cannor find geometry for detid "
327 // <<detid.rawId()<<" in layer "<<layer<<endl;
328 // return 0; // geometry not found, skip rechit
329 // }
330 
331 
332  reco::PFRecHit *rh
333  = new reco::PFRecHit( detid.rawId(), layer,
334  energy,
335  position.x(), position.y(), position.z(),
336  axis.x(), axis.y(), axis.z() );
337 
338 
339  const CaloCellGeometry::CornersVec& corners = thisCell->getCorners();
340  assert( corners.size() == 8 );
341 
342  rh->setNECorner( corners[0].x(), corners[0].y(), corners[0].z() );
343  rh->setSECorner( corners[1].x(), corners[1].y(), corners[1].z() );
344  rh->setSWCorner( corners[2].x(), corners[2].y(), corners[2].z() );
345  rh->setNWCorner( corners[3].x(), corners[3].y(), corners[3].z() );
346 
347  return rh;
348 }
void setSECorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:226
void setNECorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:231
T y() const
Definition: PV3DBase.h:63
float float float z
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void setSWCorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:221
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
T z() const
Definition: PV3DBase.h:64
void setNWCorner(double posx, double posy, double posz)
search for pointers to neighbours, using neighbours&#39; DetId.
Definition: PFRecHit.cc:216
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
Definition: DDAxes.h:10
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell&#39;s volume.
void PFRecHitProducerECAL::createRecHits ( std::vector< reco::PFRecHit > &  rechits,
std::vector< reco::PFRecHit > &  rechitsCleaned,
edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

gets ecal barrel and endcap rechits, translate them to PFRecHits, which are stored in the rechits vector

Implements PFRecHitProducer.

Definition at line 77 of file PFRecHitProducerECAL.cc.

References EcalRecHit::checkFlag(), createEcalRecHit(), CaloRecHit::detid(), cond::rpcobgas::detid, DetId::Ecal, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, EcalBarrel, EcalEndcap, ecalNeighbArray(), CaloRecHit::energy(), relval_parameters_module::energy, edm::hlt::Exception, findRecHitNeighboursECAL(), newFWLiteAna::found, edm::EventSetup::get(), edm::Event::getByLabel(), i, inputTagEcalRecHitsEB_, inputTagEcalRecHitsEE_, edm::HandleBase::isValid(), EcalRecHit::kDiWeird, EcalRecHit::kOutOfTime, EcalRecHit::kTowerRecovered, EcalRecHit::kWeird, neighbourmapcalculated_, DetId::rawId(), reco::PFRecHit::setRescale(), DetId::subdetId(), PFRecHitProducer::thresh_Barrel_, PFRecHitProducer::thresh_Endcap_, threshCleaningEB_, threshCleaningEE_, CaloRecHit::time(), cond::rpcobgas::time, timingCleaning_, and topologicalCleaning_.

80  {
81 
82 
83 
84  // this map is necessary to find the rechit neighbours efficiently
85  //C but I should think about using Florian's hashed index to do this.
86  //C in which case the map might not be necessary anymore
87  //
88  // the key of this map is detId.
89  // the value is the index in the rechits vector
90  map<unsigned, unsigned > idSortedRecHits;
91 // typedef map<unsigned, unsigned >::iterator IDH;
92 
94  iSetup.get<CaloGeometryRecord>().get(geoHandle);
95 
96  // get the ecalBarrel geometry
97  const CaloSubdetectorGeometry *ebtmp =
98  geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
99 
100  const EcalBarrelGeometry* ecalBarrelGeometry =
101  dynamic_cast< const EcalBarrelGeometry* > (ebtmp);
102  assert( ecalBarrelGeometry );
103 
104  // get the ecalBarrel topology
105  EcalBarrelTopology ecalBarrelTopology(geoHandle);
106 
107  // get the endcap geometry
108  const CaloSubdetectorGeometry *eetmp =
109  geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
110 
111  const EcalEndcapGeometry* ecalEndcapGeometry =
112  dynamic_cast< const EcalEndcapGeometry* > (eetmp);
113  assert( ecalEndcapGeometry );
114 
115 
116  // get the endcap topology
117  EcalEndcapTopology ecalEndcapTopology(geoHandle);
118 
119 
121  ecalNeighbArray( *ecalBarrelGeometry,
122  ecalBarrelTopology,
123  *ecalEndcapGeometry,
124  ecalEndcapTopology );
125 
126 
127  // get the ecalBarrel rechits
128 
130 
131 
132  bool found = iEvent.getByLabel(inputTagEcalRecHitsEB_,
133  rhcHandle);
134 
135  if(!found) {
136 
137  ostringstream err;
138  err<<"could not find rechits "<<inputTagEcalRecHitsEB_;
139  LogError("PFRecHitProducerECAL")<<err.str()<<endl;
140 
141  throw cms::Exception( "MissingProduct", err.str());
142  }
143  else {
144  assert( rhcHandle.isValid() );
145 
146  // process ecal ecalBarrel rechits
147  for(unsigned i=0; i<rhcHandle->size(); i++) {
148 
149  const EcalRecHit& erh = (*rhcHandle)[i];
150  const DetId& detid = erh.detid();
151  double energy = erh.energy();
152  // uint32_t flag = erh.recoFlag();
153  double time = erh.time();
154 
156  if (esd != 1) continue;
157 
158  if(energy < thresh_Barrel_ ) continue;
159 
160  // Check and skip the TT recovered rechits
161  //if ( flag == EcalRecHit::kTowerRecovered ) {
163  // std::cout << "Rechit was recovered with energy " << energy << std::endl;
164  continue;
165  }
166 
167  // Just clean ECAL Barrel rechits out of time by more than 5 sigma.
168  // if ( timingCleaning_ && energy > threshCleaning_ && flag == EcalRecHit::kOutOfTime ) {
169  if ( ( timingCleaning_ && energy > threshCleaningEB_ &&
172  ( erh.checkFlag(EcalRecHit::kWeird) ||
173  erh.checkFlag(EcalRecHit::kDiWeird) ) ) ) {
174  reco::PFRecHit *pfrhCleaned = createEcalRecHit(detid, energy,
176  ecalBarrelGeometry);
177  if( !pfrhCleaned ) continue; // problem with this rechit. skip it
178  pfrhCleaned->setRescale(time);
179  rechitsCleaned.push_back( *pfrhCleaned );
180  delete pfrhCleaned;
181  continue;
182  }
183 
184 
185  reco::PFRecHit *pfrh = createEcalRecHit(detid, energy,
187  ecalBarrelGeometry);
188 
189  if( !pfrh ) continue; // problem with this rechit. skip it
190  pfrh->setRescale(time);
191 
192  rechits.push_back( *pfrh );
193  delete pfrh;
194  idSortedRecHits.insert( make_pair(detid.rawId(), rechits.size()-1 ) );
195  }
196  }
197 
198 
199 
200  //C proceed as for the barrel
201  // process ecal endcap rechits
202 
203  found = iEvent.getByLabel(inputTagEcalRecHitsEE_,
204  rhcHandle);
205 
206  if(!found) {
207  ostringstream err;
208  err<<"could not find rechits "<<inputTagEcalRecHitsEE_;
209  LogError("PFRecHitProducerECAL")<<err.str()<<endl;
210 
211  throw cms::Exception( "MissingProduct", err.str());
212  }
213  else {
214  assert( rhcHandle.isValid() );
215 
216  for(unsigned i=0; i<rhcHandle->size(); i++) {
217 
218  const EcalRecHit& erh = (*rhcHandle)[i];
219  const DetId& detid = erh.detid();
220  double energy = erh.energy();
221  //uint32_t flag = erh.recoFlag();
222  double time = erh.time();
224  if (esd != 2) continue;
225  if(energy < thresh_Endcap_ ) continue;
226 
227  // Check and skip the TT recovered rechits
229  // if ( flag == EcalRecHit::kTowerRecovered ) {
230  // std::cout << "Rechit was recovered with energy " << energy << std::endl;
231  continue;
232  }
233 
234 
235  // EE cleaning
236 
237  if ( ( timingCleaning_ && energy > threshCleaningEE_ &&
240  ( erh.checkFlag(EcalRecHit::kWeird) ) ) ) {
241  reco::PFRecHit *pfrhCleaned = createEcalRecHit(detid, energy,
243  ecalEndcapGeometry);
244  if( !pfrhCleaned ) continue; // problem with this rechit. skip it
245  pfrhCleaned->setRescale(time);
246  rechitsCleaned.push_back( *pfrhCleaned );
247  delete pfrhCleaned;
248  continue;
249  }
250 
251 
252 
253 
254  reco::PFRecHit *pfrh = createEcalRecHit(detid, energy,
256  ecalEndcapGeometry);
257  if( !pfrh ) continue; // problem with this rechit. skip it
258  pfrh->setRescale(time);
259 
260  rechits.push_back( *pfrh );
261  delete pfrh;
262  idSortedRecHits.insert( make_pair(detid.rawId(), rechits.size()-1 ) );
263  }
264  }
265 
266 
267  // do navigation
268  for(unsigned i=0; i<rechits.size(); i++ ) {
269 
270 // findRecHitNeighbours( rechits[i], idSortedRecHits,
271 // ecalBarrelTopology,
272 // *ecalBarrelGeometry,
273 // ecalEndcapTopology,
274 // *ecalEndcapGeometry);
275  findRecHitNeighboursECAL( rechits[i], idSortedRecHits );
276 
277  }
278 }
int i
Definition: DBlmapReader.cc:9
void ecalNeighbArray(const EcalBarrelGeometry &barrelGeom, const CaloSubdetectorTopology &barrelTopo, const EcalEndcapGeometry &endcapGeom, const CaloSubdetectorTopology &endcapTopo)
edm::InputTag inputTagEcalRecHitsEE_
const DetId & detid() const
Definition: CaloRecHit.h:20
float time() const
Definition: CaloRecHit.h:19
edm::InputTag inputTagEcalRecHitsEB_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:106
float energy() const
Definition: CaloRecHit.h:17
void setRescale(double factor)
Definition: PFRecHit.h:80
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
Definition: DetId.h:18
reco::PFRecHit * createEcalRecHit(const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom)
const T & get() const
Definition: EventSetup.h:55
void findRecHitNeighboursECAL(reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits)
find rechit neighbours, using the hashed index
double thresh_Barrel_
rechits with E &lt; threshold will not give rise to a PFRecHit
bool neighbourmapcalculated_
set to true in ecalNeighbArray
EcalSubdetector
void PFRecHitProducerECAL::ecalNeighbArray ( const EcalBarrelGeometry &  barrelGeom,
const CaloSubdetectorTopology barrelTopo,
const EcalEndcapGeometry &  endcapGeom,
const CaloSubdetectorTopology endcapTopo 
)
private

fill the vectors neighboursEB_ and neighboursEE_ which keep track of the neighbours of each rechit. to be called at the beginning of the run

Definition at line 454 of file PFRecHitProducerECAL.cc.

References EAST, DetId::Ecal, EcalBarrel, EcalEndcap, CaloSubdetectorTopology::getWindow(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), recoMuon::in, LogDebug, neighbourmapcalculated_, neighboursEB_, neighboursEE_, NORTH, NORTHEAST, NORTHWEST, findQualityFiles::size, SOUTH, SOUTHEAST, SOUTHWEST, ntuplemaker::status, stdmove(), and WEST.

Referenced by createRecHits().

458  {
459 
460 
461  static const CaloDirection orderedDir[8]={SOUTHWEST,
462  SOUTH,
463  SOUTHEAST,
464  WEST,
465  EAST,
466  NORTHWEST,
467  NORTH,
468  NORTHEAST};
469 
470  const unsigned nbarrel = 62000;
471  // Barrel first. The hashed index runs from 0 to 61199
472  neighboursEB_.resize(nbarrel);
473 
474  //std::cout << " Building the array of neighbours (barrel) " ;
475 
476  const std::vector<DetId>& vec(barrelGeom.getValidDetIds(DetId::Ecal,
477  EcalBarrel));
478  unsigned size=vec.size();
479  for(unsigned ic=0; ic<size; ++ic)
480  {
481  // We get the 9 cells in a square.
482  std::vector<DetId> neighbours(barrelTopo.getWindow(vec[ic],3,3));
483  // std::cout << " Cell " << EBDetId(vec[ic]) << std::endl;
484  unsigned nneighbours=neighbours.size();
485 
486  unsigned hashedindex=EBDetId(vec[ic]).hashedIndex();
487  if(hashedindex>=nbarrel)
488  {
489  LogDebug("CaloGeometryTools") << " Array overflow " << std::endl;
490  }
491 
492 
493  // If there are 9 cells, it is easy, and this order is know:
494 // 6 7 8
495 // 3 4 5
496 // 0 1 2 (0 = SOUTHWEST)
497 
498  if(nneighbours==9)
499  {
500  neighboursEB_[hashedindex].reserve(8);
501  for(unsigned in=0;in<nneighbours;++in)
502  {
503  // remove the centre
504  if(neighbours[in]!=vec[ic])
505  {
506  neighboursEB_[hashedindex].push_back(neighbours[in]);
507  // std::cout << " Neighbour " << in << " " << EBDetId(neighbours[in]) << std::endl;
508  }
509  }
510  }
511  else
512  {
513  DetId central(vec[ic]);
514  neighboursEB_[hashedindex].resize(8,DetId(0));
515  for(unsigned idir=0;idir<8;++idir)
516  {
517  DetId testid=central;
518  bool status=stdmove(testid,orderedDir[idir],
519  barrelTopo, endcapTopo,
520  barrelGeom, endcapGeom);
521  if(status) neighboursEB_[hashedindex][idir]=testid;
522  }
523 
524  }
525  }
526 
527  // Moved to the endcap
528 
529  // std::cout << " done " << size << std::endl;
530  // std::cout << " Building the array of neighbours (endcap) " ;
531 
532 // vec.clear();
533  const std::vector<DetId>& vecee=endcapGeom.getValidDetIds(DetId::Ecal,EcalEndcap);
534  size=vecee.size();
535  // There are some holes in the hashedIndex for the EE. Hence the array is bigger than the number
536  // of crystals
537  const unsigned nendcap=19960;
538 
539  neighboursEE_.resize(nendcap);
540  for(unsigned ic=0; ic<size; ++ic)
541  {
542  // We get the 9 cells in a square.
543  std::vector<DetId> neighbours(endcapTopo.getWindow(vecee[ic],3,3));
544  unsigned nneighbours=neighbours.size();
545  // remove the centre
546  unsigned hashedindex=EEDetId(vecee[ic]).hashedIndex();
547 
548  if(hashedindex>=nendcap)
549  {
550  LogDebug("CaloGeometryTools") << " Array overflow " << std::endl;
551  }
552 
553  if(nneighbours==9)
554  {
555  neighboursEE_[hashedindex].reserve(8);
556  for(unsigned in=0;in<nneighbours;++in)
557  {
558  // remove the centre
559  if(neighbours[in]!=vecee[ic])
560  {
561  neighboursEE_[hashedindex].push_back(neighbours[in]);
562  }
563  }
564  }
565  else
566  {
567  DetId central(vecee[ic]);
568  neighboursEE_[hashedindex].resize(8,DetId(0));
569  for(unsigned idir=0;idir<8;++idir)
570  {
571  DetId testid=central;
572  bool status=stdmove(testid,orderedDir[idir],
573  barrelTopo, endcapTopo,
574  barrelGeom, endcapGeom);
575 
576  if(status) neighboursEE_[hashedindex][idir]=testid;
577  }
578 
579  }
580  }
581  // std::cout << " done " << size <<std::endl;
583 }
#define LogDebug(id)
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
bool stdmove(DetId &cell, const CaloDirection &dir, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorTopology &endcapTopo, const EcalBarrelGeometry &barrelGeom, const EcalEndcapGeometry &endcapGeom) const
std::vector< std::vector< DetId > > neighboursEB_
for each ecal barrel rechit, keep track of the neighbours
Definition: DetId.h:18
int hashedIndex() const
Definition: EEDetId.h:182
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
std::vector< std::vector< DetId > > neighboursEE_
for each ecal endcap rechit, keep track of the neighbours
bool neighbourmapcalculated_
set to true in ecalNeighbArray
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
tuple status
Definition: ntuplemaker.py:245
tuple size
Write out results.
bool PFRecHitProducerECAL::findEcalRecHitGeometry ( const DetId detid,
const CaloSubdetectorGeometry geom,
math::XYZVector position,
math::XYZVector axis 
)
private

find the position and the axis of the cell for a given rechit

Definition at line 354 of file PFRecHitProducerECAL.cc.

References CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), DetId::rawId(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

357  {
358 
359 
360  const CaloCellGeometry *thisCell
361  = geom->getGeometry(detid);
362 
363  // find rechit geometry
364  if(!thisCell) {
365  LogError("PFRecHitProducerECAL")
366  <<"warning detid "<<detid.rawId()
367  <<" not found in geometry"<<endl;
368  return false;
369  }
370 
371  position.SetCoordinates ( thisCell->getPosition().x(),
372  thisCell->getPosition().y(),
373  thisCell->getPosition().z() );
374 
375 
376 
377  // the axis vector is the difference
378  const TruncatedPyramid* pyr
379  = dynamic_cast< const TruncatedPyramid* > (thisCell);
380  if( pyr ) {
381  axis.SetCoordinates( pyr->getPosition(1).x(),
382  pyr->getPosition(1).y(),
383  pyr->getPosition(1).z() );
384 
385  math::XYZVector axis0( pyr->getPosition(0).x(),
386  pyr->getPosition(0).y(),
387  pyr->getPosition(0).z() );
388 
389  axis -= axis0;
390 
391 
392  return true;
393  }
394  else return false;
395 }
T y() const
Definition: PV3DBase.h:63
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T z() const
Definition: PV3DBase.h:64
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62
void PFRecHitProducerECAL::findRecHitNeighboursECAL ( reco::PFRecHit rh,
const std::map< unsigned, unsigned > &  sortedHits 
)
private

find rechit neighbours, using the hashed index

Definition at line 401 of file PFRecHitProducerECAL.cc.

References reco::PFRecHit::add4Neighbour(), reco::PFRecHit::add8Neighbour(), reco::PFRecHit::detId(), EAST, east, i, NORTH, north, NORTHEAST, NORTHWEST, DetId::rawId(), SOUTH, south, SOUTHEAST, SOUTHWEST, WEST, and west.

Referenced by createRecHits().

402  {
403 
404  DetId center( rh.detId() );
405 
406 
407  DetId north = move( center, NORTH );
408  DetId northeast = move( center, NORTHEAST );
409  DetId northwest = move( center, NORTHWEST );
410  DetId south = move( center, SOUTH );
411  DetId southeast = move( center, SOUTHEAST );
412  DetId southwest = move( center, SOUTHWEST );
413  DetId east = move( center, EAST );
414  DetId west = move( center, WEST );
415 
416  IDH i = sortedHits.find( north.rawId() );
417  if(i != sortedHits.end() )
418  rh.add4Neighbour( i->second );
419 
420  i = sortedHits.find( northeast.rawId() );
421  if(i != sortedHits.end() )
422  rh.add8Neighbour( i->second );
423 
424  i = sortedHits.find( south.rawId() );
425  if(i != sortedHits.end() )
426  rh.add4Neighbour( i->second );
427 
428  i = sortedHits.find( southwest.rawId() );
429  if(i != sortedHits.end() )
430  rh.add8Neighbour( i->second );
431 
432  i = sortedHits.find( east.rawId() );
433  if(i != sortedHits.end() )
434  rh.add4Neighbour( i->second );
435 
436  i = sortedHits.find( southeast.rawId() );
437  if(i != sortedHits.end() )
438  rh.add8Neighbour( i->second );
439 
440  i = sortedHits.find( west.rawId() );
441  if(i != sortedHits.end() )
442  rh.add4Neighbour( i->second );
443 
444  i = sortedHits.find( northwest.rawId() );
445  if(i != sortedHits.end() )
446  rh.add8Neighbour( i->second );
447 }
void add4Neighbour(unsigned index)
Definition: PFRecHit.cc:176
int i
Definition: DBlmapReader.cc:9
void add8Neighbour(unsigned index)
Definition: PFRecHit.cc:181
unsigned detId() const
rechit detId
Definition: PFRecHit.h:105
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
Definition: DetId.h:18
std::map< unsigned, unsigned >::const_iterator IDH
DetId move(DetId cell, const CaloDirection &dir) const
DetId PFRecHitProducerECAL::move ( DetId  cell,
const CaloDirection dir 
) const
private

Definition at line 759 of file PFRecHitProducerECAL.cc.

References dir, EcalBarrel, EBDetId::hashedIndex(), EEDetId::hashedIndex(), neighbourmapcalculated_, neighboursEB_, neighboursEE_, NONE, query::result, and DetId::subdetId().

Referenced by Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

761 {
762  DetId originalcell = cell;
763  if(dir==NONE || cell==DetId(0)) return false;
764 
765  // Conversion CaloDirection and index in the table
766  // CaloDirection :NONE,SOUTH,SOUTHEAST,SOUTHWEST,EAST,WEST, NORTHEAST,NORTHWEST,NORTH
767  // Table : SOUTHWEST,SOUTH,SOUTHEAST,WEST,EAST,NORTHWEST,NORTH, NORTHEAST
768  static const int calodirections[9]={-1,1,2,0,4,3,7,5,6};
769 
770  assert(neighbourmapcalculated_);
771 
772  DetId result = (originalcell.subdetId()==EcalBarrel) ?
773  neighboursEB_[EBDetId(originalcell).hashedIndex()][calodirections[dir]]:
774  neighboursEE_[EEDetId(originalcell).hashedIndex()][calodirections[dir]];
775  return result;
776 }
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
tuple result
Definition: query.py:137
std::vector< std::vector< DetId > > neighboursEB_
for each ecal barrel rechit, keep track of the neighbours
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
int hashedIndex() const
Definition: EEDetId.h:182
std::vector< std::vector< DetId > > neighboursEE_
for each ecal endcap rechit, keep track of the neighbours
bool neighbourmapcalculated_
set to true in ecalNeighbArray
dbl *** dir
Definition: mlp_gen.cc:35
bool PFRecHitProducerECAL::stdmove ( DetId cell,
const CaloDirection dir,
const CaloSubdetectorTopology barrelTopo,
const CaloSubdetectorTopology endcapTopo,
const EcalBarrelGeometry &  barrelGeom,
const EcalEndcapGeometry &  endcapGeom 
) const
private

Definition at line 666 of file PFRecHitProducerECAL.cc.

References EAST, NORTH, NORTHEAST, NORTHWEST, query::result, SOUTH, SOUTHEAST, SOUTHWEST, stdsimplemove(), and WEST.

Referenced by ecalNeighbArray().

673  {
674 
675 
676  bool result;
677 
678  if(dir==NORTH) {
679  result = stdsimplemove(cell,NORTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
680  return result;
681  }
682  else if(dir==SOUTH) {
683  result = stdsimplemove(cell,SOUTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
684  return result;
685  }
686  else if(dir==EAST) {
687  result = stdsimplemove(cell,EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
688  return result;
689  }
690  else if(dir==WEST) {
691  result = stdsimplemove(cell,WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
692  return result;
693  }
694 
695 
696  // One has to try both paths
697  else if(dir==NORTHEAST)
698  {
699  result = stdsimplemove(cell,NORTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
700  if(result)
701  return stdsimplemove(cell,EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
702  else
703  {
704  result = stdsimplemove(cell,EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
705  if(result)
706  return stdsimplemove(cell,NORTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
707  else
708  return false;
709  }
710  }
711  else if(dir==NORTHWEST)
712  {
713  result = stdsimplemove(cell,NORTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
714  if(result)
715  return stdsimplemove(cell,WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
716  else
717  {
718  result = stdsimplemove(cell,WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
719  if(result)
720  return stdsimplemove(cell,NORTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
721  else
722  return false;
723  }
724  }
725  else if(dir == SOUTHEAST)
726  {
727  result = stdsimplemove(cell,SOUTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
728  if(result)
729  return stdsimplemove(cell,EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
730  else
731  {
732  result = stdsimplemove(cell,EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
733  if(result)
734  return stdsimplemove(cell,SOUTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
735  else
736  return false;
737  }
738  }
739  else if(dir == SOUTHWEST)
740  {
741  result = stdsimplemove(cell,SOUTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
742  if(result)
743  return stdsimplemove(cell,WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
744  else
745  {
746  result = stdsimplemove(cell,SOUTH, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
747  if(result)
748  return stdsimplemove(cell,WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
749  else
750  return false;
751  }
752  }
753  cell = DetId(0);
754  return false;
755 }
tuple result
Definition: query.py:137
bool stdsimplemove(DetId &cell, const CaloDirection &dir, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorTopology &endcapTopo, const EcalBarrelGeometry &barrelGeom, const EcalEndcapGeometry &endcapGeom) const
Definition: DetId.h:18
dbl *** dir
Definition: mlp_gen.cc:35
bool PFRecHitProducerECAL::stdsimplemove ( DetId cell,
const CaloDirection dir,
const CaloSubdetectorTopology barrelTopo,
const CaloSubdetectorTopology endcapTopo,
const EcalBarrelGeometry &  barrelGeom,
const EcalEndcapGeometry &  endcapGeom 
) const
private

Definition at line 588 of file PFRecHitProducerECAL.cc.

References crossBarrelEndcapBorder_, EcalBarrel, EcalEndcap, CaloSubdetectorTopology::getNeighbours(), EBDetId::ietaAbs(), EEDetId::iPhiOuterRing(), EBDetId::MAX_IETA, and DetId::subdetId().

Referenced by stdmove().

594  {
595 
596  std::vector<DetId> neighbours;
597 
598  // BARREL CASE
599  if(cell.subdetId()==EcalBarrel) {
600  EBDetId ebDetId = cell;
601 
602  neighbours = barrelTopo.getNeighbours(ebDetId,dir);
603 
604  // first try to move according to the standard navigation
605  if(neighbours.size()>0 && !neighbours[0].null()) {
606  cell = neighbours[0];
607  return true;
608  }
609 
610  // failed.
611 
613  // are we on the outer ring ?
614  const int ietaAbs ( ebDetId.ietaAbs() ) ; // abs value of ieta
615  if( EBDetId::MAX_IETA == ietaAbs ) {
616  // get ee nbrs for for end of barrel crystals
617 
618  // yes we are
619  const EcalBarrelGeometry::OrderedListOfEEDetId&
620  ol( * barrelGeom.getClosestEndcapCells( ebDetId ) ) ;
621 
622  // take closest neighbour on the other side, that is in the barrel.
623  cell = *(ol.begin() );
624  return true;
625  }
626  }
627  }
628 
629  // ENDCAP CASE
630  else if(cell.subdetId()==EcalEndcap) {
631 
632  EEDetId eeDetId = cell;
633 
634  neighbours= endcapTopo.getNeighbours(eeDetId,dir);
635 
636  if(neighbours.size()>0 && !neighbours[0].null()) {
637  cell = neighbours[0];
638  return true;
639  }
640 
641  // failed.
642 
644  // are we on the outer ring ?
645  const int iphi ( eeDetId.iPhiOuterRing() ) ;
646  if( iphi!= 0) {
647  // yes we are
648  const EcalEndcapGeometry::OrderedListOfEBDetId&
649  ol( * endcapGeom.getClosestBarrelCells( eeDetId ) ) ;
650 
651  // take closest neighbour on the other side, that is in the barrel.
652  cell = *(ol.begin() );
653  return true;
654  }
655  }
656  }
657 
658  // everything failed
659  cell = DetId(0);
660  return false;
661 }
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
bool crossBarrelEndcapBorder_
if true, navigation will cross the barrel-endcap border
int iPhiOuterRing() const
Definition: EEDetId.cc:388
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
static const int MAX_IETA
Definition: EBDetId.h:143
dbl *** dir
Definition: mlp_gen.cc:35
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:49

Member Data Documentation

bool PFRecHitProducerECAL::crossBarrelEndcapBorder_
private

if true, navigation will cross the barrel-endcap border

Definition at line 117 of file PFRecHitProducerECAL.h.

Referenced by PFRecHitProducerECAL(), and stdsimplemove().

edm::InputTag PFRecHitProducerECAL::inputTagEcalRecHitsEB_
private

Definition at line 120 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), and PFRecHitProducerECAL().

edm::InputTag PFRecHitProducerECAL::inputTagEcalRecHitsEE_
private

Definition at line 121 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), and PFRecHitProducerECAL().

bool PFRecHitProducerECAL::neighbourmapcalculated_
private

set to true in ecalNeighbArray

Definition at line 114 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), ecalNeighbArray(), move(), and PFRecHitProducerECAL().

std::vector<std::vector<DetId> > PFRecHitProducerECAL::neighboursEB_
private

for each ecal barrel rechit, keep track of the neighbours

Definition at line 108 of file PFRecHitProducerECAL.h.

Referenced by ecalNeighbArray(), and move().

std::vector<std::vector<DetId> > PFRecHitProducerECAL::neighboursEE_
private

for each ecal endcap rechit, keep track of the neighbours

Definition at line 111 of file PFRecHitProducerECAL.h.

Referenced by ecalNeighbArray(), and move().

double PFRecHitProducerECAL::threshCleaningEB_
private

Definition at line 125 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), and PFRecHitProducerECAL().

double PFRecHitProducerECAL::threshCleaningEE_
private

Definition at line 126 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), and PFRecHitProducerECAL().

bool PFRecHitProducerECAL::timingCleaning_
private

Definition at line 124 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), and PFRecHitProducerECAL().

bool PFRecHitProducerECAL::topologicalCleaning_
private

Definition at line 129 of file PFRecHitProducerECAL.h.

Referenced by createRecHits(), and PFRecHitProducerECAL().