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,
142 std::cout <<
"\nT_AnalysisConfigMT_Tier0::name: " <<
name() <<
"\t" <<
this << std::endl;
143 std::cout <<
"T_AnalysisConfigMT_Tier0::chain specification: " << testChainName <<
" -> " <<
chain <<
"\t" <<
chain.raw() << std::endl;
144 std::cout <<
"\tchain: " <<
chain.head() << std::endl;
145 std::cout <<
"\tkey: " <<
chain.tail() << std::endl;
146 std::cout <<
"\troi: " <<
chain.roi() << std::endl;
147 std::cout <<
"\tvtx: " <<
chain.vtx() << std::endl;
148 std::cout <<
"\tte: " <<
chain.element() << std::endl;
150 std::cout <<
"\tpost: " <<
chain.post() << std::endl;
151 std::cout <<
"\tpt: " <<
chain.postvalue(
"pt") << std::endl;
210 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
212 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
222 std::vector<ChainString>
chains;
238 std::string selectChain =
chainName.raw();
246 std::vector<std::string> selectChains = (*(
m_tdt))->getListOfTriggers(
chainName.head() );
248 for (
unsigned iselected=0 ; iselected<selectChains.size() ; iselected++ ) {
250 selectChains[iselected] =
chainName.subs( selectChains[iselected] );
253 std::cout <<
"sorting:: chain specification: " <<
chainName <<
"\traw:" <<
chainName.raw() << std::endl;
254 std::cout <<
"\tchain: " <<
chainName.head() << std::endl;
255 std::cout <<
"\tkey: " <<
chainName.tail() << std::endl;
256 std::cout <<
"\tind: " <<
chainName.extra() << std::endl;
257 std::cout <<
"\troi: " <<
chainName.roi() << std::endl;
258 std::cout <<
"\tvtx: " <<
chainName.vtx() << std::endl;
259 std::cout <<
"\tte: " <<
chainName.element() << std::endl;
315 if ( xbeam!=0 || ybeam!=0 ) {
329 unsigned long long event_number = 0;
330 unsigned lumi_block = 0;
331 unsigned bunch_crossing_id = 0;
332 unsigned time_stamp = 0;
337 if ( this->
template retrieve(pEventInfo,
"EventInfo").isFailure() ) {
345 bunch_crossing_id = pEventInfo->
bcid();
351 <<
"\tevent " << event_number
352 <<
"\tlb " << lumi_block <<
endmsg;
375 bool analyse =
false;
381 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
383 const std::string& chainname =
m_chainNames[ichain].head();
385 if ( chainname ==
"" ) analyse =
true;
389 if ( chainname.find(
"L2") == std::string::npos &&
390 chainname.find(
"EF") == std::string::npos &&
391 chainname.find(
"HLT") == std::string::npos )
continue;
395 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
396 <<
"\tpres " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
402 if ( (*(
m_tdt))->isPassed(chainname) || (*(
m_tdt))->getPrescale(chainname) ) analyse =
true;
426 selectorTruth.
clear();
438 if ( this->
template retrieve(truthMap,
"TrigInDetTrackTruthMap").isFailure()) {
453 std::vector<TIDA::Vertex> vertices;
454 std::vector<TIDA::Vertex> vertices_rec;
456 std::vector<double> refbeamspot;
457 std::vector<double> testbeamspot;
463 if ( !this->
select( vertices,
"PrimaryVertices" ) ) {
478 for (
unsigned i=0 ;
i<vertices.size() ;
i++ ) {
488 std::vector<TIDA::Track*> offline_tracks;
489 std::vector<TIDA::Track*> electron_tracks;
490 std::vector<TIDA::Track*> muon_tracks;
492 std::vector<TIDA::Track*> ref_tracks;
493 std::vector<TIDA::Track*> test_tracks;
495 offline_tracks.clear();
496 electron_tracks.clear();
506 bool foundTruth =
false;
512 selectorTruth.
clear();
517 if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"INav4MomTruthEvent") ) {
519 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"INav4MomTruthEvent" );
522 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"SpclMC") ) {
524 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"SpclMC");
527 else if (
m_provider->evtStore()->template contains<xAOD::TruthParticleContainer>(
"TruthParticles") ) {
529 this->
template selectTracks<xAOD::TruthParticleContainer>( &selectorTruth,
"TruthParticles");
532 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"") ) {
534 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"");
555 std::string
keys[4] = {
"GEN_AOD",
"TruthEvent",
"",
"G4Truth" };
557 std::string
key =
"";
559 bool foundcollection =
false;
561 for (
int ik=0 ; ik<4 ; ik++ ) {
567 if ( !
m_provider->evtStore()->template contains<McEventCollection>(
keys[ik]) ) {
576 if ( this->
template retrieve( mcevent,
keys[ik] ).isFailure() ) {
585 foundcollection =
true;
591 if ( !foundcollection ) {
593 m_provider->msg(MSG::WARNING) <<
"No MC Truth Collections of any sort, whatsoever!!!" <<
endmsg;
613 while ( evitr!=evend ) {
622 for (
auto pitr: *(*evitr) ) {
647 if(selectorTruth.
size() > 0) foundTruth =
true;
660 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
"InDetTrackParticles") ) {
661 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorRef,
"InDetTrackParticles" );
662 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
"InDetTrackParticles" );
664 else if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
665 this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorRef,
"TrackParticleCandidate" );
667 else if (
m_provider->msg().level() <= MSG::WARNING ) {
677 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
682 const std::string& chainname =
m_chainNames[ichain].head();
684 const std::string& vtx_name =
m_chainNames[ichain].vtx();
691 std::string ptvalue =
m_chainNames[ichain].postvalue(
"pt");
696 unsigned _decisiontype = TrigDefs::Physics;
697 unsigned decisiontype;
699 if ( this->
requireDecision() ) _decisiontype = TrigDefs::requireDecision;
703 else decisiontype = TrigDefs::alsoDeactivateTEs;
712 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
713 <<
"\tprescale " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
730 if ( chainname!=
"" && !this->
m_keepAllEvents && !(*m_tdt)->isPassed( chainname, decisiontype ) )
continue;
741 std::vector<std::string> chainNames ;
752 for (
unsigned i = 0 ;
i < chainNames.size() ; ++
i ) {
771 chain.addRoi( *roiInfo );
773 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
key) ) {
774 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
key );
775 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
key );
780 chain.back().addTracks(testtracks);
782 if ( vtx_name!=
"" ) {
788 std::vector<TIDA::Vertex> tidavertices;
790 if ( this->
select( tidavertices, vtx_name ) )
chain.back().addVertices( tidavertices );
794 if ( roiInfo )
delete roiInfo;
803 std::string roi_key = chainConfig.
roi();
805 unsigned feature_type =TrigDefs::lastFeatureOfType;
807 if ( roi_key!=
"" ) feature_type= TrigDefs::allFeaturesOfType;
813 if ( chainConfig.
element()!=
"" ) {
817 std::vector< TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> >
rois =
837 if ( roi_key==
"SuperRoi" && iroi>1 )
continue;
844 if ( roi_key!=
"" && roi_link.
dataID()!=roi_key )
continue;
866 if ( this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest, roi_link,
key ) ) { }
872 chain.addRoi( *roiInfo );
878 chain.back().addTracks(testtracks);
883 if ( vtx_name!=
"" ) {
885 std::vector<TIDA::Vertex> tidavertices;
887 this->
select( tidavertices, roi_link, vtx_name );
889 chain.back().addVertices( tidavertices );
896 std::cout <<
"\tTIDA analysis for chain: " << chainname <<
"\t key: " <<
key <<
"\t" << **roiptr << std::endl;
897 std::cout <<
"\tcollections: " <<
chain.back() << std::endl;
901 if ( roiInfo )
delete roiInfo;
919 for (
unsigned ichain=0 ; ichain<
m_event->
size() ; ichain++ ) {
923 const std::string& vtx_name = chainConfig.
vtx();
926 if ( TnP_flag && chainConfig.
extra().find(
"_tag")!=std::string::npos ) continue ;
928 std::vector<TIDA::Roi*>
rois ;
943 for (
unsigned iroi=0 ; iroi<
rois.size() ; iroi++ ) {
949 else filterRef.
setRoi( 0 );
990 for (
unsigned itrk=0 ; itrk<
rois.at(iroi)->tracks().
size() ; itrk++ ) {
991 test_tracks.push_back(&(
rois.at(iroi)->tracks().at(itrk)));
996 _analysis->setvertices( vertices.size() );
998 if ( refbeamspot.size()>0 )
_analysis->setBeamRef( refbeamspot );
999 if ( testbeamspot.size()>0 )
_analysis->setBeamTest( testbeamspot );
1042 if ( vtx_name!=
"" ) {
1044 std::vector<TIDA::Vertex>
vr =
rois.at(iroi)->vertices();
1045 std::vector<TIDA::Vertex*> vtx_rec;
1046 for (
unsigned iv=0 ; iv<
vr.size() ; iv++ ) vtx_rec.push_back( &
vr[iv] );
1048 std::vector<TIDA::Vertex*> vtx;
1050 for (
unsigned iv=0 ; iv<vertices.size() ; iv++ ) vtx.push_back( &vertices[iv] );
1053 if ( vertices.size()>
unsigned(this->getVtxIndex()) ) vtx.push_back( &vertices[this->
getVtxIndex()] );
1056 _analysis->execute_vtx( vtx, vtx_rec,
m_event );
1064 <<
"\tevent " << event_number
1065 <<
"\tlb " << lumi_block <<
endmsg;
1084 m_provider->msg(MSG::ERROR) <<
"AnalysisConfigMT_Tier0::book() should no longer be called: " <<
name() <<
endmsg;
1163 #endif // TrigInDetAnalysisExample_T_AnalysisConfigMT_Tier0_H