ATLAS Offline Software
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 
13 #include "TrigJetCRVARHypoTool.h"
14 #include "GaudiKernel/StatusCode.h"
15 #include "CLHEP/Units/PhysicalConstants.h"
16 
19 #include "./DebugInfoCollector.h"
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 
35 using namespace TrigCompositeUtils;
36 
38  const std::string& name,
39  const IInterface* parent) :
41  m_decisionId(HLT::Identifier::fromToolName(name)){
42 
43 }
44 
45 
47 }
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 
137 return 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 
208 return true;
209 }
210 
211 StatusCode 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 
TrigJetCRVARHypoTool.h
xAOD::CaloCluster_v1::rawE
flt_t rawE() const
lineSplitter.h
beamspotman.r
def r
Definition: beamspotman.py:676
TrigJetCRVARHypoTool::m_dBIBtime
Gaudi::Property< float > m_dBIBtime
Definition: TrigJetCRVARHypoTool.h:109
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
DebugInfoCollector::toString
virtual std::string toString() const override
Definition: DebugInfoCollector.cxx:70
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::CaloCluster_v1::rawEta
flt_t rawEta() const
Get in signal state UNCALIBRATED.
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
TrigJetCRVARHypoTool::emf_dis
bool emf_dis(const xAOD::Jet *jet) const
Definition: TrigJetCRVARHypoTool.cxx:68
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::CaloCluster_v1::getMomentValue
double getMomentValue(MomentType type) const
Retrieve individual moment - no check for existance! Returns -999 on error.
Definition: CaloCluster_v1.h:906
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigJetCRVARHypoTool::~TrigJetCRVARHypoTool
~TrigJetCRVARHypoTool()
Definition: TrigJetCRVARHypoTool.cxx:46
TrigJetCRVARHypoTool::decide_on_single_jet
bool decide_on_single_jet(JetInfo &input) const
Auxiluary method, single jet selection.
Definition: TrigJetCRVARHypoTool.cxx:142
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
index
Definition: index.py:1
xAODP4Helpers.h
TrigJetCRVARHypoTool::m_visitDebug
Gaudi::Property< bool > m_visitDebug
Definition: TrigJetCRVARHypoTool.h:91
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
TrigJetCRVARHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigJetCRVARHypoTool.h:85
TrigJetCRVARHypoTool::m_deltaR
Gaudi::Property< float > m_deltaR
Definition: TrigJetCRVARHypoTool.h:101
CaloCell_ID_FCS::FCAL1
@ FCAL1
Definition: FastCaloSim_CaloCell_ID.h:41
CaloCell.h
TrigJetCRVARHypoTool::m_countCaloCell
Gaudi::Property< int > m_countCaloCell
Definition: TrigJetCRVARHypoTool.h:110
xAOD::CaloCluster_v1::CENTER_LAMBDA
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
Definition: CaloCluster_v1.h:136
lineSplitter
std::vector< std::string > lineSplitter(const std::string &s, char delimiter)
Definition: lineSplitter.cxx:8
xAOD::P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: xAODP4Helpers.h:69
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
x
#define x
CxxUtils::fpcompare::greater
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:140
CxxUtils::fpcompare::equal
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:114
TrigCompositeUtils.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
TrigJetCRVARHypoTool::JetInfo
Definition: TrigJetCRVARHypoTool.h:58
TrigJetCRVARHypoTool::TrigJetCRVARHypoTool
TrigJetCRVARHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigJetCRVARHypoTool.cxx:37
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
TrigJetCRVARHypoTool::m_jetlogRCut
Gaudi::Property< float > m_jetlogRCut
Definition: TrigJetCRVARHypoTool.h:97
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCluster.h
z
#define z
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DebugInfoCollector.h
DebugInfoCollector
Definition: DebugInfoCollector.h:13
fpcompare.h
Workaround x86 precision issues for FP inequality comparisons.
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
xAODJetCollector.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigJetCRVARHypoTool::m_trackPtCut
Gaudi::Property< float > m_trackPtCut
Definition: TrigJetCRVARHypoTool.h:100
TrigCompositeContainer.h
TrigJetCRVARHypoTool::m_minCellEt
Gaudi::Property< float > m_minCellEt
Definition: TrigJetCRVARHypoTool.h:107
CxxUtils::fpcompare::greater_equal
bool greater_equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:192
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
xAODJetAsIJetFactory.h
phihelper.h
Helper for azimuthal angle calculations.
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
CaloCellContainer.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
DeMoScan.index
string index
Definition: DeMoScan.py:364
y
#define y
xAOD::CaloCluster_v1::rawPhi
flt_t rawPhi() const
Get in signal state UNCALIBRATED.
TrigJetCRVARHypoTool::m_celltime
Gaudi::Property< float > m_celltime
Definition: TrigJetCRVARHypoTool.h:108
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigJetCRVARHypoTool::initialize
virtual StatusCode initialize() override final
Definition: TrigJetCRVARHypoTool.cxx:51
HLTIdentifier.h
TrigJetCRVARHypoTool::m_helper
ToolHandle< ITrigJetHypoToolHelper > m_helper
Definition: TrigJetCRVARHypoTool.h:87
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigJetCRVARHypoTool::m_pufixLogRatio
Gaudi::Property< float > m_pufixLogRatio
Definition: TrigJetCRVARHypoTool.h:99
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AthAlgTool
Definition: AthAlgTool.h:26
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
TrigJetCRVARHypoTool::m_doBIBrm
Gaudi::Property< bool > m_doBIBrm
Definition: TrigJetCRVARHypoTool.h:103
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
TrigJetCRVARHypoTool::decide
StatusCode decide(std::vector< JetInfo > &decisions) const
decides upon a collection of jets
Definition: TrigJetCRVARHypoTool.cxx:211
Identifier
Definition: IdentifierFieldParser.cxx:14