78 vector<reco::PFRecHit>& rechitsCleaned,
90 map<unsigned, unsigned > idSortedRecHits;
102 assert( ecalBarrelGeometry );
113 assert( ecalEndcapGeometry );
124 ecalEndcapTopology );
139 LogError(
"PFRecHitProducerECAL")<<err.str()<<endl;
147 for(
unsigned i=0;
i<rhcHandle->size();
i++) {
156 if (esd != 1)
continue;
177 if( !pfrhCleaned )
continue;
179 rechitsCleaned.push_back( *pfrhCleaned );
189 if( !pfrh )
continue;
192 rechits.push_back( *pfrh );
194 idSortedRecHits.insert( make_pair(detid.
rawId(), rechits.size()-1 ) );
209 LogError(
"PFRecHitProducerECAL")<<err.str()<<endl;
216 for(
unsigned i=0;
i<rhcHandle->size();
i++) {
224 if (esd != 2)
continue;
244 if( !pfrhCleaned )
continue;
246 rechitsCleaned.push_back( *pfrhCleaned );
257 if( !pfrh )
continue;
260 rechits.push_back( *pfrh );
262 idSortedRecHits.insert( make_pair(detid.
rawId(), rechits.size()-1 ) );
268 for(
unsigned i=0;
i<rechits.size();
i++ ) {
298 <<
"warning detid "<<detid.
rawId()
299 <<
" not found in geometry"<<endl;
335 position.x(), position.y(), position.z(),
336 axis.x(), axis.y(), axis.z() );
340 assert( corners.size() == 8 );
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() );
366 <<
"warning detid "<<detid.
rawId()
367 <<
" not found in geometry"<<endl;
402 const map<unsigned,unsigned >& sortedHits ) {
416 IDH i = sortedHits.find( north.rawId() );
417 if(i != sortedHits.end() )
420 i = sortedHits.find( northeast.
rawId() );
421 if(i != sortedHits.end() )
424 i = sortedHits.find( south.
rawId() );
425 if(i != sortedHits.end() )
428 i = sortedHits.find( southwest.
rawId() );
429 if(i != sortedHits.end() )
432 i = sortedHits.find( east.
rawId() );
433 if(i != sortedHits.end() )
436 i = sortedHits.find( southeast.
rawId() );
437 if(i != sortedHits.end() )
440 i = sortedHits.find( west.
rawId() );
441 if(i != sortedHits.end() )
444 i = sortedHits.find( northwest.
rawId() );
445 if(i != sortedHits.end() )
470 const unsigned nbarrel = 62000;
478 unsigned size=vec.size();
479 for(
unsigned ic=0; ic<
size; ++ic)
482 std::vector<DetId> neighbours(barrelTopo.
getWindow(vec[ic],3,3));
484 unsigned nneighbours=neighbours.size();
487 if(hashedindex>=nbarrel)
489 LogDebug(
"CaloGeometryTools") <<
" Array overflow " << std::endl;
501 for(
unsigned in=0;
in<nneighbours;++
in)
504 if(neighbours[
in]!=vec[ic])
513 DetId central(vec[ic]);
515 for(
unsigned idir=0;idir<8;++idir)
517 DetId testid=central;
519 barrelTopo, endcapTopo,
520 barrelGeom, endcapGeom);
537 const unsigned nendcap=19960;
540 for(
unsigned ic=0; ic<
size; ++ic)
543 std::vector<DetId> neighbours(endcapTopo.
getWindow(vecee[ic],3,3));
544 unsigned nneighbours=neighbours.size();
548 if(hashedindex>=nendcap)
550 LogDebug(
"CaloGeometryTools") <<
" Array overflow " << std::endl;
556 for(
unsigned in=0;
in<nneighbours;++
in)
559 if(neighbours[
in]!=vecee[ic])
567 DetId central(vecee[ic]);
569 for(
unsigned idir=0;idir<8;++idir)
571 DetId testid=central;
573 barrelTopo, endcapTopo,
574 barrelGeom, endcapGeom);
596 std::vector<DetId> neighbours;
605 if(neighbours.size()>0 && !neighbours[0].null()) {
606 cell = neighbours[0];
614 const int ietaAbs ( ebDetId.
ietaAbs() ) ;
623 cell = *(ol.begin() );
636 if(neighbours.size()>0 && !neighbours[0].null()) {
637 cell = neighbours[0];
652 cell = *(ol.begin() );
682 else if(dir==
SOUTH) {
687 result =
stdsimplemove(cell,
EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
691 result =
stdsimplemove(cell,
WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
701 return stdsimplemove(cell,
EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
704 result =
stdsimplemove(cell,
EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
715 return stdsimplemove(cell,
WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
718 result =
stdsimplemove(cell,
WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
729 return stdsimplemove(cell,
EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
732 result =
stdsimplemove(cell,
EAST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
743 return stdsimplemove(cell,
WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
748 return stdsimplemove(cell,
WEST, barrelTopo, endcapTopo, barrelGeom, endcapGeom );
762 DetId originalcell = cell;
763 if(dir==
NONE || cell==
DetId(0))
return false;
768 static const int calodirections[9]={-1,1,2,0,4,3,7,5,6};
void setSECorner(double posx, double posy, double posz)
T getParameter(std::string const &) const
void add4Neighbour(unsigned index)
const OrderedListOfEEDetId * getClosestEndcapCells(EBDetId id) const
int hashedIndex() const
get a compact index for arrays
void ecalNeighbArray(const EcalBarrelGeometry &barrelGeom, const CaloSubdetectorTopology &barrelTopo, const EcalEndcapGeometry &endcapGeom, const CaloSubdetectorTopology &endcapTopo)
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
void add8Neighbour(unsigned index)
void setNECorner(double posx, double posy, double posz)
edm::InputTag inputTagEcalRecHitsEE_
const DetId & detid() const
unsigned detId() const
rechit detId
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
edm::InputTag inputTagEcalRecHitsEB_
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
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
void setSWCorner(double posx, double posy, double posz)
bool crossBarrelEndcapBorder_
if true, navigation will cross the barrel-endcap border
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Base producer for particle flow rechits (PFRecHit)
bool checkFlag(int flag) const
check if the flag is true
PFRecHitProducerECAL(const edm::ParameterSet &)
bool stdmove(DetId &cell, const CaloDirection &dir, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorTopology &endcapTopo, const EcalBarrelGeometry &barrelGeom, const EcalEndcapGeometry &endcapGeom) const
int iPhiOuterRing() const
bool stdsimplemove(DetId &cell, const CaloDirection &dir, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorTopology &endcapTopo, const EcalBarrelGeometry &barrelGeom, const EcalEndcapGeometry &endcapGeom) const
const OrderedListOfEBDetId * getClosestBarrelCells(EEDetId id) const
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
void setRescale(double factor)
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's numbering enum) ...
void setNWCorner(double posx, double posy, double posz)
search for pointers to neighbours, using neighbours' DetId.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
reco::PFRecHit * createEcalRecHit(const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom)
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const GlobalPoint getPosition(CCGFloat depth) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
static const int MAX_IETA
void findRecHitNeighboursECAL(reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits)
find rechit neighbours, using the hashed index
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
std::vector< std::vector< DetId > > neighboursEE_
for each ecal endcap rechit, keep track of the neighbours
void createRecHits(std::vector< reco::PFRecHit > &rechits, std::vector< reco::PFRecHit > &rechitsCleaned, edm::Event &, const edm::EventSetup &)
std::map< unsigned, unsigned >::const_iterator IDH
static int position[264][3]
DetId move(DetId cell, const CaloDirection &dir) const
double thresh_Barrel_
rechits with E < threshold will not give rise to a PFRecHit
bool neighbourmapcalculated_
set to true in ecalNeighbArray
CaloDirection
Codes the local directions in the cell lattice.
int ietaAbs() const
get the absolute value of the crystal ieta
tuple size
Write out results.
bool topologicalCleaning_
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell's volume.