ATLAS Offline Software
Loading...
Searching...
No Matches
TrigJetCRVARHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ********************************************************************
6//
7// NAME: TrigJetCRVARHypoTool.cxx
8// PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo
9//
10//
11// ********************************************************************
12
14#include "GaudiKernel/StatusCode.h"
15#include "CLHEP/Units/PhysicalConstants.h"
16
20#include "./xAODJetCollector.h"
21
25
27#include "CaloEvent/CaloCell.h"
29#include "CaloEvent/CaloClusterContainer.h"
30
31#include "CxxUtils/fpcompare.h"
32#include "CxxUtils/phihelper.h"
34
35using namespace TrigCompositeUtils;
36
38 const std::string& name,
39 const IInterface* parent) :
40 AthAlgTool(type, name, parent),
41 m_decisionId(HLT::Identifier::fromToolName(name)){
42
43}
44
45
48
49
50
52 ATH_MSG_VERBOSE( "In TrigJetCRVARHypoTool, initialize()." );
53
54 if (m_visitDebug){
55
56 DebugInfoCollector collector(name());
57 ATH_CHECK(m_helper->getDescription(collector));
58 auto s = collector.toString();
59
60 for(const auto& l : lineSplitter(s)){
61 ATH_MSG_INFO(l);
62 }
63 }
64
65 return StatusCode::SUCCESS;
66}
67
69
70 double jetEMF = jet->getAttribute<float>("EMFrac");
71 double jetRatio=-999;
72 if (CxxUtils::fpcompare::greater(jetEMF,0.)){
74 ATH_MSG_DEBUG( "Fails logR cut, EMF>=1" );
75 return false;
76 }
77 else jetRatio = log10(double(1./jetEMF - 1.));
78
79 if ( jetRatio < m_pufixLogRatio)
80 return false;
81
82 // Loop over all tracks above m_trackPtCut and reject the jet if the closest track is at dR(jet, track)< m_deltaR
83 auto jetPhi= jet->phi();
84 auto jetEta= jet->eta();
85 double pufixLR = -1;
86
87 if( jetRatio < m_jetlogRCut ) {
88 size_t nClusters = jet->numConstituents();
89 double clusterPU_sumEEM = 0; double clusterPU_sumE = 0;
90 for (size_t clust = 0; clust < nClusters; clust++) {
91 const xAOD::CaloCluster * aCluster = dynamic_cast<const xAOD::CaloCluster*> (jet->rawConstituent(clust));
92 double clusEEM = 0;
93 clusEEM+=(aCluster)->eSample(CaloSampling::EMB1);
94 clusEEM+=(aCluster)->eSample(CaloSampling::EMB2);
95 clusEEM+=(aCluster)->eSample(CaloSampling::EMB3);
96 clusEEM+=(aCluster)->eSample(CaloSampling::EME1);
97 clusEEM+=(aCluster)->eSample(CaloSampling::EME2);
98 clusEEM+=(aCluster)->eSample(CaloSampling::EME3);
99 clusEEM+=(aCluster)->eSample(CaloSampling::FCAL1);
100 double lambda = aCluster->getMomentValue(xAOD::CaloCluster::CENTER_LAMBDA);
101
102 if (lambda > 500) continue;
103
104 double d_eta = aCluster->rawEta() - jetEta;
105 double d_phi = xAOD::P4Helpers::deltaPhi(aCluster->rawPhi(),jetPhi);
106 double d_R2 = d_eta*d_eta + d_phi*d_phi;
107
108 if (d_R2 < 0.15*0.15) continue;
109 clusterPU_sumEEM+=clusEEM/1000.;
110 clusterPU_sumE+=aCluster->rawE()/1000.;
111 }
112
113 double jetEEM_EMscale = 0; double jetE_EMscale = 0; //Working on EM scale because calE() doesn't always return correct EEM and cluster moment EMF not accessable during testing
114 std::vector<double> samplingEnergy = jet->getAttribute<std::vector<double> >("EnergyPerSampling");
115
116 for(size_t s=0; s<samplingEnergy.size(); s++) {
117 double samplingE = 0.001*(samplingEnergy.at(s));
118 if ( s < 8 || (s > 20 && s < 28) ) jetEEM_EMscale+=samplingE; // EM layers 0-7 and 21-27
119 jetE_EMscale+=samplingE;
120 }
121
122 double pufixEMF = -999;
123 if (CxxUtils::fpcompare::equal (0.,double(jetE_EMscale - clusterPU_sumE))) pufixEMF=999;
124 else pufixEMF = (jetEEM_EMscale - clusterPU_sumEEM)/(jetE_EMscale - clusterPU_sumE);
125 if (CxxUtils::fpcompare::greater(pufixEMF,0.)){
126 if(CxxUtils::fpcompare::greater_equal(pufixEMF,1.0)) pufixLR = -999.;
127 else pufixLR = log10(double(1./pufixEMF - 1.));
128 }else return true;
129
130 if ( pufixLR < m_jetlogRCut) return false;
131
132 jetRatio = pufixLR;
133 }
134 return true;
135 }
136
137return true;
138}
139
140
141
143
144 auto jet = input.jet;
145 auto cellContainer = input.cells;
146 auto alltracks= jet->getAttribute<std::vector<ElementLink<xAOD::IParticleContainer> >>("TracksForMinimalJetTag");
147 //Checking jet logRatio requirements
148 if (!emf_dis(jet)){
149 return false;
150 }
151
152 auto jetPhi= jet->phi();
153 auto jetEta= jet->eta();
154
155 // Loop over all tracks above m_trackPtCut and reject the jet if the closest track is at dR(jet, track)< m_deltaR
156 for ( unsigned int index(0); index < alltracks.size(); index++ ) {
157 const xAOD::IParticle* track = *( alltracks.at(index));
158 if(track->pt() < m_trackPtCut ) continue;
159 double phi = track->p4().Phi();
160 double eta = track->p4().Eta() ;
161 double dR = xAOD::P4Helpers::deltaR( eta, phi, jetEta, jetPhi );
162 if (dR<m_deltaR) return false;
163 }
164
165 if(m_doBIBrm==1){
166 int countCaloCell=0;
167 double countCell_layer[4] = {0,0,0,0};
168
169 for(CaloCellContainer::const_iterator celliter = cellContainer->begin(); celliter != cellContainer->end(); ++celliter){
170 //LoF cell selection in tile:
171 if((*celliter)->caloDDE()->is_tile() && (*celliter)->energy() > m_minCellEt){
172 double d_phi = xAOD::P4Helpers::deltaPhi( (*celliter)->phi(), jetPhi );
173 double d_R = xAOD::P4Helpers::deltaR( (*celliter)->eta(), (*celliter)->phi(), jetEta, jetPhi );
174 //select cells in a horizontal line, not being part of the jet and timing consistent with BIB
175 if(std::abs(d_phi) < 0.2 && d_R > 0.4){
176 //-early
177 float t = (*celliter)->time();
178 if(t < m_celltime){
179 // check cell's time consitency with BIB
180 float x = (*celliter)->x();
181 float y = (*celliter)->y();
182 float z = (*celliter)->z();
183 float r = sqrt(x*x + y*y);
184
185 if((std::abs(t - (z-sqrt(z*z + r*r))/CLHEP::c_light) < m_dBIBtime) || (std::abs(t - (-z-sqrt(z*z + r*r))/CLHEP::c_light) < m_dBIBtime)){
186 // for selected cells, store in which layer they are
187 if(r<2200){ countCell_layer[0]++;}
188 else if(r>=2200 && r<2600){ countCell_layer[1]++;}
189 else if(r>=2600 && r<3100){ countCell_layer[2]++;}
190 else if(r>=3100){ countCell_layer[3]++;}
191 }
192 }
193 }
194 }
195 }
196
197 // get max number of selected cells in a layer
198 for(int i=0; i<4; i++){
199 if(countCaloCell<countCell_layer[i]) countCaloCell=countCell_layer[i];
200 }
201
202 //apply cut on number of cells here
203 if (countCaloCell>=m_countCaloCell) return false;
204
205 return true;
206}
207
208return true;
209}
210
211StatusCode TrigJetCRVARHypoTool::decide( std::vector<JetInfo>& input ) const{
212 for ( JetInfo& j: input ) {
213 if ( passed ( m_decisionId.numeric(), j.previousDecisionIDs ) ) {
214
215 if ( decide_on_single_jet( j ) ) {
216 addDecisionID( m_decisionId, j.decision );
217 return StatusCode::SUCCESS;
218 }
219 }
220 }
221 return StatusCode::SUCCESS;
222}
223
224
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual std::string toString() const override
bool decide_on_single_jet(JetInfo &input) const
Auxiluary method, single jet selection.
ToolHandle< ITrigJetHypoToolHelper > m_helper
TrigJetCRVARHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override final
Gaudi::Property< float > m_dBIBtime
bool emf_dis(const xAOD::Jet *jet) const
Gaudi::Property< float > m_pufixLogRatio
Gaudi::Property< float > m_trackPtCut
StatusCode decide(std::vector< JetInfo > &decisions) const
decides upon a collection of jets
Gaudi::Property< int > m_countCaloCell
Gaudi::Property< float > m_celltime
Gaudi::Property< float > m_deltaR
Gaudi::Property< float > m_jetlogRCut
Gaudi::Property< float > m_minCellEt
Gaudi::Property< bool > m_doBIBrm
Gaudi::Property< bool > m_visitDebug
flt_t rawE() const
double getMomentValue(MomentType type) const
Retrieve individual moment - no check for existance! Returns -999 on error.
flt_t rawPhi() const
Get in signal state UNCALIBRATED.
flt_t rawEta() const
Get in signal state UNCALIBRATED.
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
Class providing the definition of the 4-vector interface.
Workaround x86 precision issues for FP inequality comparisons.
int r
Definition globals.cxx:22
std::vector< std::string > lineSplitter(const std::string &s, char delimiter)
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition fpcompare.h:114
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition fpcompare.h:140
bool greater_equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition fpcompare.h:192
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.
Definition index.py:1
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Helper for azimuthal angle calculations.