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 246 of file T_AnalysisConfigR3_Tier0.h.
268 std::vector<std::string> configuredChains = (*(
m_tdt))->getListOfTriggers(
"L2_.*, EF_.*, HLT_.*");
270 for (
unsigned i=0 ;
i<configuredChains.size() ;
i++ ) {
315 if (
m_mcTruth ) pselectorRef = &selectorTruth;
328 double beamline[4] = { 0, 0, 0, 0 };
338 unsigned long long event_number = 0;
339 unsigned lumi_block = 0;
340 unsigned bunch_crossing_id = 0;
341 unsigned time_stamp = 0;
347 if ( this->
template retrieve( pEventInfo,
"EventInfo" ).isFailure() ) {
355 bunch_crossing_id = pEventInfo->
bcid();
361 <<
"\tevent " << event_number
362 <<
"\tlb " << lumi_block <<
endmsg;
378 bool analyse =
false;
382 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
384 const std::string& chainname =
m_chainNames[ichain].head();
386 if ( chainname ==
"" ) analyse =
true;
390 if ( chainname.find(
"L2") == std::string::npos &&
391 chainname.find(
"EF") == std::string::npos &&
392 chainname.find(
"HLT") == std::string::npos )
continue;
396 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
397 <<
"\tpres " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
404 if ( (*(
m_tdt))->isPassed(chainname) ) analyse =
true;
421 selectorTruth.clear();
428 std::vector<TIDA::Vertex> vertices;
429 std::vector<TIDA::Vertex> vertices_rec;
431 std::vector<double> refbeamspot;
432 std::vector<double> testbeamspot;
438 if ( !this->
select( vertices,
"PrimaryVertices" ) ) {
439 m_provider->msg(
MSG::VERBOSE) <<
"could not retrieve the 'PrimaryVertices' vertex collection" << std::endl;
453 for (
unsigned i=0 ;
i<vertices.size() ;
i++ ) {
464 std::vector<TIDA::Track*> offline_tracks;
465 std::vector<TIDA::Track*> electron_tracks;
466 std::vector<TIDA::Track*> muon_tracks;
468 std::vector<TIDA::Track*> ref_tracks;
469 std::vector<TIDA::Track*> test_tracks;
471 offline_tracks.clear();
472 electron_tracks.clear();
482 bool foundTruth =
false;
488 filter_truth.setRoi( 0 );
490 selectorTruth.clear();
495 if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"INav4MomTruthEvent") ) {
497 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"INav4MomTruthEvent" );
500 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"SpclMC") ) {
502 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"SpclMC");
505 else if (
m_provider->evtStore()->template contains<xAOD::TruthParticleContainer>(
"TruthParticles") ) {
507 this->
template selectTracks<xAOD::TruthParticleContainer>( &selectorTruth,
"TruthParticles");
510 else if (
m_provider->evtStore()->template contains<TruthParticleContainer>(
"") ) {
512 this->
template selectTracks<TruthParticleContainer>( &selectorTruth,
"");
533 std::string
keys[4] = {
"GEN_AOD",
"TruthEvent",
"",
"G4Truth" };
535 std::string
key =
"";
537 bool foundcollection =
false;
539 for (
int ik=0 ; ik<4 ; ik++ ) {
545 if ( !
m_provider->evtStore()->template contains<McEventCollection>(
keys[ik]) ) {
554 if ( this->
template retrieve( mcevent,
keys[ik] ).isFailure() ) {
563 foundcollection =
true;
569 if ( !foundcollection ) {
571 m_provider->msg(MSG::WARNING) <<
"No MC Truth Collections of any sort, whatsoever!!!" <<
endmsg;
591 while ( evitr!=evend ) {
608 while ( pitr!=pend ) {
610 selectorTruth.selectTrack( *pitr++ );
633 if(selectorTruth.size() > 0) foundTruth =
true;
644 bool found_offline =
false;
648 this->
template selectTracks<xAOD::TrackParticleContainer>( pselectorRef,
m_offline_types[
it] );
649 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
m_offline_types[
it] );
650 found_offline =
true;
657 if ( !found_offline ) {
658 if (
m_provider->evtStore()->template contains<Rec::TrackParticleContainer>(
"TrackParticleCandidate") ) {
660 this->
template selectTracks<Rec::TrackParticleContainer>( pselectorRef,
"TrackParticleCandidate" );
663 m_provider->msg(MSG::WARNING) <<
"Offline tracks not found: " <<
"TrackParticleCandidate" <<
endmsg;
676 for (
unsigned ichain=0 ; ichain<
m_chainNames.size() ; ichain++ ) {
681 const std::string& chainname =
m_chainNames[ichain].head();
683 const std::string& vtx_name =
m_chainNames[ichain].vtx();
691 std::string ptvalue =
m_chainNames[ichain].postvalue(
"pt");
696 unsigned decisiontype = TrigDefs::Physics;
698 if ( !
m_chainNames[ichain].
passed() ) decisiontype = TrigDefs::includeFailedDecisions;
707 <<
"\tpass " << (*m_tdt)->isPassed(chainname)
708 <<
"\tprescale " << (*m_tdt)->getPrescale(chainname) <<
endmsg;
725 if ( chainname!=
"" && !this->
m_keepAllEvents && !(*m_tdt)->isPassed( chainname, decisiontype ) )
continue;
735 std::vector<std::string> chainNames ;
741 chainNames.push_back(pTnP_tool->
tag());
742 chainNames.push_back(pTnP_tool->
probe());
746 for (
size_t i=0 ;
i<chainNames.size() ;
i++ ) {
759 pselectorTest->
clear();
769 if (
m_provider->evtStore()->template contains<xAOD::TrackParticleContainer>(
key) ) {
770 this->
template selectTracks<xAOD::TrackParticleContainer>( pselectorTest,
key );
771 refbeamspot = this->
template getBeamspot<xAOD::TrackParticleContainer>(
key );
774 const std::vector<TIDA::Track*>& testtracks = pselectorTest->
tracks();
776 chain.back().addTracks(testtracks);
778 if ( vtx_name!=
"" ) {
784 std::vector<TIDA::Vertex> tidavertices;
786 if ( this->
select( tidavertices, vtx_name ) )
chain.back().addVertices( tidavertices );
799 std::string roi_key = chainConfig.
roi();
801 unsigned feature_type =TrigDefs::lastFeatureOfType;
803 if ( roi_key!=
"" ) feature_type= TrigDefs::allFeaturesOfType;
809 if ( chainConfig.
element()!=
"" ) {
813 std::string rgex = roi_key;
815 std::vector< TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> >
rois =
826 if (
rois.empty() ) {
827 if ( !rgex.empty() ) {
848 if ( roi_key==
"SuperRoi" && iroi>1 )
continue;
855 if ( roi_key!=
"" && roi_link.
dataID()!=rgex )
continue;
858 if ( !roi_link.
isValid() )
continue;
862 if ( roiptr == 0 )
continue;
878 pselectorTest->
clear();
880 if ( this->
template selectTracks<xAOD::TrackParticleContainer>( pselectorTest, roi_link,
key ) ) { }
886 chain.addRoi( *roiInfo );
890 const std::vector<TIDA::Track*>& testtracks = pselectorTest->
tracks();
892 chain.back().addTracks(testtracks);
897 if ( vtx_name!=
"" ) {
899 std::vector<TIDA::Vertex> tidavertices;
901 this->
select( tidavertices, roi_link, vtx_name );
903 chain.back().addVertices( tidavertices );
910 std::cout <<
"\tTIDA analysis for chain: " << chainname <<
"\t key: " <<
key <<
"\t" << **roiptr << std::endl;
911 std::cout <<
"\tcollections: " <<
chain.back() << std::endl;
933 for (
unsigned ichain=0 ; ichain<eventp->
size() ; ichain++ ) {
937 const std::string& vtx_name = chainConfig.
vtx();
940 if (
m_tnp_flag && chainConfig.
extra().find(
"_tag")!=std::string::npos ) continue ;
942 std::vector<TIDA::Roi*>
rois ;
957 for (
unsigned iroi=0 ; iroi<
rois.size() ; iroi++ ) {
960 filterRef.setRoi( &(
rois.at(iroi)->roi() ) );
963 else filterRef.setRoi( 0 );
987 if ( this->
filterOnRoi() ) filter_truth.setRoi( &(
rois.at(iroi)->roi() ) );
988 ref_tracks = pselectorRef->
tracks(&filter_truth);
991 ref_tracks = pselectorRef->
tracks(&filterRef) ;
996 for (
int ii=pselectorRef->
tracks().size() ; ii-- ; ) {
1001 test_tracks.clear();
1004 for (
unsigned itrk=0 ; itrk<
rois.at(iroi)->tracks().
size() ; itrk++ ) {
1005 test_tracks.push_back(&(
rois.at(iroi)->tracks().at(itrk)));
1013 beamline[0] = pselectorTest->
getBeamX();
1014 beamline[1] = pselectorTest->
getBeamY();
1015 beamline[2] = pselectorTest->
getBeamZ();
1017 beamline[3] = vertices.size();
1043 associator->
match( test_tracks, ref_tracks );
1045 m_manalysis->execute( test_tracks, ref_tracks, associator, eventp, beamline );
1067 associator->
match( ref_tracks, test_tracks );
1074 m_manalysis->execute( ref_tracks, test_tracks, associator, eventp, beamline, &(
rois.at(iroi)->roi()) );
1076 if ( vtx_name!=
"" ) {
1078 std::vector<TIDA::Vertex>
vr =
rois.at(iroi)->vertices();
1079 std::vector<TIDA::Vertex*> vtx_rec;
1080 for (
unsigned iv=0 ; iv<
vr.size() ; iv++ ) vtx_rec.push_back( &
vr[iv] );
1082 std::vector<TIDA::Vertex*> vtx;
1084 for (
unsigned iv=0 ; iv<vertices.size() ; iv++ ) vtx.push_back( &vertices[iv] );
1087 if ( vertices.size()>
unsigned(this->getVtxIndex()) ) vtx.push_back( &vertices[this->
getVtxIndex()] );
1098 <<
"\tevent " << event_number
1099 <<
"\tlb " << lumi_block <<
endmsg;