ATLAS Offline Software
TrigEFTauDiKaonHypoTool.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 /********************************************************************
6  *
7  * NAME: TrigEFTauDiKaonHypoTool.cxx
8  * PACKAGE: Trigger/TrigHypothesis/TrigTauHypo
9  *
10  * AUTHOR: J. Silva based on TrigEFTauMVHypoTool
11  * CREATED: Feb. 17, 2021
12  *
13  *********************************************************************/
14 
15 #include <list>
16 #include <iterator>
17 #include <sstream>
18 
19 #include "GaudiKernel/StatusCode.h"
20 #include "GaudiKernel/TypeNameString.h"
21 
24 
27 
29 
31 
32 using namespace TrigCompositeUtils;
33 
35 // CONSTRUCTOR:
37 //
39  const std::string& name,
40  const IInterface* parent )
41  : base_class( type, name, parent ),
42  m_decisionId( HLT::Identifier::fromToolName( name ) )
43 {
44 }
45 
47 // DESTRUCTOR:
49 //
51 {
52 }
53 
55 // INITIALIZE:
57 //
58 
59 // ----------------------------------------------------------------------
61  // ----------------------------------------------------------------------
62 {
63 
64  msg() << MSG::DEBUG << "in initialize()" << endmsg;
65 
66  msg() << MSG::DEBUG << " REGTEST: EFTauDiKaonHypo will cut on "<<endmsg;
67  msg() << MSG::DEBUG << " REGTEST: param massTrkSysMin " << m_massTrkSysMin <<endmsg;
68  msg() << MSG::DEBUG << " REGTEST: param massTrkSysMax " << m_massTrkSysMax <<endmsg;
69  msg() << MSG::DEBUG << " REGTEST: param massTrkSysKaonMin " << m_massTrkSysKaonMin <<endmsg;
70  msg() << MSG::DEBUG << " REGTEST: param massTrkSysKaonMax " << m_massTrkSysKaonMax <<endmsg;
71  msg() << MSG::DEBUG << " REGTEST: param massTrkSysKaonPiMin " << m_massTrkSysKaonPiMin <<endmsg;
72  msg() << MSG::DEBUG << " REGTEST: param massTrkSysKaonPiMax " << m_massTrkSysKaonPiMax <<endmsg;
73  msg() << MSG::DEBUG << " REGTEST: param targetMassTrkSysKaonPi " << m_targetMassTrkSysKaonPi <<endmsg;
74  msg() << MSG::DEBUG << " REGTEST: param leadTrkPtMin " << m_leadTrkPtMin <<endmsg;
75  msg() << MSG::DEBUG << " REGTEST: param EtCalibMin " << m_EtCalibMin <<endmsg;
76  msg() << MSG::DEBUG << " REGTEST: param nTrackMin (included) " << m_nTrackMin <<endmsg;
77  msg() << MSG::DEBUG << " REGTEST: param nTrackMax (included) " << m_nTrackMax <<endmsg;
78  msg() << MSG::DEBUG << " REGTEST: param nWideTrackMax (included) " << m_nWideTrackMax <<endmsg;
79  msg() << MSG::DEBUG << " REGTEST: param EMPOverTrkSysPMax " << m_EMPOverTrkSysPMax <<endmsg;
80  msg() << MSG::DEBUG << " REGTEST: param dRmaxMax " << m_dRmaxMax <<endmsg;
81  msg() << MSG::DEBUG << " REGTEST: param etOverPtLeadTrkMin " << m_etOverPtLeadTrkMin <<endmsg;
82  msg() << MSG::DEBUG << " REGTEST: param etOverPtLeadTrkMax " << m_etOverPtLeadTrkMax <<endmsg;
83 
84  msg() << MSG::DEBUG << " REGTEST: ------ "<<endmsg;
85 
86 
88  {
89  msg() << MSG::ERROR << "EFTauDiKaonHypo is uninitialized! " << endmsg;
90  return StatusCode::FAILURE;
91  }
92 
93  msg() << MSG::DEBUG
94  << "Initialization of EFTauDiKaonHypo completed successfully"
95  << endmsg;
96 
97  return StatusCode::SUCCESS;
98 }
99 
100 
101 
103 {
104 
105  ATH_MSG_DEBUG("REGTEST:"<< name() << ": in execute()" );
106  bool pass=false;
107 
108  using namespace Monitored;
109 
110  auto PassedCuts = Monitored::Scalar<int>( "CutCounter", 0 );
111  auto massTrkSysAccepted = Monitored::Scalar<float>("massTrkSysAccepted", -10);
112  auto massTrkSysKaonAccepted = Monitored::Scalar<float>( "massTrkSysKaonAccepted", -10);
113  auto massTrkSysKaonPiAccepted = Monitored::Scalar<float>( "massTrkSysKaonPiAccepted", -10);
114  auto leadTrkPtAccepted = Monitored::Scalar<float>( "leadTrkPtAccepted", -10);
115  auto ptAccepted = Monitored::Scalar<float>( "ptAccepted", -10);
116  auto nTrackAccepted = Monitored::Scalar<float>( "nTrackAccepted", -1);
117  auto nWideTrackAccepted = Monitored::Scalar<float>( "nWideTrackAccepted", -1);
118  auto dRAccepted = Monitored::Scalar<float>( "dRAccepted", -1);
119  auto etOverPtLeadTrkAccepted = Monitored::Scalar<float>( "etOverPtLeadTrkAccepted", -10);
120  auto EMOverTrkSysPAccepted = Monitored::Scalar<float>( "EMOverTrkSysPAccepted", -10);
121  auto ninputTaus = Monitored::Scalar<int>( "nInputTaus", -1);
122  auto monitorIt = Monitored::Group(m_monTool, PassedCuts, massTrkSysAccepted, massTrkSysKaonAccepted, massTrkSysKaonPiAccepted, leadTrkPtAccepted, ptAccepted, nTrackAccepted, nWideTrackAccepted , dRAccepted, etOverPtLeadTrkAccepted, EMOverTrkSysPAccepted, ninputTaus);
123 
124 
125  PassedCuts = 0;
126 
127  if ( m_acceptAll ) {
128  pass = true;
129  ATH_MSG_DEBUG( "AcceptAll property is set: taking all events" );
130  } else {
131  pass = false;
132  ATH_MSG_DEBUG( "AcceptAll property not set: applying selection" );
133  }
134 
135 
136 
137  //get RoI descriptor
138  auto roiDescriptor = input.roi;
139  float roIZ = roiDescriptor->zed();
140  float roIEta = roiDescriptor->eta();
141  float roIPhi = roiDescriptor->phi();
142 
143  ATH_MSG_DEBUG( "Input RoI eta: " << roIEta << " Input RoI phi: " << roIPhi << " Input RoI z: " << roIZ);
144 
145 
146  // get tau objects from the trigger element:
147  //--------------------------------------------------
148 
149  auto TauContainer = input.taujetcontainer;
150  ninputTaus = TauContainer->size();
151 
152  for(auto Tau: *TauContainer){
153 
154  ATH_MSG_DEBUG( " tauRec candidate ");
155  PassedCuts++;
156 
157  // cut on calibrated pt:
158 
159  double EFet = Tau->pt()*1e-3; //Convert to GeV
160  ATH_MSG_DEBUG( " REGTEST: Et Calib "<<EFet);
161 
162  if(!( EFet > m_EtCalibMin*1e-3)) continue;
163  PassedCuts++;
164  ptAccepted = EFet;
165 
166  int numTrack = -100;
167  int numWideTrack = -100;
168  // cut on core and wide tracks:
169  numTrack = Tau->nTracks();
170  #ifndef XAODTAU_VERSIONS_TAUJET_V3_H
171  numWideTrack = Tau->nWideTracks();
172  #else
173  numWideTrack = Tau->nTracksIsolation();
174  #endif
175 
176  ATH_MSG_DEBUG( " REGTEST: Track size "<<numTrack );
177  ATH_MSG_DEBUG( " REGTEST: Wide Track size "<<numWideTrack );
178 
179  if (!( (numTrack >= m_nTrackMin) && (numTrack <= m_nTrackMax))) continue;
180  if (!( numWideTrack <= m_nWideTrackMax )) continue;
181  PassedCuts++;
182  nTrackAccepted = numTrack;
183  nWideTrackAccepted = numWideTrack;
184 
185  // cut on leading track pt:
186  float leadTrkPt = -1.;
188  ATH_MSG_DEBUG( " REGTEST: leadTrkPt "<< leadTrkPt);
189  if(!( leadTrkPt > m_leadTrkPtMin)) continue;
190  PassedCuts++;
191  leadTrkPtAccepted = leadTrkPt*1e-3; //Convert to GeV
192 
193  // cut on massTrkSys:
194  float massTrkSys = -1.;
196 
197  ATH_MSG_DEBUG(" REGTEST: massTrkSys "<< massTrkSys );
198  // for dikaon mass hypothesis, compute invariant mass with kaon mass
199  TLorentzVector my_kaons(0.,0.,0.,0.);
200  std::vector<TLorentzVector> my_trks;
201  // need to add checks for valid link
202  for (unsigned int i=0;i<Tau->nTracks();++i) {
203  const xAOD::TrackParticle* trk = 0;
204  TLorentzVector tmpKaon(0.,0.,0.,0.);
205 
206  try
207  {
208  #ifndef XAODTAU_VERSIONS_TAUJET_V3_H
209  trk = Tau->track(i);
210  #else
211  trk = Tau->track(i)->track();
212  #endif
213  }
214  catch(const std::exception& e)
215  {
216  msg() << MSG::WARNING << " REGTEST: EFTauDiKaonHypo, failed to get tau track link! " <<endmsg;
217  }
218 
219  if(trk) {
220  tmpKaon.SetPtEtaPhiM(trk->pt(), trk->eta(), trk->phi(), 493.677);
221  my_trks.push_back(trk->p4());
222  }
223  my_kaons = my_kaons + tmpKaon;
224  }
225  float massTrkSysKaon = my_kaons.M();
226  ATH_MSG_DEBUG( " REGTEST: massTrkSys with kaon mass hypo "<< massTrkSysKaon );
227  // kaon+pi mass hypo
228  double finalKPiMass = 0;
229  if(my_trks.size()==2){
230 
231  TLorentzVector tmpKaon;
232  tmpKaon.SetPtEtaPhiM(my_trks.at(0).Pt(), my_trks.at(0).Eta(), my_trks.at(0).Phi(), 493.677);
233  TLorentzVector tmpPion = my_trks.at(1);
234 
235  double kPiMass1 = (tmpKaon+tmpPion).M();
236 
237  tmpKaon.SetPtEtaPhiM(my_trks.at(1).Pt(), my_trks.at(1).Eta(), my_trks.at(1).Phi(), 493.677);
238  tmpPion = my_trks.at(0);
239 
240  double kPiMass2 = (tmpKaon+tmpPion).M();
241 
242  if(std::abs(kPiMass1 - m_targetMassTrkSysKaonPi) < std::abs(kPiMass2 - m_targetMassTrkSysKaonPi))
243  {
244  finalKPiMass = kPiMass1;
245  }else{
246  finalKPiMass = kPiMass2;
247  }
248  }
249  float massTrkSysKaonPi = finalKPiMass;
250  ATH_MSG_DEBUG( " REGTEST: massTrkSys with kaon+pi mass hypo "<< massTrkSysKaonPi );
251  if (!( (massTrkSys > m_massTrkSysMin) && (massTrkSys < m_massTrkSysMax) ) ) continue;
252  PassedCuts++;
253  massTrkSysAccepted = massTrkSys*1e-3; //Convert to GeV
254 
255  if (!( (massTrkSysKaon > m_massTrkSysKaonMin) && (massTrkSysKaon < m_massTrkSysKaonMax) ) ) continue;
256  PassedCuts++;
257  massTrkSysKaonAccepted = massTrkSysKaon*1e-3; //Convert to GeV
258 
259  if (!( (massTrkSysKaonPi >= m_massTrkSysKaonPiMin) && (massTrkSysKaonPi < m_massTrkSysKaonPiMax) ) ) continue; //use >= otherwise singlepion chain would fail here!
260  PassedCuts++;
261  massTrkSysKaonPiAccepted = massTrkSysKaonPi*1e-3; //Convert to GeV
262 
263  // cut on EMPOverTrkSysP:
264  float EMPOverTrkSysP = -1.;
266  ATH_MSG_DEBUG( " REGTEST: EMPOverTrkSysP "<< EMPOverTrkSysP);
267  if ( !(EMPOverTrkSysP < m_EMPOverTrkSysPMax) ) continue;
268  PassedCuts++;
269  EMOverTrkSysPAccepted = EMPOverTrkSysP;
270 
271  // cut on etOverPtLeadTrk:
272  float etOverPtLeadTrk = -1.;
274  ATH_MSG_DEBUG( " REGTEST: etOverPtLeadTrk "<< etOverPtLeadTrk);
276  PassedCuts++;
277  etOverPtLeadTrkAccepted = etOverPtLeadTrk;
278 
279  // cut on dRmax:
280  float dRmax = -1.;
282 
283  ATH_MSG_DEBUG( " REGTEST: dRmax "<< dRmax);
284  if( !( dRmax < m_dRmaxMax ) ) continue;
285  PassedCuts++;
286  dRAccepted = dRmax;
287 
288 
289  //-------------------------------------------------
290  // At least one Tau matching passed all cuts.
291  // Accept the event!
292  //-------------------------------------------------
293 
294  pass=true;
295 
296  ATH_MSG_DEBUG(" REGTEST: pass taurec is "<<pass);
297  } // end of loop in int numWideTrack = -100; tau objects.
298 
299  if(pass)
300  {
301 
302 
303  ATH_MSG_DEBUG( " REGTEST: TE accepted !! ");
304  // activate Trigger Element.
305  }
306  else
307  {
308  ATH_MSG_DEBUG( " REGTEST: No good tau found !! TE rejected ");
309  }
310 
311  return pass;
312 
313 }
314 
315 StatusCode TrigEFTauDiKaonHypoTool::decide( std::vector<TauJetInfo>& input ) const {
316 
317  for ( auto& i: input ) {
318  if ( passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
319  if ( decide( i ) ) {
320  addDecisionID( m_decisionId, i.decision );
321  }
322  }
323  }
324  return StatusCode::SUCCESS;
325 }
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:73
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TrigEFTauDiKaonHypoTool::m_massTrkSysKaonPiMax
Gaudi::Property< float > m_massTrkSysKaonPiMax
Definition: TrigEFTauDiKaonHypoTool.h:55
TrigEFTauDiKaonHypoTool::m_targetMassTrkSysKaonPi
Gaudi::Property< float > m_targetMassTrkSysKaonPi
Definition: TrigEFTauDiKaonHypoTool.h:56
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
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:77
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
TrigEFTauDiKaonHypoTool::m_massTrkSysMax
Gaudi::Property< float > m_massTrkSysMax
Definition: TrigEFTauDiKaonHypoTool.h:51
TrigEFTauDiKaonHypoTool::~TrigEFTauDiKaonHypoTool
virtual ~TrigEFTauDiKaonHypoTool()
Definition: TrigEFTauDiKaonHypoTool.cxx:50
Tau
Definition: EfficiencyPtPlots.cxx:9
TrigEFTauDiKaonHypoTool::m_massTrkSysMin
Gaudi::Property< float > m_massTrkSysMin
Definition: TrigEFTauDiKaonHypoTool.h:50
TrigEFTauDiKaonHypoTool::m_etOverPtLeadTrkMin
Gaudi::Property< float > m_etOverPtLeadTrkMin
Definition: TrigEFTauDiKaonHypoTool.h:65
xAOD::TauJetParameters::dRmax
@ dRmax
Get maximal dR of tracks associated to calo-seeded tau.
Definition: TauDefs.h:226
TrigEFTauDiKaonHypoTool::m_massTrkSysKaonMax
Gaudi::Property< float > m_massTrkSysKaonMax
Definition: TrigEFTauDiKaonHypoTool.h:53
xAOD::TrackParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TrackParticle_v1.cxx:129
TrigEFTauDiKaonHypoTool::m_EtCalibMin
Gaudi::Property< float > m_EtCalibMin
Definition: TrigEFTauDiKaonHypoTool.h:57
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
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
TrigEFTauDiKaonHypoTool::m_dRmaxMax
Gaudi::Property< float > m_dRmaxMax
Definition: TrigEFTauDiKaonHypoTool.h:63
TrigEFTauDiKaonHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigEFTauDiKaonHypoTool.h:68
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
calibdata.exception
exception
Definition: calibdata.py:496
TrigEFTauDiKaonHypoTool::TrigEFTauDiKaonHypoTool
TrigEFTauDiKaonHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigEFTauDiKaonHypoTool.cxx:38
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigEFTauDiKaonHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigEFTauDiKaonHypoTool.cxx:60
TrigEFTauDiKaonHypoTool::m_nWideTrackMax
Gaudi::Property< int > m_nWideTrackMax
Definition: TrigEFTauDiKaonHypoTool.h:61
xAOD::TauJetParameters::etOverPtLeadTrk
@ etOverPtLeadTrk
Definition: TauDefs.h:158
TauJetContainer.h
TrigEFTauDiKaonHypoTool::m_decisionId
HLT::Identifier m_decisionId
Cuts to be applied.
Definition: TrigEFTauDiKaonHypoTool.h:48
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
xAOD::TauJetParameters::massTrkSys
@ massTrkSys
Definition: TauDefs.h:161
TrigEFTauDiKaonHypoTool::m_nTrackMax
Gaudi::Property< int > m_nTrackMax
Definition: TrigEFTauDiKaonHypoTool.h:59
TrigEFTauDiKaonHypoTool::decide
virtual StatusCode decide(std::vector< ITrigEFTauMVHypoTool::TauJetInfo > &input) const override
TrigEFTauDiKaonHypoTool::m_leadTrkPtMin
Gaudi::Property< float > m_leadTrkPtMin
Definition: TrigEFTauDiKaonHypoTool.h:58
TrigEFTauDiKaonHypoTool::m_massTrkSysKaonPiMin
Gaudi::Property< float > m_massTrkSysKaonPiMin
Definition: TrigEFTauDiKaonHypoTool.h:54
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigEFTauDiKaonHypoTool.h
TrigEFTauDiKaonHypoTool::m_EMPOverTrkSysPMax
Gaudi::Property< float > m_EMPOverTrkSysPMax
Definition: TrigEFTauDiKaonHypoTool.h:62
TrackParticle.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
TrigEFTauDiKaonHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: TrigEFTauDiKaonHypoTool.h:66
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigRoiDescriptor.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrigEFTauDiKaonHypoTool::m_nTrackMin
Gaudi::Property< int > m_nTrackMin
Definition: TrigEFTauDiKaonHypoTool.h:60
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigEFTauDiKaonHypoTool::m_massTrkSysKaonMin
Gaudi::Property< float > m_massTrkSysKaonMin
Definition: TrigEFTauDiKaonHypoTool.h:52
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
xAOD::TauJetParameters::EMPOverTrkSysP
@ EMPOverTrkSysP
Definition: TauDefs.h:279
xAOD::TrackParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
ITrigEFTauMVHypoTool::TauJetInfo
Definition: ITrigEFTauMVHypoTool.h:22
TrigEFTauDiKaonHypoTool::m_etOverPtLeadTrkMax
Gaudi::Property< float > m_etOverPtLeadTrkMax
Definition: TrigEFTauDiKaonHypoTool.h:64
xAOD::TauJetParameters::leadTrkPt
@ leadTrkPt
Definition: TauDefs.h:159
Identifier
Definition: IdentifierFieldParser.cxx:14