this isn't working yet - will renable once we have a workaround
will need to add a vertex filter at some point probably
switch reference selector to truth if requested
this isn't working yet - will renable once we have a workaround if ( xbeam!=0 || ybeam!=0 ) { std::cerr << "Oh no ! setBeamLine() : " << xbeam << " " << ybeam << std::endl; pselectorRef->setBeamline( xbeam, ybeam ); }
now start everything going for this event properly ...
the fourth value will store the number of vertices
(obviously) get the event info
for debugging ...
first check whether the chains have actually run, otherwise there's no point doing anything
for debugging ...
for Monte Carlo get the truth particles if requested to do so
get the offline vertices into our structure
fetch offline vertices ...
add the truth particles if needed
now add the vertices
now add the offline tracks and reco objects
FIXME: most of the different truth selection can go
AOD
xAOD::TruthParticles
anything else?
selectTracks<TruthParticleContainer>( &selectorTruth, "INav4MomTruthEvent" );
now as a check go through the GenEvent collection
found this key
not found any truth collection
count of "events" - or interactions
count of particles
count of "events with some particles"
count of particles in this interaction
hooray! actually found a sensible event
if there were some particles in this interaction ...
need to be careful here, if not requiring truth only should not return
do we still want to support Rec::TrackParticles ? Would this even still work ?
clone the asociator
now loop over all relevant chains to get the trigger tracks...
create chains for ntpl
why does this need to be a class variable ???
useful debug information to be kept in for the time being
useful debug information to be kept in
Get chain combinations and loop on them
- loop made on chain selected as the one steering RoI creation
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
do we still want the blind chain access for track collections ???
dummy full scan chain
MT Vertex access
new Roi based feature access
new FeatureRequestDescriptor with leg access
a hack to fetch back the Rois with "_probe" in the name if the standard named RoiDescriptors are not actually present for this chain ...
count of how many rois processed so far
don't extract any additional rois if a superRoi is requested: In this case, the superRoi would be shared between the different chains - this shouldn't be needed now ...
check this is not a spurious TDT match
invalid feature links can happen for missing (or truncated) Aux containers
for debug ...
get the tracks
create analysis chain
get tracks
now get the vertices
retrieve online vertices
"offline" of "roi" type chains
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
- check_a_trigger_chain_has_passed
- get_offline_or_truth_particles
- loop_over_rois
- get_trigger_tracks
- filter_offline_or_truth_reference
- match_tracks
- call_analyis_routine
will leave as it is for the time being
debug ...
get the beamline
the original code sets a class variable on the fill class this will not be reentrant, as another instance could overwrite it, but will keep it in for now. MAybe we could clone the analysis class each time we have an instance. Need to investigate whether such an event-by-event might be fast enough. Foe the time being, leave the original code here, but commented
if we want a purity, we need to swap round which tracks are the reference tracks and which the test tracks
stats book keeping
match test and reference tracks
filter on highest pt track only if required
ignore all tracks belong the specific analysis pt threshold if set
should be included - but leave commented out here to allow study of rois with *no relevant truth particles !!!
stats book keeping
match test and reference tracks
this setting of the roi is not thread safe so it has been diabled for the time being in principle we may be able to remove it completely, but we need to check whether we can do without this functionality, so leave the code in place until we either fix it properly in the future, or determine that it is not needed
get vertices for this roi - have to copy to a vector<Vertex*>
Implements T_AnalysisConfig< T >.
Definition at line 242 of file T_AnalysisConfigR3_Tier0.h.
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;
484 filter_truth.setRoi( 0 );
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 ) {
606 selectorTruth.selectTrack( *pitr++ );
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++ ) {
956 filterRef.setRoi( &(
rois.at(iroi)->roi() ) );
959 else filterRef.setRoi( 0 );
983 if ( this->
filterOnRoi() ) filter_truth.setRoi( &(
rois.at(iroi)->roi() ) );
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()] );
1094 <<
"\tevent " << event_number
1095 <<
"\tlb " << lumi_block <<
endmsg;