ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaPrecisionCaloHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <algorithm>
11
13
14
15namespace TCU = TrigCompositeUtils;
16
18 const std::string& name,
19 const IInterface* parent )
20 : base_class( type, name, parent ),
21 m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
22
24 ATH_MSG_DEBUG( "Initialization completed successfully" );
25 ATH_MSG_DEBUG( "EtaBins = " << m_etabin );
26 ATH_MSG_DEBUG( "ETthr = " << m_eTthr << "( lo )/" << m_eT2thr << "( hi )" );
27 ATH_MSG_DEBUG( "dPHICLUSTERthr = " << m_dphicluster );
28 ATH_MSG_DEBUG( "dETACLUSTERthr = " << m_detacluster );
29
30 if ( m_etabin.size() == 0 ) {
31 ATH_MSG_ERROR( " There are no cuts set (EtaBins property is an empty list)" );
32 return StatusCode::FAILURE;
33 }
34
35 unsigned int nEtaBin = m_etabin.size();
36#define CHECK_SIZE( __n) if ( m_##__n.size() != (nEtaBin - 1) ) \
37 { ATH_MSG_DEBUG(" __n size is " << m_##__n.size() << " but needs to be " << (nEtaBin - 1) ); return StatusCode::FAILURE; }
38
39 CHECK_SIZE( eTthr );
40 CHECK_SIZE( eT2thr );
41#undef CHECK_SIZE
42
43
44
45 ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
46
47 if ( not m_monTool.name().empty() )
48 CHECK( m_monTool.retrieve() );
49
50 return StatusCode::SUCCESS;
51}
52
53
55
56 bool pass = false;
57
58 auto mon_dEta = Monitored::Scalar( "dEta", -1. );
59 auto mon_dPhi = Monitored::Scalar( "dPhi", -1. );
60 auto mon_eta = Monitored::Scalar( "Eta", -99. );
61 auto mon_phi = Monitored::Scalar( "Phi", -99. );
62 auto mon_eT_Cluster = Monitored::Scalar( "Et_em" , -1.0 );
63 auto cutCounter = Monitored::Scalar<int>( "CutCounter", -1 );
64 auto monitorIt = Monitored::Group( m_monTool, mon_dEta, mon_dPhi, mon_eta, mon_phi, mon_eT_Cluster,cutCounter);
65
66
67 // when leaving scope it will ship data to monTool
68
69 float dEta(0), dPhi(0), eta(0), phi(0), eT_Cluster(0);
70
71 auto roiDescriptor = input.roi;
72
73
74 if ( fabs( roiDescriptor->eta() ) > 2.6 ) {
75 ATH_MSG_DEBUG( "REJECT The cluster had eta coordinates beyond the EM fiducial volume : " << roiDescriptor->eta() << "; stop the chain now" );
76 pass=false; // special case
77 return pass;
78 }
79
80 cutCounter++;
81 ATH_MSG_DEBUG( "; RoI ID = " << roiDescriptor->roiId()
82 << ": Eta = " << roiDescriptor->eta()
83 << ", Phi = " << roiDescriptor->phi() );
84
85 // fill local variables for RoI reference position
86 double etaRef = roiDescriptor->eta();
87 double phiRef = roiDescriptor->phi();
88
89 // correct phi the to right range ( probably not needed anymore )
90 if ( fabs( phiRef ) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
91
92
93 auto pClus = input.cluster;
94 eta = pClus->eta();
95 phi = pClus->phi();
96
97 float absEta = fabs( pClus->eta() );
98 const int cutIndex = findCutIndex( absEta );
99
100 dEta = pClus->eta() - etaRef;
101 // Deal with angle diferences greater than Pi
102 dPhi = fabs( pClus->phi() - phiRef );
103 dPhi = ( dPhi < M_PI ? dPhi : 2*M_PI - dPhi ); // TB why only <
104 eT_Cluster = pClus->et();
105 // apply cuts: DeltaEta( clus-ROI )
106 ATH_MSG_DEBUG( "CaloCluster: eta=" << pClus->eta()
107 << " roi eta=" << etaRef << " DeltaEta=" << dEta
108 << " cut: <" << m_detacluster );
109
110 if ( fabs(dEta) > m_detacluster ) {
111 ATH_MSG_DEBUG("REJECT Cluster dEta cut failed");
112 return pass;
113 }
114 mon_eta = eta;
115 mon_dEta = dEta;
116 cutCounter++; //Deta
117
118 // DeltaPhi( clus-ROI )
119 ATH_MSG_DEBUG( ": phi=" << pClus->phi()
120 << " roi phi="<< phiRef << " DeltaPhi="<< dPhi
121 << " cut: <" << m_dphicluster );
122
123 if( dPhi > m_dphicluster ) {
124 ATH_MSG_DEBUG("REJECT Clsuter dPhi cut failed");
125 return pass;
126 }
127 mon_dPhi = dPhi;
128 mon_phi = phi;
129 cutCounter++; //DPhi
130
131 // eta range
132 if ( cutIndex == -1 ) { // VD
133 ATH_MSG_DEBUG( "Cluster eta: " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
134 return pass;
135 } else {
136 ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex );
137 }
138 cutCounter++; // passed eta cut
139
140 // ET_em
141 ATH_MSG_DEBUG( "PrecisionCaloCluster: ET_em=" << eT_Cluster << " cut: >" << m_eTthr[cutIndex] );
142 if ( eT_Cluster < m_eTthr[cutIndex] ) {
143 ATH_MSG_DEBUG("REJECT et cut failed");
144 return pass;
145 }
146 mon_eT_Cluster = eT_Cluster;
147
148 // got this far => passed!
149 pass = true;
150 cutCounter++;
151 // Reach this point successfully
152 ATH_MSG_DEBUG( "pass = " << pass );
153
154 return pass;
155
156}
157
159 const float absEta = std::abs(eta);
160
161 auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
162 if ( binIterator == m_etabin.end() ) {
163 return -1;
164 }
165 return binIterator - m_etabin.begin();
166}
167
168
169StatusCode TrigEgammaPrecisionCaloHypoTool::decide( std::vector<ClusterInfo>& input ) const {
170 for ( auto& i: input ) {
171 if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
172 if ( decide( i ) ) {
173 TCU::addDecisionID( m_decisionId, i.decision );
174 }
175 }
176 }
177 return StatusCode::SUCCESS;
178}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Header file to be included by clients of the Monitored infrastructure.
#define CHECK_SIZE(__n)
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
Gaudi::Property< std::vector< float > > m_etabin
selection variable for PRECISION calo selection:eta bins
virtual StatusCode decide(std::vector< ITrigEgammaPrecisionCaloHypoTool::ClusterInfo > &input) const override
Gaudi::Property< std::vector< float > > m_eTthr
TrigEgammaPrecisionCaloHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< GenericMonitoringTool > m_monTool
Gaudi::Property< std::vector< float > > m_eT2thr
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.