12 #ifndef TrigInDetAnalysisUtils_T_AnalysisConfig_H
13 #define TrigInDetAnalysisUtils_T_AnalysisConfig_H
20 #include "GaudiKernel/IToolSvc.h"
21 #include "GaudiKernel/ITHistSvc.h"
39 #ifdef XAODTRACKING_TRACKPARTICLE_H
58 template<
class Prov
ider>
70 const std::string& testChainName,
const std::string& testType,
const std::string& testKey,
71 const std::string& referenceChainName,
const std::string& referenceType,
const std::string& referenceKey,
72 const std::string& selectionChainName,
const std::string& selectionType,
const std::string& selectionKey,
100 std::vector<std::string> testChainNames; testChainNames.push_back(testChainName);
101 std::vector<std::string> referenceChainNames; referenceChainNames.push_back(referenceChainName);
102 std::vector<std::string> selectionChainNames; selectionChainNames.push_back(selectionChainName);
105 std::vector<std::string> testTypes; testTypes.push_back(testType);
106 std::vector<std::string> referenceTypes; referenceTypes.push_back(referenceType);
107 std::vector<std::string> selectionTypes; selectionTypes.push_back(selectionType);
111 std::vector<std::string> referenceKeys; referenceKeys.push_back(referenceKey);
112 std::vector<std::string> selectionKeys; selectionKeys.push_back(selectionKey);
115 std::vector<TrackFilter*> testFilters; testFilters.push_back(testFilter);
116 std::vector<TrackFilter*> referenceFilters; referenceFilters.push_back(referenceFilter);
117 std::vector<TrackFilter*> selectionFilters; selectionFilters.push_back(selectionFilter);
129 const std::string& testChainName,
const std::string& testType,
const std::string& testKey,
130 const std::string& referenceChainName,
const std::string& referenceType,
const std::string& referenceKey,
158 std::vector<std::string> testChainNames; testChainNames.push_back(testChainName);
159 std::vector<std::string> referenceChainNames; referenceChainNames.push_back(referenceChainName);
160 std::vector<std::string> selectionChainNames; selectionChainNames.push_back(
"NONE");
163 std::vector<std::string> testTypes; testTypes.push_back(testType);
164 std::vector<std::string> referenceTypes; referenceTypes.push_back(referenceType);
165 std::vector<std::string> selectionTypes; selectionTypes.push_back(
"");
169 std::vector<std::string> referenceKeys; referenceKeys.push_back(referenceKey);
170 std::vector<std::string> selectionKeys; selectionKeys.push_back(
"");
173 std::vector<TrackFilter*> testFilters; testFilters.push_back(testFilter);
174 std::vector<TrackFilter*> referenceFilters; referenceFilters.push_back(referenceFilter);
175 std::vector<TrackFilter*> selectionFilters;
224 if ( !
m_provider ) std::cerr <<
"ERROR T_AnalysisConfig::execute() called without initialising" << std::endl;
295 template<
class Collection>
296 std::pair< typename Collection::const_iterator, typename Collection::const_iterator >
298 const std::string&
key=
"" ) {
306 std::string key_collection =
key;
307 std::string key_tename =
"";
308 size_t pos = key_collection.find(
"/");
309 if (
pos!=std::string::npos ) {
311 key_tename =
key.substr( 0,
pos );
314 std::pair<
typename Collection::const_iterator,
315 typename Collection::const_iterator > itrpair;
320 const std::string* keyStr =
m_provider->evtStore()->keyToString(roi_link.
key(), checkCLID);
321 m_provider->msg(
MSG::DEBUG) <<
"Requesting range over (" <<
key <<
") associated to ROI from " << (keyStr ==
nullptr ?
"UNKNOWN" : *keyStr) <<
endmsg;
323 itrpair = (*m_tdt)->associateToEventView( handle, roi_link );
340 bool select( std::vector<TIDA::Vertex>& vertices,
346 for ( ; vtxitr!=vtx_end ; vtxitr++ ) {
347 if ( (*vtxitr)->vertexType()!=0 ) {
357 (*vtxitr)->nTrackParticles(),
359 (*vtxitr)->chiSquared(),
360 (*vtxitr)->numberDoF() ) );
369 bool select( std::vector<TIDA::Vertex>& vertices,
371 const std::string&
key=
"" ) {
378 if ( vtx_itrpair.first == vtx_itrpair.second ) {
383 m_provider->msg(
MSG::DEBUG) <<
"\txAOD::VertexContainer found with size " << (vtx_itrpair.second - vtx_itrpair.first)
386 return select( vertices, vtx_itrpair.first, vtx_itrpair.second );
392 bool select( std::vector<TIDA::Vertex>& vertices,
const std::string&
key=
"" ) {
398 if (
retrieve( xaodVtxCollection,
key ).isFailure()) {
399 m_provider->msg(MSG::WARNING) <<
"xAOD vertex container not found with key " <<
key <<
endmsg;
403 if ( xaodVtxCollection!=0 ) {
407 return select( vertices, xaodVtxCollection->
begin(), xaodVtxCollection->
end() );
413 for ( ; vtxitr != xaodVtxCollection->
end(); vtxitr++ ) {
414 if ( (*vtxitr)->nTrackParticles()>0 && (*vtxitr)->vertexType()!=0 ) {
422 (*vtxitr)->nTrackParticles(),
424 (*vtxitr)->chiSquared(),
425 (*vtxitr)->numberDoF() ) );
438 template<
class Collection>
442 const std::string&
key=
"" ) {
451 std::string key_collection =
key;
452 std::string key_tename =
"";
453 size_t pos = key_collection.find(
"/");
454 if (
pos!=std::string::npos ) {
456 key_tename =
key.substr( 0,
pos );
459 std::pair<
typename Collection::const_iterator,
460 typename Collection::const_iterator > itrpair;
465 const std::string* keyStr =
m_provider->evtStore()->keyToString(roi_link.
key(), checkCLID);
466 m_provider->msg(
MSG::DEBUG) <<
"Requesting range over (" <<
key <<
") associated to ROI from " << (keyStr ==
nullptr ?
"UNKNOWN" : *keyStr) <<
endmsg;
468 itrpair = (*m_tdt)->associateToEventView( handle, roi_link );
470 if ( itrpair.first != itrpair.second ) {
471 selector->selectTracks( itrpair.first, itrpair.second );
484 template<
class Collection>
489 std::string key_collection =
key;
490 std::string key_tename =
"";
491 size_t pos = key_collection.find(
"/");
492 if (
pos!=std::string::npos ) {
494 key_tename =
key.substr( 0,
pos );
497 std::vector< Trig::Feature<Collection> > trackcollections = citr->get<
Collection>( key_collection, TrigDefs::alsoDeactivateTEs, key_tename );
498 if ( !trackcollections.empty() ) {
500 for (
unsigned ifeat=0 ; ifeat<trackcollections.size() ; ifeat++ ) {
502 if ( !trackfeature.
empty() ) {
505 selector->selectTracks( trigtracks );
520 template<
class Collection>
525 std::vector< Trig::Feature<Collection> > trackcollections = citr->get<
Collection>(
key, TrigDefs::alsoDeactivateTEs );
526 if ( !trackcollections.empty() ) {
534 for (
unsigned ifeat=0 ; ifeat<trackcollections.size() ; ifeat++ ) {
542 std::vector< const Collection* > collectionVector;
549 for (
unsigned iv=collectionVector.size() ; iv-- ; ) {
553 if (
index!=iv )
continue;
556 selector->selectTracks( collectionVector[iv], truthmap );
570 template<
class Collection>
574 if (
m_provider->evtStore()->template contains<Collection>(
key ) ) {
579 collection = handle.
cptr();
580 return StatusCode::SUCCESS;
583 return StatusCode::FAILURE;
588 template<
class Collection>
605 template<
class Collection>
608 if (
key.empty() )
return false;
609 if ( !
m_provider->evtStore()->template contains<Collection>(
key ) )
return false;
615 if ( !(
sc.isSuccess() && collection ) )
return false;
618 if ( collection->size() == 0 ) {
623 selector->selectTracks( collection );
631 template<
class Collection>
634 std::vector<double>
v;
637 if (
m_provider->evtStore()->template contains<Collection>(
key ) ) {
640 if(
sc.isSuccess() && collection ) {
642 typename Collection::const_iterator trackitr = collection->begin();
643 typename Collection::const_iterator trackend = collection->end();
644 if ( trackitr!=trackend ) {
646 v[0] = (*trackitr)->vx();
647 v[1] = (*trackitr)->vy();
648 v[2] = (*trackitr)->vz();
660 template<
class Collection>
662 std::vector< Trig::Feature<Collection> > trackcollections = citr->get<
Collection>(
key, TrigDefs::alsoDeactivateTEs );
663 std::vector<double>
v;
664 if ( !trackcollections.empty() ) {
667 for (
unsigned ifeat=0 ; ifeat<trackcollections.size() ; ifeat++ ) {
670 if ( !trackfeature.
empty() ) {
675 typename Collection::const_iterator trackitr = trigtracks->begin();
676 typename Collection::const_iterator trackend = trigtracks->end();
677 if ( trackitr!=trackend ) {
679 v[0] = (*trackitr)->vx();
680 v[1] = (*trackitr)->vy();
681 v[2] = (*trackitr)->vz();
702 std::vector<TrackTrigObject>* elevec=0,
704 bool raw_track=
false,
706 # ifdef XAODTRACKING_TRACKPARTICLE_H
707 const std::string& containerName =
"Electrons"
709 const std::string& containerName =
"ElectronAODCollection"
717 # ifdef XAODTRACKING_TRACKPARTICLE_H
726 if( !
m_provider->evtStore()->template contains<Container>(containerName) ) {
727 m_provider->msg(MSG::WARNING) <<
"Error No Electron Container " << containerName <<
" !" <<
endmsg;
732 if(
sc.isFailure() || !container ) {
733 m_provider->msg(MSG::WARNING) <<
"Error retrieving container: " << containerName <<
" !" <<
endmsg;
739 Container::const_iterator elec = container->begin();
740 Container::const_iterator elec_end = container->end();
742 for( ; elec!=elec_end ; ++elec ){
753 bool good_electron =
false;
754 # ifdef XAODTRACKING_TRACKPARTICLE_H
762 long unsigned eleid = (
unsigned long)(&eleduff) ;
772 else trk_added = selectorRef.
selectTrack( (*elec)->trackParticle() );
774 if (trk_added) eleobj.
addChild( selectorRef.
tracks().back()->id() );
775 if (elevec) elevec->push_back( eleobj );
779 return selectorRef.
tracks().size();
789 # ifdef XAODTRACKING_TRACKPARTICLE_H
790 const std::string& containerName =
"Muons"
792 const std::string& containerName =
"StacoMuonCollection"
796 # ifdef XAODTRACKING_TRACKPARTICLE_H
808 if( !
m_provider->evtStore()->template contains<Container>(containerName) ) {
809 m_provider->msg(MSG::WARNING) <<
"Error No MuonCollection" << containerName <<
" !" <<
endmsg;
814 if(
sc.isFailure() || !container ) {
815 m_provider->msg(MSG::WARNING) <<
"Error retrieving " << containerName <<
" !" <<
endmsg;
819 auto muon = container->begin();
820 auto muon_end = container->end();
825 # ifdef XAODTRACKING_TRACKPARTICLE_H
836 return selectorRef.
tracks().size();
845 std::vector<TrackTrigObject>* tauvec=0,
847 int requireNtracks=0,
848 double EtCutOffline=0,
849 # ifdef XAODTRACKING_TRACKPARTICLE_H
850 const std::string& containerName =
"TauJets"
852 const std::string& containerName =
"TauRecContainer"
856 # ifdef XAODTRACKING_TRACKPARTICLE_H
870 if ( !
m_provider->evtStore()->template contains<Container>(containerName)) {
876 if (
sc != StatusCode::SUCCESS) {
877 m_provider->msg(MSG::WARNING) <<
" Offline tau retrieval not successful" <<
endmsg;
881 Container::const_iterator tau = container->begin();
882 Container::const_iterator tau_end = container->end();
885 for ( ; tau!=tau_end ; ++tau ) {
887 # ifdef XAODTRACKING_TRACKPARTICLE_H
890 # ifndef XAODTAU_VERSIONS_TAUJET_V3_H
891 int N = (*tau)->nTracks();
900 unsigned N = (*tau)->numTrack();
904 bool good_tau =
false;
905 # ifdef XAODTRACKING_TRACKPARTICLE_H
915 long unsigned tauid = (
unsigned long)(&duff) ;
923 bool trk_added =
false;
925 for (
unsigned i=
N ;
i-- ; ) {
926 # ifdef XAODTAU_TAUTRACK_H
928 std::vector< ElementLink<xAOD::TrackParticleContainer> > alink = (*tau)->track(
i)->trackLinks();
932 for (
size_t ilink=0 ; ilink<alink.size() ; ilink++ ) {
941 if ( trk_added ) tauobj.
addChild( selectorRef.
tracks().back()->id() );
943 if ( tauvec ) tauvec->push_back( tauobj );
947 return selectorRef.
tracks().size();
957 ToolHandle<Trig::TrigDecisionTool>*
m_tdt;
967 std::vector< std::vector<std::string> >
m_types;
968 std::vector< std::vector<std::string> >
m_keys;
1008 #endif // TrigInDetAnalysisUtils_T_AnalysisConfig_H