23 #ifndef TrigInDetAnalysisExample_T_AnalysisConfig_Tier0_H
24 #define TrigInDetAnalysisExample_T_AnalysisConfig_Tier0_H
48 #include "EventInfo/EventInfo.h"
98 const std::string& testChainName,
const std::string& testType,
const std::string& testKey,
99 const std::string& referenceChainName,
const std::string& referenceType,
const std::string& referenceKey,
104 testChainName, testType, testKey,
105 referenceChainName, referenceType, referenceKey,
106 testFilter, referenceFilter,
134 std::cout <<
"\nT_AnalysisConfig_Tier0::name: " <<
name() <<
"\t" <<
this << std::endl;
135 std::cout <<
"T_AnalysisConfig_Tier0::chain specification: " << testChainName <<
" -> " <<
chain <<
"\t" <<
chain.raw() << std::endl;
136 std::cout <<
"\tchain: " <<
chain.head() << std::endl;
137 std::cout <<
"\tkey: " <<
chain.tail() << std::endl;
138 std::cout <<
"\troi: " <<
chain.roi() << std::endl;
139 std::cout <<
"\tvtx: " <<
chain.vtx() << std::endl;
140 std::cout <<
"\tte: " <<
chain.element() << std::endl;
142 std::cout <<
"\tpost: " <<
chain.post() << std::endl;
143 std::cout <<
"\tpt: " <<
chain.postvalue(
"pt") << std::endl;
206 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
208 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
217 std::vector<ChainString>
chains;
231 std::string selectChain =
chainName.raw();
243 std::vector<std::string> selectChains = (*(
m_tdt))->getListOfTriggers(
chainName.head() );
246 for (
unsigned iselected=0 ; iselected<selectChains.size() ; iselected++ ) {
248 selectChains[iselected] =
chainName.subs( selectChains[iselected] );
251 std::cout <<
"sorting:: chain specification: " <<
chainName <<
"\traw:" <<
chainName.raw() << std::endl;
252 std::cout <<
"\tchain: " <<
chainName.head() << std::endl;
253 std::cout <<
"\tkey: " <<
chainName.tail() << std::endl;
254 std::cout <<
"\troi: " <<
chainName.roi() << std::endl;
255 std::cout <<
"\tvtx: " <<
chainName.vtx() << std::endl;
256 std::cout <<
"\tte: " <<
chainName.element() << std::endl;
257 std::cout <<
"\tind: " <<
chainName.extra() << std::endl;
307 if ( xbeam!=0 || ybeam!=0 ) {
317 #ifndef XAODTRACKING_TRACKPARTICLE_H
324 unsigned lumi_block = 0;
325 unsigned bunch_crossing_id = 0;
326 unsigned time_stamp = 0;
329 if ( this->
template retrieve(pEventInfo,
"EventInfo").isFailure() ) {
333 #ifndef XAODTRACKING_TRACKPARTICLE_H
334 run_number = pEventInfo->event_ID()->run_number();
335 event_number = pEventInfo->event_ID()->event_number();
336 lumi_block = pEventInfo->event_ID()->lumi_block();
337 time_stamp = pEventInfo->event_ID()->time_stamp();
338 bunch_crossing_id = pEventInfo->event_ID()->bunch_crossing_id();
345 bunch_crossing_id = pEventInfo->
bcid();
352 <<
"\tevent " << event_number
353 <<
"\tlb " << lumi_block <<
endmsg;
376 bool analyse =
false;
380 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
382 const std::string& chainname =
m_chainNames[ichain].head();
384 if ( chainname ==
"" ) analyse =
true;
388 if ( chainname.find(
"L2") == std::string::npos &&
389 chainname.find(
"EF") == std::string::npos &&
390 chainname.find(
"HLT") == std::string::npos )
continue;
394 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
395 <<
"\tpres " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
401 if ( (*(
m_tdt))->isPassed(chainname) || (*(
m_tdt))->getPrescale(chainname) ) analyse =
true;
425 selectorTruth.
clear();
435 if ( this->
template retrieve(truthMap,
"TrigInDetTrackTruthMap").isFailure()) {
450 std::vector<TIDA::Vertex> vertices;
451 std::vector<TIDA::Vertex> vertices_rec;
453 std::vector<double> refbeamspot;
454 std::vector<double> testbeamspot;
458 #ifndef XAODTRACKING_TRACKPARTICLE_H
463 if (
m_provider->evtStore()->template contains<VxContainer>(
"VxPrimaryCandidate") ) {
464 if ( this->
template retrieve(primaryVtxCollection,
"VxPrimaryCandidate").isFailure()) {
465 if (
m_provider->msg().level() <= MSG::WARNING)
m_provider->msg(MSG::WARNING) <<
"Primary vertex container not found" <<
endmsg;
469 for ( ; vtxitr != primaryVtxCollection->
end(); ++vtxitr) {
470 if ( (*vtxitr)->vxTrackAtVertex()->size()>0 ) {
471 vertices.push_back(
TIDA::Vertex( (*vtxitr)->recVertex().position().x(),
472 (*vtxitr)->recVertex().position().y(),
473 (*vtxitr)->recVertex().position().z(),
475 (*vtxitr)->vxTrackAtVertex()->size() ) );
492 if ( this->
template retrieve( xaodVtxCollection,
"PrimaryVertices" ).isFailure()) {
493 if (
m_provider->msg().level() <= MSG::WARNING)
m_provider->msg(MSG::WARNING) <<
"xAOD Primary vertex container not found with key " <<
"PrimaryVertices" <<
endmsg;
496 if ( xaodVtxCollection!=0 ) {
501 for ( ; vtxitr != xaodVtxCollection->
end(); ++vtxitr ) {
502 if ( (*vtxitr)->nTrackParticles()>0 && (*vtxitr)->vertexType()!=0 ) {
510 (*vtxitr)->nTrackParticles(),
512 (*vtxitr)->chiSquared(),
513 (*vtxitr)->numberDoF() ) );
533 for (
unsigned i=0 ;
i<vertices.size() ;
i++ ) {
543 std::vector<TIDA::Track*> offline_tracks;
544 std::vector<TIDA::Track*> electron_tracks;
545 std::vector<TIDA::Track*> muon_tracks;
547 std::vector<TIDA::Track*> ref_tracks;
548 std::vector<TIDA::Track*> test_tracks;
550 offline_tracks.clear();
551 electron_tracks.clear();
558 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
565 const std::string& chainname =
m_chainNames[ichain].head();
567 const std::string& vtx_name =
m_chainNames[ichain].vtx();
575 std::string ptvalue =
m_chainNames[ichain].postvalue(
"pt");
581 unsigned _decisiontype = TrigDefs::Physics;
582 unsigned decisiontype;
584 if ( this->
requireDecision() ) _decisiontype = TrigDefs::requireDecision;
588 else decisiontype = TrigDefs::alsoDeactivateTEs;
595 const std::string& key_index_string =
m_chainNames[ichain].extra();
596 unsigned key_index = 0;
597 if ( key_index_string!=
"" ) key_index =
std::atoi( key_index_string.c_str() );
602 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
603 <<
"\tprescale " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
619 if ( chainname!=
"" && !this->
m_keepAllEvents && !(*m_tdt)->isPassed( chainname, decisiontype ) )
continue;
644 chain.addRoi( *roiInfo );
647 # ifdef XAODTRACKING_TRACKPARTICLE_H
648 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
key) ) {
649 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
key );
650 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
key );
656 chain.back().addTracks(testtracks);
681 for( ;
c!=cEnd ; ++
c ) {
691 std::vector< Trig::Feature<TrigRoiDescriptor> > initRois;
695 if ( roi_key==
"SuperRoi" && icomb>1 )
continue;
703 if ( initRois.empty() ) initRois =
c->get<
TrigRoiDescriptor>(
"initialRoI", decisiontype );
708 if ( initRois.empty() )
continue;
716 if(initRois.size()>1 && roi_key!=
"SuperRoi" ) {
724 if( !initRois.empty() ) {
760 if (
key.find(
"InDetTrigParticleCreation")!=std::string::npos ||
761 key.find(
"_IDTrig")!=std::string::npos ||
762 key.find(
"_EFID")!=std::string::npos ||
763 chainName.find(
"EF_")!=std::string::npos ||
764 chainName.find(
"HLT_")!=std::string::npos ) {
765 # ifdef XAODTRACKING_TRACKPARTICLE_H
766 if ( this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
c,
key ) ) testbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
c,
key );
767 else if ( this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorTest,
c,
key ) );
769 if ( this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorTest,
c,
key ) );
772 else if ( this->
template selectTracks<TrigInDetTrackCollection>(
m_selectorTest,
c, truthMap,
key, key_index ) );
779 if (
chainName.find(
"L2_")!=std::string::npos ) {
780 if ( this->
template selectTracks<TrigInDetTrackCollection>(
m_selectorTest,
c, truthMap,
key, key_index ) );
781 else if ( this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorTest,
c,
key ) );
783 # ifdef XAODTRACKING_TRACKPARTICLE_H
784 else if ( this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
c,
key ) ) testbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
c,
key );
800 for (
int ii=testtracks.size() ; ii-- ; ) {
806 chain.addRoi( *roiInfo );
808 chain.back().addTracks(testtracks);
818 if ( vtx_name!=
"" ) {
822 std::vector< Trig::Feature<xAOD::VertexContainer> > xaodtrigvertices =
c->get<
xAOD::VertexContainer>(vtx_name);
824 if ( xaodtrigvertices.empty() ) {
826 m_provider->msg(MSG::WARNING) <<
"\tNo xAOD::VertexContainer for chain " << chainConfig <<
" for key " << vtx_name <<
endmsg;
833 for (
unsigned iv=0 ; iv<xaodtrigvertices.size() ; iv++ ) {
841 for ( ; vtxitr != vert->
end(); ++vtxitr) {
845 if ( (*vtxitr)->vertexType()!=0 || vtx_name==
"EFHistoPrmVtx" ) {
853 (*vtxitr)->nTrackParticles(),
855 (*vtxitr)->chiSquared(),
856 (*vtxitr)->numberDoF() ) );
877 for (
unsigned iroi=0 ; iroi<
chain.size() ; iroi++ ) {
885 else filterRef.
setRoi( 0 );
907 bool foundTruth =
false;
912 else filter_truth.
setRoi( 0 );
914 selectorTruth.
clear();
919 if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"INav4MomTruthEvent") ) {
921 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"INav4MomTruthEvent" );
924 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"SpclMC") ) {
926 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"SpclMC");
929 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"") ) {
931 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"");
953 std::string
keys[4] = {
"GEN_AOD",
"TruthEvent",
"",
"G4Truth" };
955 std::string
key =
"";
957 bool foundcollection =
false;
959 for (
int ik=0 ; ik<4 ; ik++ ) {
965 if ( !
m_provider->evtStore()->template contains<McEventCollection>(
keys[ik]) ) {
974 if ( this->
template retrieve( mcevent,
keys[ik] ).isFailure() ) {
983 foundcollection =
true;
989 if ( !foundcollection ) {
991 m_provider->msg(MSG::WARNING) <<
"No MC Truth Collections of any sort, whatsoever!!!" <<
endmsg;
1011 while ( evitr!=evend ) {
1020 for (
auto pitr: *(*evitr)) {
1045 if(selectorTruth.
size() > 0) foundTruth =
true;
1060 # ifdef XAODTRACKING_TRACKPARTICLE_H
1061 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
"InDetTrackParticles") ) {
1062 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorRef,
"InDetTrackParticles" );
1063 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
"InDetTrackParticles" );
1065 else if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
1066 this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorRef,
"TrackParticleCandidate" );
1069 if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
1070 this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorRef,
"TrackParticleCandidate" );
1073 else if (
m_provider->msg().level() <= MSG::WARNING ) {
1090 ref_tracks=selectorTruth.
tracks();
1096 test_tracks.clear();
1098 for (
unsigned itrk=0 ; itrk<
chain.rois().at(iroi).tracks().
size() ; itrk++ ) {
1099 test_tracks.push_back(&(
chain.rois().at(iroi).tracks().at(itrk)));
1155 if ( vtx_name!=
"" ) {
1157 std::vector<TIDA::Vertex>
vr =
chain.rois().at(iroi).vertices();
1158 std::vector<TIDA::Vertex*> vtx_rec;
1159 for (
unsigned iv=0 ; iv<
vr.size() ; iv++ ) vtx_rec.push_back( &
vr[iv] );
1161 std::vector<TIDA::Vertex*> vtx;
1163 for (
unsigned iv=0 ; iv<vertices.size() ; iv++ ) vtx.push_back( &vertices[iv] );
1166 if ( vertices.size()>
unsigned(this->getVtxIndex()) ) vtx.push_back( &vertices[this->
getVtxIndex()] );
1177 <<
"\tevent " << event_number
1178 <<
"\tlb " << lumi_block <<
endmsg;
1197 m_provider->msg(MSG::ERROR) <<
"AnalysisConfig_Tier0::book() should no longer ever be called: " <<
name() <<
endmsg;
1258 #endif // TrigInDetAnalysisExample_T_AnalysisConfig_Tier0_H