ATLAS Offline Software
Loading...
Searching...
No Matches
T_AnalysisConfig.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
10
11
12#ifndef TrigInDetAnalysisUtils_T_AnalysisConfig_H
13#define TrigInDetAnalysisUtils_T_AnalysisConfig_H
14
15#include <iostream>
16#include <sstream>
17#include <string>
18#include <map>
19
20#include "GaudiKernel/IToolSvc.h"
21#include "GaudiKernel/ITHistSvc.h"
22
24
29
33
38
39class MsgSvc;
40
41// class TrackAssociator;
42// class Converter;
43
44// class RoI;
45// class TrackFilter;
46
47template<class Provider>
49
50public:
51
52 // Full constructor: test/reference/selection
53 // - analysisInstanceName: the name of the analysis chain being created
54 // - xxxChainName: the name of the chain to be used as test/reference/selection; must be "StoreGate" in case of direct access to SG containers
55 // - xxxType: the type of tracks to be retrieved from the test/reference/selection chain or container
56 // - xxxKey: the key for tracks to be retrieved from the test/reference/selection chain or container
57 // - all standard operations are performed in loops over 0=test 1=reference 2=selection
58 T_AnalysisConfig(const std::string& analysisInstanceName,
59 const std::string& testChainName, const std::string& testType, const std::string& testKey,
60 const std::string& referenceChainName, const std::string& referenceType, const std::string& referenceKey,
61 const std::string& selectionChainName, const std::string& selectionType, const std::string& selectionKey,
62 TrackFilter* testFilter, TrackFilter* referenceFilter, TrackFilter* selectionFilter,
63 TrackAssociator* associator,
65 m_provider(0),
66 m_tdt(0),
67 m_analysisInstanceName(analysisInstanceName),
68 m_chainNames { {testChainName}, {referenceChainName}, {selectionChainName} },
69 m_types { {testType}, {referenceType}, {selectionType} },
70 m_keys { {testKey}, {referenceKey}, {selectionKey} },
71 m_filters { {testFilter}, {referenceFilter}, {selectionFilter} },
72 m_refChainName(referenceChainName),
73 m_refChainKey(referenceKey),
74 m_testChainName(testChainName),
75 m_testChainKey(testKey),
76 m_selectorRef(0),
77 m_selectorTest(0),
78 m_selectorSel(0),
79 m_associator(associator),
80 m_analysis(analysis),
81 m_mcTruth(false),
82 m_beamX(0),
83 m_beamY(0),
84 m_beamZ(0),
85 m_genericFlag(true),
86 m_releaseData(""),
87 m_keepAllEvents(false),
88 m_useHighestPT(false),
89 m_vtxIndex(-1),
90 m_filterOnRoi(true),
91 m_requireDecision(false) {
92
93 }
94
95
96 // Partial constructor: test/reference
97 // - analysisInstanceName: the name of the analysis chain being created
98 // - xxxChainName: the name of the chain to be used as test/reference; must be "StoreGate" in case of direct access to SG containers
99 // - xxxType: the type of tracks to be retrieved from the test/reference chain or container
100 // - xxxKey: the key for tracks to be retrieved from the test/reference chain or container
101 // - all standard operations are performed in loops over 0=test 1=reference 2=selection
102 T_AnalysisConfig(const std::string& analysisInstanceName,
103 const std::string& testChainName, const std::string& testType, const std::string& testKey,
104 const std::string& referenceChainName, const std::string& referenceType, const std::string& referenceKey,
105 TrackFilter* testFilter, TrackFilter* referenceFilter,
106 TrackAssociator* associator,
108 m_provider(0),
109 m_tdt(0),
110 m_analysisInstanceName(analysisInstanceName),
111 m_chainNames { {testChainName}, {referenceChainName}, {"NONE"} },
112 m_types { {testType}, {referenceType}, {""} },
113 m_keys { {testKey}, {referenceKey}, {""} },
114 m_filters { {testFilter}, {referenceFilter}, {} },
115 m_refChainName(referenceChainName),
116 m_refChainKey(referenceKey),
117 m_testChainName(testChainName),
118 m_testChainKey(testKey),
119 m_selectorRef(0),
120 m_selectorTest(0),
121 m_selectorSel(0),
122 m_associator(associator),
123 m_analysis(analysis),
124 m_mcTruth(false),
125 m_beamX(0),
126 m_beamY(0),
127 m_beamZ(0),
128 m_genericFlag(true),
129 m_releaseData(""),
130 m_keepAllEvents(false),
131 m_useHighestPT(false),
132 m_vtxIndex(-1),
133 m_filterOnRoi(true),
134 m_requireDecision(false){
135
136 }
137
138
139
140
141
142 // Destructor
144 // if ( m_selectorRef ) delete m_selectorRef;
145 // if ( m_selectorTest ) delete m_selectorTest;
146 // if ( m_selectorSel ) delete m_selectorSel;
147 // if ( m_analysis ) delete m_analysis;
148 }
149
150
151
152 // Configuration methods
153 void addTestChain(const std::string& chainName, const std::string& type, const std::string& key) {
154 m_chainNames[0].push_back(chainName); m_types[0].push_back(type); m_keys[0].push_back(key);
155 }
156
157 void addReferenceChain(const std::string& chainName, const std::string& type, const std::string& key) {
158 m_chainNames[1].push_back(chainName); m_types[1].push_back(type); m_keys[1].push_back(key);
159 }
160
161 void addSelectionChain(const std::string& chainName, const std::string& type, const std::string& key) {
162 m_chainNames[2].push_back(chainName); m_types[2].push_back(type); m_keys[2].push_back(key);
163 }
164
165 void addTestFilter(TrackFilter* filter) { m_filters[0].push_back(filter); }
166 void addReferenceFilter(TrackFilter* filter) { m_filters[1].push_back(filter); }
167 void addSelectionFilter(TrackFilter* filter) { m_filters[2].push_back(filter); }
168
169 // Initialize, execute and finalize generic methods
170 virtual void initialize(Provider* p, ToolHandle<Trig::TrigDecisionTool>* tdt ) {
171 m_provider = p;
172 m_tdt = tdt;
173 if ( m_tdt==0 ) m_analysis->initialise();
174
175 }
176
177
178
179 virtual void execute() {
180 if ( !m_provider ) std::cerr << "ERROR T_AnalysisConfig::execute() called without initialising" << std::endl;
181 loop();
182 }
183
184 virtual void finalize() { m_analysis->finalise(); }
185
186 virtual void book() { }
187
188 // Accessor methods
189 const std::string& name() const {return m_analysisInstanceName;}
190
191 const std::string testChains() const {
192 std::string name;
193 for(unsigned int i=0; i<m_chainNames[0].size(); i++)
194 name += (m_chainNames[0][i]+"::"+m_types[0][i]+"::"+m_keys[0][i]+" ");
195 return name;
196 }
197
198 const std::string referenceChains() const {
199 std::string name;
200 for(unsigned int i=0; i<m_chainNames[1].size(); i++)
201 name += (m_chainNames[1][i]+"::"+m_types[1][i]+"::"+m_keys[1][i]+" ");
202 return name;
203 }
204
205 const std::string selectionChains() const {
206 std::string name;
207 for(unsigned int i=0; i<m_chainNames[2].size(); i++)
208 name += (m_chainNames[2][i]+"::"+m_types[2][i]+"::"+m_keys[2][i]+" ");
209 return name;
210 }
211
212 const TrackAnalysis* analysis() const {return m_analysis;}
213
214 void setMCTruth(bool b=true) { m_mcTruth=b; }
215 bool mcTruth() const { return m_mcTruth; }
216
217 void setBeamX(double d) { m_beamX=d; }
218 void setBeamY(double d) { m_beamY=d; }
219 void setBeamZ(double d) { m_beamZ=d; }
220 double beamX() const { return m_beamX; }
221 double beamY() const { return m_beamY; }
222 double beamZ() const { return m_beamZ; }
223
224 bool genericFlag() const { return m_genericFlag; }
225 void setGenericFlag(bool b) { m_genericFlag=b; }
226
227 const std::string& releaseData() const { return m_releaseData; }
228 void releaseData(const std::string& s) { m_releaseData = s; }
229
230 void keepAllEvents( bool b ) { m_keepAllEvents = b; }
231
232 void setUseHighestPT( bool b ) { m_useHighestPT=b; }
233 bool getUseHighestPT() const { return m_useHighestPT; }
234
235 void setVtxIndex( int i ) { m_vtxIndex=i; }
236 int getVtxIndex() const { return m_vtxIndex; }
237
238 bool filterOnRoi() const { return m_filterOnRoi; }
239 bool setFilterOnRoi(bool b) { return m_filterOnRoi=b; }
240
242 bool requireDecision() const { return m_requireDecision; }
243
244protected:
245
246 virtual void loop() = 0;
247
248
250
251 template<class Collection>
252 std::pair< typename Collection::const_iterator, typename Collection::const_iterator >
254 const std::string& key="" ) {
255
258 // std::cout << "try " << key << "\t" << m_provider->evtStore()->template transientContains<Collection>(key) << std::endl;
259
262 std::string key_collection = key;
263 std::string key_tename = "";
264 size_t pos = key_collection.find("/");
265 if ( pos!=std::string::npos ) {
266 key_collection = key.substr( pos+1, key.size()-pos );
267 key_tename = key.substr( 0, pos );
268 }
269
270 std::pair< typename Collection::const_iterator,
271 typename Collection::const_iterator > itrpair;
272
273 SG::ReadHandle<Collection> handle(key);
274
275 CLID checkCLID;
276 const std::string* keyStr = m_provider->evtStore()->keyToString(roi_link.key(), checkCLID);
277 m_provider->msg(MSG::DEBUG) << "Requesting range over (" << key << ") associated to ROI from " << (keyStr == nullptr ? "UNKNOWN" : *keyStr) << endmsg;
278
279 itrpair = (*m_tdt)->associateToEventView( handle, roi_link );
280
281 return itrpair;
282 }
283
284
285
286
287
288
289
290
291
292
293
294
295
296 bool select( std::vector<TIDA::Vertex>& vertices,
299
300 xAOD::VertexContainer::const_iterator vtxitr = vtx_start;
301
302 for ( ; vtxitr!=vtx_end ; ++vtxitr ) {
303 if ( (*vtxitr)->vertexType()!=0 ) {
304 m_provider->msg(MSG::VERBOSE) << "\tvertex " << (*vtxitr)->z() << endmsg;
305
306 vertices.push_back( TIDA::Vertex( (*vtxitr)->x(),
307 (*vtxitr)->y(),
308 (*vtxitr)->z(),
310 (*vtxitr)->covariancePosition()(Trk::x,Trk::x),
311 (*vtxitr)->covariancePosition()(Trk::y,Trk::y),
312 (*vtxitr)->covariancePosition()(Trk::z,Trk::z),
313 (*vtxitr)->nTrackParticles(),
315 (*vtxitr)->chiSquared(),
316 (*vtxitr)->numberDoF() ) );
317
318 }
319 }
320
321 return true;
322 }
323
324
325 bool select( std::vector<TIDA::Vertex>& vertices,
327 const std::string& key="" ) {
328
329 m_provider->msg(MSG::VERBOSE) << "\tFetch xAOD::VertexContainer for key: " << key << endmsg;
330
332 xAOD::VertexContainer::const_iterator > vtx_itrpair = this->template getCollection<xAOD::VertexContainer>( roi_link, key );
333
334 if ( vtx_itrpair.first == vtx_itrpair.second ) {
335 m_provider->msg(MSG::WARNING) << "\tNo xAOD::Vertex collection for key " << key << endmsg;
336 return false;
337 }
338
339 m_provider->msg(MSG::DEBUG) << "\txAOD::VertexContainer found with size " << (vtx_itrpair.second - vtx_itrpair.first)
340 << "\t:" << key << endmsg;
341
342 return select( vertices, vtx_itrpair.first, vtx_itrpair.second );
343 }
344
345
346
347
348 bool select( std::vector<TIDA::Vertex>& vertices, const std::string& key="" ) {
349
350 m_provider->msg(MSG::VERBOSE) << "fetching AOD vertex container" << endmsg;
351
352 const xAOD::VertexContainer* xaodVtxCollection = 0;
353
354 if ( retrieve( xaodVtxCollection, key ).isFailure()) {
355 m_provider->msg(MSG::WARNING) << "xAOD vertex container not found with key " << key << endmsg;
356 return false;
357 }
358
359 if ( xaodVtxCollection!=0 ) {
360
361 m_provider->msg(MSG::VERBOSE) << "xAOD vertex container " << xaodVtxCollection->size() << " entries" << endmsg;
362
363 return select( vertices, xaodVtxCollection->begin(), xaodVtxCollection->end() );
364
365#if 0
366
367 xAOD::VertexContainer::const_iterator vtxitr = xaodVtxCollection->begin();
368
369 for ( ; vtxitr != xaodVtxCollection->end(); vtxitr++ ) {
370 if ( (*vtxitr)->nTrackParticles()>0 && (*vtxitr)->vertexType()!=0 ) {
371 vertices.push_back( TIDA::Vertex( (*vtxitr)->x(),
372 (*vtxitr)->y(),
373 (*vtxitr)->z(),
375 (*vtxitr)->covariancePosition()(Trk::x,Trk::x),
376 (*vtxitr)->covariancePosition()(Trk::y,Trk::y),
377 (*vtxitr)->covariancePosition()(Trk::z,Trk::z),
378 (*vtxitr)->nTrackParticles(),
380 (*vtxitr)->chiSquared(),
381 (*vtxitr)->numberDoF() ) );
382 }
383 }
384
385#endif
386
387 }
388
389 return true;
390 }
391
392
393
394 template<class Collection>
396 // const TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> roi_link,
398 const std::string& key="" ) {
399
400
403 // std::cout << "try " << key << "\t" << m_provider->evtStore()->template transientContains<Collection>(key) << std::endl;
404
407 std::string key_collection = key;
408 std::string key_tename = "";
409 size_t pos = key_collection.find("/");
410 if ( pos!=std::string::npos ) {
411 key_collection = key.substr( pos+1, key.size()-pos );
412 key_tename = key.substr( 0, pos );
413 }
414
415 std::pair< typename Collection::const_iterator,
416 typename Collection::const_iterator > itrpair;
417
418 SG::ReadHandle<Collection> handle(key);
419
420 CLID checkCLID;
421 const std::string* keyStr = m_provider->evtStore()->keyToString(roi_link.key(), checkCLID);
422 m_provider->msg(MSG::DEBUG) << "Requesting range over (" << key << ") associated to ROI from " << (keyStr == nullptr ? "UNKNOWN" : *keyStr) << endmsg;
423
424 itrpair = (*m_tdt)->associateToEventView( handle, roi_link );
425
426 if ( itrpair.first != itrpair.second ) {
427 selector->selectTracks( itrpair.first, itrpair.second );
428 return true;
429 }
430 else {
431 m_provider->msg(MSG::DEBUG) << "TDT TrackFeature collection (" << key << ") is empty " << endmsg;
432 return false;
433 }
434 }
435
436
437
439
440 template<class Collection>
441 bool selectTracks( TrigTrackSelector* selector, Trig::FeatureContainer::combination_const_iterator citr, const std::string& key="" ) {
442 // std::cout << "try " << key << "\t" << m_provider->evtStore()->template transientContains<Collection>(key) << std::endl;
443
444 std::string key_collection = key;
445 std::string key_tename = "";
446 size_t pos = key_collection.find("/");
447 if ( pos!=std::string::npos ) {
448 key_collection = key.substr( pos+1, key.size()-pos );
449 key_tename = key.substr( 0, pos );
450 }
451
452 std::vector< Trig::Feature<Collection> > trackcollections = citr->get<Collection>( key_collection, TrigDefs::alsoDeactivateTEs, key_tename );
453 if ( !trackcollections.empty() ) {
454 // NB!! a combination should never have more than one entry for a track collection from a single algorithm, for single object triggers
455 for ( unsigned ifeat=0 ; ifeat<trackcollections.size() ; ifeat++ ) {
456 Trig::Feature<Collection> trackfeature = trackcollections.at(ifeat);
457 if ( !trackfeature.empty() ) {
458 // actually select the tracks from this roi at last!!
459 const Collection* trigtracks = trackfeature.cptr();
460 selector->selectTracks( trigtracks );
461 }
462 }
463 return true;
464 }
465 else {
466 m_provider->msg(MSG::DEBUG) << "TDT TrackFeature collection (" << key << ") is empty " << endmsg;
467 return false;
468 }
469 }
470
471
473 template<class Collection>
474 bool selectTracks( TrigTrackSelector* selector, Trig::FeatureContainer::combination_const_iterator citr, const std::string& key, unsigned index ) {
475
476 // std::cout << "try " << key << "\t" << m_provider->evtStore()->template transientContains<Collection>(key) << std::endl;
477
478 std::vector< Trig::Feature<Collection> > trackcollections = citr->get<Collection>( key, TrigDefs::alsoDeactivateTEs );
479 if ( !trackcollections.empty() ) {
480
481 const HLT::NavigationCore* nc = (*m_tdt)->ExperimentalAndExpertMethods().getNavigation();
482
483 // NB!! a combination should never have more than one entry for a track collection from a single algorithm,
484 // if ( trackcollections.size()>1 ) std::cerr << "SUTT OH NO!!!!!!!!" << endmsg;
485 // maybe a bit dodgy, if we really do have multiple objects returned, but that should only be for
486 // multiple object triggers - then probably none of this would work anyhow
487 for ( unsigned ifeat=0 ; ifeat<trackcollections.size() ; ifeat++ ) {
488
489 Trig::Feature<Collection> trackfeature = trackcollections.at(ifeat);
490
492 const HLT::TriggerElement* te = trackfeature.te();
493
495 std::vector< const Collection* > collectionVector;
496 if ( !const_cast<HLT::NavigationCore *>(nc)->getFeatures( te, collectionVector, key ) ) return false;
497
498 // std::cout << "foundok " << foundok << "\tsize " << collectionVector.size() << std::endl;
499
501
502 for ( unsigned iv=collectionVector.size() ; iv-- ; ) {
506 if ( index!=iv ) continue;
508 // m_provider->msg(MSG::DEBUG) << "TDT TrackFeature->size() " << collectionVector[iv]->size() << " (" << key << ")" << endmsg;
509 selector->selectTracks( collectionVector[iv] );
510 break;
511 }
512 }
513 return true;
514 }
515 else {
516 m_provider->msg(MSG::DEBUG) << "TDT TrackFeature collection (" << key << ") is empty" << endmsg;
517 return false;
518 }
519 }
520
521
522
523 template<class Collection>
524 StatusCode retrieve( Collection const*& collection, const std::string& key="" ) {
527 if ( m_provider->evtStore()->template contains<Collection>( key ) ) {
528 SG::ReadHandle<Collection> handle(key);
529 if ( handle.isValid() ) {
532 collection = handle.cptr();
533 return StatusCode::SUCCESS;
534 }
535 }
536 return StatusCode::FAILURE;
537 }
538
539
540
541 template<class Collection>
542 bool selectTracks( TrigTrackSelector* selector, const std::string& key ) {
543 if ( key!="" ) {
544 SG::ReadHandle<Collection> handle(key);
545 if ( handle.isValid() ) {
547 // std::cout << "\t\t\t T_AnalysisConfig::selectTracks() - > TrackSelector" << std::endl;
548 selector->selectTracks( handle.cptr() );
549 return true;
550 }
551 }
552 return false;
553 }
554
555
556
557
558 template<class Collection>
559 bool selectTracksNotEmpty( TrigTrackSelector* selector, const std::string& key ) {
560 const Collection* collection = nullptr;
561 if ( key.empty() ) return false;
562 if ( !m_provider->evtStore()->template contains<Collection>( key ) ) return false;
563
564 StatusCode sc = retrieve( collection, key );
565
566 if ( !( sc.isSuccess() && collection ) ) return false;
567
568 m_provider->msg(MSG::DEBUG) << "SG Collection->size() " << collection->size() << " (" << key << ")" << endmsg;
569
570 // added to fix muon samples bug
571 if ( collection->size() == 0 ) {
572 m_provider->msg(MSG::WARNING) << "no particles in collection" << endmsg;
573 return false;
574 }
575
576 selector->selectTracks( collection );
577 return true;
578 }
579
580
581
582
583
584 template<class Collection>
585 std::vector<double> getBeamspot( const std::string& key ) {
586 const Collection* collection = 0;
587 std::vector<double> v;
588
589 if ( key!="" ) {
590 if ( m_provider->evtStore()->template contains<Collection>( key ) ) {
591 StatusCode sc = retrieve( collection, key );
592 if( sc.isSuccess() && collection ) {
593 m_provider->msg(MSG::DEBUG) << "SG Collection->size() " << collection->size() << " (" << key << ")" << endmsg;
594
595 typename Collection::const_iterator trackitr = collection->begin();
596 typename Collection::const_iterator trackend = collection->end();
597 if ( trackitr!=trackend ) {
598 v.resize(3);
599 v[0] = (*trackitr)->vx();
600 v[1] = (*trackitr)->vy();
601 v[2] = (*trackitr)->vz();
602 return v;
603 } // only need to look at the first track
604 }
605 }
606 }
607 return v;
608 }
609
610
611
612
613 template<class Collection>
614 std::vector<double> getBeamspot( Trig::FeatureContainer::combination_const_iterator citr, const std::string& key="" ) {
615 std::vector< Trig::Feature<Collection> > trackcollections = citr->get<Collection>( key, TrigDefs::alsoDeactivateTEs );
616 std::vector<double> v;
617 if ( !trackcollections.empty() ) {
618 // NB!! a combination should never have more than one entry for a track collection from a single algorithm,
619 // if ( trackcollections.size()>1 ) std::cerr << "SUTT OH NO!!!!!!!!" << endmsg;
620 for ( unsigned ifeat=0 ; ifeat<trackcollections.size() ; ifeat++ ) {
621 // std::cout << "selectTracks() ifeat=" << ifeat << "\tkey " << key << std::endl;
622 Trig::Feature<Collection> trackfeature = trackcollections.at(ifeat);
623 if ( !trackfeature.empty() ) {
624 // m_provider->msg(MSG::DEBUG) << "TDT TrackFeature->size() " << trackfeature.cptr()->size() << " (" << key << ")" << endmsg;
625 // actually select the tracks from this roi at last!!
626 const Collection* trigtracks = trackfeature.cptr();
627
628 typename Collection::const_iterator trackitr = trigtracks->begin();
629 typename Collection::const_iterator trackend = trigtracks->end();
630 if ( trackitr!=trackend ) {
631 v.resize(3);
632 v[0] = (*trackitr)->vx();
633 v[1] = (*trackitr)->vy();
634 v[2] = (*trackitr)->vz();
635 return v;
636 } // only need to look at the first track
637 }
638 }
639 return v;
640 }
641 else {
642 m_provider->msg(MSG::DEBUG) << "TDT TrackFeature collection (" << key << ") is empty " << endmsg;
643 return v;
644 }
645 }
646
647
648
649
650
654 unsigned processElectrons( TrigTrackSelector& selectorRef,
655 std::vector<TrackTrigObject>* elevec=0,
656 const unsigned int selection=0,
657 bool raw_track=false,
658 double ETOffline=0,
659 const std::string& containerName = "Electrons"
660 ) {
661
662 m_provider->msg(MSG::DEBUG) << "Fetching offline electrons: " << containerName << endmsg;
663
664 selectorRef.clear();
665
667
668 const Container* container = 0;
669
670 if( ! m_provider->evtStore()->template contains<Container>(containerName) ) {
671 m_provider->msg(MSG::WARNING) << "Error No Electron Container " << containerName << " !" << endmsg;
672 return 0;
673 }
674
675 StatusCode sc = retrieve( container, containerName);
676 if( sc.isFailure() || !container ) {
677 m_provider->msg(MSG::WARNING) << "Error retrieving container: " << containerName << " !" << endmsg;
678 return 0;
679 }
680
681 m_provider->msg(MSG::DEBUG) << "Event with " << container->size() << " Electron object(s) " << endmsg;
682
683 Container::const_iterator elec = container->begin();
684 Container::const_iterator elec_end = container->end();
685
686 for( ; elec!=elec_end ; ++elec ){
687 //m_provider->msg(MSG::DEBUG) << " Electron " << (*elec)
688 // << ", eta " << (*elec)->eta()
689 // << ", phi " << (*elec)->phi()
690 // << ", ET " << (*elec)->pt()
691 // << ", author " << (*elec)->author()
692 // << ", trackParticle " << (*elec)->trackParticle()
693 // << ", conversion " << (*elec)->conversion()
694 // << ", mediumPP " << ((*elec)->isem(egammaPID::ElectronMediumPP)==0)
695 // << endmsg;
696
697 bool good_electron = false;
698 good_electron = TIDA::isGoodOffline( *(*elec), selection, ETOffline );
699
700 if (good_electron) {
701 const xAOD::Electron_v1& eleduff = *(*elec);
702 long unsigned eleid = (unsigned long)(&eleduff) ;
703 TrackTrigObject eleobj = TrackTrigObject( (*elec)->eta(),
704 (*elec)->phi(),
705 (*elec)->pt(),
706 0,
707 (*elec)->type(),
708 eleid );
709
710 bool trk_added ;
711 if ( raw_track ) trk_added = selectorRef.selectTrack( xAOD::EgammaHelpers::getOriginalTrackParticle( *elec ) );
712 else trk_added = selectorRef.selectTrack( (*elec)->trackParticle() );
713
714 if (trk_added) eleobj.addChild( selectorRef.tracks().back()->id() );
715 if (elevec) elevec->push_back( eleobj );
716 }
717 }
718
719 return selectorRef.tracks().size();
720 }
721
722
723
727 unsigned processMuons( TrigTrackSelector& selectorRef, const unsigned int selection=0,
728 double ETOffline=0,
729 const std::string& containerName = "Muons"
730 ) {
731
733
734 m_provider->msg(MSG::DEBUG) << " Offline muons (" << containerName << ")" << endmsg;
735
736 selectorRef.clear();
737
738 const Container* container = 0;
739
740 if( ! m_provider->evtStore()->template contains<Container>(containerName) ) {
741 m_provider->msg(MSG::WARNING) << "Error No MuonCollection" << containerName << " !" << endmsg;
742 return 0;
743 }
744
745 StatusCode sc = retrieve( container, containerName );
746 if( sc.isFailure() || !container ) {
747 m_provider->msg(MSG::WARNING) << "Error retrieving " << containerName << " !" << endmsg;
748 return 0;
749 }
750
751 auto muon = container->begin();
752 auto muon_end = container->end();
753
754 // std::cout << "SUTT Offline muons " << container->size() << "\t threshold " << ETOffline << std::endl;
755
756 for( ; muon!=muon_end ; ++muon ){
757 if ( TIDA::isGoodOffline(*(*muon), selection, ETOffline ) ) selectorRef.selectTrack((*muon)->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle));
758 }
759
760
761 // std::cout << "SUTT found " << selectorRef.tracks().size() << " muons for " << containerName << std::endl;
762 m_provider->msg(MSG::DEBUG) << "found " << selectorRef.tracks().size() << " muons for " << containerName << endmsg;
763
764 return selectorRef.tracks().size();
765}
766
767
768
772unsigned processTaus( TrigTrackSelector& selectorRef,
773 std::vector<TrackTrigObject>* tauvec=0,
774 const unsigned selection=0,
775 int requireNtracks=0,
776 double EtCutOffline=0,
777 const std::string& containerName = "TauJets"
778 ) {
779
781
782 selectorRef.clear();
783
784 const Container* container = 0;
785
786 selectorRef.clear();
787
788 m_provider->msg(MSG::DEBUG) << " Offline taus " << containerName << endmsg;
789
790 if ( !m_provider->evtStore()->template contains<Container>(containerName)) {
791 m_provider->msg(MSG::WARNING) << " Offline taus not found" << endmsg;
792 return 0;
793 }
794
795 StatusCode sc = retrieve( container, containerName);
796 if (sc != StatusCode::SUCCESS) {
797 m_provider->msg(MSG::WARNING) << " Offline tau retrieval not successful" << endmsg;
798 return 0;
799 }
800
801 Container::const_iterator tau = container->begin();
802 Container::const_iterator tau_end = container->end();
803
804
805 for ( ; tau!=tau_end ; ++tau ) {
806
807# ifndef XAODTAU_VERSIONS_TAUJET_V3_H
808 int N = (*tau)->nTracks();
809 // std::cout << "SUTT no tau detail " << N << "\t3prong: " << doThreeProng << std::endl;
810# else
811 int N=0;
812 (*tau)->detail( xAOD::TauJetParameters::nChargedTracks, N );
813 // std::cout << "SUTT tau detail: N " << N << "\t3prong: " << doThreeProng << std::endl;
814# endif
815
816 bool good_tau = false;
817 good_tau = TIDA::isGoodOffline( *(*tau), selection, requireNtracks, EtCutOffline );
818
819 // std::cout << "SUTT tau ntracks: " << N << "\tgoodtau: " << good_tau << "\tpt: " << (*tau)->p4().Et() << "\t3prong: " << doThreeProng << std::endl;
820
821 if (good_tau){
822 const xAOD::TauJet_v3& duff = *(*tau);
823 long unsigned tauid = (unsigned long)(&duff) ;
824 TrackTrigObject tauobj = TrackTrigObject( (*tau)->eta(),
825 (*tau)->phi(),
826 (*tau)->pt(),
827 0,
828 (*tau)->type(),
829 tauid );
830
831 bool trk_added = false;
832
833 for ( unsigned i=N ; i-- ; ) {
834
835 std::vector< ElementLink<xAOD::TrackParticleContainer> > alink = (*tau)->track(i)->trackLinks();
836
837 trk_added = false;
838
839 for ( size_t ilink=0 ; ilink<alink.size() ; ilink++ ) {
840 if ( alink[ilink].isValid() ) trk_added = selectorRef.selectTrack((*alink[ilink]));
841 }
843 // trk_added = selectorRef.selectTrack((*tau)->track(i)->track());
845 if ( trk_added ) tauobj.addChild( selectorRef.tracks().back()->id() );
846 }
847 if ( tauvec ) tauvec->push_back( tauobj );
848 }
849 }
850
851 return selectorRef.tracks().size();
852
853}
854
855protected:
856
857 // Athena tools
858
859 Provider* m_provider;
860
861 ToolHandle<Trig::TrigDecisionTool>* m_tdt;
862
863 // TrigInDetAnalysis tools
864 // Converter* m_converter;
865
866 // Analysis instance name
868
869 // Chain info
870 std::vector< std::vector<std::string> > m_chainNames;
871 std::vector< std::vector<std::string> > m_types;
872 std::vector< std::vector<std::string> > m_keys;
873 // Analysis tools
874 std::vector< std::vector<TrackFilter*> > m_filters;
875
876 std::string m_refChainName;
877 std::string m_refChainKey;
878
879 std::string m_testChainName;
880 std::string m_testChainKey;
881
885
888
890
892
894 std::string m_releaseData;
895
897
899
901
903
905
906};
907
908//}
909
910
911#endif // TrigInDetAnalysisUtils_T_AnalysisConfig_H
#define endmsg
uint32_t CLID
The Class ID type.
static Double_t sc
TIDA::Associator< TIDA::Track > TrackAssociator
base class for a single track selection filter allowing parameter setting for complex track selection
Read-only collection implementation.
Definition Collection.h:22
std::size_t size()
Returns the number of rows without advancing the reader.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:861
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
double beamX() const
unsigned processMuons(TrigTrackSelector &selectorRef, const unsigned int selection=0, double ETOffline=0, const std::string &containerName="Muons")
select offlinqe muons
std::pair< typename Collection::const_iterator, typename Collection::const_iterator > getCollection(const ElementLink< TrigRoiDescriptorCollection > &roi_link, const std::string &key="")
new MT feature access
const TrackAnalysis * analysis() const
bool setFilterOnRoi(bool b)
const std::string referenceChains() const
void setRequireDecision(bool b)
std::vector< std::vector< std::string > > m_chainNames
int getVtxIndex() const
TrackAnalysis * m_analysis
unsigned processElectrons(TrigTrackSelector &selectorRef, std::vector< TrackTrigObject > *elevec=0, const unsigned int selection=0, bool raw_track=false, double ETOffline=0, const std::string &containerName="Electrons")
select offline electrons
bool select(std::vector< TIDA::Vertex > &vertices, const std::string &key="")
bool requireDecision() const
const std::string & name() const
void addSelectionChain(const std::string &chainName, const std::string &type, const std::string &key)
bool select(std::vector< TIDA::Vertex > &vertices, const ElementLink< TrigRoiDescriptorCollection > &roi_link, const std::string &key="")
void addTestChain(const std::string &chainName, const std::string &type, const std::string &key)
void setBeamY(double d)
void setVtxIndex(int i)
std::vector< std::vector< std::string > > m_types
virtual void finalize()
bool filterOnRoi() const
bool getUseHighestPT() const
std::string m_releaseData
TrigTrackSelector * m_selectorTest
TrigTrackSelector * m_selectorSel
std::string m_analysisInstanceName
bool selectTracks(TrigTrackSelector *selector, const ElementLink< TrigRoiDescriptorCollection > &roi_link, const std::string &key="")
std::string m_testChainKey
bool selectTracks(TrigTrackSelector *selector, const std::string &key)
std::vector< std::vector< TrackFilter * > > m_filters
unsigned processTaus(TrigTrackSelector &selectorRef, std::vector< TrackTrigObject > *tauvec=0, const unsigned selection=0, int requireNtracks=0, double EtCutOffline=0, const std::string &containerName="TauJets")
select offline taus
void setGenericFlag(bool b)
void keepAllEvents(bool b)
void setBeamZ(double d)
void addReferenceFilter(TrackFilter *filter)
bool selectTracks(TrigTrackSelector *selector, Trig::FeatureContainer::combination_const_iterator citr, const std::string &key="")
lagacy run 2 access
void addReferenceChain(const std::string &chainName, const std::string &type, const std::string &key)
void setUseHighestPT(bool b)
void addTestFilter(TrackFilter *filter)
std::string m_testChainName
void releaseData(const std::string &s)
TrigTrackSelector * m_selectorRef
double beamZ() const
void setBeamX(double d)
virtual void initialize(Provider *p, ToolHandle< Trig::TrigDecisionTool > *tdt)
T_AnalysisConfig(const std::string &analysisInstanceName, const std::string &testChainName, const std::string &testType, const std::string &testKey, const std::string &referenceChainName, const std::string &referenceType, const std::string &referenceKey, TrackFilter *testFilter, TrackFilter *referenceFilter, TrackAssociator *associator, TrackAnalysis *analysis)
const std::string selectionChains() const
virtual void loop()=0
StatusCode retrieve(Collection const *&collection, const std::string &key="")
std::string m_refChainName
std::vector< double > getBeamspot(Trig::FeatureContainer::combination_const_iterator citr, const std::string &key="")
std::vector< double > getBeamspot(const std::string &key)
void setMCTruth(bool b=true)
ToolHandle< Trig::TrigDecisionTool > * m_tdt
std::string m_refChainKey
T_AnalysisConfig(const std::string &analysisInstanceName, const std::string &testChainName, const std::string &testType, const std::string &testKey, const std::string &referenceChainName, const std::string &referenceType, const std::string &referenceKey, const std::string &selectionChainName, const std::string &selectionType, const std::string &selectionKey, TrackFilter *testFilter, TrackFilter *referenceFilter, TrackFilter *selectionFilter, TrackAssociator *associator, TrackAnalysis *analysis)
double beamY() const
bool genericFlag() const
const std::string testChains() const
void addSelectionFilter(TrackFilter *filter)
bool selectTracksNotEmpty(TrigTrackSelector *selector, const std::string &key)
bool selectTracks(TrigTrackSelector *selector, Trig::FeatureContainer::combination_const_iterator citr, const std::string &key, unsigned index)
NB: because we want to use this for the L2Star chains, we have to use this method,...
virtual ~T_AnalysisConfig()
TrackAssociator * m_associator
bool select(std::vector< TIDA::Vertex > &vertices, xAOD::VertexContainer::const_iterator vtx_start, xAOD::VertexContainer::const_iterator vtx_end)
virtual void book()
virtual void execute()
const std::string & releaseData() const
std::vector< std::vector< std::string > > m_keys
const std::vector< TIDA::Track * > & tracks() const
void addChild(unsigned long id)
bool selectTrack(HepMC::ConstGenParticlePtr track)
virtual void clear() override
std::vector< Combination >::const_iterator combination_const_iterator
is basic vehicle of object access in TDT
Definition Feature.h:112
const T * cptr() const
explicit conversion to object
Definition Feature.h:171
const HLT::TriggerElement * te() const
explicit conversion to TriggerElement
Definition Feature.h:181
bool empty() const
test method to check if the object is truly there
Definition Feature.h:197
Class describing a tau jet.
Definition TauJet_v3.h:41
const std::string selection
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
bool isGoodOffline(const xAOD::Electron &elec, const unsigned int selection=0, double ETOffline=0)
@ x
Definition ParamDefs.h:55
@ z
global position (cartesian)
Definition ParamDefs.h:57
@ y
Definition ParamDefs.h:56
Definition index.py:1
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".