ATLAS Offline Software
Loading...
Searching...
No Matches
TrigHitDVHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
4 * Trigger Hypo Tool, that is aimed at triggering displaced vertex
5 * author Kunihiro Nagano <kunihiro.nagano@cern.ch> - KEK
6*/
7#include "TrigHitDVHypoAlg.h"
11#include "GaudiKernel/SystemOfUnits.h"
13#include "GaudiKernel/PhysicalConstants.h"
16
18#include "CxxUtils/phihelper.h"
20
21#include "TFile.h"
22#include "TTree.h"
23
24#include <vector>
25#include <unordered_map>
26
41
43
44// ------------------------------------------------------------------------------------------------
45// ------------------------------------------------------------------------------------------------
46
47TrigHitDVHypoAlg::TrigHitDVHypoAlg( const std::string& name,
48 ISvcLocator* pSvcLocator ) :
49 ::HypoBase( name, pSvcLocator ),
50 m_lumiBlockMuTool("LumiBlockMuTool/LumiBlockMuTool")
51{}
52
53// ------------------------------------------------------------------------------------------------
54// ------------------------------------------------------------------------------------------------
55
57{
60 CHECK( m_hypoTools.retrieve() );
61 for ( auto & tool: m_hypoTools ) {
62 ATH_MSG_VERBOSE( "+++++ Hypo Tool name: " << tool->name() );
63 std::cmatch results;
64 if( std::regex_search(tool->name().c_str(),results,std::regex("hitdvjet(\\d+)_(\\w+)_")) ) {
65 std::string sth = results[1].str();
66 std::string swp = results[2].str();
67 ATH_MSG_VERBOSE( " thres = " << sth << ", wp = " << swp );
68 int thres = std::stoi(sth);
69 if( thres < m_tools_lowest_jetEt ) m_tools_lowest_jetEt = thres;
70 if( swp == "loose" && m_tools_loosest_wp >= 1 ) m_tools_loosest_wp = 1;
71 if( swp == "medium" && m_tools_loosest_wp >= 2 ) m_tools_loosest_wp = 2;
72 if( swp == "tight" && m_tools_loosest_wp >= 3 ) m_tools_loosest_wp = 3;
73 }
74 }
75 ATH_MSG_DEBUG( "Lowest jetEt used in hypo tools = " << m_tools_lowest_jetEt << " (GeV)" );
76 ATH_MSG_DEBUG( "Loosest WP used in hypo tools = " << m_tools_loosest_wp << " (loose=1,medium=2,tight=3)");
77 // loose : eta<2.0, SP seed=true, BDT eff=0.9
78 // medium: eta<2.0, SP seed=false, BDT eff=0.75
79 // tight : eta<1.0, SP seed=false, BDT eff=0.75
80
81 CHECK( m_jetsKey.initialize() );
82 CHECK( m_hitDVKey.initialize());
83 CHECK( m_tracksKey.initialize());
84 CHECK( m_lumiDataKey.initialize(!m_isMC) );
86
87 if ( !m_monTool.empty() ) CHECK( m_monTool.retrieve() );
88
89 ATH_CHECK(m_beamSpotKey.initialize());
90 ATH_CHECK(m_spacePointTool.retrieve() );
91
92 // MVAUtils BDT initialisation
93 // could make this configurable as a property
94 std::string weightfile[2];
95 weightfile[0] = PathResolver::find_calib_file("TrigHitDVHypo/HitDV.BDT.weights.0eta1.v22a.root");
96 weightfile[1] = PathResolver::find_calib_file("TrigHitDVHypo/HitDV.BDT.weights.1eta2.v22a.root");
97 for (unsigned int i=0; i<2; ++i) {
98 std::unique_ptr<TFile> rootFile(TFile::Open(weightfile[i].c_str(), "READ"));
99 if (!rootFile) {
100 ATH_MSG_ERROR("Can not open BDT root file: " << weightfile[i] );
101 return StatusCode::FAILURE;
102 }
103 std::unique_ptr<TTree> tree((TTree*)rootFile->Get("BDT"));
104 if (!tree) {
105 ATH_MSG_ERROR("Can not find BDT tree in file: " << weightfile[i]);
106 return StatusCode::FAILURE;
107 }
108 ATH_MSG_INFO("Loading BDT tree from file: " << weightfile[i]);
109 m_bdt_eta[i] = std::make_unique<MVAUtils::BDT>(tree.get());
110 }
111
112 return StatusCode::SUCCESS;
113}
114
115// ------------------------------------------------------------------------------------------------
116// ------------------------------------------------------------------------------------------------
117
118StatusCode TrigHitDVHypoAlg::execute( const EventContext& context ) const
119{
120
121 const TrigRoiDescriptor roi = TrigRoiDescriptor(0, -4.5, 4.5, 0, -M_PI, M_PI, 0, -168.0, 168.0);
122 std::vector<TrigSiSpacePointBase> convertedSpacePoints;
123 convertedSpacePoints.reserve(5000);
124 int mnt_roi_nSPsPIX;
125 int mnt_roi_nSPsSCT;
126 ATH_CHECK(m_spacePointTool->getSpacePoints(roi, convertedSpacePoints, mnt_roi_nSPsPIX, mnt_roi_nSPsSCT, context));
127
128 // monitoring
129 auto mon_n_dvtrks = Monitored::Scalar<int>( "n_dvtrks", 0 );
130 auto mon_n_dvsps = Monitored::Scalar<int>( "n_dvsps", 0 );
131 auto mon_n_jetseeds = Monitored::Scalar<int>( "n_jetseeds", 0 );
132 auto mon_n_jetseedsdel= Monitored::Scalar<int>( "n_jetseedsdel",0 );
133 auto mon_n_spseeds = Monitored::Scalar<int>( "n_spseeds", 0 );
134 auto mon_n_spseedsdel = Monitored::Scalar<int>( "n_spseedsdel", 0 );
135 auto mon_average_mu = Monitored::Scalar<float>( "average_mu", 0.);
136 auto monitorIt = Monitored::Group( m_monTool, mon_n_dvtrks, mon_n_dvsps, mon_n_jetseeds, mon_n_jetseedsdel, mon_n_spseeds, mon_n_spseedsdel, mon_average_mu );
137
138 // previous decisions
139 ATH_MSG_DEBUG( "Retrieving pervious decision: \"" << decisionInput().key() << "\"" );
140 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
141 ATH_CHECK( previousDecisionsHandle.isValid() );
142
143 ATH_MSG_DEBUG( "Running with " << previousDecisionsHandle->size() << " previous decisions" );
144 if( previousDecisionsHandle->size()!=1 ) {
145 ATH_MSG_ERROR( "Previous decision handle size is not 1. It is" << previousDecisionsHandle->size() );
146 return StatusCode::FAILURE;
147 }
148 const Decision * previousDecision = previousDecisionsHandle->at(0);
149
150 TrigCompositeUtils::DecisionIDContainer previousDecisionIDs;
151 TrigCompositeUtils::decisionIDs(previousDecision, previousDecisionIDs);
152 ATH_MSG_DEBUG( "IDs of active legs:" );
153 for(auto decisionID: previousDecisionIDs) { ATH_MSG_DEBUG( " " << decisionID ); }
154
155 // new output decisions
156 ATH_MSG_DEBUG( "Creating new output decision handle" );
158 auto outputDecisions = outputHandle.ptr();
159
160 // input objects
161
162 // jets
163 auto jetsHandle = SG::makeHandle(m_jetsKey, context );
164 ATH_CHECK( jetsHandle.isValid() );
165 ATH_MSG_DEBUG( "jet handle size: " << jetsHandle->size() );
166
167 const xAOD::JetContainer* jetsContainer = jetsHandle.get();
168 if( jetsContainer == nullptr ) {
169 ATH_MSG_ERROR( "ERROR Cannot get jet container" );
170 return StatusCode::FAILURE;
171 }
172 bool isJetEtPassToolsCut = false;
173 float jetEtaToolsCut = 2.0;
174 if( m_tools_loosest_wp >= 3 ) jetEtaToolsCut = 1.0;
175 for ( const xAOD::Jet* jet : *jetsContainer ) {
176 float jet_pt = static_cast<float>(jet->pt() / Gaudi::Units::GeV );
177 float jet_eta = static_cast<float>(jet->eta());
178 if( jet_pt >= m_tools_lowest_jetEt && std::abs(jet_eta)<=jetEtaToolsCut ) {
179 isJetEtPassToolsCut = true;
180 break;
181 }
182 }
183
184 auto tracks = SG::makeHandle( m_tracksKey, context );
185 ATH_CHECK(tracks.isValid());
186
187 std::vector<HitDVSeed> hitDVSeedsContainer;
188 std::vector<HitDVTrk> hitDVTrksContainer;
189 std::vector<HitDVSpacePoint> hitDVSPsContainer;
190
191
192 ATH_CHECK( findHitDV(context, convertedSpacePoints, *tracks, hitDVSeedsContainer, hitDVTrksContainer, hitDVSPsContainer) );
193
194 mon_n_dvtrks = hitDVTrksContainer.size();
195 mon_n_dvsps = hitDVSPsContainer.size();
196 const unsigned int N_MAX_SP_STORED = 100000;
197 bool isSPOverflow = false;
198 if( hitDVSPsContainer.size() >= N_MAX_SP_STORED ) isSPOverflow = true;
199 ATH_MSG_DEBUG( "hitDVSP size=" << mon_n_dvsps );
200
201 // average mu
202 float averageMu = 0;
203 if( m_isMC ) {
204 if( m_lumiBlockMuTool ) {
205 averageMu = static_cast<float>(m_lumiBlockMuTool->averageInteractionsPerCrossing(context));
206 ATH_MSG_DEBUG( "offline averageMu = " << averageMu );
207 }
208 }
209 else {
211 averageMu = lcd.cptr()->lbAverageInteractionsPerCrossing();
212 ATH_MSG_DEBUG( "online averageMu = " << averageMu );
213 }
214 mon_average_mu = averageMu;
215
216 // find seeds based on HLT jets
217 std::vector<float> jetSeeds_pt;
218 std::vector<float> jetSeeds_eta;
219 std::vector<float> jetSeeds_phi;
220 ATH_CHECK( findJetSeeds(jetsContainer, m_jetSeed_ptMin, m_jetSeed_etaMax, jetSeeds_pt, jetSeeds_eta, jetSeeds_phi) );
221 int n_alljetseeds = jetSeeds_eta.size();
222 ATH_CHECK( selectSeedsNearby(hitDVSeedsContainer, jetSeeds_eta, jetSeeds_phi, jetSeeds_pt) );
223 mon_n_jetseeds = jetSeeds_eta.size();
224 mon_n_jetseedsdel = n_alljetseeds - jetSeeds_eta.size();
225
226 // find seeds based on SP frac itself
227 std::vector<float> spSeeds_eta;
228 std::vector<float> spSeeds_phi;
229 std::vector<float> void_pt;
230 int n_allspseeds = 0;
231 if( m_tools_loosest_wp <= 1 ) {
232 ATH_CHECK( findSPSeeds(context, hitDVSPsContainer, spSeeds_eta, spSeeds_phi) );
233 n_allspseeds = spSeeds_eta.size();
234 ATH_CHECK( selectSeedsNearby(hitDVSeedsContainer, spSeeds_eta, spSeeds_phi, void_pt) );
235 mon_n_spseeds = spSeeds_eta.size();
236 mon_n_spseedsdel = n_allspseeds - spSeeds_eta.size();
237 }
238 else {
239 mon_n_spseeds = 0;
240 mon_n_spseedsdel = 0;
241 }
242
243 // output EDM object
244 auto hitDVContainer = std::make_unique<xAOD::TrigCompositeContainer>();
245 auto hitDVContainerAux = std::make_unique<xAOD::TrigCompositeAuxContainer>();
246 hitDVContainer->setStore(hitDVContainerAux.get());
247
248 xAOD::TrigCompositeContainer* dvContainer = hitDVContainer.get();
249 std::vector<TrigHitDVHypoTool::HitDVHypoInfo> hitDVHypoInputs;
250 std::unordered_map<Decision*, size_t> mapDecIdx;
251
252 // calculate BDT and create hitDVContainer EDM
253 if( isJetEtPassToolsCut ) {
254 const float preselBDTthreshold = -0.6;
255
256 int n_passed_jet = 0;
257 int seed_type = SeedType::HLTJet;
258 ATH_CHECK( calculateBDT(hitDVSPsContainer, hitDVTrksContainer, jetSeeds_pt, jetSeeds_eta, jetSeeds_phi, preselBDTthreshold, seed_type, dvContainer, n_passed_jet) );
259
260 int n_passed_sp = 0;
261 if( m_tools_loosest_wp <= 1 ) {
262 seed_type = SeedType::SP;
263 ATH_CHECK( calculateBDT(hitDVSPsContainer, hitDVTrksContainer, void_pt, spSeeds_eta, spSeeds_phi, preselBDTthreshold, seed_type, dvContainer, n_passed_sp) );
264 }
265
266 ATH_MSG_DEBUG( "nr of dv container / jet-seeded / sp-seed candidates = " << dvContainer->size() << " / " << n_passed_jet << " / " << n_passed_sp );
267
268 // Prepare inputs to HypoTool
269 for ( auto dv : *dvContainer ) {
270 Decision* newDecision = TrigCompositeUtils::newDecisionIn( outputDecisions, previousDecision, TrigCompositeUtils::hypoAlgNodeName(), context);
271 mapDecIdx.emplace( newDecision, dv->index() );
272 TrigHitDVHypoTool::HitDVHypoInfo hypoInfo{ newDecision, isSPOverflow, averageMu, dv, previousDecisionIDs };
273 hitDVHypoInputs.push_back( hypoInfo );
274 }
275 }
276
277 // monitor
278 ATH_CHECK( doMonitor(dvContainer) );
279
280 // Loop over all hypoToolinputs and get their decisions
281 for ( auto & tool: m_hypoTools ) {
282 ATH_MSG_DEBUG( "+++++ Now computing decision for " << tool->name() );
283 ATH_CHECK( tool->decide( hitDVHypoInputs ) );
284 }
285
286 // record hitDV object
288 ATH_CHECK( hitDVHandle.record( std::move( hitDVContainer ), std::move( hitDVContainerAux ) ) );
289 ATH_MSG_DEBUG( "recorded hitDV object to SG" );
290
291 DecisionContainer::iterator it = outputDecisions->begin();
292 while(it != outputDecisions->end()) {
293 ATH_MSG_DEBUG( "+++++ outputDecision: " << *it << " +++++" );
294 if ( allFailed( *it ) ) {
295 ATH_MSG_DEBUG( "---> all failed, erasing" );
296 it = outputDecisions->erase(it);
297 } else {
298 ATH_MSG_DEBUG( "---> not all failed" );
299
300 // Link hitDV object
301 auto decision = *it;
302 size_t idx = mapDecIdx.at(*it);
303
305 ATH_CHECK( dvEL.isValid() );
306
307 ATH_CHECK( decision->setObjectLink<xAOD::TrigCompositeContainer>(featureString(), dvEL) );
308
309 ATH_MSG_DEBUG(*decision);
310 ++it;
311 }
312 }
313
314 //
315 ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
316
317 //
318 return StatusCode::SUCCESS;
319}
320
321// ------------------------------------------------------------------------------------------------
322// ------------------------------------------------------------------------------------------------
323
324float TrigHitDVHypoAlg::deltaR2(float eta_1, float phi_1, float eta_2, float phi_2) const {
325 float dPhi = CxxUtils::wrapToPi(phi_1 - phi_2);
326 float dEta = eta_1 - eta_2;
327 return (dPhi*dPhi)+(dEta*dEta);
328}
329
330// ------------------------------------------------------------------------------------------------
331// ------------------------------------------------------------------------------------------------
332
333int TrigHitDVHypoAlg::getSPLayer(int layer, float eta) const
334{
335 float abseta = std::fabs(eta);
336
337 // if Pixel/SCT barrel, layer number is as it is
338 if( 0<=layer && layer <=7 ) {
339 ATH_MSG_VERBOSE("layer=" << layer << ", eta=" << abseta);
340 return layer;
341 }
342
343 // for Pixel/SCT endcap, assign layer number of 0-7 depending on eta range
344
345 int base = 0;
346
347 //
348 const float PixBR6limit = 1.29612;
349 const float PixBR5limit = 1.45204;
350 const float PixBR4limit = 1.64909;
351 const float PixBR3limit = 1.90036;
352 const float PixBR2limit = 2.2146;
353
354 // Pixel Endcap #1
355 base = 8;
356 if( layer==base || layer==(base+12) ) {
357 ATH_MSG_VERBOSE("Pix EC1, eta=" << abseta);
358 if( abseta > PixBR2limit ) return 2;
359 return 3;
360 }
361
362 // Pixel Endcap #2
363 base = 9;
364 if( layer==base || layer==(base+12) ) {
365 ATH_MSG_VERBOSE("Pix EC2, eta=" << abseta);
366 if( abseta > PixBR2limit ) return 2;
367 return 3;
368 }
369
370 // Pixel Endcap #3
371 base = 10;
372 if( layer==base || layer==(base+12) ) {
373 ATH_MSG_VERBOSE("Pix EC3, eta=" << abseta);
374 return 3;
375 }
376
377 // SCT Endcap #1
378 base = 11;
379 if( layer==base || layer==(base+12) ) {
380 ATH_MSG_VERBOSE("Sct EC1, eta=" << abseta);
381 if( abseta < PixBR6limit ) return 7;
382 else if( abseta < PixBR5limit ) return 6;
383 return 5;
384 }
385
386 // SCT Endcap #2
387 base = 12;
388 if( layer==base || layer==(base+12) ) {
389 ATH_MSG_VERBOSE("Sct EC2, eta=" << abseta);
390 if( abseta < PixBR5limit ) return 7;
391 else if( abseta < PixBR4limit ) return 6;
392 return 4;
393 }
394
395 // SCT Endcap #3
396 base = 13;
397 if( layer==base || layer==(base+12) ) {
398 ATH_MSG_VERBOSE("Sct EC3, eta=" << abseta);
399 if( abseta < PixBR4limit ) return 7;
400 return 5;
401 }
402
403 // SCT Endcap #4
404 base = 14;
405 if( layer==base || layer==(base+12) ) {
406 ATH_MSG_VERBOSE("Sct EC4, eta=" << abseta);
407 if( abseta < PixBR4limit ) return 6;
408 else if( abseta < PixBR3limit ) return 6;
409 return 4;
410 }
411
412 // SCT Endcap #5
413 base = 15;
414 if( layer==base || layer==(base+12) ) {
415 ATH_MSG_VERBOSE("Sct EC5, eta=" << abseta);
416 if( abseta < PixBR3limit ) return 7;
417 return 5;
418 }
419
420 // SCT Endcap #6
421 base = 16;
422 if( layer==base || layer==(base+12) ) {
423 ATH_MSG_VERBOSE("Sct EC6, eta=" << abseta);
424 if( abseta < PixBR3limit ) return 6;
425 return 4;
426 }
427
428 // SCT Endcap #7
429 base = 17;
430 if( layer==base || layer==(base+12) ) {
431 ATH_MSG_VERBOSE("Sct EC7, eta=" << abseta);
432 if( abseta < PixBR3limit ) return 7;
433 return 5;
434 }
435
436 // SCT Endcap #8
437 base = 18;
438 if( layer==base || layer==(base+12) ) {
439 ATH_MSG_VERBOSE("Sct EC8, eta=" << abseta);
440 if( abseta < PixBR3limit ) return 7;
441 return 6;
442 }
443
444 // SCT Endcap #9
445 base = 19;
446 if( layer==base || layer==(base+12) ) {
447 ATH_MSG_VERBOSE("Sct EC9, eta=" << abseta);
448 return 7;
449 }
450
451 return 0;
452}
453
454// ------------------------------------------------------------------------------------------------
455// ------------------------------------------------------------------------------------------------
456
458{
459 auto mon_ly0_spfr = Monitored::Collection(
460 "ly0_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly0_sp_frac"); });
461 auto mon_ly1_spfr = Monitored::Collection(
462 "ly1_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly1_sp_frac"); });
463 auto mon_ly2_spfr = Monitored::Collection(
464 "ly2_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly2_sp_frac"); });
465 auto mon_ly3_spfr = Monitored::Collection(
466 "ly3_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly3_sp_frac"); });
467 auto mon_ly4_spfr = Monitored::Collection(
468 "ly4_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly4_sp_frac"); });
469 auto mon_ly5_spfr = Monitored::Collection(
470 "ly5_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly5_sp_frac"); });
471 auto mon_ly6_spfr = Monitored::Collection(
472 "ly6_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly6_sp_frac"); });
473 auto mon_ly7_spfr = Monitored::Collection(
474 "ly7_spfr", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_ly7_sp_frac"); });
475 auto mon_bdtscore = Monitored::Collection(
476 "bdtscore", *dvContainer, [&](const Decision* d){ return d->getDetail<float>("hitDV_bdt_score"); });
477 auto mon_n_qtrk = Monitored::Collection(
478 "n_qtrk", *dvContainer, [&](const Decision* d){ return d->getDetail<int>("hitDV_n_track_qual"); });
479
480 // fill CutMask to split spacespoints into eta regions
481 std::vector<char> mask_eta1(dvContainer->size(), 0);
482 std::vector<char> mask_1eta2(dvContainer->size(), 0);
483 auto mon_eta1_mask = Monitored::Collection( "cutEta1", mask_eta1 );
484 auto mon_1eta2_mask = Monitored::Collection( "cut1Eta2", mask_1eta2 );
485
486 for (size_t i = 0; i<dvContainer->size(); ++i) {
487 const Decision* dv = (*dvContainer)[i];
488
489 // do not fill sp-seeded candidates
490 if( dv->getDetail<int>("hitDV_seed_type") == SeedType::SP ) continue;
491
492 // fill the cut mask according to eta range
493 const float abs_eta = std::abs(dv->getDetail<float>("hitDV_seed_eta"));
494 if ( abs_eta < 1.0 ) mask_eta1[i] = 1;
495 else if( abs_eta < 2.0 ) mask_1eta2[i] = 1;
496 }
497
498 auto monitorIt = Monitored::Group( m_monTool,
499 mon_ly0_spfr, mon_ly1_spfr, mon_ly2_spfr, mon_ly3_spfr,
500 mon_ly4_spfr, mon_ly5_spfr, mon_ly6_spfr, mon_ly7_spfr,
501 mon_n_qtrk, mon_bdtscore, mon_eta1_mask, mon_1eta2_mask );
502
503 return StatusCode::SUCCESS;
504}
505
506// ------------------------------------------------------------------------------------------------
507// ------------------------------------------------------------------------------------------------
508
509StatusCode TrigHitDVHypoAlg::calculateBDT(const std::vector<HitDVSpacePoint>& spsContainer,
510 const std::vector<HitDVTrk>& trksContainer,
511 const std::vector<float>& seeds_pt,
512 const std::vector<float>& seeds_eta, const std::vector<float>& seeds_phi,
513 const float& cutBDTthreshold, const int seed_type,
514 xAOD::TrigCompositeContainer* dvContainer, int& n_passed) const
515{
516 if( seeds_eta.size() != seeds_phi.size() ) return StatusCode::SUCCESS;
517 n_passed = 0;
518
519 for(unsigned int iseed=0; iseed<seeds_eta.size(); iseed++) {
520
521 float seed_eta = seeds_eta[iseed];
522 float seed_phi = seeds_phi[iseed];
523
524 ATH_MSG_VERBOSE("+++++ seed eta: " << seed_eta << ", phi:" << seed_phi << " +++++");
525
526 // loop on space points
527 const int N_LAYER = 8;
528 const float DR_SQUARED_TO_REF_CUT = 0.16; // const float DR_TO_REF_CUT = 0.4;
529
530 int n_sp_injet = 0;
531 int n_sp_injet_usedByTrk = 0;
532 int v_n_sp_injet[N_LAYER];
533 int v_n_sp_injet_usedByTrk[N_LAYER];
534 for(int i=0; i<N_LAYER; i++) { v_n_sp_injet[i]=0; v_n_sp_injet_usedByTrk[i]=0; }
535
536 for ( const auto & spData : spsContainer ) {
537 // match within dR
538 float sp_eta = spData.eta;
539 float sp_phi = spData.phi;
540 float dR2 = deltaR2(sp_eta,sp_phi,seed_eta,seed_phi);
541 if( dR2 > DR_SQUARED_TO_REF_CUT ) continue;
542
543 //
544 int sp_layer = (int)spData.layer;
545 int sp_trkid = (int)spData.usedTrkId;
546 bool isUsedByTrk = (sp_trkid != -1);
547
548 int ilayer = getSPLayer(sp_layer,sp_eta);
549
550 if( ilayer<=7 ) { // Pixel barrel or Sct barrel
551 n_sp_injet++;
552 v_n_sp_injet[ilayer]++;
553 if( isUsedByTrk ) {
554 n_sp_injet_usedByTrk++;
555 v_n_sp_injet_usedByTrk[ilayer]++;
556 }
557 }
558 }
559 ATH_MSG_VERBOSE("nr of SPs in jet: usedByTrk / all = " << n_sp_injet_usedByTrk << " / " << n_sp_injet);
560 float v_ly_sp_frac[N_LAYER];
561 for(int i=0; i<N_LAYER; i++) {
562 float frac = 0.;
563 if( v_n_sp_injet[i] > 0 ) frac = 1.0 - static_cast<float>(v_n_sp_injet_usedByTrk[i]) / static_cast<float>(v_n_sp_injet[i]);
564 v_ly_sp_frac[i] = frac;
565 ATH_MSG_VERBOSE("Layer " << i << ": frac=" << v_ly_sp_frac[i] << ", n used / all = " << v_n_sp_injet_usedByTrk[i] << " / " << v_n_sp_injet[i]);
566 }
567
568 // loop on tracks
569 const float TRK_PT_GEV_CUT = 2.0;
570
571 unsigned int n_qtrk_injet = 0;
572 for ( const auto& trk : trksContainer ) {
573 float trk_ptGeV = trk.pt;
574 trk_ptGeV /= Gaudi::Units::GeV;
575 if( trk_ptGeV < TRK_PT_GEV_CUT ) continue;
576 float dR2 = deltaR2(trk.eta,trk.phi,seed_eta,seed_phi);
577 if( dR2 > DR_SQUARED_TO_REF_CUT ) continue;
578 n_qtrk_injet++;
579 }
580 ATH_MSG_DEBUG("nr of all / quality tracks matched = " << trksContainer.size() << " / " << n_qtrk_injet);
581
582 // evaluate BDT
583 bool isSeedOutOfRange = false;
584 if( n_qtrk_injet == 0 ) {
585 isSeedOutOfRange = true;
586 for(int i=0; i<N_LAYER; i++) {
587 if( std::fabs(v_ly_sp_frac[i]) > 1e-3 ) {
588 isSeedOutOfRange = false; break;
589 }
590 }
591 }
592 float bdt_score = -2.0;
593 if( ! isSeedOutOfRange ) {
594 const std::vector<float> input_values = {
595 static_cast<float>(n_qtrk_injet),
596 v_ly_sp_frac[0],
597 v_ly_sp_frac[1],
598 v_ly_sp_frac[2],
599 v_ly_sp_frac[3],
600 v_ly_sp_frac[4],
601 v_ly_sp_frac[5],
602 v_ly_sp_frac[6],
603 v_ly_sp_frac[7] };
604
605 if ( std::abs(seed_eta) < 1 ) {
606 bdt_score = m_bdt_eta[0]->GetClassification(input_values);
607 } else if ( std::abs(seed_eta) < 2 ) {
608 bdt_score = m_bdt_eta[1]->GetClassification(input_values);
609 }
610 }
611
612 // BDT threshold
613 if( bdt_score < cutBDTthreshold ) continue;
614
615 // passed selection
616 ATH_MSG_VERBOSE("Passed selection");
617 n_passed++;
618
619 // create EDM object
621 dv->makePrivateStore();
622 dvContainer->push_back(dv);
623
624 float seed_pt = 0;
625 if ( seed_type == SeedType::HLTJet ) seed_pt = seeds_pt[iseed];
626 dv->setDetail<float>("hitDV_seed_pt", seed_pt);
627 dv->setDetail<float>("hitDV_seed_eta", seed_eta);
628 dv->setDetail<float>("hitDV_seed_phi", seed_phi);
629 dv->setDetail<int> ("hitDV_seed_type", seed_type);
630 dv->setDetail<int> ("hitDV_n_track_qual", n_qtrk_injet);
631 dv->setDetail<float>("hitDV_ly0_sp_frac", v_ly_sp_frac[0]);
632 dv->setDetail<float>("hitDV_ly1_sp_frac", v_ly_sp_frac[1]);
633 dv->setDetail<float>("hitDV_ly2_sp_frac", v_ly_sp_frac[2]);
634 dv->setDetail<float>("hitDV_ly3_sp_frac", v_ly_sp_frac[3]);
635 dv->setDetail<float>("hitDV_ly4_sp_frac", v_ly_sp_frac[4]);
636 dv->setDetail<float>("hitDV_ly5_sp_frac", v_ly_sp_frac[5]);
637 dv->setDetail<float>("hitDV_ly6_sp_frac", v_ly_sp_frac[6]);
638 dv->setDetail<float>("hitDV_ly7_sp_frac", v_ly_sp_frac[7]);
639 dv->setDetail<float>("hitDV_bdt_score", bdt_score);
640
641 ATH_MSG_VERBOSE("Created a new entry EDM");
642 }
643 ATH_MSG_DEBUG("nr of BDT passed = " << n_passed);
644
645 //
646 return StatusCode::SUCCESS;
647}
648
649// ------------------------------------------------------------------------------------------------
650// ------------------------------------------------------------------------------------------------
651
652StatusCode TrigHitDVHypoAlg::findJetSeeds(const xAOD::JetContainer* jetsContainer, const float cutJetPt, const float cutJetEta,
653 std::vector<float>& jetSeeds_pt, std::vector<float>& jetSeeds_eta, std::vector<float>& jetSeeds_phi) const
654{
655 std::vector<float> mnt_jet_pt;
656 std::vector<float> mnt_jet_eta;
657 auto mon_jet_pt = Monitored::Collection("jet_pt", mnt_jet_pt);
658 auto mon_jet_eta = Monitored::Collection("jet_eta", mnt_jet_eta);
659 auto monitorIt = Monitored::Group( m_monTool, mon_jet_pt, mon_jet_eta );
660
661 ATH_MSG_VERBOSE("looking for jet seed with pt cut=" << cutJetPt << ", eta cut=" << cutJetEta);
662 for ( const xAOD::Jet* jet : *jetsContainer ) {
663 float jet_pt = static_cast<float>(jet->pt() / Gaudi::Units::GeV );
664 if( jet_pt < cutJetPt ) {
665 ATH_MSG_VERBOSE("Fails jet pt cut, pt = " << jet_pt);
666 continue;
667 }
668 mnt_jet_pt.push_back(jet_pt);
669 float jet_eta = static_cast<float>(jet->eta());
670 mnt_jet_eta.push_back(jet_eta);
671 if( std::fabs(jet_eta) > cutJetEta ) {
672 ATH_MSG_VERBOSE("Fails jet eta cut, eta = " << jet_eta);
673 continue;
674 }
675 float jet_phi = static_cast<float>(jet->phi());
676 jetSeeds_pt.push_back(jet_pt);
677 jetSeeds_eta.push_back(jet_eta);
678 jetSeeds_phi.push_back(jet_phi);
679 }
680 ATH_MSG_VERBOSE("nr of jet seeds=" << jetSeeds_eta.size());
681
682 return StatusCode::SUCCESS;
683}
684
685// ------------------------------------------------------------------------------------------------
686// ------------------------------------------------------------------------------------------------
687
688StatusCode TrigHitDVHypoAlg::findSPSeeds( const EventContext& ctx, const std::vector<HitDVSpacePoint>& spsContainer,
689 std::vector<float>& seeds_eta, std::vector<float>& seeds_phi ) const
690{
691 seeds_eta.clear();
692 seeds_phi.clear();
693
694 const int NBINS_ETA = 50;
695 const float ETA_MIN = -2.5;
696 const float ETA_MAX = 2.5;
697
698 const int NBINS_PHI = 80;
699 const float PHI_MIN = -4.0;
700 const float PHI_MAX = 4.0;
701
702 char hname[64];
703
704 unsigned int slotnr = ctx.slot();
705 unsigned int subSlotnr = ctx.subSlot();
706
707 sprintf(hname,"hitdv_s%u_ss%u_ly6_h2_nsp",slotnr,subSlotnr);
708 std::unique_ptr<TH2F> ly6_h2_nsp = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
709 sprintf(hname,"hitdv_s%u_ss%u_ly7_h2_nsp",slotnr,subSlotnr);
710 std::unique_ptr<TH2F> ly7_h2_nsp = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
711
712 sprintf(hname,"hitdv_s%u_ss%u_ly6_h2_nsp_notrk",slotnr,subSlotnr);
713 std::unique_ptr<TH2F> ly6_h2_nsp_notrk = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
714 sprintf(hname,"hitdv_s%u_ss%u_ly7_h2_nsp_notrk",slotnr,subSlotnr);
715 std::unique_ptr<TH2F> ly7_h2_nsp_notrk = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
716
717 for ( const auto& spData : spsContainer ) {
718 int16_t sp_layer = spData.layer;
719 float sp_eta = spData.eta;
720 int ilayer = getSPLayer(sp_layer,sp_eta);
721 if( ilayer<6 ) continue;
722
723 int sp_trkid = (int)spData.usedTrkId;
724 bool isUsedByTrk = (sp_trkid != -1);
725 float sp_phi = spData.phi;
726
727 bool fill_out_of_pi = false;
728 float sp_phi2 = 0;
729 if( sp_phi < 0 ) {
730 sp_phi2 = 2*TMath::Pi() + sp_phi;
731 if( sp_phi2 < PHI_MAX ) fill_out_of_pi = true;
732 }
733 else {
734 sp_phi2 = -2*TMath::Pi() + sp_phi;
735 if( PHI_MIN < sp_phi2 ) fill_out_of_pi = true;
736 }
737 if( ilayer==6 ) {
738 ly6_h2_nsp->Fill(sp_eta,sp_phi);
739 if( fill_out_of_pi ) ly6_h2_nsp->Fill(sp_eta,sp_phi2);
740 if( ! isUsedByTrk ) ly6_h2_nsp_notrk->Fill(sp_eta,sp_phi);
741 if( ! isUsedByTrk && fill_out_of_pi) ly6_h2_nsp_notrk->Fill(sp_eta,sp_phi2);
742 }
743 if( ilayer==7 ) {
744 ly7_h2_nsp->Fill(sp_eta,sp_phi);
745 if( fill_out_of_pi ) ly7_h2_nsp->Fill(sp_eta,sp_phi2);
746 if( ! isUsedByTrk ) ly7_h2_nsp_notrk->Fill(sp_eta,sp_phi);
747 if( ! isUsedByTrk && fill_out_of_pi) ly7_h2_nsp_notrk->Fill(sp_eta,sp_phi2);
748 }
749 }
750
751 ATH_MSG_VERBOSE("looking for ly6/ly6 doublet seeds");
752
753 // (idx, sort/weight, eta, phi)
754 std::vector<std::tuple<int,float,float,float>> QT;
755
756 for(int ly6_ieta=1; ly6_ieta<=NBINS_ETA; ly6_ieta++) {
757 float ly6_eta = (ly6_h2_nsp->GetXaxis()->GetBinLowEdge(ly6_ieta) + ly6_h2_nsp->GetXaxis()->GetBinUpEdge(ly6_ieta))/2.0;
758 for(int ly6_iphi=1; ly6_iphi<=NBINS_PHI; ly6_iphi++) {
759 float ly6_phi = (ly6_h2_nsp->GetYaxis()->GetBinLowEdge(ly6_iphi) + ly6_h2_nsp->GetYaxis()->GetBinUpEdge(ly6_iphi))/2.0;
760
761 float ly6_nsp = ly6_h2_nsp ->GetBinContent(ly6_ieta,ly6_iphi);
762 float ly6_nsp_notrk = ly6_h2_nsp_notrk->GetBinContent(ly6_ieta,ly6_iphi);
763 float ly6_frac = ( ly6_nsp > 0 ) ? ly6_nsp_notrk / ly6_nsp : 0;
764 if( ly6_nsp < 10 || ly6_frac < 0.85 ) continue;
765
766 float ly7_frac_max = 0;
767 float ly7_eta_max = 0;
768 float ly7_phi_max = 0;
769 for(int ly7_ieta=std::max(1,ly6_ieta-1); ly7_ieta<std::min(NBINS_ETA,ly6_ieta+1); ly7_ieta++) {
770 for(int ly7_iphi=std::max(1,ly6_iphi-1); ly7_iphi<=std::min(NBINS_PHI,ly6_iphi+1); ly7_iphi++) {
771 float ly7_nsp = ly7_h2_nsp ->GetBinContent(ly7_ieta,ly7_iphi);
772 float ly7_nsp_notrk = ly7_h2_nsp_notrk->GetBinContent(ly7_ieta,ly7_iphi);
773 float ly7_frac = ( ly7_nsp > 0 ) ? ly7_nsp_notrk / ly7_nsp : 0;
774 if( ly7_nsp < 10 ) continue;
775 if( ly7_frac > ly7_frac_max ) {
776 ly7_frac_max = ly7_frac;
777 ly7_eta_max = (ly7_h2_nsp->GetXaxis()->GetBinLowEdge(ly7_ieta) + ly7_h2_nsp->GetXaxis()->GetBinUpEdge(ly7_ieta))/2.0;
778 ly7_phi_max = (ly7_h2_nsp->GetXaxis()->GetBinLowEdge(ly7_iphi) + ly7_h2_nsp->GetXaxis()->GetBinUpEdge(ly7_iphi))/2.0;
779 }
780 }
781 }
782 if( ly7_frac_max < 0.85 ) continue;
783 //
784 float wsum = ly6_frac + ly7_frac_max;
785 float weta = (ly6_eta*ly6_frac + ly7_eta_max*ly7_frac_max) / wsum;
786 float wphi = (ly6_phi*ly6_frac + ly7_phi_max*ly7_frac_max) / wsum;
787 float w = wsum / 2.0;
788 QT.push_back(std::make_tuple(-1,w,weta,wphi));
789 }
790 }
791 ATH_MSG_VERBOSE("nr of ly6/ly7 doublet candidate seeds=" << QT.size() << ", doing clustering...");
792
793 // sort
794 std::sort(QT.begin(), QT.end(),
795 [](const std::tuple<int,float,float,float>& lhs, const std::tuple<int,float,float,float>& rhs) {
796 return std::get<1>(lhs) > std::get<1>(rhs); } );
797
798 // clustering
799 const double CLUSTCUT_DIST_SQUARED = 0.04; // const double CLUSTCUT_DIST = 0.2;
800 const double CLUSTCUT_SEED_FRAC = 0.9;
801
802 std::vector<float> seeds_wsum;
803
804 for(unsigned int i=0; i<QT.size(); i++) {
805 float phi = std::get<3>(QT[i]);
806 float eta = std::get<2>(QT[i]);
807 float w = std::get<1>(QT[i]);
808 if(i==0) {
809 seeds_eta.push_back(w*eta); seeds_phi.push_back(w*phi);
810 seeds_wsum.push_back(w);
811 continue;
812 }
813 const int IDX_INITIAL = 100;
814 float dist2_min = 100.0;
815 int idx_min = IDX_INITIAL;
816 for(unsigned j=0; j<seeds_eta.size(); j++) {
817 float ceta = seeds_eta[j]/seeds_wsum[j];
818 float cphi = seeds_phi[j]/seeds_wsum[j];
819 // intentionally calculate in this way as phi is defined beyond -Pi/Pi (no boundary)
820 float deta = std::fabs(ceta-eta);
821 float dphi = std::fabs(cphi-phi);
822 float dist2 = dphi*dphi+deta*deta;
823 if( dist2 < dist2_min ) {
824 dist2_min = dist2;
825 idx_min = j;
826 }
827 }
828 int match_idx = IDX_INITIAL;
829 if( idx_min != IDX_INITIAL ) {
830 if( dist2_min < CLUSTCUT_DIST_SQUARED ) { match_idx = idx_min; }
831 }
832 if( match_idx == IDX_INITIAL ) {
833 if( w > CLUSTCUT_SEED_FRAC && dist2_min > CLUSTCUT_DIST_SQUARED ) {
834 seeds_eta.push_back(w*eta); seeds_phi.push_back(w*phi);
835 seeds_wsum.push_back(w);
836 }
837 continue;
838 }
839 float new_eta = seeds_eta[match_idx] + w*eta;
840 float new_phi = seeds_phi[match_idx] + w*phi;
841 float new_wsum = seeds_wsum[match_idx] + w;
842 seeds_eta[match_idx] = new_eta;
843 seeds_phi[match_idx] = new_phi;
844 seeds_wsum[match_idx] = new_wsum;
845 }
846 QT.clear();
847 for(unsigned int i=0; i<seeds_eta.size(); i++) {
848 float eta = seeds_eta[i] / seeds_wsum[i];
849 float phi = seeds_phi[i] / seeds_wsum[i];
850 seeds_eta[i] = eta;
851 seeds_phi[i] = phi;
852 if( phi < -TMath::Pi() ) phi = 2*TMath::Pi() + phi;
853 if( phi > TMath::Pi() ) phi = -2*TMath::Pi() + phi;
854 seeds_phi[i] = phi;
855 }
856 ATH_MSG_VERBOSE("after clustering, nr of seeds = " << seeds_eta.size());
857
858 // delete overlap (can happen at phi=-Pi/Pi bounadry)
859 std::vector<unsigned int> idx_to_delete;
860 for(unsigned int i=0; i<seeds_eta.size(); i++) {
861 if( std::find(idx_to_delete.begin(),idx_to_delete.end(),i) != idx_to_delete.end() ) continue;
862 float eta_i = seeds_eta[i];
863 float phi_i = seeds_phi[i];
864 for(unsigned int j=i+1; j<seeds_eta.size(); j++) {
865 if( std::find(idx_to_delete.begin(),idx_to_delete.end(),j) != idx_to_delete.end() ) continue;
866 float eta_j = seeds_eta[j];
867 float phi_j = seeds_phi[j];
868 float dR2 = deltaR2(eta_i,phi_i,eta_j,phi_j);
869 if( dR2 < CLUSTCUT_DIST_SQUARED ) idx_to_delete.push_back(j);
870 }
871 }
872 ATH_MSG_VERBOSE("nr of duplicated seeds to be removed = " << idx_to_delete.size());
873 if( idx_to_delete.size() > 0 ) {
874 std::sort(idx_to_delete.begin(),idx_to_delete.end());
875 for(unsigned int j=idx_to_delete.size(); j>0; j--) {
876 unsigned int idx = idx_to_delete[j-1];
877 seeds_eta.erase(seeds_eta.begin()+idx);
878 seeds_phi.erase(seeds_phi.begin()+idx);
879 }
880 }
881
882 ATH_MSG_VERBOSE("nr of ly6/ly7 seeds=" << seeds_eta.size());
883
884 // return
885 return StatusCode::SUCCESS;
886}
887
888// ------------------------------------------------------------------------------------------------
889// ------------------------------------------------------------------------------------------------
890
891StatusCode TrigHitDVHypoAlg::selectSeedsNearby(const std::vector<HitDVSeed>& hitDVSeedsContainer,
892 std::vector<float>& jetSeeds_eta, std::vector<float>& jetSeeds_phi, std::vector<float>& jetSeeds_pt) const
893{
894 std::vector<unsigned int> idx_to_delete;
895 for(unsigned int idx=0; idx<jetSeeds_eta.size(); ++idx) {
896 const float DR_SQUARED_CUT_TO_FTFSEED = 0.09; // const float DR_CUT_TO_FTFSEED = 0.3;
897 float eta = jetSeeds_eta[idx];
898 float phi = jetSeeds_phi[idx];
899 float dR2min = 9999;
900 for ( const auto& seed : hitDVSeedsContainer ) {
901 float dR2 = deltaR2(eta,phi,seed.eta,seed.phi);
902 if( dR2 < dR2min ) dR2min = dR2;
903 }
904 if( dR2min > DR_SQUARED_CUT_TO_FTFSEED ) idx_to_delete.push_back(idx);
905 }
906 if( idx_to_delete.size() > 0 ) {
907 std::sort(idx_to_delete.begin(),idx_to_delete.end());
908 for(unsigned int j=idx_to_delete.size(); j>0; j--) {
909 unsigned int idx = idx_to_delete[j-1];
910 jetSeeds_eta.erase(jetSeeds_eta.begin()+idx);
911 jetSeeds_phi.erase(jetSeeds_phi.begin()+idx);
912 if( jetSeeds_pt.size() > 0 ) jetSeeds_pt.erase(jetSeeds_pt.begin()+idx);
913 }
914 }
915 return StatusCode::SUCCESS;
916}
917
918// ------------------------------------------------------------------------------------------------
919// ------------------------------------------------------------------------------------------------
920
921StatusCode TrigHitDVHypoAlg::findSPSeeds( const EventContext& ctx,
922 const std::vector<float>& v_sp_eta, const std::vector<float>& v_sp_phi,
923 const std::vector<int>& v_sp_layer, const std::vector<int>& v_sp_usedTrkId,
924 std::vector<float>& seeds_eta, std::vector<float>& seeds_phi ) const
925{
926 const int NBINS_ETA = 50;
927 const float ETA_MIN = -2.5;
928 const float ETA_MAX = 2.5;
929
930 const int NBINS_PHI = 80;
931 const float PHI_MIN = -4.0;
932 const float PHI_MAX = 4.0;
933
934 char hname[64];
935
936 unsigned int slotnr = ctx.slot();
937 unsigned int subSlotnr = ctx.subSlot();
938
939 sprintf(hname,"ftf_s%u_ss%u_ly6_h2_nsp",slotnr,subSlotnr);
940 std::unique_ptr<TH2F> ly6_h2_nsp = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
941 sprintf(hname,"ftf_s%u_ss%u_ly7_h2_nsp",slotnr,subSlotnr);
942 std::unique_ptr<TH2F> ly7_h2_nsp = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
943
944 sprintf(hname,"ftf_s%u_ss%u_ly6_h2_nsp_notrk",slotnr,subSlotnr);
945 std::unique_ptr<TH2F> ly6_h2_nsp_notrk = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
946 sprintf(hname,"ftf_s%u_ss%u_ly7_h2_nsp_notrk",slotnr,subSlotnr);
947 std::unique_ptr<TH2F> ly7_h2_nsp_notrk = std::make_unique<TH2F>(hname,hname,NBINS_ETA,ETA_MIN,ETA_MAX,NBINS_PHI,PHI_MIN,PHI_MAX);
948
949 for(unsigned int iSeed=0; iSeed<v_sp_eta.size(); ++iSeed) {
950
951 int sp_layer = v_sp_layer[iSeed];
952 float sp_eta = v_sp_eta[iSeed];
953 int ilayer = getSPLayer(sp_layer,sp_eta);
954 if( ilayer<6 ) continue;
955
956 int sp_trkid = v_sp_usedTrkId[iSeed];
957 bool isUsedByTrk = (sp_trkid != -1);
958 float sp_phi = v_sp_phi[iSeed];
959
960 bool fill_out_of_pi = false;
961 float sp_phi2 = 0;
962 if( sp_phi < 0 ) {
963 sp_phi2 = 2*TMath::Pi() + sp_phi;
964 if( sp_phi2 < PHI_MAX ) fill_out_of_pi = true;
965 }
966 else {
967 sp_phi2 = -2*TMath::Pi() + sp_phi;
968 if( PHI_MIN < sp_phi2 ) fill_out_of_pi = true;
969 }
970 if( ilayer==6 ) {
971 ly6_h2_nsp->Fill(sp_eta,sp_phi);
972 if( fill_out_of_pi ) ly6_h2_nsp->Fill(sp_eta,sp_phi2);
973 if( ! isUsedByTrk ) ly6_h2_nsp_notrk->Fill(sp_eta,sp_phi);
974 if( ! isUsedByTrk && fill_out_of_pi) ly6_h2_nsp_notrk->Fill(sp_eta,sp_phi2);
975 }
976 if( ilayer==7 ) {
977 ly7_h2_nsp->Fill(sp_eta,sp_phi);
978 if( fill_out_of_pi ) ly7_h2_nsp->Fill(sp_eta,sp_phi2);
979 if( ! isUsedByTrk ) ly7_h2_nsp_notrk->Fill(sp_eta,sp_phi);
980 if( ! isUsedByTrk && fill_out_of_pi) ly7_h2_nsp_notrk->Fill(sp_eta,sp_phi2);
981 }
982 }
983
984 ATH_MSG_VERBOSE("looking for ly6/ly6 doublet seeds");
985
986 // (idx, sort/weight, eta, phi)
987 std::vector<std::tuple<int,float,float,float>> QT;
988
989 for(int ly6_ieta=1; ly6_ieta<=NBINS_ETA; ly6_ieta++) {
990 float ly6_eta = (ly6_h2_nsp->GetXaxis()->GetBinLowEdge(ly6_ieta) + ly6_h2_nsp->GetXaxis()->GetBinUpEdge(ly6_ieta))/2.0;
991 for(int ly6_iphi=1; ly6_iphi<=NBINS_PHI; ly6_iphi++) {
992 float ly6_phi = (ly6_h2_nsp->GetYaxis()->GetBinLowEdge(ly6_iphi) + ly6_h2_nsp->GetYaxis()->GetBinUpEdge(ly6_iphi))/2.0;
993
994 float ly6_nsp = ly6_h2_nsp ->GetBinContent(ly6_ieta,ly6_iphi);
995 float ly6_nsp_notrk = ly6_h2_nsp_notrk->GetBinContent(ly6_ieta,ly6_iphi);
996 float ly6_frac = ( ly6_nsp > 0 ) ? ly6_nsp_notrk / ly6_nsp : 0;
997 if( ly6_nsp < 10 || ly6_frac < 0.85 ) continue;
998
999 float ly7_frac_max = 0;
1000 float ly7_eta_max = 0;
1001 float ly7_phi_max = 0;
1002 for(int ly7_ieta=std::max(1,ly6_ieta-1); ly7_ieta<std::min(NBINS_ETA,ly6_ieta+1); ly7_ieta++) {
1003 for(int ly7_iphi=std::max(1,ly6_iphi-1); ly7_iphi<=std::min(NBINS_PHI,ly6_iphi+1); ly7_iphi++) {
1004 float ly7_nsp = ly7_h2_nsp ->GetBinContent(ly7_ieta,ly7_iphi);
1005 float ly7_nsp_notrk = ly7_h2_nsp_notrk->GetBinContent(ly7_ieta,ly7_iphi);
1006 float ly7_frac = ( ly7_nsp > 0 ) ? ly7_nsp_notrk / ly7_nsp : 0;
1007 if( ly7_nsp < 10 ) continue;
1008 if( ly7_frac > ly7_frac_max ) {
1009 ly7_frac_max = ly7_frac;
1010 ly7_eta_max = (ly7_h2_nsp->GetXaxis()->GetBinLowEdge(ly7_ieta) + ly7_h2_nsp->GetXaxis()->GetBinUpEdge(ly7_ieta))/2.0;
1011 ly7_phi_max = (ly7_h2_nsp->GetXaxis()->GetBinLowEdge(ly7_iphi) + ly7_h2_nsp->GetXaxis()->GetBinUpEdge(ly7_iphi))/2.0;
1012 }
1013 }
1014 }
1015 if( ly7_frac_max < 0.85 ) continue;
1016 //
1017 float wsum = ly6_frac + ly7_frac_max;
1018 float weta = (ly6_eta*ly6_frac + ly7_eta_max*ly7_frac_max) / wsum;
1019 float wphi = (ly6_phi*ly6_frac + ly7_phi_max*ly7_frac_max) / wsum;
1020 float w = wsum / 2.0;
1021 QT.push_back(std::make_tuple(-1,w,weta,wphi));
1022 }
1023 }
1024 ATH_MSG_VERBOSE("nr of ly6/ly7 doublet candidate seeds=" << QT.size() << ", doing clustering...");
1025
1026 // sort
1027 std::sort(QT.begin(), QT.end(),
1028 [](const std::tuple<int,float,float,float>& lhs, const std::tuple<int,float,float,float>& rhs) {
1029 return std::get<1>(lhs) > std::get<1>(rhs); } );
1030
1031 // clustering
1032 const double CLUSTCUT_DIST_SQUARED = 0.04; // const double CLUSTCUT_DIST = 0.2;
1033 const double CLUSTCUT_SEED_FRAC = 0.9;
1034
1035 std::vector<float> seeds_wsum;
1036
1037 for(unsigned int i=0; i<QT.size(); i++) {
1038 float phi = std::get<3>(QT[i]);
1039 float eta = std::get<2>(QT[i]);
1040 float w = std::get<1>(QT[i]);
1041 if(i==0) {
1042 seeds_eta.push_back(w*eta); seeds_phi.push_back(w*phi);
1043 seeds_wsum.push_back(w);
1044 continue;
1045 }
1046 const int IDX_INITIAL = 100;
1047 float dist2_min = 100.0;
1048 int idx_min = IDX_INITIAL;
1049 for(unsigned j=0; j<seeds_eta.size(); j++) {
1050 float ceta = seeds_eta[j]/seeds_wsum[j];
1051 float cphi = seeds_phi[j]/seeds_wsum[j];
1052 // intentionally calculate in this way as phi is defined beyond -Pi/Pi (no boundary)
1053 float deta = std::fabs(ceta-eta);
1054 float dphi = std::fabs(cphi-phi);
1055 float dist2 = dphi*dphi+deta*deta;
1056 if( dist2 < dist2_min ) {
1057 dist2_min = dist2;
1058 idx_min = j;
1059 }
1060 }
1061 int match_idx = IDX_INITIAL;
1062 if( idx_min != IDX_INITIAL ) {
1063 if( dist2_min < CLUSTCUT_DIST_SQUARED ) { match_idx = idx_min; }
1064 }
1065 if( match_idx == IDX_INITIAL ) {
1066 if( w > CLUSTCUT_SEED_FRAC && dist2_min > CLUSTCUT_DIST_SQUARED ) {
1067 seeds_eta.push_back(w*eta); seeds_phi.push_back(w*phi);
1068 seeds_wsum.push_back(w);
1069 }
1070 continue;
1071 }
1072 float new_eta = seeds_eta[match_idx] + w*eta;
1073 float new_phi = seeds_phi[match_idx] + w*phi;
1074 float new_wsum = seeds_wsum[match_idx] + w;
1075 seeds_eta[match_idx] = new_eta;
1076 seeds_phi[match_idx] = new_phi;
1077 seeds_wsum[match_idx] = new_wsum;
1078 }
1079 QT.clear();
1080 for(unsigned int i=0; i<seeds_eta.size(); i++) {
1081 float eta = seeds_eta[i] / seeds_wsum[i];
1082 float phi = seeds_phi[i] / seeds_wsum[i];
1083 seeds_eta[i] = eta;
1084 if( phi < -TMath::Pi() ) phi = 2*TMath::Pi() + phi;
1085 if( phi > TMath::Pi() ) phi = -2*TMath::Pi() + phi;
1086 seeds_phi[i] = phi;
1087 }
1088 ATH_MSG_VERBOSE("after clustering, nr of seeds = " << seeds_eta.size());
1089
1090 // delete overlap (can happen at phi=-Pi/Pi bounadry)
1091 std::vector<unsigned int> idx_to_delete;
1092 for(unsigned int i=0; i<seeds_eta.size(); i++) {
1093 if( std::find(idx_to_delete.begin(),idx_to_delete.end(),i) != idx_to_delete.end() ) continue;
1094 float eta_i = seeds_eta[i];
1095 float phi_i = seeds_phi[i];
1096 for(unsigned int j=i+1; j<seeds_eta.size(); j++) {
1097 if( std::find(idx_to_delete.begin(),idx_to_delete.end(),j) != idx_to_delete.end() ) continue;
1098 float eta_j = seeds_eta[j];
1099 float phi_j = seeds_phi[j];
1100 float dR2 = deltaR2(eta_i,phi_i,eta_j,phi_j);
1101 if( dR2 < CLUSTCUT_DIST_SQUARED ) idx_to_delete.push_back(j);
1102 }
1103 }
1104 ATH_MSG_VERBOSE("nr of duplicated seeds to be removed = " << idx_to_delete.size());
1105 if( idx_to_delete.size() > 0 ) {
1106 std::sort(idx_to_delete.begin(),idx_to_delete.end());
1107 for(unsigned int j=idx_to_delete.size(); j>0; j--) {
1108 unsigned int idx = idx_to_delete[j-1];
1109 seeds_eta.erase(seeds_eta.begin()+idx);
1110 seeds_phi.erase(seeds_phi.begin()+idx);
1111 }
1112 }
1113
1114 ATH_MSG_VERBOSE("nr of ly6/ly7 seeds=" << seeds_eta.size());
1115
1116 // return
1117 return StatusCode::SUCCESS;
1118}
1119
1120StatusCode TrigHitDVHypoAlg::findHitDV(const EventContext& ctx, const std::vector<TrigSiSpacePointBase>& convertedSpacePoints,
1121 const DataVector<Trk::Track>& tracks, std::vector<HitDVSeed>& hitDVSeedsContainer,
1122 std::vector<HitDVTrk>& hitDVTrksContainer,
1123 std::vector<HitDVSpacePoint>& hitDVSPsContainer) const
1124{
1125 std::vector<int> v_dvtrk_id;
1126 std::vector<float> v_dvtrk_pt;
1127 std::vector<float> v_dvtrk_eta;
1128 std::vector<float> v_dvtrk_phi;
1129 std::vector<int> v_dvtrk_n_hits_inner;
1130 std::vector<int> v_dvtrk_n_hits_pix;
1131 std::vector<int> v_dvtrk_n_hits_sct;
1132 std::vector<float> v_dvtrk_a0beam;
1133 std::unordered_map<Identifier, int> umap_fittedTrack_identifier;
1134 int fittedTrack_id = -1;
1135
1136 static constexpr float TRKCUT_PTGEV_HITDV = 0.5;
1137
1138 for (const auto track: tracks) {
1139 float shift_x = 0; float shift_y = 0;
1140 if(m_useBeamSpot) {
1142 FTF::getBeamSpotShift(shift_x, shift_y, **beamSpotHandle);
1143 }
1144 trackInfo theTrackInfo;
1145 bool igt = FTF::isGoodTrackUTT(track, theTrackInfo, shift_x, shift_y, TRKCUT_PTGEV_HITDV);
1146 if (not igt) {continue;}
1147
1148 fittedTrack_id++;
1149 ATH_MSG_DEBUG("Selected track pT = " << theTrackInfo.ptGeV << " GeV");
1150
1151
1153 m = track->measurementsOnTrack()->begin(),
1154 me = track->measurementsOnTrack()->end ();
1155 for(; m!=me; ++m ) {
1156 const Trk::PrepRawData* prd = ((const Trk::RIO_OnTrack*)(*m))->prepRawData();
1157 if( prd == nullptr ) continue;
1158 Identifier id_prd = prd->identify();
1159 if( umap_fittedTrack_identifier.find(id_prd) == umap_fittedTrack_identifier.end() ) {
1160 umap_fittedTrack_identifier.insert(std::make_pair(id_prd,fittedTrack_id));
1161 }
1162 }
1163 float phi = track->perigeeParameters()->parameters()[Trk::phi];
1164 v_dvtrk_id.push_back(fittedTrack_id);
1165 v_dvtrk_pt.push_back(theTrackInfo.ptGeV*Gaudi::Units::GeV);
1166 v_dvtrk_eta.push_back(theTrackInfo.eta);
1167 v_dvtrk_phi.push_back(phi);
1168 v_dvtrk_n_hits_inner.push_back(theTrackInfo.n_hits_inner);
1169 v_dvtrk_n_hits_pix.push_back(theTrackInfo.n_hits_pix);
1170 v_dvtrk_n_hits_sct.push_back(theTrackInfo.n_hits_sct);
1171 v_dvtrk_a0beam.push_back(theTrackInfo.a0beam);
1172 }
1173 ATH_MSG_DEBUG("Nr of selected tracks / all = " << fittedTrack_id << " / " << tracks.size());
1174 ATH_MSG_DEBUG("Nr of Identifiers used by selected tracks = " << umap_fittedTrack_identifier.size());
1175
1176 // space points
1177 int n_sp = 0;
1178 int n_sp_usedByTrk = 0;
1179
1180 std::unordered_map<Identifier, int> umap_sp_identifier;
1181 umap_sp_identifier.reserve(1.3*convertedSpacePoints.size());//up to 2 Identifiers per spacepoint, end up with 1.3 from measurements
1182
1183 auto add_to_sp_map = [&](const Trk::PrepRawData* prd) {
1184 if (prd) {
1185 Identifier id_prd = prd->identify();
1186 if( umap_sp_identifier.find(id_prd) == umap_sp_identifier.end() ) {
1187 umap_sp_identifier.insert(std::make_pair(id_prd,-1));
1188 }
1189 }
1190 };
1191
1192 for(unsigned int iSp=0; iSp<convertedSpacePoints.size(); ++iSp) {
1193 bool isPix = convertedSpacePoints[iSp].isPixel();
1194 bool isSct = convertedSpacePoints[iSp].isSCT();
1195 if( ! isPix && ! isSct ) continue;
1196 const Trk::SpacePoint* sp = convertedSpacePoints[iSp].offlineSpacePoint();
1197 add_to_sp_map(sp->clusterList().first);
1198 add_to_sp_map(sp->clusterList().second);
1199 }
1200 int n_id_usedByTrack = 0;
1201 for(auto it=umap_sp_identifier.begin(); it!=umap_sp_identifier.end(); ++it) {
1202 Identifier id_sp = it->first;
1203 if( umap_fittedTrack_identifier.find(id_sp) != umap_fittedTrack_identifier.end() ) {
1204 umap_sp_identifier[id_sp] = umap_fittedTrack_identifier[id_sp];
1205 ++n_id_usedByTrack;
1206 }
1207 }
1208 ATH_MSG_DEBUG("Nr of SPs / Identifiers (all) / Identifiers (usedByTrack) = " << convertedSpacePoints.size() << " / " << umap_sp_identifier.size() << " / " << n_id_usedByTrack);
1209
1210 auto sp_map_used_id = [&](const Trk::PrepRawData* prd) {
1211 int usedTrack_id = -1;
1212 if (prd) {
1213 Identifier id_prd = prd->identify();
1214 if( umap_sp_identifier.find(id_prd) != umap_sp_identifier.end() ) {
1215 usedTrack_id = umap_sp_identifier[id_prd];
1216 }
1217 }
1218 return usedTrack_id;
1219 };
1220
1221 std::vector<float> v_sp_eta;
1222 v_sp_eta.reserve(convertedSpacePoints.size());
1223 std::vector<float> v_sp_r;
1224 v_sp_r.reserve(convertedSpacePoints.size());
1225 std::vector<float> v_sp_phi;
1226 v_sp_phi.reserve(convertedSpacePoints.size());
1227 std::vector<int> v_sp_layer;
1228 v_sp_layer.reserve(convertedSpacePoints.size());
1229 std::vector<bool> v_sp_isPix;
1230 v_sp_isPix.reserve(convertedSpacePoints.size());
1231 std::vector<bool> v_sp_isSct;
1232 v_sp_isSct.reserve(convertedSpacePoints.size());
1233 std::vector<int> v_sp_usedTrkId;
1234 v_sp_usedTrkId.reserve(convertedSpacePoints.size());
1235
1236 for(const auto& sp : convertedSpacePoints) {
1237 bool isPix = sp.isPixel();
1238 bool isSct = sp.isSCT();
1239 if( ! isPix && ! isSct ) continue;
1240 const Trk::SpacePoint* osp = sp.offlineSpacePoint();
1241
1242 int usedTrack_id = -1;
1243 int usedTrack_id_first = sp_map_used_id(osp->clusterList().first);
1244 if (usedTrack_id_first != -1) {
1245 usedTrack_id = usedTrack_id_first;
1246 }
1247 int usedTrack_id_second = sp_map_used_id(osp->clusterList().second);
1248 if (usedTrack_id_second != -1) {
1249 usedTrack_id = usedTrack_id_second;
1250 }
1251
1252 //
1253 n_sp++;
1254 if( usedTrack_id != -1 ) n_sp_usedByTrk++;
1255 int layer = sp.layer();
1256 float sp_r = sp.r();
1257
1258 const Amg::Vector3D& pos_sp = osp->globalPosition();//Go back to globalPosition to get the non-shifted spacepoint positions
1259 float sp_eta = pos_sp.eta();
1260 float sp_phi = pos_sp.phi();
1261
1262 v_sp_eta.push_back(sp_eta);
1263 v_sp_r.push_back(sp_r);
1264 v_sp_phi.push_back(sp_phi);
1265 v_sp_layer.push_back(layer);
1266 v_sp_isPix.push_back(isPix);
1267 v_sp_isSct.push_back(isSct);
1268 v_sp_usedTrkId.push_back(usedTrack_id);
1269
1270 ATH_MSG_VERBOSE("+++ SP eta / phi / layer / ixPix / usedTrack_id = " << sp_eta << " / " << sp_phi << " / " << layer << " / " << isPix << " / " << usedTrack_id);
1271
1272 }
1273 ATH_MSG_DEBUG("Nr of SPs / all = " << n_sp << " / " << convertedSpacePoints.size());
1274 ATH_MSG_DEBUG("Nr of SPs used by selected tracks = " << n_sp_usedByTrk);
1275
1276 // Seed
1277 std::vector<float> v_seeds_eta;
1278 std::vector<float> v_seeds_phi;
1279 std::vector<int16_t> v_seeds_type;
1280
1281 if( m_doHitDV_Seeding ) {
1282
1283 // add L1 Jet seeds
1284 const unsigned int L1JET_ET_CUT = 27; // Mapping from legacy J30, make configurable?
1285
1286 auto jetRoiCollectionHandle = SG::makeHandle( m_jetRoiCollectionKey, ctx );
1287 const DataVector<xAOD::jFexSRJetRoI> *jetRoiCollection = jetRoiCollectionHandle.cptr();
1288 if (!jetRoiCollectionHandle.isValid()){
1289 ATH_MSG_ERROR("ReadHandle for DataVector<xAOD::jFexSRJetRoI> key:" << m_jetRoiCollectionKey.key() << " isn't Valid");
1290 return StatusCode::FAILURE;
1291 }
1292 for (size_t size=0; size<jetRoiCollection->size(); ++size){
1293 const xAOD::jFexSRJetRoI* jetRoI = jetRoiCollection->at(size);
1294 if( jetRoI == nullptr ) continue;
1295 // Good seed
1296 if( jetRoI->et() >= L1JET_ET_CUT ) {
1297 v_seeds_eta.push_back(jetRoI->eta());
1298 v_seeds_phi.push_back(jetRoI->phi());
1299 v_seeds_type.push_back(0); // L1_J:0
1300 }
1301 }
1302 ATH_MSG_DEBUG("Nr of L1_J" << L1JET_ET_CUT << " seeds = " << v_seeds_eta.size());
1303
1304 // space-point based (unseeded mode)
1305 std::vector<float> v_spseeds_eta;
1306 std::vector<float> v_spseeds_phi;
1307 ATH_CHECK( findSPSeeds(ctx, v_sp_eta, v_sp_phi, v_sp_layer, v_sp_usedTrkId, v_spseeds_eta, v_spseeds_phi) );
1308 ATH_MSG_DEBUG("Nr of SP seeds = " << v_spseeds_eta.size());
1309 for(size_t idx=0; idx<v_spseeds_eta.size(); ++idx) {
1310 v_seeds_eta.push_back(v_spseeds_eta[idx]);
1311 v_seeds_phi.push_back(v_spseeds_phi[idx]);
1312 v_seeds_type.push_back(1); // SP: 1
1313 }
1314 ATH_MSG_DEBUG("Nr of SP + L1_J" << L1JET_ET_CUT << " seeds = " << v_seeds_eta.size());
1315 }
1316
1317 // fill objects
1318
1319 // seeds
1320 const int N_MAX_SEEDS = 200;
1321 int n_seeds = std::min(N_MAX_SEEDS,(int)v_seeds_eta.size());
1322 hitDVSeedsContainer.reserve(n_seeds);
1323 for(auto iSeed=0; iSeed < n_seeds; ++iSeed) {
1324 HitDVSeed seed;
1325 seed.eta = v_seeds_eta[iSeed];
1326 seed.phi = v_seeds_phi[iSeed];
1327 seed.type = v_seeds_type[iSeed];
1328 hitDVSeedsContainer.push_back(seed);
1329 }
1330
1331 // track
1332 const float TRKCUT_DELTA_R_TO_SEED = 1.0;
1333 hitDVTrksContainer.reserve(v_dvtrk_pt.size());
1334 for(unsigned int iTrk=0; iTrk<v_dvtrk_pt.size(); ++iTrk) {
1335 float trk_eta = v_dvtrk_eta[iTrk];
1336 float trk_phi = v_dvtrk_phi[iTrk];
1337 if( m_doHitDV_Seeding ) {
1338 bool isNearSeed = false;
1339 for (unsigned int iSeed=0; iSeed<v_seeds_eta.size(); ++iSeed) {
1340 float seed_eta = v_seeds_eta[iSeed];
1341 float seed_phi = v_seeds_phi[iSeed];
1342 float dR2 = deltaR2(trk_eta,trk_phi,seed_eta,seed_phi);
1343 if( dR2 <= TRKCUT_DELTA_R_TO_SEED*TRKCUT_DELTA_R_TO_SEED ) { isNearSeed = true; break; }
1344 }
1345 if( ! isNearSeed ) continue;
1346 }
1347 HitDVTrk hitDVTrk;
1348 hitDVTrk.id = v_dvtrk_id[iTrk];
1349 hitDVTrk.pt = v_dvtrk_pt[iTrk];
1350 hitDVTrk.eta = v_dvtrk_eta[iTrk];
1351 hitDVTrk.phi = v_dvtrk_phi[iTrk];
1352 hitDVTrk.n_hits_inner = v_dvtrk_n_hits_inner[iTrk];
1353 hitDVTrk.n_hits_pix = v_dvtrk_n_hits_pix[iTrk];
1354 hitDVTrk.n_hits_sct = v_dvtrk_n_hits_sct[iTrk];
1355 hitDVTrk.a0beam = v_dvtrk_a0beam[iTrk];
1356
1357 hitDVTrksContainer.push_back(hitDVTrk);
1358 }
1359
1360 // space points
1361 const float SPCUT_DELTA_R_TO_SEED = 1.0;
1362 const size_t n_sp_max = std::min<size_t>(100000, v_sp_eta.size());
1363 size_t n_sp_stored = 0;
1364
1365 hitDVSPsContainer.reserve(n_sp_max);
1366
1367 for(size_t iSp=0; iSp<v_sp_eta.size(); ++iSp) {
1368 if( m_doHitDV_Seeding ) {
1369 const float sp_eta = v_sp_eta[iSp];
1370 const float sp_phi = v_sp_phi[iSp];
1371 bool isNearSeed = false;
1372 for (size_t iSeed=0; iSeed<v_seeds_eta.size(); ++iSeed) {
1373 const float seed_eta = v_seeds_eta[iSeed];
1374 const float seed_phi = v_seeds_phi[iSeed];
1375 const float dR2 = deltaR2(sp_eta, sp_phi, seed_eta, seed_phi);
1376 if( dR2 <= SPCUT_DELTA_R_TO_SEED*SPCUT_DELTA_R_TO_SEED ) { isNearSeed = true; break; }
1377 }
1378 if( ! isNearSeed ) continue;
1379 }
1380 if( n_sp_stored >= n_sp_max ) break;
1381 HitDVSpacePoint hitDVSP;
1382 hitDVSP.eta = v_sp_eta[iSp];
1383 hitDVSP.r = v_sp_r[iSp];
1384 hitDVSP.phi = v_sp_phi[iSp];
1385 hitDVSP.layer = v_sp_layer[iSp];
1386 hitDVSP.isPix = v_sp_isPix[iSp];
1387 hitDVSP.isSct = v_sp_isSct[iSp];
1388 hitDVSP.usedTrkId = v_sp_usedTrkId[iSp];
1389 hitDVSPsContainer.push_back(hitDVSP);
1390 ++n_sp_stored;
1391 }
1392 ATH_MSG_DEBUG("Nr of SPs stored = " << n_sp_stored);
1393
1394 return StatusCode::SUCCESS;
1395}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t sp
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & featureString()
Header file to be included by clients of the Monitored infrastructure.
bool allFailed(const Decision *d)
return true if there is no positive decision stored
Athena::TPCnvVers::Current TrigRoiDescriptor
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
size_type size() const noexcept
Returns the number of elements in the collection.
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & decisionInput() const
methods for derived classes to access handles of the base class input other read/write handles may be...
Definition HypoBase.cxx:18
const SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > & decisionOutput() const
methods for derived classes to access handles of the base class output other read/write handles may b...
Definition HypoBase.cxx:22
StatusCode hypoBaseOutputProcessing(SG::WriteHandle< TrigCompositeUtils::DecisionContainer > &outputHandle, MSG::Level lvl=MSG::DEBUG) const
Base class function to be called once slice specific code has finished. Handles debug printing and va...
Definition HypoBase.cxx:35
HypoBase(const std::string &name, ISvcLocator *pSvcLocator)
constructor, to be called by sub-class constructors
Definition HypoBase.cxx:12
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
static std::string find_calib_file(const std::string &logical_file_name)
const_pointer_type cptr()
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
float deltaR2(float, float, float, float) const
ToolHandleArray< TrigHitDVHypoTool > m_hypoTools
ToolHandle< GenericMonitoringTool > m_monTool
TrigHitDVHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode findHitDV(const EventContext &ctx, const std::vector< TrigSiSpacePointBase > &convertedSpacePoints, const DataVector< Trk::Track > &tracks, std::vector< HitDVSeed > &hitDVSeedsContainer, std::vector< HitDVTrk > &hitDVTrksContainer, std::vector< HitDVSpacePoint > &hitDVSPContainer) const
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
Gaudi::Property< float > m_jetSeed_ptMin
virtual StatusCode execute(const EventContext &context) const override
StatusCode calculateBDT(const std::vector< HitDVSpacePoint > &, const std::vector< HitDVTrk > &, const std::vector< float > &, const std::vector< float > &, const std::vector< float > &, const float &, const int, xAOD::TrigCompositeContainer *, int &) const
int getSPLayer(int, float) const
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_jetRoiCollectionKey
SG::ReadHandleKey< TrackCollection > m_tracksKey
Gaudi::Property< float > m_jetSeed_etaMax
ToolHandle< ITrigSpacePointConversionTool > m_spacePointTool
StatusCode selectSeedsNearby(const std::vector< HitDVSeed > &hitDVSeedsContainer, std::vector< float > &jetSeeds_eta, std::vector< float > &jetSeeds_phi, std::vector< float > &jetSeeds_pt) const
Gaudi::Property< bool > m_isMC
StatusCode findJetSeeds(const xAOD::JetContainer *, const float, const float, std::vector< float > &, std::vector< float > &, std::vector< float > &) const
ToolHandle< ILumiBlockMuTool > m_lumiBlockMuTool
StatusCode findSPSeeds(const EventContext &, const std::vector< HitDVSpacePoint > &, std::vector< float > &, std::vector< float > &) const
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
virtual StatusCode initialize() override
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_hitDVKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
StatusCode doMonitor(const xAOD::TrigCompositeContainer *) const
std::unique_ptr< MVAUtils::BDT > m_bdt_eta[2]
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
Identifier identify() const
return the identifier
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
virtual const Amg::Vector3D & globalPosition() const override final
Interface method to get the global Position.
const std::pair< const PrepRawData *, const PrepRawData * > & clusterList() const
return the pair of cluster pointers by reference
unsigned int et() const
Methods that require combining results or applying scales.
std::string base
Definition hcg.cxx:81
Eigen::Matrix< double, 3, 1 > Vector3D
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
void getBeamSpotShift(float &shift_x, float &shift_y, const InDet::BeamSpotData &beamSpotHandle)
bool isGoodTrackUTT(const Trk::Track *track, trackInfo &theTrackInfo, const float shift_x, const float shift_y, float trkcut_ptgev)
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & viewString()
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
const std::string & featureString()
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
std::set< DecisionID > DecisionIDContainer
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & hypoAlgNodeName()
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
bool allFailed(const Decision *d)
return true if there is no positive decision stored
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
@ phi
Definition ParamDefs.h:75
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Jet_v1 Jet
Definition of the current "jet version".
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
jFexSRJetRoI_v1 jFexSRJetRoI
Define the latest version of the jFexSRJetRoI class.
Helper for azimuthal angle calculations.
int16_t n_hits_inner
int16_t n_hits_sct
int16_t n_hits_pix
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22
TChain * tree