104 produces<reco::PFRecHitCollection>(
"HFHAD").setBranchAlias(
"HFHADRecHits");
105 produces<reco::PFRecHitCollection>(
"HFEM").setBranchAlias(
"HFEMRecHits");
116 vector<reco::PFRecHit>& rechitsCleaned,
128 map<unsigned, unsigned > idSortedRecHits;
129 map<unsigned, unsigned > idSortedRecHitsHFEM;
130 map<unsigned, unsigned > idSortedRecHitsHFHAD;
131 typedef map<unsigned, unsigned >::iterator
IDH;
152 auto_ptr< vector<reco::PFRecHit> > HFHADRecHits(
new vector<reco::PFRecHit> );
153 auto_ptr< vector<reco::PFRecHit> > HFEMRecHits(
new vector<reco::PFRecHit> );
182 LogError(
"PFHCALDualTimeRecHitProducer")<<err.str()<<endl;
187 assert( caloTowers.
isValid() );
197 LogError(
"PFHCALDualTimeRecHitProducer")<<err.str()<<endl;
202 assert( hfHandle.isValid() );
214 LogError(
"PFHCALDualTimeRecHitProducer")<<err.str()<<endl;
219 assert( hbheHandle.
isValid() );
222 for(
unsigned irechit=0; irechit<hbheHandle->size(); irechit++) {
226 double hitenergy = hit.
energy();
227 double hittime = hit.
time();
234 switch( detid.
subdet() ) {
238 if(detid.
depth()==1) {
239 hittime -= 48.9580/(2.16078+hitenergy);
240 }
else if(detid.
depth()==2) {
241 hittime -= 34.2860/(1.23746+hitenergy);
242 }
else if(detid.
depth()==3) {
243 hittime -= 38.6872/(1.48051+hitenergy);
246 if( (detid.
depth()==1 && hittime>-20 && hittime<5)
247 || (detid.
depth()==2 && hittime>-17 && hittime<8)
248 || (detid.
depth()==3 && hittime>-15 && hittime<10)
253 hcalBarrelGeometry );
263 if(detid.
depth()==1) {
264 hittime -= 60.8050/(3.07285+hitenergy);
265 }
else if(detid.
depth()==2) {
266 hittime -= 47.1677/(2.06485+hitenergy);
267 }
else if(detid.
depth()==3) {
268 hittime -= 37.1941/(1.53790+hitenergy);
269 }
else if(detid.
depth()==4) {
270 hittime -= 42.9898/(1.92969+hitenergy);
271 }
else if(detid.
depth()==5) {
272 hittime -= 48.3157/(2.29903+hitenergy);
275 if( (detid.
depth()==1 && hittime>-20 && hittime<5)
276 || (detid.
depth()==2 && hittime>-19 && hittime<6)
277 || (detid.
depth()==3 && hittime>-18 && hittime<7)
278 || (detid.
depth()==4 && hittime>-17 && hittime<8)
279 || (detid.
depth()==5 && hittime>-15 && hittime<10)
284 hcalEndcapGeometry );
290 LogError(
"PFHCALDualTimeRecHitProducer")
291 <<
"HCAL rechit: unknown layer : "<<detid.
subdet()<<endl;
296 rechits.push_back( *pfrh );
298 idSortedRecHits.insert( make_pair(detid.
rawId(),
299 rechits.size()-1 ) );
302 rechitsCleaned.push_back( *pfrhCleaned );
312 for(ICT ict=caloTowers->begin(); ict!=caloTowers->end();ict++) {
317 if(!caloTowerGeometry)
318 caloTowerGeometry = geoHandle->getSubdetectorGeometry(ct.
id());
331 if( (energy+energyEM) < 1
e-9 )
continue;
369 bool foundHCALConstituent =
false;
375 for(
unsigned int i=0;
i< hits.size();++
i) {
377 foundHCALConstituent =
true;
381 for(
unsigned int j=0;
j<allConstituents.size();++
j) {
410 if(foundHCALConstituent)
413 switch( detid.
subdet() ) {
512 if((energyemHF+energyhadHF) <
thresh_HF_ )
continue;
515 double longFibre = energyemHF + energyhadHF/2.;
516 double shortFibre = energyhadHF/2.;
517 int ieta = detid.
ieta();
518 int iphi = detid.
iphi();
522 iHF theLongHit = hfHandle->find(theLongDetId);
523 iHF theShortHit = hfHandle->find(theShortDetId);
525 double theLongHitEnergy = 0.;
526 double theShortHitEnergy = 0.;
527 bool flagShortDPG =
false;
528 bool flagLongDPG =
false;
529 bool flagShortTimeDPG =
false;
530 bool flagLongTimeDPG =
false;
531 bool flagShortPulseDPG =
false;
532 bool flagLongPulseDPG =
false;
534 if ( theLongHit != hfHandle->end() ) {
535 theLongHitEnergy = theLongHit->energy();
541 if ( theShortHit != hfHandle->end() ) {
542 theShortHitEnergy = theShortHit->energy();
552 flagShortTimeDPG || flagShortPulseDPG ) ) {
559 pfrhHFHADCleaned->
setRescale(theShortHit->time());
572 shortFibre -= theShortHitEnergy;
573 theShortHitEnergy = 0.;
580 flagLongTimeDPG || flagLongPulseDPG ) ) {
587 pfrhHFEMCleaned->
setRescale(theLongHit->time());
600 longFibre -= theLongHitEnergy;
601 theLongHitEnergy = 0.;
611 unsigned theStatusValue = theStatus->
getValue();
613 if ( !theStatusValue ) {
620 pfrhHFHADCleaned->
setRescale(theShortHit->time());
634 shortFibre -= theShortHitEnergy;
635 theShortHitEnergy = 0.;
645 unsigned theStatusValue = theStatus->
getValue();
647 if ( !theStatusValue ) {
654 pfrhHFEMCleaned->
setRescale(theLongHit->time());
668 longFibre -= theLongHitEnergy;
669 theLongHitEnergy = 0.;
675 if (
abs(ieta) == 29 ) {
684 pfrhHFEMCleaned29->
setRescale(theLongHit->time());
692 longFibre -= theLongHitEnergy;
693 theLongHitEnergy = 0.;
702 pfrhHFHADCleaned29->
setRescale(theShortHit->time());
710 shortFibre -= theShortHitEnergy;
711 theShortHitEnergy = 0.;
717 else if (
abs(ieta) == 30 ) {
718 int ieta29 = ieta > 0 ? 29 : -29;
721 iHF theLongHit29 = hfHandle->find(theLongDetId29);
722 iHF theShortHit29 = hfHandle->find(theShortDetId29);
724 double theLongHitEnergy29 = 0.;
725 double theShortHitEnergy29 = 0.;
726 bool flagShortDPG29 =
false;
727 bool flagLongDPG29 =
false;
728 bool flagShortTimeDPG29 =
false;
729 bool flagLongTimeDPG29 =
false;
730 bool flagShortPulseDPG29 =
false;
731 bool flagLongPulseDPG29 =
false;
733 if ( theLongHit29 != hfHandle->end() ) {
734 theLongHitEnergy29 = theLongHit29->energy() ;
740 if ( theShortHit29 != hfHandle->end() ) {
741 theShortHitEnergy29 = theShortHit29->energy();
750 flagLongTimeDPG29 || flagLongPulseDPG29 ) ) {
757 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
770 longFibre -= theLongHitEnergy29;
771 theLongHitEnergy29 = 0;
777 flagShortTimeDPG29 || flagShortPulseDPG29 ) ) {
784 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
797 shortFibre -= theShortHitEnergy29;
798 theShortHitEnergy29 = 0.;
808 unsigned theStatusValue = theStatus->
getValue();
810 if ( !theStatusValue ) {
817 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
831 shortFibre -= theShortHitEnergy29;
832 theShortHitEnergy29 = 0.;
843 unsigned theStatusValue = theStatus->
getValue();
845 if ( !theStatusValue ) {
852 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
866 longFibre -= theLongHitEnergy29;
867 theLongHitEnergy29 = 0.;
879 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
887 longFibre -= theLongHitEnergy29;
888 theLongHitEnergy29 = 0.;
897 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
905 shortFibre -= theShortHitEnergy29;
906 theShortHitEnergy29 = 0.;
912 energyhadHF = 2.*shortFibre;
913 energyemHF = longFibre - shortFibre;
919 energyhadHF += energyemHF;
942 pfrhHFHAD->setEnergyUp(energyemHF);
948 LogError(
"PFHCALDualTimeRecHitProducer")
949 <<
"CaloTower constituent: unknown layer : "
966 HFEMRecHits->push_back( *pfrhHFEM );
968 idSortedRecHitsHFEM.insert( make_pair(ct.
id().
rawId(),
969 HFEMRecHits->size()-1 ) );
972 HFHADRecHits->push_back( *pfrhHFHAD );
974 idSortedRecHitsHFHAD.insert( make_pair(ct.
id().
rawId(),
975 HFHADRecHits->size()-1 ) );
978 if(pfrhHFEMCleaned) {
979 rechitsCleaned.push_back( *pfrhHFEMCleaned );
980 delete pfrhHFEMCleaned;
982 if(pfrhHFHADCleaned) {
983 rechitsCleaned.push_back( *pfrhHFHADCleaned );
984 delete pfrhHFHADCleaned;
986 if(pfrhHFEMCleaned29) {
987 rechitsCleaned.push_back( *pfrhHFEMCleaned29 );
988 delete pfrhHFEMCleaned29;
990 if(pfrhHFHADCleaned29) {
991 rechitsCleaned.push_back( *pfrhHFHADCleaned29 );
992 delete pfrhHFHADCleaned29;
1005 for(
unsigned i=0;
i<rechits.size();
i++ ) {
1009 *hcalBarrelGeometry,
1011 *hcalEndcapGeometry);
1014 for(
unsigned i=0;
i<HFEMRecHits->size();
i++ ) {
1016 idSortedRecHitsHFEM,
1019 for(
unsigned i=0;
i<HFHADRecHits->size();
i++ ) {
1021 idSortedRecHitsHFHAD,
1024 iEvent.
put( HFHADRecHits,
"HFHAD" );
1025 iEvent.
put( HFEMRecHits,
"HFEM" );
1044 LogError(
"PFHCALDualTimeRecHitProducer")<<err.str()<<endl;
1049 assert( hcalHandle.
isValid() );
1053 for(
unsigned irechit=0; irechit<handle->size(); irechit++) {
1063 switch( detid.
subdet() ) {
1070 hcalBarrelGeometry );
1079 hcalEndcapGeometry );
1088 hcalEndcapGeometry );
1092 LogError(
"PFHCALDualTimeRecHitProducer")
1093 <<
"HCAL rechit: unknown layer : "<<detid.
subdet()<<endl;
1098 rechits.push_back( *pfrh );
1100 idSortedRecHits.insert( make_pair(detid.
rawId(),
1101 rechits.size()-1 ) );
1107 for(
unsigned i=0;
i<rechits.size();
i++ ) {
1111 *hcalBarrelGeometry,
1113 *hcalEndcapGeometry);
1129 unsigned newDetId ) {
1134 <<
"warning detid "<<detid.
rawId()<<
" not found in layer "
1141 double depth_correction = 0.;
1153 unsigned id =
detid;
1154 if(newDetId)
id = newDetId;
1157 position.
x(), position.
y(), position.
z()+depth_correction,
1166 assert( corners.size() == 8 );
1168 rh->
setNECorner( corners[0].
x(), corners[0].
y(), corners[0].
z()+depth_correction );
1169 rh->
setSECorner( corners[1].
x(), corners[1].
y(), corners[1].
z()+depth_correction );
1170 rh->
setSWCorner( corners[2].
x(), corners[2].
y(), corners[2].
z()+depth_correction );
1171 rh->
setNWCorner( corners[3].
x(), corners[3].
y(), corners[3].
z()+depth_correction );
1182 const map<unsigned,unsigned >& sortedHits,
1189 if(navigation_HF_ ==
false){
1201 switch( rh.
layer() ) {
1203 topology = &endcapTopology;
1204 geometry = &endcapGeometry;
1207 topology = &barrelTopology;
1208 geometry = &barrelGeometry;
1211 topology = &endcapTopology;
1212 geometry = &endcapGeometry;
1216 topology = &barrelTopology;
1217 geometry = &barrelGeometry;
1222 topology = &barrelTopology;
1223 geometry = &barrelGeometry;
1230 assert( topology && geometry );
1232 CaloNavigator<DetId> navigator(
detid, topology);
1237 if( north !=
DetId(0) ) {
1238 northeast = navigator.east();
1248 if( south !=
DetId(0) ) {
1249 southwest = navigator.west();
1256 if( east !=
DetId(0) ) {
1257 southeast = navigator.south();
1262 if( west !=
DetId(0) ) {
1263 northwest = navigator.north();
1267 IDH i = sortedHits.find( north.
rawId() );
1268 if(i != sortedHits.end() )
1271 i = sortedHits.find( northeast.
rawId() );
1272 if(i != sortedHits.end() )
1275 i = sortedHits.find( south.
rawId() );
1276 if(i != sortedHits.end() )
1279 i = sortedHits.find( southwest.
rawId() );
1280 if(i != sortedHits.end() )
1283 i = sortedHits.find( east.
rawId() );
1284 if(i != sortedHits.end() )
1287 i = sortedHits.find( southeast.
rawId() );
1288 if(i != sortedHits.end() )
1291 i = sortedHits.find( west.
rawId() );
1292 if(i != sortedHits.end() )
1295 i = sortedHits.find( northwest.
rawId() );
1296 if(i != sortedHits.end() )
1306 const map<unsigned, unsigned >& sortedHits,
1314 if(navigation_HF_ ==
false){
1323 vector<DetId> northids = topology.
north(ctDetId);
1324 vector<DetId> westids = topology.
west(ctDetId);
1325 vector<DetId> southids = topology.
south(ctDetId);
1326 vector<DetId> eastids = topology.
east(ctDetId);
1349 switch( northids.size() ) {
1353 north = northids[0];
1356 stringstream err(
"PFHCALDualTimeRecHitProducer::findRecHitNeighboursCT : incorrect number of neighbours north: ");
1357 err<<northids.size();
1361 switch( southids.size() ) {
1365 south = southids[0];
1368 stringstream err(
"PFHCALDualTimeRecHitProducer::findRecHitNeighboursCT : incorrect number of neighbours south: ");
1369 err<<southids.size();
1376 switch( eastids.size() ) {
1381 northeast = getNorth(east, topology);
1382 southeast = getSouth(east, topology);
1388 northeast = getNorth(east, topology );
1389 southeast = getSouth(east2, topology);
1390 northeast2 = getNorth(northeast, topology );
1391 southeast2 = getSouth(southeast, topology);
1394 stringstream err(
"PFHCALDualTimeRecHitProducer::findRecHitNeighboursCT : incorrect number of neighbours eastids: ");
1395 err<<eastids.size();
1400 switch( westids.size() ) {
1405 northwest = getNorth(west, topology);
1406 southwest = getSouth(west, topology);
1412 northwest = getNorth(west, topology );
1413 southwest = getSouth(west2, topology );
1414 northwest2 = getNorth(northwest, topology );
1415 southwest2 = getSouth(southwest, topology );
1418 stringstream err(
"PFHCALDualTimeRecHitProducer::findRecHitNeighboursCT : incorrect number of neighbours westids: ");
1419 err<< westids.size();
1428 IDH i = sortedHits.find( north.
rawId() );
1429 if(i != sortedHits.end() )
1432 i = sortedHits.find( northeast.
rawId() );
1433 if(i != sortedHits.end() )
1436 i = sortedHits.find( northeast2.
rawId() );
1437 if(i != sortedHits.end() )
1440 i = sortedHits.find( south.
rawId() );
1441 if(i != sortedHits.end() )
1444 i = sortedHits.find( southwest.
rawId() );
1445 if(i != sortedHits.end() )
1448 i = sortedHits.find( southwest2.
rawId() );
1449 if(i != sortedHits.end() )
1452 i = sortedHits.find( east.
rawId() );
1453 if(i != sortedHits.end() )
1456 i = sortedHits.find( east2.
rawId() );
1457 if(i != sortedHits.end() )
1460 i = sortedHits.find( southeast.
rawId() );
1461 if(i != sortedHits.end() )
1464 i = sortedHits.find( southeast2.
rawId() );
1465 if(i != sortedHits.end() )
1468 i = sortedHits.find( west.
rawId() );
1469 if(i != sortedHits.end() )
1472 i = sortedHits.find( west2.
rawId() );
1473 if(i != sortedHits.end() )
1476 i = sortedHits.find( northwest.
rawId() );
1477 if(i != sortedHits.end() )
1480 i = sortedHits.find( northwest2.
rawId() );
1481 if(i != sortedHits.end() )
1498 vector<DetId> sids = topology.
south(
id);
1499 if(sids.size() == 1)
1512 vector<DetId> nids = topology.
north(
id);
1513 if(nids.size() == 1)
void setSECorner(double posx, double posy, double posz)
T getParameter(std::string const &) const
void add4Neighbour(unsigned index)
void add8Neighbour(unsigned index)
size_t constituentsSize() const
void setNECorner(double posx, double posy, double posz)
HcalSubdetector subdet() const
get the subdetector
const DetId & detid() const
unsigned detId() const
rechit detId
void createRecHits(std::vector< reco::PFRecHit > &rechits, std::vector< reco::PFRecHit > &rechitsCleaned, edm::Event &, const edm::EventSetup &)
std::vector< CaloTower >::const_iterator const_iterator
virtual std::vector< DetId > west(const DetId &id) const =0
unsigned int ECAL_Dead_Code_
double shortFibre_Fraction
const Item * getValues(DetId fId, bool throwOnFail=true) const
const EcalChannelStatus * theEcalChStatus
static int position[TOTALCHAMBERS][3]
double minShortTiming_Cut
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
uint32_t rawId() const
get the raw id
PFLayer::Layer layer() const
rechit layer
void setSWCorner(double posx, double posy, double posz)
edm::InputTag inputTagHcalRecHitsHBHE_
int depth() const
get the tower depth
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Base producer for particle flow rechits (PFRecHit)
~PFHCALDualTimeRecHitProducer()
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
DetId getSouth(const DetId &id, const CaloSubdetectorTopology &topology)
void setEnergyUp(double eUp)
edm::InputTag inputTagHcalRecHitsHF_
int ieta() const
get the cell ieta
double longShortFibre_Cut
Abs< T >::type abs(const T &t)
void findRecHitNeighboursCT(reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits, const CaloSubdetectorTopology &topology)
const std::vector< DetId > & constituents() const
void setRescale(double factor)
void setNWCorner(double posx, double posy, double posz)
search for pointers to neighbours, using neighbours' DetId.
void findRecHitNeighbours(reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorGeometry &barrelGeom, const CaloSubdetectorTopology &endcapTopo, const CaloSubdetectorGeometry &endcapGeom)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double ECAL_Compensation_
virtual std::vector< DetId > north(const DetId &id) const =0
int iphi() const
get the cell iphi
CaloTowerDetId id() const
const HcalChannelQuality * theHcalChStatus
std::vector< Item >::const_iterator const_iterator
double thresh_HF_
threshold for HF
const CaloTowerConstituentsMap * theTowerConstituentsMap
edm::InputTag inputTagCaloTowers_
ESHandle< TrackerGeometry > geometry
double maxShortTiming_Cut
std::map< unsigned, unsigned >::const_iterator IDH
reco::PFRecHit * createHcalRecHit(const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom, unsigned newDetId=0)
virtual std::vector< DetId > south(const DetId &id) const =0
const_iterator find(uint32_t rawId) const
double thresh_Barrel_
rechits with E < threshold will not give rise to a PFRecHit
const_iterator end() const
DetId getNorth(const DetId &id, const CaloSubdetectorTopology &topology)
PFHCALDualTimeRecHitProducer(const edm::ParameterSet &)
uint32_t getValue() const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
virtual std::vector< DetId > east(const DetId &id) const =0
double longFibre_Fraction
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell's volume.