23 #ifndef TrigInDetAnalysisExample_T_AnalysisConfigMT_Tier0_H
24 #define TrigInDetAnalysisExample_T_AnalysisConfigMT_Tier0_H
41 #include "GaudiKernel/ToolHandle.h"
92 template<
typename T,
typename A=Analysis_Tier0>
104 const std::string& testChainName,
const std::string& testType,
const std::string& testKey,
105 const std::string& referenceChainName,
const std::string& referenceType,
const std::string& referenceKey,
111 testChainName, testType, testKey,
112 referenceChainName, referenceType, referenceKey,
113 testFilter, referenceFilter,
146 std::cout <<
"\nT_AnalysisConfigMT_Tier0::name: " <<
name() <<
"\t" <<
this << std::endl;
147 std::cout <<
"T_AnalysisConfigMT_Tier0::chain specification: " << testChainName <<
" -> " <<
chain <<
"\t" <<
chain.raw() << std::endl;
148 std::cout <<
"\tchain: " <<
chain.head() << std::endl;
149 std::cout <<
"\tkey: " <<
chain.tail() << std::endl;
150 std::cout <<
"\troi: " <<
chain.roi() << std::endl;
151 std::cout <<
"\tvtx: " <<
chain.vtx() << std::endl;
152 std::cout <<
"\tte: " <<
chain.element() << std::endl;
154 std::cout <<
"\tpost: " <<
chain.post() << std::endl;
155 std::cout <<
"\tpt: " <<
chain.postvalue(
"pt") << std::endl;
214 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
216 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
226 std::vector<ChainString>
chains;
242 std::string selectChain =
chainName.raw();
250 std::vector<std::string> selectChains = (*(
m_tdt))->getListOfTriggers(
chainName.head() );
252 for (
unsigned iselected=0 ; iselected<selectChains.size() ; iselected++ ) {
254 selectChains[iselected] =
chainName.subs( selectChains[iselected] );
257 std::cout <<
"sorting:: chain specification: " <<
chainName <<
"\traw:" <<
chainName.raw() << std::endl;
258 std::cout <<
"\tchain: " <<
chainName.head() << std::endl;
259 std::cout <<
"\tkey: " <<
chainName.tail() << std::endl;
260 std::cout <<
"\tind: " <<
chainName.extra() << std::endl;
261 std::cout <<
"\troi: " <<
chainName.roi() << std::endl;
262 std::cout <<
"\tvtx: " <<
chainName.vtx() << std::endl;
263 std::cout <<
"\tte: " <<
chainName.element() << std::endl;
319 if ( xbeam!=0 || ybeam!=0 ) {
333 unsigned long long event_number = 0;
334 unsigned lumi_block = 0;
335 unsigned bunch_crossing_id = 0;
336 unsigned time_stamp = 0;
341 if ( this->
template retrieve(pEventInfo,
"EventInfo").isFailure() ) {
349 bunch_crossing_id = pEventInfo->
bcid();
355 <<
"\tevent " << event_number
356 <<
"\tlb " << lumi_block <<
endmsg;
379 bool analyse =
false;
385 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
387 const std::string& chainname =
m_chainNames[ichain].head();
389 if ( chainname ==
"" ) analyse =
true;
393 if ( chainname.find(
"L2") == std::string::npos &&
394 chainname.find(
"EF") == std::string::npos &&
395 chainname.find(
"HLT") == std::string::npos )
continue;
399 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
400 <<
"\tpres " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
406 if ( (*(
m_tdt))->isPassed(chainname) || (*(
m_tdt))->getPrescale(chainname) ) analyse =
true;
430 selectorTruth.
clear();
442 if ( this->
template retrieve(truthMap,
"TrigInDetTrackTruthMap").isFailure()) {
457 std::vector<TIDA::Vertex> vertices;
458 std::vector<TIDA::Vertex> vertices_rec;
460 std::vector<double> refbeamspot;
461 std::vector<double> testbeamspot;
467 if ( !this->
select( vertices,
"PrimaryVertices" ) ) {
482 for (
unsigned i=0 ;
i<vertices.size() ;
i++ ) {
492 std::vector<TIDA::Track*> offline_tracks;
493 std::vector<TIDA::Track*> electron_tracks;
494 std::vector<TIDA::Track*> muon_tracks;
496 std::vector<TIDA::Track*> ref_tracks;
497 std::vector<TIDA::Track*> test_tracks;
499 offline_tracks.clear();
500 electron_tracks.clear();
510 bool foundTruth =
false;
516 selectorTruth.
clear();
521 if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"INav4MomTruthEvent") ) {
523 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"INav4MomTruthEvent" );
526 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"SpclMC") ) {
528 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"SpclMC");
531 else if (
m_provider->evtStore()->template contains<xAOD::TruthParticleContainer>(
"TruthParticles") ) {
533 this->
template selectTracks<xAOD::TruthParticleContainer>( &selectorTruth,
"TruthParticles");
536 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"") ) {
538 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"");
559 std::string
keys[4] = {
"GEN_AOD",
"TruthEvent",
"",
"G4Truth" };
561 std::string
key =
"";
563 bool foundcollection =
false;
565 for (
int ik=0 ; ik<4 ; ik++ ) {
571 if ( !
m_provider->evtStore()->template contains<McEventCollection>(
keys[ik]) ) {
580 if ( this->
template retrieve( mcevent,
keys[ik] ).isFailure() ) {
589 foundcollection =
true;
595 if ( !foundcollection ) {
597 m_provider->msg(MSG::WARNING) <<
"No MC Truth Collections of any sort, whatsoever!!!" <<
endmsg;
617 while ( evitr!=evend ) {
626 for (
auto pitr: *(*evitr) ) {
651 if(selectorTruth.
size() > 0) foundTruth =
true;
664 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
"InDetTrackParticles") ) {
665 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorRef,
"InDetTrackParticles" );
666 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
"InDetTrackParticles" );
668 else if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
669 this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorRef,
"TrackParticleCandidate" );
671 else if (
m_provider->msg().level() <= MSG::WARNING ) {
681 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
686 const std::string& chainname =
m_chainNames[ichain].head();
688 const std::string& vtx_name =
m_chainNames[ichain].vtx();
695 std::string ptvalue =
m_chainNames[ichain].postvalue(
"pt");
700 unsigned _decisiontype = TrigDefs::Physics;
701 unsigned decisiontype;
703 if ( this->
requireDecision() ) _decisiontype = TrigDefs::requireDecision;
707 else decisiontype = TrigDefs::alsoDeactivateTEs;
716 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
717 <<
"\tprescale " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
734 if ( chainname!=
"" && !this->
m_keepAllEvents && !(*m_tdt)->isPassed( chainname, decisiontype ) )
continue;
745 std::vector<std::string> chainNames ;
756 for (
unsigned i = 0 ;
i < chainNames.size() ; ++
i ) {
775 chain.addRoi( *roiInfo );
777 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
key) ) {
778 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
key );
779 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
key );
784 chain.back().addTracks(testtracks);
786 if ( vtx_name!=
"" ) {
792 std::vector<TIDA::Vertex> tidavertices;
794 if ( this->
select( tidavertices, vtx_name ) )
chain.back().addVertices( tidavertices );
807 std::string roi_key = chainConfig.
roi();
809 unsigned feature_type =TrigDefs::lastFeatureOfType;
811 if ( roi_key!=
"" ) feature_type= TrigDefs::allFeaturesOfType;
817 if ( chainConfig.
element()!=
"" ) {
821 std::vector< TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> >
rois =
841 if ( roi_key==
"SuperRoi" && iroi>1 )
continue;
848 if ( roi_key!=
"" && roi_link.
dataID()!=roi_key )
continue;
870 if ( this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest, roi_link,
key ) ) { }
876 chain.addRoi( *roiInfo );
882 chain.back().addTracks(testtracks);
887 if ( vtx_name!=
"" ) {
889 std::vector<TIDA::Vertex> tidavertices;
891 this->
select( tidavertices, roi_link, vtx_name );
893 chain.back().addVertices( tidavertices );
900 std::cout <<
"\tTIDA analysis for chain: " << chainname <<
"\t key: " <<
key <<
"\t" << **roiptr << std::endl;
901 std::cout <<
"\tcollections: " <<
chain.back() << std::endl;
923 for (
unsigned ichain=0 ; ichain<
m_event->
size() ; ichain++ ) {
927 const std::string& vtx_name = chainConfig.
vtx();
930 if ( TnP_flag && chainConfig.
extra().find(
"_tag")!=std::string::npos ) continue ;
932 std::vector<TIDA::Roi*>
rois ;
947 for (
unsigned iroi=0 ; iroi<
rois.size() ; iroi++ ) {
953 else filterRef.
setRoi( 0 );
994 for (
unsigned itrk=0 ; itrk<
rois.at(iroi)->tracks().
size() ; itrk++ ) {
995 test_tracks.push_back(&(
rois.at(iroi)->tracks().at(itrk)));
1000 _analysis->setvertices( vertices.size() );
1002 if ( refbeamspot.size()>0 )
_analysis->setBeamRef( refbeamspot );
1003 if ( testbeamspot.size()>0 )
_analysis->setBeamTest( testbeamspot );
1046 if ( vtx_name!=
"" ) {
1048 std::vector<TIDA::Vertex>
vr =
rois.at(iroi)->vertices();
1049 std::vector<TIDA::Vertex*> vtx_rec;
1050 for (
unsigned iv=0 ; iv<
vr.size() ; iv++ ) vtx_rec.push_back( &
vr[iv] );
1052 std::vector<TIDA::Vertex*> vtx;
1054 for (
unsigned iv=0 ; iv<vertices.size() ; iv++ ) vtx.push_back( &vertices[iv] );
1057 if ( vertices.size()>
unsigned(this->getVtxIndex()) ) vtx.push_back( &vertices[this->
getVtxIndex()] );
1060 _analysis->execute_vtx( vtx, vtx_rec,
m_event );
1068 <<
"\tevent " << event_number
1069 <<
"\tlb " << lumi_block <<
endmsg;
1088 m_provider->msg(MSG::ERROR) <<
"AnalysisConfigMT_Tier0::book() should no longer be called: " <<
name() <<
endmsg;
1167 #endif // TrigInDetAnalysisExample_T_AnalysisConfigMT_Tier0_H