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