@@ -235,6 +235,9 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthre
235
235
theMomEEDepth(momEEDepth)
236
236
237
237
{
238
+ // static int N = 0;
239
+ // std::cout << "VI Algo " << ++N << std::endl;
240
+ // nalgo=N;
238
241
}
239
242
240
243
@@ -292,6 +295,9 @@ void CaloTowersCreationAlgo::finish(CaloTowerCollection& result) {
292
295
// now copy this map into the final collection
293
296
result.reserve (theTowerMapSize);
294
297
// auto k=0U;
298
+ // if (!theEbHandle.isValid()) std::cout << "VI ebHandle not valid" << std::endl;
299
+ // if (!theEeHandle.isValid()) std::cout << "VI eeHandle not valid" << std::endl;
300
+
295
301
for (auto const & mt : theTowerMap ) {
296
302
// Convert only if there is at least one constituent in the metatower.
297
303
// The check of constituents size in the coverted tower is still needed!
@@ -412,9 +418,12 @@ void CaloTowersCreationAlgo::rescaleTowers(const CaloTowerCollection& ctc, CaloT
412
418
void CaloTowersCreationAlgo::assignHit (const CaloRecHit * recHit) {
413
419
DetId detId = recHit->detid ();
414
420
415
- unsigned int chStatusForCT = (detId.det ()==DetId::Hcal)?
416
- hcalChanStatusForCaloTower (recHit) :
417
- ecalChanStatusForCaloTower (recHit);
421
+ unsigned int chStatusForCT;
422
+ bool ecalIsBad=false ;
423
+ if (detId.det ()==DetId::Hcal)
424
+ chStatusForCT = hcalChanStatusForCaloTower (recHit);
425
+ else
426
+ std::tie (chStatusForCT,ecalIsBad) = ecalChanStatusForCaloTower (recHit);
418
427
419
428
// this is for skipping channls: mostly needed for the creation of
420
429
// bad towers from hits i the bad channel collections.
@@ -523,12 +532,30 @@ void CaloTowersCreationAlgo::assignHit(const CaloRecHit * recHit) {
523
532
else passEmThreshold = (energy >= threshold);
524
533
}
525
534
535
+ CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf (detId);
536
+ if (towerDetId.null ()) return ;
537
+ MetaTower & tower = find (towerDetId);
538
+
539
+
540
+ // count bad cells and avoid double counting with those from DB (Recovered are counted bad)
541
+
542
+ // somehow misses some
543
+ // if ( (chStatusForCT == CaloTowersCreationAlgo::BadChan) & (!ecalIsBad) ) ++tower.numBadEcalCells;
544
+
545
+ // a bit slower...
546
+ if ( chStatusForCT == CaloTowersCreationAlgo::BadChan ) {
547
+ auto thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel (detId);
548
+ // check if the Ecal severity is ok to keep
549
+ auto sevit = std::find (theEcalSeveritiesToBeExcluded.begin (),
550
+ theEcalSeveritiesToBeExcluded.end (),
551
+ thisEcalSevLvl);
552
+ if (sevit==theEcalSeveritiesToBeExcluded.end ()) ++tower.numBadEcalCells ; // notinDB
553
+ }
554
+
526
555
527
556
// if (chStatusForCT != CaloTowersCreationAlgo::BadChan && energy >= threshold) {
528
557
if (chStatusForCT != CaloTowersCreationAlgo::BadChan && passEmThreshold) {
529
- CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf (detId);
530
- if (towerDetId.null ()) return ;
531
- MetaTower & tower = find (towerDetId);
558
+
532
559
tower.E_em += e;
533
560
tower.E += e;
534
561
@@ -970,8 +997,8 @@ void CaloTowersCreationAlgo::convert(const CaloTowerDetId& id, const MetaTower&
970
997
971
998
// for ECAL the number of all bad channels is obtained here -----------------------
972
999
973
- /* old hyper slow algorithm
974
-
1000
+ /*
1001
+ // old hyper slow algorithm
975
1002
// get all possible constituents of the tower
976
1003
std::vector<DetId> allConstituents = theTowerConstituentsMap->constituentsOf(id);
977
1004
@@ -1000,11 +1027,25 @@ void CaloTowersCreationAlgo::convert(const CaloTowerDetId& id, const MetaTower&
1000
1027
}
1001
1028
1002
1029
// compare with fast version
1003
- auto numBadEcalChanNew = ecalBadChs[id.denseIndex()];
1004
- if (numBadEcalChanNew!=numBadEcalChan) std::cout << "wrong " << id << " " << numBadEcalChanNew << " " << numBadEcalChan << " " << mt.numBadEcalCells << std::endl;
1005
- */
1030
+
1031
+ // hcal:
1032
+ int inEcals[2] = {0,0};
1033
+ for (std::vector<std::pair<DetId,float> >::iterator i=metaContains.begin(); i!=metaContains.end(); ++i) {
1034
+ DetId detId = i->first;
1035
+ if(detId.det() == DetId::Ecal){
1036
+ if( detId.subdetId()==EcalBarrel ) inEcals[0] =1;
1037
+ else if( detId.subdetId()==EcalEndcap ) inEcals[1] =1;
1038
+ }
1039
+ }
1006
1040
1007
- numBadEcalChan = ecalBadChs[id.denseIndex ()];
1041
+ auto numBadEcalChanNew = ecalBadChs[id.denseIndex()]+mt.numBadEcalCells; // - mt.numRecEcalCells
1042
+ if (int(numBadEcalChanNew)!=int(numBadEcalChan)) {
1043
+ std::cout << "VI wrong " << ((inEcals[1]==1) ? "EE" : "" ) << id << " " << numBadEcalChanNew << " " << numBadEcalChan
1044
+ << " " << mt.numBadEcalCells << " " << mt.numRecEcalCells << std::endl;
1045
+ }
1046
+ */
1047
+
1048
+ numBadEcalChan = ecalBadChs[id.denseIndex ()]+mt.numBadEcalCells ; // - mt.numRecEcalCells
1008
1049
1009
1050
// --------------------------------------------------------------------------------------
1010
1051
@@ -1043,7 +1084,8 @@ void CaloTowersCreationAlgo::convert(const CaloTowerDetId& id, const MetaTower&
1043
1084
caloTower.setConstituents (std::move (contains));
1044
1085
caloTower.setHottestCellE (maxCellE);
1045
1086
1046
- // std::cout << "CaloTowerVI " << caloTower.id() << ' ' << caloTower.pt() << ' ' << caloTower.et() << ' ' << caloTower.mass() << ' '<< caloTower.constituentsSize() <<' '<< caloTower.towerStatusWord() << std::endl;
1087
+ // std::cout << "CaloTowerVI " << nalgo << ' ' << caloTower.id() << ((inEcals[1]==1) ? "EE " : " " ) << caloTower.pt() << ' ' << caloTower.et() << ' ' << caloTower.mass() << ' '
1088
+ // << caloTower.constituentsSize() <<' '<< caloTower.towerStatusWord() << std::endl;
1047
1089
1048
1090
}
1049
1091
@@ -1447,6 +1489,8 @@ void CaloTowersCreationAlgo::makeHcalDropChMap() {
1447
1489
1448
1490
void CaloTowersCreationAlgo::makeEcalBadChs () {
1449
1491
1492
+ // std::cout << "VI making EcalBadChs ";
1493
+
1450
1494
// for ECAL the number of all bad channels is obtained here -----------------------
1451
1495
1452
1496
for (auto ind=0U ; ind<CaloTowerDetId::kSizeForDenseIndexing ; ++ind) {
@@ -1464,15 +1508,8 @@ void CaloTowersCreationAlgo::makeEcalBadChs() {
1464
1508
ac_it!=allConstituents.end (); ++ac_it) {
1465
1509
1466
1510
if (ac_it->det ()!=DetId::Ecal) continue ;
1467
-
1468
- int thisEcalSevLvl = -999 ;
1469
-
1470
- if (ac_it->subdetId () == EcalBarrel) {
1471
- thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel ( *ac_it);
1472
- }
1473
- else if (ac_it->subdetId () == EcalEndcap) {
1474
- thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel ( *ac_it);
1475
- }
1511
+
1512
+ auto thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel ( *ac_it);
1476
1513
1477
1514
// check if the Ecal severity is ok to keep
1478
1515
std::vector<int >::const_iterator sevit = std::find (theEcalSeveritiesToBeExcluded.begin (),
@@ -1482,7 +1519,18 @@ void CaloTowersCreationAlgo::makeEcalBadChs() {
1482
1519
++numBadEcalChan;
1483
1520
}
1484
1521
}
1485
- }
1522
+
1523
+ // if (0!=numBadEcalChan) std::cout << id << ":" << numBadEcalChan << ", ";
1524
+ }
1525
+
1526
+ /*
1527
+ int tot=0;
1528
+ for (auto ind=0U; ind<CaloTowerDetId::kSizeForDenseIndexing; ++ind) {
1529
+ if (ecalBadChs[ind]!=0) ++tot;
1530
+ }
1531
+ std::cout << " | " << tot << std::endl;
1532
+ */
1533
+
1486
1534
}
1487
1535
1488
1536
@@ -1550,7 +1598,7 @@ unsigned int CaloTowersCreationAlgo::hcalChanStatusForCaloTower(const CaloRecHit
1550
1598
1551
1599
1552
1600
1553
- unsigned int CaloTowersCreationAlgo::ecalChanStatusForCaloTower (const CaloRecHit* hit) {
1601
+ std::tuple< unsigned int , bool > CaloTowersCreationAlgo::ecalChanStatusForCaloTower (const CaloRecHit* hit) {
1554
1602
1555
1603
// const DetId id = hit->detid();
1556
1604
@@ -1580,6 +1628,7 @@ unsigned int CaloTowersCreationAlgo::ecalChanStatusForCaloTower(const CaloRecHit
1580
1628
// exclude problematic channels as defined by ECAL.
1581
1629
// For definitions of ECAL severity levels see RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h
1582
1630
1631
+ bool isBad = (severityLevel == EcalSeverityLevel::kBad );
1583
1632
1584
1633
bool isRecovered = (severityLevel == EcalSeverityLevel::kRecovered );
1585
1634
@@ -1603,42 +1652,38 @@ unsigned int CaloTowersCreationAlgo::ecalChanStatusForCaloTower(const CaloRecHit
1603
1652
if (accepted ||
1604
1653
std::find (theEcalSeveritiesToBeUsedInBadTowers.begin (), theEcalSeveritiesToBeUsedInBadTowers.end (), severityLevel)
1605
1654
== theEcalSeveritiesToBeUsedInBadTowers.end ())
1606
- return CaloTowersCreationAlgo::IgnoredChan;
1655
+ return std::make_tuple ( CaloTowersCreationAlgo::IgnoredChan,isBad) ;
1607
1656
// this hit was either already accepted, or is not eligible for inclusion
1608
1657
}
1609
1658
else {
1610
1659
1611
1660
if (theRecoveredEcalHitsAreUsed || !useRejectedRecoveredEcalHits) {
1612
1661
// skip recovered hits either because they were already used or because there was an explicit instruction
1613
- return CaloTowersCreationAlgo::IgnoredChan;
1662
+ return std::make_tuple ( CaloTowersCreationAlgo::IgnoredChan,isBad); ;
1614
1663
}
1615
1664
else if (useRejectedRecoveredEcalHits) {
1616
- return CaloTowersCreationAlgo::RecoveredChan;
1665
+ return std::make_tuple ( CaloTowersCreationAlgo::RecoveredChan,isBad) ;
1617
1666
}
1618
1667
1619
1668
} // recovered channels
1620
1669
1621
1670
// clasify channels as problematic
1622
- return CaloTowersCreationAlgo::ProblematicChan;
1671
+ return std::make_tuple ( CaloTowersCreationAlgo::ProblematicChan,isBad) ;
1623
1672
1624
1673
} // treatment of rejected hits
1625
1674
1626
1675
1627
1676
1628
1677
// for normal reconstruction
1629
- if (severityLevel == EcalSeverityLevel::kGood ) return CaloTowersCreationAlgo::GoodChan;
1678
+ if (severityLevel == EcalSeverityLevel::kGood ) return std::make_tuple ( CaloTowersCreationAlgo::GoodChan, false ) ;
1630
1679
1631
1680
if (isRecovered) {
1632
- return (theRecoveredEcalHitsAreUsed) ?
1633
- CaloTowersCreationAlgo::RecoveredChan : CaloTowersCreationAlgo::BadChan;
1681
+ return std::make_tuple ( (theRecoveredEcalHitsAreUsed) ?
1682
+ CaloTowersCreationAlgo::RecoveredChan : CaloTowersCreationAlgo::BadChan, true ) ;
1634
1683
}
1635
1684
else {
1636
- if (!accepted) {
1637
- return CaloTowersCreationAlgo::BadChan;
1638
- }
1639
- else {
1640
- return CaloTowersCreationAlgo::ProblematicChan;
1641
- }
1685
+ return std::make_tuple (accepted ? CaloTowersCreationAlgo::ProblematicChan : CaloTowersCreationAlgo::BadChan,isBad);
1686
+
1642
1687
}
1643
1688
1644
1689
0 commit comments