PFSubtractionStatusSetter.cxx 4.46 KB
Newer Older
Mark Hodgkinson's avatar
Mark Hodgkinson committed
1
/*                                                                                                                                                                                                                                          
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration                                                                                                                                                                   
Mark Hodgkinson's avatar
Mark Hodgkinson committed
3
4
5
*/


6
7
8
9
10
11
#include "GaudiKernel/IMessageSvc.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/Bootstrap.h"

#include "AthenaKernel/getMessageSvc.h"

12
13
14
15
16
#include "eflowRec/PFSubtractionStatusSetter.h"
#include "eflowRec/eflowCaloObject.h"
#include "eflowRec/eflowRecCluster.h"
#include "eflowRec/eflowTrackClusterLink.h"

17
18
19
20
PFSubtractionStatusSetter::PFSubtractionStatusSetter() : AthMessaging(Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc"),
                  "PFSubtractionStatusSetter"){}

void PFSubtractionStatusSetter::markSubtractionStatus(const std::vector<std::pair<xAOD::CaloCluster*, bool> >& clusterList, std::vector<float>& clusterSubtractedEnergyRatios, eflowCaloObject& thisEflowCaloObject, unsigned int trackIndex){
21
22
23
  //An eflowCaloObject may have one cluster and N tracks, and then one would have N eflowTrackClusterLink* for each track-cluster pair
  //Hence there can be more entries in the track cluster link list due to duplication

24
25
  ATH_MSG_DEBUG("Executing markSubtractionStatus and have clusterList of size " << clusterList.size() << ", clusterSubtractedEnergyRatios of size " << clusterSubtractedEnergyRatios.size() << " and trackIndex of " << trackIndex);  

26
  const std::vector<std::pair<eflowTrackClusterLink*, float> >& matchedTrackList = thisEflowCaloObject.efRecLink();
27

28
  unsigned int clusCounter = 0;
29
30
  for (auto thisClusterPair : clusterList){
    xAOD::CaloCluster* thisCluster = thisClusterPair.first;
31
    ATH_MSG_DEBUG("Cluster with e and eta " << thisCluster->e() << " and " << thisCluster->eta());
32
    unsigned int counter = 0;
33
    for (const auto & thisTrackClusterLinkPair : matchedTrackList){
34
35
36
37
38
39
40
41

      if (trackIndex != thisTrackClusterLinkPair.first->getTrack()->getTrack()->index()){
        counter++;
        continue;
      }

      ATH_MSG_DEBUG("Track with e and eta " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->e() << " and " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->eta());

42
      //if the subtraction status is already true, then no need to update it
43
44
45
      if (!std::isnan(thisTrackClusterLinkPair.second)) {
    	  counter++;
	      continue;
46
      }
47
48
49

      ATH_MSG_DEBUG("Not already subtracted");

50
51
      //eflowTrackCluster link returns an eflowRecCluster pointer, which in turn returns an xAOD:;CaloCluster* pointer
      xAOD::CaloCluster* thisMatchedTrackCluster = (thisTrackClusterLinkPair.first)->getCluster()->getCluster();
52
53
54
55
56
57
58
59
      //Now we can do a pointer comparison of the two clusters to see if we have a match
      ATH_MSG_DEBUG("Comparing clusters with energies " << thisCluster->e() << " and " << thisMatchedTrackCluster->e());
      if (thisCluster == thisMatchedTrackCluster){      
        ATH_MSG_DEBUG("Passed cluster energy check");
	      if (thisClusterPair.second && !std::isnan(clusterSubtractedEnergyRatios[clusCounter])) {
          ATH_MSG_DEBUG("Will set ratio to be " << clusterSubtractedEnergyRatios[clusCounter]);
          thisEflowCaloObject.setTrackClusterLinkSubtractionStatus(counter, clusterSubtractedEnergyRatios[clusCounter]);        
        }
60
61
62
      }//if have a match of the cluster
      counter++;
    }//loop on track cluster link pairs
63
    clusCounter++;
64
  }//loop on cluster pair list
65

66
67
}

68
void PFSubtractionStatusSetter::markAllTracksAnnihStatus(eflowCaloObject& thisEflowCaloObject){
69

70
  ATH_MSG_DEBUG("Executing markAllTracksAnnihStatus");
71

72
73
74
75
76
77
78
79
80
81
  const std::vector<std::pair<eflowTrackClusterLink*, float> >& matchedTrackList = thisEflowCaloObject.efRecLink();
  
  unsigned int counter = 0;
  for (const auto & thisTrackClusterLinkPair : matchedTrackList){
    ATH_MSG_DEBUG("Track with e and eta " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->e() << " and " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->eta());
    ATH_MSG_DEBUG("will annihilate cluster with e and eta " << thisTrackClusterLinkPair.first->getCluster()->getCluster()->e() << " and " << thisTrackClusterLinkPair.first->getCluster()->getCluster()->eta());
    thisEflowCaloObject.setTrackClusterLinkSubtractionStatus(counter, 0.0);  
    counter++;
  }
  
82
83
}