handle wildcard chain selection - but only the first time NB: also check all other chains as well - only set up an analysis for configured chains
replace wildcard with actual matching chains ...
now start everything going for this event properly ...
first check whether the chains have actually run, otherwise there's no point doing anything
now loop over all relevant chains to get the trigger tracks...
only use the TDT for extracting collections if this was a trigger analysis for fullscan "offline" type analyses (ie fullscan FTK) do not use this
leave this code commented so that we have a record of the change - as soon as we can fix the missing track multiplicity from the vertex this will need to go back
This is nonsense and needs restructuring - why is the truth and offline selection done within this RoI loop? It means the complete offline and truth tracks will be retrieved for every RoI ! really we should have the structure
if there were some particles in this interaction ...
if we want a purity, we need to swap round which tracks are the reference tracks and which the test tracks
203 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
205 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
214 std::vector<ChainString>
chains;
228 std::string selectChain =
chainName.raw();
240 std::vector<std::string> selectChains = (*(
m_tdt))->getListOfTriggers(
chainName.head() );
243 for (
unsigned iselected=0 ; iselected<selectChains.size() ; iselected++ ) {
245 selectChains[iselected] =
chainName.subs( selectChains[iselected] );
248 std::cout <<
"sorting:: chain specification: " <<
chainName <<
"\traw:" <<
chainName.raw() << std::endl;
249 std::cout <<
"\tchain: " <<
chainName.head() << std::endl;
250 std::cout <<
"\tkey: " <<
chainName.tail() << std::endl;
251 std::cout <<
"\troi: " <<
chainName.roi() << std::endl;
252 std::cout <<
"\tvtx: " <<
chainName.vtx() << std::endl;
253 std::cout <<
"\tte: " <<
chainName.element() << std::endl;
254 std::cout <<
"\tind: " <<
chainName.extra() << std::endl;
304 if ( xbeam!=0 || ybeam!=0 ) {
314 #ifndef XAODTRACKING_TRACKPARTICLE_H
321 unsigned lumi_block = 0;
322 unsigned bunch_crossing_id = 0;
323 unsigned time_stamp = 0;
326 if ( this->
template retrieve(pEventInfo,
"EventInfo").isFailure() ) {
330 #ifndef XAODTRACKING_TRACKPARTICLE_H
331 run_number = pEventInfo->event_ID()->run_number();
332 event_number = pEventInfo->event_ID()->event_number();
333 lumi_block = pEventInfo->event_ID()->lumi_block();
334 time_stamp = pEventInfo->event_ID()->time_stamp();
335 bunch_crossing_id = pEventInfo->event_ID()->bunch_crossing_id();
342 bunch_crossing_id = pEventInfo->
bcid();
349 <<
"\tevent " << event_number
350 <<
"\tlb " << lumi_block <<
endmsg;
373 bool analyse =
false;
377 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
379 const std::string& chainname =
m_chainNames[ichain].head();
381 if ( chainname ==
"" ) analyse =
true;
385 if ( chainname.find(
"L2") == std::string::npos &&
386 chainname.find(
"EF") == std::string::npos &&
387 chainname.find(
"HLT") == std::string::npos )
continue;
391 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
392 <<
"\tpres " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
398 if ( (*(
m_tdt))->isPassed(chainname) || (*(
m_tdt))->getPrescale(chainname) ) analyse =
true;
422 selectorTruth.clear();
432 if ( this->
template retrieve(truthMap,
"TrigInDetTrackTruthMap").isFailure()) {
447 std::vector<TIDA::Vertex> vertices;
448 std::vector<TIDA::Vertex> vertices_rec;
450 std::vector<double> refbeamspot;
451 std::vector<double> testbeamspot;
455 #ifndef XAODTRACKING_TRACKPARTICLE_H
460 if (
m_provider->evtStore()->template contains<VxContainer>(
"VxPrimaryCandidate") ) {
461 if ( this->
template retrieve(primaryVtxCollection,
"VxPrimaryCandidate").isFailure()) {
462 if (
m_provider->msg().level() <= MSG::WARNING)
m_provider->msg(MSG::WARNING) <<
"Primary vertex container not found" <<
endmsg;
466 for ( ; vtxitr != primaryVtxCollection->
end(); ++vtxitr) {
467 if ( (*vtxitr)->vxTrackAtVertex()->size()>0 ) {
468 vertices.push_back(
TIDA::Vertex( (*vtxitr)->recVertex().position().x(),
469 (*vtxitr)->recVertex().position().y(),
470 (*vtxitr)->recVertex().position().z(),
472 (*vtxitr)->vxTrackAtVertex()->size() ) );
489 if ( this->
template retrieve( xaodVtxCollection,
"PrimaryVertices" ).isFailure()) {
490 if (
m_provider->msg().level() <= MSG::WARNING)
m_provider->msg(MSG::WARNING) <<
"xAOD Primary vertex container not found with key " <<
"PrimaryVertices" <<
endmsg;
493 if ( xaodVtxCollection!=0 ) {
498 for ( ; vtxitr != xaodVtxCollection->
end(); vtxitr++ ) {
499 if ( (*vtxitr)->nTrackParticles()>0 && (*vtxitr)->vertexType()!=0 ) {
507 (*vtxitr)->nTrackParticles(),
509 (*vtxitr)->chiSquared(),
510 (*vtxitr)->numberDoF() ) );
530 for (
unsigned i=0 ;
i<vertices.size() ;
i++ ) {
540 std::vector<TIDA::Track*> offline_tracks;
541 std::vector<TIDA::Track*> electron_tracks;
542 std::vector<TIDA::Track*> muon_tracks;
544 std::vector<TIDA::Track*> ref_tracks;
545 std::vector<TIDA::Track*> test_tracks;
547 offline_tracks.clear();
548 electron_tracks.clear();
555 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
562 const std::string& chainname =
m_chainNames[ichain].head();
564 const std::string& vtx_name =
m_chainNames[ichain].vtx();
572 std::string ptvalue =
m_chainNames[ichain].postvalue(
"pt");
578 unsigned _decisiontype = TrigDefs::Physics;
579 unsigned decisiontype;
581 if ( this->
requireDecision() ) _decisiontype = TrigDefs::requireDecision;
585 else decisiontype = TrigDefs::alsoDeactivateTEs;
592 const std::string& key_index_string =
m_chainNames[ichain].extra();
593 unsigned key_index = 0;
594 if ( key_index_string!=
"" ) key_index =
std::atoi( key_index_string.c_str() );
599 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
600 <<
"\tprescale " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
616 if ( chainname!=
"" && !this->
m_keepAllEvents && !(*m_tdt)->isPassed( chainname, decisiontype ) )
continue;
641 chain.addRoi( *roiInfo );
644 # ifdef XAODTRACKING_TRACKPARTICLE_H
645 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
key) ) {
646 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
key );
647 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
key );
653 chain.back().addTracks(testtracks);
655 if ( roiInfo )
delete roiInfo;
678 for( ;
c!=cEnd ; ++
c ) {
688 std::vector< Trig::Feature<TrigRoiDescriptor> > initRois;
692 if ( roi_key==
"SuperRoi" && icomb>1 )
continue;
700 if ( initRois.empty() ) initRois =
c->get<
TrigRoiDescriptor>(
"initialRoI", decisiontype );
705 if ( initRois.empty() )
continue;
713 if(initRois.size()>1 && roi_key!=
"SuperRoi" ) {
721 if( !initRois.empty() ) {
757 if (
key.find(
"InDetTrigParticleCreation")!=std::string::npos ||
758 key.find(
"_IDTrig")!=std::string::npos ||
759 key.find(
"_EFID")!=std::string::npos ||
760 chainName.find(
"EF_")!=std::string::npos ||
761 chainName.find(
"HLT_")!=std::string::npos ) {
762 # ifdef XAODTRACKING_TRACKPARTICLE_H
763 if ( this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
c,
key ) ) testbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
c,
key );
764 else if ( this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorTest,
c,
key ) );
766 if ( this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorTest,
c,
key ) );
769 else if ( this->
template selectTracks<TrigInDetTrackCollection>(
m_selectorTest,
c, truthMap,
key, key_index ) );
776 if (
chainName.find(
"L2_")!=std::string::npos ) {
777 if ( this->
template selectTracks<TrigInDetTrackCollection>(
m_selectorTest,
c, truthMap,
key, key_index ) );
778 else if ( this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorTest,
c,
key ) );
780 # ifdef XAODTRACKING_TRACKPARTICLE_H
781 else if ( this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorTest,
c,
key ) ) testbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
c,
key );
797 for (
int ii=testtracks.size() ; ii-- ; ) {
803 chain.addRoi( *roiInfo );
805 chain.back().addTracks(testtracks);
807 if ( roiInfo )
delete roiInfo;
815 if ( vtx_name!=
"" ) {
819 std::vector< Trig::Feature<xAOD::VertexContainer> > xaodtrigvertices =
c->get<
xAOD::VertexContainer>(vtx_name);
821 if ( xaodtrigvertices.empty() ) {
823 m_provider->msg(MSG::WARNING) <<
"\tNo xAOD::VertexContainer for chain " << chainConfig <<
" for key " << vtx_name <<
endmsg;
830 for (
unsigned iv=0 ; iv<xaodtrigvertices.size() ; iv++ ) {
838 for ( ; vtxitr != vert->
end(); ++vtxitr) {
842 if ( (*vtxitr)->vertexType()!=0 || vtx_name==
"EFHistoPrmVtx" ) {
850 (*vtxitr)->nTrackParticles(),
852 (*vtxitr)->chiSquared(),
853 (*vtxitr)->numberDoF() ) );
874 for (
unsigned iroi=0 ; iroi<
chain.size() ; iroi++ ) {
879 filterRef.setRoi( &
chain.rois().at(iroi).roi() );
882 else filterRef.setRoi( 0 );
904 bool foundTruth =
false;
908 if ( this->
filterOnRoi() ) filter_truth.setRoi( &
chain.rois().at(iroi).roi() );
909 else filter_truth.setRoi( 0 );
911 selectorTruth.clear();
916 if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"INav4MomTruthEvent") ) {
918 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"INav4MomTruthEvent" );
921 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"SpclMC") ) {
923 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"SpclMC");
926 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"") ) {
928 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"");
950 std::string
keys[4] = {
"GEN_AOD",
"TruthEvent",
"",
"G4Truth" };
952 std::string
key =
"";
954 bool foundcollection =
false;
956 for (
int ik=0 ; ik<4 ; ik++ ) {
962 if ( !
m_provider->evtStore()->template contains<McEventCollection>(
keys[ik]) ) {
971 if ( this->
template retrieve( mcevent,
keys[ik] ).isFailure() ) {
980 foundcollection =
true;
986 if ( !foundcollection ) {
988 m_provider->msg(MSG::WARNING) <<
"No MC Truth Collections of any sort, whatsoever!!!" <<
endmsg;
1008 while ( evitr!=evend ) {
1017 for (
auto pitr: *(*evitr)) {
1019 selectorTruth.selectTrack( pitr );
1042 if(selectorTruth.size() > 0) foundTruth =
true;
1057 # ifdef XAODTRACKING_TRACKPARTICLE_H
1058 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
"InDetTrackParticles") ) {
1059 this->
template selectTracks<xAOD::TrackParticleContainer>(
m_selectorRef,
"InDetTrackParticles" );
1060 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
"InDetTrackParticles" );
1062 else if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
1063 this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorRef,
"TrackParticleCandidate" );
1066 if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
1067 this->
template selectTracks<Rec::TrackParticleContainer>(
m_selectorRef,
"TrackParticleCandidate" );
1070 else if (
m_provider->msg().level() <= MSG::WARNING ) {
1087 ref_tracks=selectorTruth.tracks();
1093 test_tracks.clear();
1095 for (
unsigned itrk=0 ; itrk<
chain.rois().at(iroi).tracks().
size() ; itrk++ ) {
1096 test_tracks.push_back(&(
chain.rois().at(iroi).tracks().at(itrk)));
1152 if ( vtx_name!=
"" ) {
1154 std::vector<TIDA::Vertex>
vr =
chain.rois().at(iroi).vertices();
1155 std::vector<TIDA::Vertex*> vtx_rec;
1156 for (
unsigned iv=0 ; iv<
vr.size() ; iv++ ) vtx_rec.push_back( &
vr[iv] );
1158 std::vector<TIDA::Vertex*> vtx;
1160 for (
unsigned iv=0 ; iv<vertices.size() ; iv++ ) vtx.push_back( &vertices[iv] );
1163 if ( vertices.size()>
unsigned(this->getVtxIndex()) ) vtx.push_back( &vertices[this->
getVtxIndex()] );
1174 <<
"\tevent " << event_number
1175 <<
"\tlb " << lumi_block <<
endmsg;