324 std::vector<DetId> boundaryDetIds;
325 std::vector<int> stati;
327 double boundaryEnergy = 0;
328 double boundaryET = 0;
329 int beCellCounter = 0;
330 bool nextToBorder =
false;
334 boundaryEnergy +=
hit->energy();
335 EcalDetId hitdetid = (EcalDetId)
hit->
id();
336 boundaryDetIds.push_back(hitdetid);
339 double eta = cellGeom->getPosition().eta();
340 boundaryET +=
hit->energy() / cosh(
eta);
343 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"Find Boundary RecHits...";
347 <<
"Starting at : (" << ((
EBDetId)hitdetid).ieta() <<
"," << ((
EBDetId)hitdetid).iphi() <<
")";
350 <<
"Starting at : (" << ((
EEDetId)hitdetid).ix() <<
"," << ((
EEDetId)hitdetid).iy() <<
")";
357 bool reverseOrientation =
false;
360 EcalDetId
start = hitdetid;
361 EcalDetId current =
start;
362 int current_status = 0;
365 bool startAlgo =
false;
369 theEcalNav->setHome(current);
372 int status = (chit != ecalStatus.
end()) ? chit->getStatusCode() & 0x1F : -1;
378 currDirection =
turnLeft(currDirection, reverseOrientation);
381 throw cms::Exception(
"NoStartingDirection") <<
"EcalBoundaryInfoCalculator: No starting direction can be found: " 382 "This should never happen if RecHit has a dead neighbour!";
387 currDirection =
turnRight(currDirection, reverseOrientation);
390 bool nextIsStart =
false;
391 bool atBorder =
false;
393 while (!nextIsStart) {
394 bool nextStepFound =
false;
397 while (!nextStepFound) {
399 theEcalNav->setHome(current);
402 status = (chit != ecalStatus.
end()) ? chit->getStatusCode() & 0x1F : -1;
405 bool present =
false;
406 for (std::vector<int>::const_iterator
s = stati.begin();
s != stati.end(); ++
s) {
416 nextStepFound =
true;
418 currDirection =
turnRight(currDirection, reverseOrientation);
420 }
else if (
next == EcalDetId(0)) {
422 currDirection =
turnLeft(currDirection, reverseOrientation);
425 nextStepFound =
true;
430 <<
"EcalBoundaryInfoCalculator: No valid next direction can be found: This should never happen!";
440 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"Boundary path reached starting position!";
445 <<
"Next step: " << (EcalDetId)
next <<
" Status: " <<
status <<
" Start: " << (EcalDetId)
start;
448 if ((!atBorder ||
status == 0) && !nextIsStart) {
449 boundaryDetIds.push_back(
next);
454 boundaryEnergy += nexthit.
energy();
456 eta = cellGeom->getPosition().eta();
457 boundaryET += nexthit.
energy() / cosh(
eta);
461 if (current_status == 0 &&
status == 0 && atBorder) {
463 currDirection =
turnRight(currDirection, reverseOrientation);
466 if (
status == 0 && atBorder) {
468 currDirection =
turnLeft(currDirection, reverseOrientation);
472 currDirection =
turnLeft(currDirection, reverseOrientation);
475 currDirection =
turnRight(currDirection, reverseOrientation);
485 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"<<<<<<<<<<<<<<< Final Boundary object <<<<<<<<<<<<<<<";
487 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"no of neighbouring DetIds: " << boundaryDetIds.size();
488 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"boundary energy: " << boundaryEnergy;
489 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"boundary ET: " << boundaryET;
490 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"no of cells contributing to boundary energy: " << beCellCounter;
491 edm::LogInfo(
"EcalBoundaryInfoCalculator") <<
"Channel stati: ";
492 for (std::vector<int>::iterator it = stati.begin(); it != stati.end(); ++it) {
493 edm::LogInfo(
"EcalBoundaryInfoCalculator") << *it <<
" ";
499 boundInfo.
subdet = hitdetid.subdet();
500 boundInfo.
detIds = boundaryDetIds;
CdOrientation turnRight(CdOrientation currDirection, bool reverseOrientation) const
const_iterator find(uint32_t rawId) const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
BoundaryInformation boundaryRecHits(const EcalRecHitCollection &, const EcalRecHit *, const CaloTopology &theCaloTopology, const EcalChannelStatus &ecalStatus, const CaloGeometry &geometry) const
const_iterator end() const
Log< level::Info, false > LogInfo
EcalDetId makeStepInDirection(CdOrientation direction, const CaloNavigator< EcalDetId > *theNavi) const
std::vector< Item >::const_iterator const_iterator
std::unique_ptr< CaloNavigator< EcalDetId > > initializeEcalNavigator(DetId startE, const CaloTopology &theCaloTopology, EcalSubdetector ecalSubDet) const
CdOrientation turnLeft(CdOrientation currDirection, bool reverseOrientation) const
iterator find(key_type k)
const_iterator end() const