99#ifdef USE_DATE_TIME_STAMP
101 <<
" compiled " << __DATE__ <<
" " << __TIME__ <<
"\t: " <<
date() <<
"␛[m" <<
endmsg;
104 bool foundOffline =
false;
110 std::vector<double> beamline;
114 double xbeam_online = 0;
115 double ybeam_online = 0;
116 double zbeam_online = 0;
118 std::vector<double> beamline_online;
143 if ( xbeam!=0 || ybeam!=0 ) {
148 if ( xbeam_online!=0 || ybeam_online!=0 ) {
149 selectorTest.
setBeamline( xbeam_online, ybeam_online, zbeam_online );
162 unsigned run_number = 0;
163 unsigned long long event_number = 0;
164 unsigned lumi_block = 0;
165 unsigned bunch_crossing_id = 0;
166 unsigned time_stamp = 0;
169 if (
retrieve(pEventInfo,
"EventInfo").isFailure() ) {
177 bunch_crossing_id = pEventInfo->
bcid();
181 m_provider->msg(MSG::DEBUG) <<
"run " << run_number
182 <<
"\tevent " << event_number
183 <<
"\tlb " << lumi_block <<
endmsg;
185 m_event->run_number(run_number);
186 m_event->event_number(event_number);
187 m_event->lumi_block(lumi_block);
188 m_event->time_stamp(time_stamp);
189 m_event->bunch_crossing_id(bunch_crossing_id);
198 <<
"L2 pass " << L2chain->
isPassed() <<
"\t"
199 <<
"EF pass " << EFchain->
isPassed() <<
"\t"
200 <<
"HLT pass " << HLTchain->
isPassed() <<
"␛[m"
206 bool analyse =
false;
212 int passed_chains = 0;
221 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
227 if (chainName.find(
"L2") == std::string::npos &&
228 chainName.find(
"EF") == std::string::npos &&
229 chainName.find(
"HLT") == std::string::npos )
continue;
231 if ( configuredHLTChains.find(chainName)==configuredHLTChains.end() ) {
232 m_provider->msg(MSG::WARNING) <<
"␛[91;1m" <<
"Chain " << chainName
233 <<
" is not configured for this event" <<
"␛[m"
241 std::string roistring =
"";
244 bool passPhysics = (*m_tdt)->isPassed(chainName);
246 m_provider->msg(MSG::DEBUG) <<
"Chain " << chainName <<
"\troi " << roistring
247 <<
"\tpres " << (*m_tdt)->getPrescale(chainName)
248 << ( passPhysics ?
"␛[91;1m" :
"" ) <<
"\tpass physics " << passPhysics << ( passPhysics ?
"␛[m" :
"" )
249 <<
"\t: ( pass " << (*m_tdt)->isPassed(chainName, decisiontype ) <<
"\tdec type " << decisiontype <<
" ) " <<
endmsg;
251 if ( (*m_tdt)->isPassed(chainName, decisiontype ) || !
m_chainNames[ichain].passed() ) {
263 m_provider->msg(MSG::DEBUG) <<
"No chains passed unprescaled - not processing this event: " << run_number <<
" " << event_number <<
" " << lumi_block <<
endmsg;
275 selectorTruth.
clear();
303 m_provider->msg(MSG::WARNING) <<
"Truth not found - none whatsoever!" <<
endmsg;
330 std::vector<TIDA::Vertex> vertices;
332 std::string vertexType =
"PrimaryVertices";
333 std::string vertexChainname =
"Vertex";
336 vertexChainname +=
":" + vertexType;
339 m_provider->msg(MSG::VERBOSE) <<
"fetching offline AOD vertex container with key " << vertexType <<
endmsg;
343 if (
retrieve( xaodVtxCollection, vertexType ).isFailure()) {
344 if (
m_provider->msg().level() <= MSG::WARNING)
m_provider->msg(MSG::WARNING) <<
"xAOD vertex container not found with key " << vertexType <<
endmsg;
347 if ( xaodVtxCollection!=0 ) {
349 m_provider->msg(MSG::DEBUG) <<
"xAOD vertex container " << vertexType <<
" found with " << xaodVtxCollection->
size() <<
" entries" <<
endmsg;
353 if ( vertexType.find(
"SecVtx") != std::string::npos ) {
354 vertices = vertexBuilder.
select( xaodVtxCollection, &selectorRef.
tracks(),
true );
357 vertices = vertexBuilder.
select( xaodVtxCollection, &selectorRef.
tracks() );
363 m_event->addChain( vertexChainname );
365 m_event->back().back().addVertices( vertices );
381 for (
unsigned i=0 ; i<vertices.size() ; i++ ) {
382 m_provider->msg(MSG::DEBUG) <<
"vertex " << i <<
" " << vertices[i] <<
endmsg;
383 m_event->addVertex(vertices[i]);
398 m_event->addChain(
"Offline" );
403 std::vector<double> beamline_;
404 beamline_.push_back( selectorRef.
getBeamX() );
405 beamline_.push_back( selectorRef.
getBeamY() );
406 beamline_.push_back( selectorRef.
getBeamZ() );
407 m_event->back().back().addUserData(beamline_);
411 Noff = selectorRef.
tracks().size();
414 for (
int ii=selectorRef.
tracks().size() ; ii-- ; )
m_provider->msg(MSG::DEBUG) <<
" ref track " << ii <<
" " << *selectorRef.
tracks()[ii] <<
endmsg;
419 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
426 std::string collectionname =
m_chainNames[ichain].tail();
430 if ( chainname!=
"" )
continue;
431 if ( collectionname==
"" )
continue;
433 chainname = collectionname;
434 if ( vtx_name!=
"" ) chainname +=
":" + vtx_name;
441 selectorTest.
clear();
445 std::string collection_test = collectionname;
446 size_t pos = collectionname.find(
"/");
447 if ( pos!=std::string::npos ) collection_test = collectionname.substr( pos+1, collectionname.size()-pos );
456 m_provider->msg(MSG::WARNING) <<
"\tcollection " << collectionname <<
" not found" <<
endmsg;
462 std::vector<TIDA::Vertex> tidavertices;
464 m_provider->msg(MSG::DEBUG) <<
"\tFetch xAOD::VertexContainer with key " << vtx_name <<
endmsg;
466 if ( vtx_name!=
"" ) {
468 m_provider->msg(MSG::DEBUG) <<
"\tFetch xAOD::VertexContainer with key " << vtx_name <<
endmsg;
474 if (
retrieve( xaodVtxCollection, vtx_name ).isFailure() ) {
475 if (
m_provider->msg().level() <= MSG::WARNING)
m_provider->msg(MSG::WARNING) <<
"xAOD vertex container not found with key " << vtx_name <<
endmsg;
478 if ( xaodVtxCollection!=0 ) {
480 m_provider->msg(MSG::DEBUG) <<
"\txAOD::VertexContainer found with size " << xaodVtxCollection->
size()
481 <<
"\t" << vtx_name <<
endmsg;
485 if ( vtx_name.find(
"SecVtx") != std::string::npos ) {
486 tidavertices = vertexBuilder.
select( xaodVtxCollection, 0,
true );
489 tidavertices = vertexBuilder.
select( xaodVtxCollection );
498 m_event->addChain( chainname );
500 if ( vtx_name!=
"" )
m_event->back().back().addVertices( tidavertices );
504 std::vector<double> beamline_;
505 beamline_.push_back( selectorTest.
getBeamX() );
506 beamline_.push_back( selectorTest.
getBeamY() );
507 beamline_.push_back( selectorTest.
getBeamZ() );
508 m_event->back().back().addUserData(beamline_);
511 int Ntest = selectorTest.
tracks().size();
513 m_provider->msg(MSG::DEBUG) <<
"collection " << collectionname <<
"\ttest tracks.size() " << Ntest <<
endmsg;
514 for (
int ii=Ntest ; ii-- ; )
m_provider->msg(MSG::DEBUG) <<
" test track " << ii <<
" " << *selectorTest.
tracks()[ii] <<
endmsg;
519 std::string ElectronRef[7] = {
521 "TightCB",
"MediumCB",
"LooseCB",
522 "TightLH",
"MediumLH",
"LooseLH" };
532 for (
int it=0 ; it<7 ; it++ )
if (
m_electronType[ielec]==ElectronRef[it] ) itype = it;
533 if ( itype<0 )
continue;
535 std::vector<TrackTrigObject> elevec;
537 std::string echain = std::string(
"Electrons");
542 if ( Nel_ < 1 )
continue;
552 m_event->back().back().addObjects( elevec );
555 std::vector<double> beamline_;
556 beamline_.push_back( selectorRef.
getBeamX() );
557 beamline_.push_back( selectorRef.
getBeamY() );
558 beamline_.push_back( selectorRef.
getBeamZ() );
559 m_event->back().back().addUserData(beamline_);
565 std::string MuonRef[5] = {
"",
"Tight",
"Medium",
"Loose",
"VeryLoose" };
568 for (
size_t imuon=0 ; imuon<
m_muonType.size() ; imuon++ ) {
573 for (
int it=0 ; it<5 ; it++ )
if (
m_muonType[imuon] == MuonRef[it] ) muonType=it;
574 if ( muonType<0 )
continue;
576 std::string mchain =
"Muons";
579 int Nmu_ =
processMuons( selectorRef, muonType, 0, mchain );
581 if ( Nmu_ < 1 )
continue;
585 m_provider->msg(MSG::DEBUG) <<
"found " << Nmu <<
" offline muons " <<
endmsg;
594 std::vector<double> beamline_;
595 beamline_.push_back( selectorRef.
getBeamX() );
596 beamline_.push_back( selectorRef.
getBeamY() );
597 beamline_.push_back( selectorRef.
getBeamZ() );
598 m_event->back().back().addUserData(beamline_);
602 for (
int ii=selectorRef.
tracks().size() ; ii-- ; )
m_provider->msg(MSG::DEBUG) <<
" ref muon track " << ii <<
" " << *selectorRef.
tracks()[ii] <<
endmsg;
615 m_provider->msg(MSG::DEBUG) <<
"found " << Nmu <<
" offline muons " <<
endmsg;
622 for (
int ii=selectorRef.
tracks().size() ; ii-- ; )
m_provider->msg(MSG::DEBUG) <<
" ref muon track " << ii <<
" " << *selectorRef.
tracks()[ii] <<
endmsg;
628 std::string TauRef[4] = {
"",
"Tight",
"Medium",
"Loose" };
631 for (
size_t itau=0 ; itau<
m_tauType.size() ; itau++ ) {
636 for (
int it=0 ; it<4 ; it++ )
if (
m_tauType[itau]==TauRef[it] ) itype = it;
637 if ( itype<0 )
continue;
640 int requireNtracks = 0;
641 if (
m_tauProngs[itau]==
"3Prong" ) requireNtracks = 3;
642 if (
m_tauProngs[itau]==
"1Prong" ) requireNtracks = 1;
644 std::vector<TrackTrigObject> tauvec;
646 int Ntau_ =
processTaus( selectorRef, &tauvec, itype, requireNtracks, 20000 );
654 std::string tchain = std::string(
"Taus");
661 m_event->back().back().addObjects( tauvec ) ;
664 std::vector<double> beamline_;
665 beamline_.push_back( selectorRef.
getBeamX() );
666 beamline_.push_back( selectorRef.
getBeamY() );
667 beamline_.push_back( selectorRef.
getBeamZ() );
668 m_event->back().back().addUserData(beamline_);
674 if ( Nmu==0 && Noff==0 && Nel==0 && Ntau==0 )
m_provider->msg(MSG::DEBUG) <<
"No offline objects found " <<
endmsg;
675 else foundOffline =
true;
680 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
685 const std::string& chainName =
m_chainNames[ichain].head();
688 const std::string& collectionName =
m_chainNames[ichain].tail();
690 if( chainName.find(
"L2_")==std::string::npos &&
691 chainName.find(
"EF_")==std::string::npos &&
692 chainName.find(
"HLT_")==std::string::npos )
continue;
698 m_provider->msg(MSG::DEBUG) <<
"chain " << chainName
699 <<
"\tprescale " << (*m_tdt)->getPrescale(chainName)
700 <<
"\tpass " << (*m_tdt)->isPassed(chainName) <<
" physics "
701 <<
" (req dec " << (*m_tdt)->isPassed(chainName, decisiontype ) <<
" dec type " << decisiontype <<
")"
708 if ( !(*m_tdt)->isPassed( chainName, decisiontype ) )
continue;
724 if ( roi_name!=
"" ) {
726 std::string roi_name_tmp = roi_name;
727 std::string roi_tename =
"";
729 if ( roi_name.find(
"/")!=std::string::npos ) {
730 roi_name_tmp = roi_name.substr( roi_name.find(
"/")+1, roi_name.size()-roi_name.find(
"/") );
731 roi_tename = roi_name.substr( 0, roi_name.find(
"/") );
736 if ( roist.size()>0 ) {
737 for (
unsigned ir=0 ;
ir<roist.size() ;
ir++ )
m_provider->msg(MSG::DEBUG) <<
"\t\tRetrieved roi " << roi_name <<
"\t" << *roist[
ir].cptr() <<
endmsg;
740 m_provider->msg(MSG::WARNING) <<
"\t\tRequested roi " << roi_name <<
" not found" <<
endmsg;
760 leg = std::atoi(
m_chainNames[ichain].element().c_str());
764 std::string rgex = roi_key;
766 std::vector< TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> > rois =
776 if ( rois.empty() ) {
777 if ( !rgex.empty() ) {
792 if ( rois.size()==0 )
continue;
809 if ( roi_key==
"SuperRoi" && iroi>1 )
continue;
811 if ( roi_key.find(
"JetSuper")!=std::string::npos && iroi>1 )
continue;
816 if ( roi_key!=
"" && roi_link.
dataID()!=rgex )
continue;
825 if (
m_provider->msg().level() <= MSG::VERBOSE) {
826 m_provider->msg(MSG::VERBOSE) <<
" RoI descriptor for seeded chain " << chainName <<
" " << **roiptr <<
endmsg;
839 selectorTest.
clear();
842 if ( chainName.find(
"HLT_")!=std::string::npos || chainName.find(
"EF_")!=std::string::npos ) {
845 if (
m_provider->msg().level() <= MSG::DEBUG) {
846 m_provider->msg(MSG::WARNING) <<
"\tNo track collection " << collectionName <<
" found" <<
endmsg;
853 std::vector<TIDA::Vertex> tidavertices;
855 if ( vtx_name!=
"" ) {
857 m_provider->msg(MSG::DEBUG) <<
"\tFetch xAOD::VertexContainer for chain " << chainName <<
" with key " << vtx_name <<
endmsg;
864 if ( vtx_itrpair.first == vtx_itrpair.second ) {
865 if (
m_provider->msg().level() <= MSG::DEBUG ) {
866 m_provider->msg(MSG::WARNING) <<
"\tNo xAOD::Vertex for chain " << chainName <<
" for key " << vtx_name <<
endmsg;
871 m_provider->msg(MSG::DEBUG) <<
"\txAOD::VertexContainer found with size " << (vtx_itrpair.second - vtx_itrpair.first)
872 <<
"\t" << vtx_name <<
endmsg;
876 if ( vtx_name.find(
"SecVtx") != std::string::npos ) {
877 tidavertices = vertexBuilder.
select( vtx_itrpair.first, vtx_itrpair.second, &selectorRef.
tracks(),
true );
880 tidavertices = vertexBuilder.
select( vtx_itrpair.first, vtx_itrpair.second, &selectorTest.
tracks() );
888 std::vector<TrackTrigObject> jets;
889 if ( chainName.find(
"HLT_j")!=std::string::npos || chainName.find(
"EF_j")!=std::string::npos ) {
894 const std::vector<TIDA::Track*>& testTracks = selectorTest.
tracks();
895 m_provider->msg(MSG::DEBUG) <<
"\ttest tracks.size() " << testTracks.size() <<
endmsg;
896 for (
unsigned int ii=0; ii < testTracks.size(); ii++) {
897 m_provider->msg(MSG::DEBUG) <<
" test track " << ii <<
"for chain " << chainName +
":" + collectionName <<
" " << *testTracks[ii] <<
endmsg;
904 if ( roi_tmp == 0 ) {
905 if ( testTracks.size()>0 )
m_provider->msg(MSG::WARNING) <<
"\ttest tracks.size() " << testTracks.size() <<
"found but no roi!!!" <<
endmsg;
909 chain.addRoi( *roi_tmp );
911 chain.back().addTracks(testTracks);
912 chain.back().addVertices(tidavertices);
916 if ( chainName.find(
"HLT_j")!=std::string::npos ) chain.back().addObjects( jets );
920 std::vector<double> beamline_;
921 beamline_.push_back( selectorTest.
getBeamX() );
922 beamline_.push_back( selectorTest.
getBeamY() );
923 beamline_.push_back( selectorTest.
getBeamZ() );
924 chain.back().addUserData(beamline_);
944 std::vector<std::string> chainnames =
m_event->chainnames();
948 for (
size_t ic=chainnames.size() ; ic-- ; ) {
949 if ( chainnames[ic] ==
"Offline" ) {
957 std::vector<TIDA::Chain>& chains =
m_event->chains();
958 std::vector<TIDA::Chain>::iterator citr = chains.begin();
960 std::vector<std::pair<double,double> > philims;
962 for ( ; citr!=chains.end() ; ++citr ) {
963 if ( citr->name().find(
"HLT_")!=std::string::npos || citr->name().find(
"EF_")!=std::string::npos ) {
964 for (
size_t ir=0 ;
ir<citr->size() ;
ir++ ) {
967 for (
size_t isub=0 ; isub<roi.
size() ; isub++ ) {
968 philims.push_back( std::pair<double,double>( roi[isub]->phiMinus(), roi[isub]->phiPlus() ) );
971 else philims.push_back( std::pair<double,double>( roi.
phiMinus(), roi.
phiPlus() ) );
978 for (
size_t iroi=0 ; iroi<
offline->size() ; iroi++ ) {
980 std::vector<TIDA::Track>& tracks =
offline->rois()[iroi].tracks();
986 for ( std::vector<TIDA::Track>::iterator it=tracks.begin() ; it<tracks.end() ; ) {
989 if ( std::fabs(it->pT())<
m_ptmin ) { inc=
false; tracks.erase( it ); }
992 bool remove_track =
true;
993 for (
size_t isub=0 ; isub<philims.size() ; isub++ ) {
995 if ( philims[isub].first < philims[isub].second ) {
996 if ( it->phi()>=philims[isub].first && it->phi()<=philims[isub].second ) {
997 remove_track =
false;
1002 if ( it->phi()>=philims[isub].first || it->phi()<=philims[isub].second ) {
1003 remove_track =
false;
1008 if ( remove_track ) { inc=
false; tracks.erase( it ); }