23 #ifndef TrigInDetAnalysisExample_T_AnalysisConfigR3_Tier0_H
24 #define TrigInDetAnalysisExample_T_AnalysisConfigR3_Tier0_H
40 #include "GaudiKernel/ToolHandle.h"
89 std::ostream&
operator<<( std::ostream&
s,
const std::vector<T>&
v) {
90 for (
size_t i=0 ;
i<
v.size() ;
i++ )
s <<
" " <<
v[
i];
95 template<
typename T,
typename A=AnalysisR3_Tier0>
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,
115 testChainName, testType, testKey,
116 referenceChainName, referenceType, referenceKey,
117 testFilter, referenceFilter,
154 std::cout <<
"\nT_AnalysisConfigR3_Tier0::name: " <<
name() <<
"\t" <<
this << std::endl;
155 std::cout <<
"T_AnalysisConfigR3_Tier0::chain specification: " << testChainName <<
" -> " <<
chain <<
"\t" <<
chain.raw() << std::endl;
156 std::cout <<
"\tchain: " <<
chain.head() << std::endl;
157 std::cout <<
"\tkey: " <<
chain.tail() << std::endl;
158 std::cout <<
"\troi: " <<
chain.roi() << std::endl;
159 std::cout <<
"\tvtx: " <<
chain.vtx() << std::endl;
160 std::cout <<
"\tte: " <<
chain.element() << std::endl;
161 std::cout <<
"\textra: " <<
chain.extra() << std::endl;
163 std::cout <<
"\tpost: " <<
chain.post() << std::endl;
164 std::cout <<
"\tpt: " <<
chain.postvalue(
"pt") << std::endl;
264 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
266 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
311 if (
m_mcTruth ) pselectorRef = &selectorTruth;
324 double beamline[4] = { 0, 0, 0, 0 };
334 unsigned long long event_number = 0;
335 unsigned lumi_block = 0;
336 unsigned bunch_crossing_id = 0;
337 unsigned time_stamp = 0;
343 if ( this->
template retrieve( pEventInfo,
"EventInfo" ).isFailure() ) {
351 bunch_crossing_id = pEventInfo->
bcid();
357 <<
"\tevent " << event_number
358 <<
"\tlb " << lumi_block <<
endmsg;
374 bool analyse =
false;
378 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
380 const std::string& chainname =
m_chainNames[ichain].head();
382 if ( chainname ==
"" ) analyse =
true;
386 if ( chainname.find(
"L2") == std::string::npos &&
387 chainname.find(
"EF") == std::string::npos &&
388 chainname.find(
"HLT") == std::string::npos )
continue;
392 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
393 <<
"\tpres " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
400 if ( (*(
m_tdt))->isPassed(chainname) ) analyse =
true;
417 selectorTruth.
clear();
424 std::vector<TIDA::Vertex> vertices;
425 std::vector<TIDA::Vertex> vertices_rec;
427 std::vector<double> refbeamspot;
428 std::vector<double> testbeamspot;
434 if ( !this->
select( vertices,
"PrimaryVertices" ) ) {
435 m_provider->msg(
MSG::VERBOSE) <<
"could not retrieve the 'PrimaryVertices' vertex collection" << std::endl;
449 for (
unsigned i=0 ;
i<vertices.size() ;
i++ ) {
460 std::vector<TIDA::Track*> offline_tracks;
461 std::vector<TIDA::Track*> electron_tracks;
462 std::vector<TIDA::Track*> muon_tracks;
464 std::vector<TIDA::Track*> ref_tracks;
465 std::vector<TIDA::Track*> test_tracks;
467 offline_tracks.clear();
468 electron_tracks.clear();
478 bool foundTruth =
false;
486 selectorTruth.
clear();
491 if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"INav4MomTruthEvent") ) {
493 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"INav4MomTruthEvent" );
496 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"SpclMC") ) {
498 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"SpclMC");
501 else if (
m_provider->evtStore()->template contains<xAOD::TruthParticleContainer>(
"TruthParticles") ) {
503 this->
template selectTracks<xAOD::TruthParticleContainer>( &selectorTruth,
"TruthParticles");
506 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"") ) {
508 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"");
529 std::string
keys[4] = {
"GEN_AOD",
"TruthEvent",
"",
"G4Truth" };
531 std::string
key =
"";
533 bool foundcollection =
false;
535 for (
int ik=0 ; ik<4 ; ik++ ) {
541 if ( !
m_provider->evtStore()->template contains<McEventCollection>(
keys[ik]) ) {
550 if ( this->
template retrieve( mcevent,
keys[ik] ).isFailure() ) {
559 foundcollection =
true;
565 if ( !foundcollection ) {
567 m_provider->msg(MSG::WARNING) <<
"No MC Truth Collections of any sort, whatsoever!!!" <<
endmsg;
587 while ( evitr!=evend ) {
604 while ( pitr!=pend ) {
629 if(selectorTruth.
size() > 0) foundTruth =
true;
640 bool found_offline =
false;
644 this->
template selectTracks<xAOD::TrackParticleContainer>( pselectorRef,
m_offline_types[
it] );
645 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
m_offline_types[
it] );
646 found_offline =
true;
653 if ( !found_offline ) {
654 if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
656 this->
template selectTracks<Rec::TrackParticleContainer>( pselectorRef,
"TrackParticleCandidate" );
659 m_provider->msg(MSG::WARNING) <<
"Offline tracks not found: " <<
"TrackParticleCandidate" <<
endmsg;
672 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
677 const std::string& chainname =
m_chainNames[ichain].head();
679 const std::string& vtx_name =
m_chainNames[ichain].vtx();
687 std::string ptvalue =
m_chainNames[ichain].postvalue(
"pt");
692 unsigned decisiontype = TrigDefs::Physics;
694 if ( !
m_chainNames[ichain].
passed() ) decisiontype = TrigDefs::includeFailedDecisions;
703 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
704 <<
"\tprescale " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
721 if ( chainname!=
"" && !this->
m_keepAllEvents && !(*m_tdt)->isPassed( chainname, decisiontype ) )
continue;
731 std::vector<std::string> chainNames ;
737 chainNames.push_back(pTnP_tool->
tag());
738 chainNames.push_back(pTnP_tool->
probe());
742 for (
size_t i=0 ;
i<chainNames.size() ;
i++ ) {
755 pselectorTest->
clear();
765 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
key) ) {
766 this->
template selectTracks<xAOD::TrackParticleContainer>( pselectorTest,
key );
767 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
key );
770 const std::vector<TIDA::Track*>& testtracks = pselectorTest->
tracks();
772 chain.back().addTracks(testtracks);
774 if ( vtx_name!=
"" ) {
780 std::vector<TIDA::Vertex> tidavertices;
782 if ( this->
select( tidavertices, vtx_name ) )
chain.back().addVertices( tidavertices );
795 std::string roi_key = chainConfig.
roi();
797 unsigned feature_type =TrigDefs::lastFeatureOfType;
799 if ( roi_key!=
"" ) feature_type= TrigDefs::allFeaturesOfType;
805 if ( chainConfig.
element()!=
"" ) {
809 std::string rgex = roi_key;
811 std::vector< TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> >
rois =
822 if (
rois.empty() ) {
823 if ( !rgex.empty() ) {
844 if ( roi_key==
"SuperRoi" && iroi>1 )
continue;
851 if ( roi_key!=
"" && roi_link.
dataID()!=rgex )
continue;
854 if ( !roi_link.
isValid() )
continue;
858 if ( roiptr == 0 )
continue;
874 pselectorTest->
clear();
876 if ( this->
template selectTracks<xAOD::TrackParticleContainer>( pselectorTest, roi_link,
key ) ) { }
882 chain.addRoi( *roiInfo );
886 const std::vector<TIDA::Track*>& testtracks = pselectorTest->
tracks();
888 chain.back().addTracks(testtracks);
893 if ( vtx_name!=
"" ) {
895 std::vector<TIDA::Vertex> tidavertices;
897 this->
select( tidavertices, roi_link, vtx_name );
899 chain.back().addVertices( tidavertices );
906 std::cout <<
"\tTIDA analysis for chain: " << chainname <<
"\t key: " <<
key <<
"\t" << **roiptr << std::endl;
907 std::cout <<
"\tcollections: " <<
chain.back() << std::endl;
911 if ( roiInfo )
delete roiInfo;
929 for (
unsigned ichain=0 ; ichain<eventp->
size() ; ichain++ ) {
933 const std::string& vtx_name = chainConfig.
vtx();
936 if (
m_tnp_flag && chainConfig.
extra().find(
"_tag")!=std::string::npos ) continue ;
938 std::vector<TIDA::Roi*>
rois ;
953 for (
unsigned iroi=0 ; iroi<
rois.size() ; iroi++ ) {
959 else filterRef.
setRoi( 0 );
984 ref_tracks = pselectorRef->
tracks(&filter_truth);
987 ref_tracks = pselectorRef->
tracks(&filterRef) ;
992 for (
int ii=pselectorRef->
tracks().size() ; ii-- ; ) {
1000 for (
unsigned itrk=0 ; itrk<
rois.at(iroi)->tracks().
size() ; itrk++ ) {
1001 test_tracks.push_back(&(
rois.at(iroi)->tracks().at(itrk)));
1009 beamline[0] = pselectorTest->
getBeamX();
1010 beamline[1] = pselectorTest->
getBeamY();
1011 beamline[2] = pselectorTest->
getBeamZ();
1013 beamline[3] = vertices.size();
1039 associator->
match( test_tracks, ref_tracks );
1041 m_manalysis->execute( test_tracks, ref_tracks, associator, eventp, beamline );
1063 associator->
match( ref_tracks, test_tracks );
1070 m_manalysis->execute( ref_tracks, test_tracks, associator, eventp, beamline, &(
rois.at(iroi)->roi()) );
1072 if ( vtx_name!=
"" ) {
1074 std::vector<TIDA::Vertex>
vr =
rois.at(iroi)->vertices();
1075 std::vector<TIDA::Vertex*> vtx_rec;
1076 for (
unsigned iv=0 ; iv<
vr.size() ; iv++ ) vtx_rec.push_back( &
vr[iv] );
1078 std::vector<TIDA::Vertex*> vtx;
1080 for (
unsigned iv=0 ; iv<vertices.size() ; iv++ ) vtx.push_back( &vertices[iv] );
1083 if ( vertices.size()>
unsigned(this->getVtxIndex()) ) vtx.push_back( &vertices[this->
getVtxIndex()] );
1086 m_manalysis->execute_vtx( vtx, vtx_rec, eventp );
1094 <<
"\tevent " << event_number
1095 <<
"\tlb " << lumi_block <<
endmsg;
1119 if(
m_tdt->retrieve().isFailure() ) {
1121 m_provider->msg(MSG::ERROR) <<
" Unable to retrieve the TrigDecisionTool: Please check job options file" <<
endmsg;
1132 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
1135 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
1153 std::string folder_name =
"";
1155 if (
name()!=
"" ) folder_name =
name();
1156 else folder_name =
"HLT/TRIDT/IDMon";
1161 std::string mongroup;
1167 if (
name().find(
"Shifter")!=std::string::npos ||
m_shifter ) {
1169 if (
m_chainNames.at(
ic).tail().find(
"_FTF") != std::string::npos ) mongroup = folder_name +
"/FTF";
1170 else if (
m_chainNames.at(
ic).tail().find(
"_IDTrig") != std::string::npos ||
1171 m_chainNames.at(
ic).tail().find(
"_EFID") != std::string::npos ) mongroup = folder_name +
"/EFID";
1172 else if (
m_chainNames.at(
ic).tail().find(
"InDetTrigParticle") != std::string::npos ) mongroup = folder_name +
"/EFID_RUN1";
1173 else if (
m_chainNames.at(
ic).tail().find(
"_GSF") != std::string::npos ) mongroup = folder_name +
"/GSF";
1174 else mongroup = folder_name +
"/Unknown";
1186 std::string track_collection =
"";
1194 if ( track_collection!=
"" ) track_collection +=
"_" +
m_chainNames[
ic].roi();
1199 if ( track_collection!=
"" ) track_collection +=
"_" +
m_chainNames[
ic].vtx();
1205 if ( track_collection!=
"" ) track_collection +=
"_" +
m_chainNames[
ic].element();
1209 if ( track_collection!=
"" ) mongroup += track_collection;
1300 #endif // TrigInDetAnalysisExample_T_AnalysisConfigR3_Tier0_H