diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe.h b/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe.h index 51f53e9eff618c081654d175f31cf67321f7aacc..73f74c105503c409e2a474bd49de798d304f7e2a 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe.h +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe.h @@ -1,222 +1,183 @@ /// emacs: this is -*- c++ -*- /** - ** @file TagNProbe.h + ** @file TagNProbe2.h ** - ** @author marco aparo - ** @date Fri 02 Jul 2021 13:30:00 CET + ** @author mark sutton + ** @date Sat Apr 9 12:55:17 CEST 2022 ** - ** Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + ** Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration **/ -#ifndef TIDAUTILS_TAGNPROBE_H -#define TIDAUTILS_TAGNPROBE_H +#ifndef TIDAUTILS_TAGNPROBE2_H +#define TIDAUTILS_TAGNPROBE2_H -#include +#include -#include "TLorentzVector.h" +#include "TrigInDetAnalysis/TIDAChain.h" +#include "TrigInDetAnalysis/TIDARoiDescriptor.h" +#include "TrigInDetAnalysis/TrigObjectMatcher.h" +#include "TrigInDetAnalysis/Track.h" -#include "TrigInDetAnalysis/TIDAEvent.h" #include "TrigInDetAnalysis/TrackSelector.h" #include "TrigInDetAnalysisUtils/Filters.h" -#include "TrigInDetAnalysisUtils/Filter_Offline2017.h" -#include "TrigInDetAnalysis/TrackSelector.h" -#include "TrigInDetAnalysis/TrigObjectMatcher.h" -#include "TH1D.h" -#include -#include -#include - -#include "TrigInDetAnalysis/TrackAnalysis.h" -#include "TrigInDetAnalysis/Track.h" -#include "TrigInDetAnalysis/TIDDirectory.h" -#include "TrigInDetAnalysis/Efficiency.h" -#include "TrigInDetAnalysis/TIDARoiDescriptor.h" +#include "TLorentzVector.h" -class TagNProbe { +class TagNProbe2 { public: - TagNProbe() { } - - virtual ~TagNProbe() { } - - - /// configuration methods - - void SetEventConfiguration( - TrackSelector * refTracks, // reference tracks - TrackFilter* refFilter, // reference filter - std::string refName, // reference objects name - TrigObjectMatcher* tom, // trigger object matcher - double ZmassMin, // ZmassMin - double ZmassMax, // ZmassMax - bool unique_flag=true ) { // unique flag (default=true) - m_refTracks = refTracks; - m_refFilter = refFilter; - m_particleType = refName; - m_tom = tom; - m_ZmassMin = ZmassMin; - m_ZmassMax = ZmassMax; - m_unique = unique_flag; - } - - void ResetEventConfiguration() { - m_refTracks = 0; - m_refFilter = 0; - m_particleType = ""; - m_tom = 0; - m_ZmassMin = 0.; - m_ZmassMax = 999.; - m_unique = false; - } - - void SetUniqueFlag( bool flag ) { m_unique = flag; } - - void SetParticleType( std::string type ) { m_particleType = type; } - - void SetZmassWindow( double ZmassMin, double ZmassMax ) { m_ZmassMin = ZmassMin; m_ZmassMax = ZmassMax; } - - void SetObjMatcher( TrigObjectMatcher* tom ) { m_tom = tom; } - - void SetOfflineTracks( TrackSelector * refTracks, TrackFilter* refFilter ) { - m_refTracks = refTracks; - m_refFilter = refFilter; - } - - void SetChains( TIDA::Chain * chain, TIDA::Chain * chain_tnp ) { - m_chain = chain; - m_chain_tnp = chain_tnp; - } - - template - void Fill( T* h, T* h1, int i ) { - /// don't need to check both these, we can just call this as many times as we like, - /// could pass in the vector even so that - // we leave the old code in, but commented, since we are still developing, so once - // we know everything is working we can delete all the older code - // if ( m_masses[i].size() == m_masses_obj[i].size() && m_masses[i].size() > 0 ) { - - /// don't understand this - why is this method filling lots of masses - /// from an vector of masses from 0 up to the input index ? - /// isn't this index just the index of the roi ? Why the loop ? - for ( size_t im=0 ; imFill( m_masses[i].at(im) ); - } - for ( size_t im=0 ; imFill( m_masses_obj[i].at(im) ); - } - } - - - /// probe searching method - - bool FindProbes(); - - void FindTIDAChains( std::vector& chains ) ; - - /// getter methods - - std::vector GetProbes() { return m_probes; } - - std::vector GetTags( unsigned int probe_index=0 ) { return m_tags[ probe_index ]; } - - std::vector GetInvMasses( unsigned int probe_index=0 ) { return m_masses[ probe_index ]; } - - std::vector GetInvMasses_obj( unsigned int probe_index=0 ) { return m_masses_obj[ probe_index ]; } - - std::vector GetRois( TIDA::Chain * chain, std::vector& chains ); - - std::vector GetRois( std::vector& chains ); + TagNProbe2( const std::string& refName, double massMin, double massMax, bool unique_flag=true ); + + virtual ~TagNProbe2() { } - void tag( const std::string& chainName ) { m_tagChainName = chainName ; } + /// getters and setters - const std::string& tag() { return m_tagChainName ; } + /// could be moved to the constructor now ... + void tag( const std::string& chainName ) { m_tagChainName = chainName; } + void probe( const std::string& chainName ) { m_probeChainName = chainName; } - void probe( const std::string& chainName ) { m_probeChainName = chainName ; } + const std::string& tag() const { return m_tagChainName; } + const std::string& probe() const { return m_probeChainName; } - const std::string& probe() { return m_probeChainName ; } +public: - TIDA::Chain* GetTIDAProbe() { return m_chain_tnp ; } + template + std::vector GetRois( std::vector& chains, + const TrackSelector* refTracks, + TrackFilter* refFilter, + T* hmass, + T* hmass_obj, + TrigObjectMatcher* tom=0 ) const { - TIDA::Chain* GetTIDATag() { return m_chain ; } + std::vector probes; - TH1D* GetMinvHisto() { return m_hMinv ; } + TIDA::Chain* chain_tag = findChain( tag(), chains ); + TIDA::Chain* chain_probe = findChain( probe(), chains ); - TH1D* GetMinvObjHisto() { return m_hMinv_obj ; } + if ( chain_tag==0 || chain_probe==0 ) return probes; + // loop for possible probes + for ( size_t ip=0 ; ipsize() ; ip++ ) { + + TIDA::Roi& proi = chain_probe->rois()[ip]; + + TIDARoiDescriptor roi_probe( proi.roi() ); + + bool found_tnp = false; + + // loop for possible tags + for ( size_t it=0 ; itsize() ; it++ ) { + + TIDA::Roi& troi = chain_tag->rois()[it]; + TIDARoiDescriptor roi_tag( troi.roi() ); + + /// tag and probe are the same: skip this tag + if ( roi_probe == roi_tag ) continue; + + if ( selection( troi, proi, refTracks, refFilter, hmass, hmass_obj, tom ) ) { + found_tnp = true; + if ( m_unique ) break; + } + + } // end loop on tags + + if ( found_tnp ) probes.push_back( &proi ); + + } // end loop on probes + + return probes; + + } - /// utility methods +protected: - void FillMap( std::vector& tnpChains ); + double pt( const TIDA::Track* t ) const { return t->pT(); } + double pt( const TrackTrigObject* t ) const { return t->pt(); } - std::vector GetProbeChainNames() { return m_probe_chain_names; } - - bool isTnP() { return m_tnp_map.size()>0; } - - TIDA::Chain* GetTagChain( std::string probe_name, std::vector& chains ); + template + double mass( const T* t1, const T* t2 ) const { + TLorentzVector v1; + v1.SetPtEtaPhiM( pt(t1)*0.001, t1->eta(), t1->phi(), m_mass ); + TLorentzVector v2; + v2.SetPtEtaPhiM( pt(t2)*0.001, t2->eta(), t2->phi(), m_mass ); + return (v1+v2).M(); + } - void BookMinvHisto( std::string chain_name ); - void BookMinvHisto(); + template + bool selection( const TIDA::Roi& troi, const TIDA::Roi& proi, + const TrackSelector* refTracks, + TrackFilter* refFilter, + T* hmass, + T* hmass_obj, + TrigObjectMatcher* tom=0) const { + + /// get reference tracks from the tag roi + TIDARoiDescriptor roi_tag( troi.roi() ); - void FillMinvHisto( std::string chain_name, unsigned int probe_index ); + dynamic_cast(refFilter)->setRoi( &roi_tag ); - void FillMinvHisto( unsigned int probe_index ); + std::vector refp_tag = refTracks->tracks( refFilter ); - void WriteMinvHisto( TDirectory* foutdir ); + /// get reference tracks from the probe roi + TIDARoiDescriptor roi_probe( proi.roi() ); + dynamic_cast( refFilter )->setRoi( &roi_probe ); - /// internal methods for computation (protected) + std::vector refp_probe = refTracks->tracks( refFilter ); -protected: + /// loop over tag ref tracks + bool found = false; - std::pair selection( TIDA::Roi & troi, TIDA::Roi & proi ); + for ( size_t it=0; itz0() - refp_probe[ip]->z0() ); + + if ( invmass_obj>m_massMin && invmass_objFill( invmass ); + hmass_obj->Fill( invmass_obj ); + found = true; + } + } + } - /// internally used variables + return found; -private: + } - TrackSelector * m_refTracks; - TrackFilter * m_refFilter; - TIDA::Chain * m_chain; - TIDA::Chain * m_chain_tnp; + double mass_obj( const TIDA::Track* t1, const TIDA::Track* t2, TrigObjectMatcher* tom=0 ) const; - std::string m_probeChainName ; - std::string m_tagChainName ; + TIDA::Chain* findChain( const std::string& chainname, std::vector& chains ) const; - std::vector m_probes; - std::vector< std::vector > m_masses; - std::vector< std::vector > m_masses_obj; - std::vector< std::vector > m_tags; - bool m_unique; +private: std::string m_particleType; - double m_ZmassMin, m_ZmassMax; + double m_mass; - TrigObjectMatcher* m_tom; + double m_massMin; + double m_massMax; - /// supporting variables for utility methods + bool m_unique; - std::map m_tnp_map; - std::vector m_probe_chain_names; + std::string m_probeChainName ; + std::string m_tagChainName ; - std::map m_hMinv_map; - std::map m_hMinv_obj_map; +}; - TH1D* m_hMinv ; - TH1D* m_hMinv_obj ; -}; +#endif /// TIDAUTILS_TAGNPROBE2_H + -#endif // TIDAUTILS_TAGNPROBE_H diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe2.h b/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe2.h deleted file mode 100644 index 73f74c105503c409e2a474bd49de798d304f7e2a..0000000000000000000000000000000000000000 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/TrigInDetAnalysisUtils/TagNProbe2.h +++ /dev/null @@ -1,183 +0,0 @@ -/// emacs: this is -*- c++ -*- -/** - ** @file TagNProbe2.h - ** - ** @author mark sutton - ** @date Sat Apr 9 12:55:17 CEST 2022 - ** - ** Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration - **/ - - -#ifndef TIDAUTILS_TAGNPROBE2_H -#define TIDAUTILS_TAGNPROBE2_H - -#include - -#include "TrigInDetAnalysis/TIDAChain.h" -#include "TrigInDetAnalysis/TIDARoiDescriptor.h" -#include "TrigInDetAnalysis/TrigObjectMatcher.h" -#include "TrigInDetAnalysis/Track.h" - -#include "TrigInDetAnalysis/TrackSelector.h" -#include "TrigInDetAnalysisUtils/Filters.h" - -#include "TLorentzVector.h" - - -class TagNProbe2 { - -public: - - TagNProbe2( const std::string& refName, double massMin, double massMax, bool unique_flag=true ); - - virtual ~TagNProbe2() { } - - /// getters and setters - - /// could be moved to the constructor now ... - void tag( const std::string& chainName ) { m_tagChainName = chainName; } - void probe( const std::string& chainName ) { m_probeChainName = chainName; } - - const std::string& tag() const { return m_tagChainName; } - const std::string& probe() const { return m_probeChainName; } - -public: - - template - std::vector GetRois( std::vector& chains, - const TrackSelector* refTracks, - TrackFilter* refFilter, - T* hmass, - T* hmass_obj, - TrigObjectMatcher* tom=0 ) const { - - std::vector probes; - - TIDA::Chain* chain_tag = findChain( tag(), chains ); - TIDA::Chain* chain_probe = findChain( probe(), chains ); - - if ( chain_tag==0 || chain_probe==0 ) return probes; - - // loop for possible probes - for ( size_t ip=0 ; ipsize() ; ip++ ) { - - TIDA::Roi& proi = chain_probe->rois()[ip]; - - TIDARoiDescriptor roi_probe( proi.roi() ); - - bool found_tnp = false; - - // loop for possible tags - for ( size_t it=0 ; itsize() ; it++ ) { - - TIDA::Roi& troi = chain_tag->rois()[it]; - TIDARoiDescriptor roi_tag( troi.roi() ); - - /// tag and probe are the same: skip this tag - if ( roi_probe == roi_tag ) continue; - - if ( selection( troi, proi, refTracks, refFilter, hmass, hmass_obj, tom ) ) { - found_tnp = true; - if ( m_unique ) break; - } - - } // end loop on tags - - if ( found_tnp ) probes.push_back( &proi ); - - } // end loop on probes - - return probes; - - } - -protected: - - double pt( const TIDA::Track* t ) const { return t->pT(); } - double pt( const TrackTrigObject* t ) const { return t->pt(); } - - template - double mass( const T* t1, const T* t2 ) const { - TLorentzVector v1; - v1.SetPtEtaPhiM( pt(t1)*0.001, t1->eta(), t1->phi(), m_mass ); - TLorentzVector v2; - v2.SetPtEtaPhiM( pt(t2)*0.001, t2->eta(), t2->phi(), m_mass ); - return (v1+v2).M(); - } - - - template - bool selection( const TIDA::Roi& troi, const TIDA::Roi& proi, - const TrackSelector* refTracks, - TrackFilter* refFilter, - T* hmass, - T* hmass_obj, - TrigObjectMatcher* tom=0) const { - - /// get reference tracks from the tag roi - TIDARoiDescriptor roi_tag( troi.roi() ); - - dynamic_cast(refFilter)->setRoi( &roi_tag ); - - std::vector refp_tag = refTracks->tracks( refFilter ); - - /// get reference tracks from the probe roi - TIDARoiDescriptor roi_probe( proi.roi() ); - - dynamic_cast( refFilter )->setRoi( &roi_probe ); - - std::vector refp_probe = refTracks->tracks( refFilter ); - - /// loop over tag ref tracks - bool found = false; - - for ( size_t it=0; itz0() - refp_probe[ip]->z0() ); - - if ( invmass_obj>m_massMin && invmass_objFill( invmass ); - hmass_obj->Fill( invmass_obj ); - found = true; - } - - } - } - - return found; - - } - - - double mass_obj( const TIDA::Track* t1, const TIDA::Track* t2, TrigObjectMatcher* tom=0 ) const; - - TIDA::Chain* findChain( const std::string& chainname, std::vector& chains ) const; - - -private: - - std::string m_particleType; - - double m_mass; - - double m_massMin; - double m_massMax; - - bool m_unique; - - std::string m_probeChainName ; - std::string m_tagChainName ; - -}; - - -#endif /// TIDAUTILS_TAGNPROBE2_H - - diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe.cxx b/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe.cxx index c85753f5dc7a352856736a1b86daadcfb6f67c71..beec1a880b7157cd8343a53293947d778f3b0a5b 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe.cxx +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe.cxx @@ -1,408 +1,51 @@ /** - ** @file TagNProbe.cxx + ** @file TagNProbe2.cxx ** - ** @author marco aparo - ** @date Fri 02 Jul 2021 13:30:00 CET + ** @author mark sutton + ** @date Sat Apr 9 12:55:17 CEST 2022 ** - ** Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + ** Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration **/ -#include "TrigInDetAnalysisUtils/TagNProbe.h" +#include "TrigInDetAnalysisUtils/TagNProbe2.h" -double TagNProbe::computeZ_obj( TIDA::Track* t1, TIDA::Track* t2 ) { - - double muonMass = 0.10565; // GeV - double electronMass = 0.000510; // GeV - double tauMass = 1.77686; // GeV - - /// get tag and probe particle type and setting mass - - TString tnpType( m_particleType ); - double mass = 0.; - if ( tnpType.Contains("Muon") ) mass = muonMass; - else if ( tnpType.Contains("Electron") ) mass = electronMass; - else if ( tnpType.Contains("Tau") ) mass = tauMass; - - TLorentzVector v1, v2; - double z0_1, z0_2; - if ( tnpType.Contains("Electron") ) { - - if ( m_tom != 0 && !m_tom->status() ) - return -1.0; - - const TrackTrigObject* tobj1 = m_tom->object( t1->id() ); - const TrackTrigObject* tobj2 = m_tom->object( t2->id() ); - - v1.SetPtEtaPhiM( (tobj1->pt())/1000., tobj1->eta(), tobj1->phi(), mass ); - v2.SetPtEtaPhiM( (tobj2->pt())/1000., tobj2->eta(), tobj2->phi(), mass ); - z0_1 = (double)(tobj1->z0()); - z0_2 = (double)(tobj2->z0()); - } - else { - v1.SetPtEtaPhiM( (t1->pT())/1000., t1->eta(), t1->phi(), mass ); - v2.SetPtEtaPhiM( (t2->pT())/1000., t2->eta(), t2->phi(), mass ); - z0_1 = (double)(t1->z0()); - z0_2 = (double)(t2->z0()); - } - - double invMass = (double)( v1 + v2 ).M(); - double z0diff = std::fabs( z0_1 - z0_2 ); - - if ( invMass > m_ZmassMin && invMass < m_ZmassMax && z0diff < 5 ) return invMass; - - return -1.0; - -} - - - - -// ------------------------------------------------------------------ - -double TagNProbe::computeZ( TIDA::Track* t1, TIDA::Track* t2 ) { - - double muonMass = 0.10565; // GeV - double electronMass = 0.000510; // GeV - double tauMass = 1.77686; // GeV - - /// get tag and probe particle type and setting mass - - TString tnpType( m_particleType ); - double mass = 0.; - if ( tnpType.Contains("Muon") ) mass = muonMass; - else if ( tnpType.Contains("Electron") ) mass = electronMass; - else if ( tnpType.Contains("Tau") ) mass = tauMass; - - TLorentzVector v1; - v1.SetPtEtaPhiM( (t1->pT())/1000., t1->eta(), t1->phi(), mass ); - - TLorentzVector v2; - v2.SetPtEtaPhiM( (t2->pT())/1000., t2->eta(), t2->phi(), mass ); - - double invMass = (double)( v1 + v2 ).M(); - - /// this cut is performed on the object-based inv. mass - return invMass; - -} - - - - -// ------------------------------------------------------------------ - -std::pair TagNProbe::selection( TIDA::Roi& troi, TIDA::Roi& proi ) +TagNProbe2::TagNProbe2( const std::string& refName, double massMin, double massMax, bool unique_flag ) : + m_particleType(refName), + m_mass(0), + m_massMin(massMin), + m_massMax(massMax), + m_unique(unique_flag) { + double muonMass = 0.10565; // GeV + double electronMass = 0.000510; // GeV + double tauMass = 1.77686; // GeV - TIDARoiDescriptor roi_tag( troi.roi() ); - TIDARoiDescriptor roi_probe( proi.roi() ); - - /// getting reference tracks from the tag roi - dynamic_cast< Filter_Combined* >( m_refFilter )->setRoi( &roi_tag ); - std::vector< TIDA::Track* > refp_tag = m_refTracks->tracks( m_refFilter ); - - /// getting reference tracks from the probe roi - dynamic_cast< Filter_Combined* >( m_refFilter )->setRoi( &roi_probe ); - std::vector< TIDA::Track* > refp_probe = m_refTracks->tracks( m_refFilter ); - - /// loop on tag ref tracks - for ( size_t it=0; it InvMass = std::make_pair( pair_mass, pair_mass_obj ); - if ( pair_mass_obj > 0 ) - return InvMass; - - } - - } - - std::pair pNull = std::make_pair( 0., 0. ); - - return pNull; - -} - - - - -// ------------------------------------------------------------------ - -bool TagNProbe::FindProbes() -{ - - m_probes.clear(); - m_tags.clear(); - m_masses.clear(); - m_masses_obj.clear(); - - if ( m_chain==0 || m_chain_tnp==0 ) - return false; - - // loop for possible probes - for ( size_t ip=0 ; ipsize() ; ip++ ) { - - TIDA::Roi& proi = m_chain_tnp->rois()[ ip ]; - TIDARoiDescriptor roi_probe( proi.roi() ); - - bool found_tnp = false; - - std::vector tags; - std::vector masses; - std::vector masses_obj; - - // loop for possible tags - for ( size_t it=0 ; itsize() ; it++ ) { - - TIDA::Roi& troi = m_chain->rois()[ it ]; - TIDARoiDescriptor roi_tag( troi.roi() ); - - /// tag and probe are the same: skip this tag - if ( roi_probe == roi_tag ) continue; - - std::pair InvMasses = selection( troi, proi ); - double mass = InvMasses.first; - double mass_obj = InvMasses.second; - - if ( !found_tnp && mass>0 ) found_tnp = true; - - if ( mass>0 ) { - tags.push_back( &troi ); - masses.push_back( mass ); - masses_obj.push_back( mass_obj ); - if ( m_unique ) break; - } - - } // end loop on tags - - if ( found_tnp ) { - m_probes.push_back( &proi ); - m_tags.push_back( tags ); - m_masses.push_back( masses ); - m_masses_obj.push_back( masses_obj ); - } - - } // end loop on probes - - return true; - + if ( m_particleType.find("Muon")!=std::string::npos ) m_mass = muonMass; + else if ( m_particleType.find("Electron")!=std::string::npos ) m_mass = electronMass; + else if ( m_particleType.find("Tau")!=std::string::npos ) m_mass = tauMass; } -// ------------------------------------------------------------------ -void TagNProbe::FillMap( std::vector& tnpChains ) { - /// first clear the map - m_tnp_map.clear(); +double TagNProbe2::mass_obj( const TIDA::Track* t1, const TIDA::Track* t2, TrigObjectMatcher* tom ) const { - for ( size_t i=0 ; i::value_type( chain_probe_name, chain_tag_name ) ); - - /// new testChain vector is filled only with probe chain names - m_probe_chain_names.push_back( tnpChains[i+1] ); + if ( tom!=0 && tom->status() ) { + return mass( tom->object(t1->id()), tom->object(t2->id()) ); } - -} - -// ------------------------------------------------------------------ - -TIDA::Chain* TagNProbe::GetTagChain( std::string probe_name, std::vector& chains ) { - - TIDA::Chain* chain_tag = 0; - - std::map::const_iterator tnpitr = m_tnp_map.find( probe_name ); - - if ( tnpitr != m_tnp_map.end() ) { - - for ( size_t icp=0 ; icpsecond ) { - chain_tag = &( chains[icp] ); - break; - } - } + else { + return mass( t1, t2 ); } - - return chain_tag; - -} - -// ------------------------------------------------------------------ - -std::vector TagNProbe::GetRois( TIDA::Chain * chain, std::vector& chains ) { - - std::vector rois; - TIDA::Chain* chain_tag = 0; - - /// for each configured probe chain find the correspondig tag chain in the event - chain_tag = GetTagChain( chain->name(), chains ); - if ( chain_tag == 0 ) return rois; - - /// resetting the chains - m_chain = 0; - m_chain_tnp = 0; - - /// setting the chains - SetChains( chain, chain_tag ); - - /// find the probe RoIs - if ( !FindProbes() ) return rois; - - /// getting the vector of rois to process - rois = GetProbes(); - - return rois; -} - -// ------------------------------------------------------------------ - -std::vector TagNProbe::GetRois( std::vector& chains ) { - - std::vector rois; - FindTIDAChains(chains) ; - - /// find the probe RoIs - if ( !FindProbes() ) return rois; - - /// getting the vector of rois to process - rois = GetProbes(); - - return rois; -} - -// ------------------------------------------------------------------ - -void TagNProbe::BookMinvHisto( std::string chain_name ) { - - std::string hname_base = chain_name; - std::replace( hname_base.begin(), hname_base.end(), '/', '_' ); - std::replace( hname_base.begin(), hname_base.end(), ':', '_' ); - - std::string hname_1 = hname_base + "_Minv_TnP"; - std::string hname_2 = hname_base + "_Minv_obj_TnP"; - - m_hMinv_map[ chain_name ] = new TH1D( hname_1.c_str(), hname_1.c_str(), 320, 0, 200 ); - m_hMinv_obj_map[ chain_name ] = new TH1D( hname_2.c_str(), hname_2.c_str(), 320, 0, 200 ); - -} - -// ------------------------------------------------------------------ - -void TagNProbe::BookMinvHisto( ) { - - m_hMinv = new TH1D( "Minv_TnP", "Tag&Probe invariant mass", 320, 0, 200 ); - m_hMinv_obj = new TH1D( "Minv_obj_TnP", "Tag&Probe invariant mass (object-based)", 320, 0, 200 ); - -} - -// ------------------------------------------------------------------ - -void TagNProbe::FillMinvHisto( std::string chain_name, unsigned int probe_index ) { - - /// find the histogram for chain_name - std::map::iterator hMinv_itr = m_hMinv_map.find( chain_name ); - std::map::iterator hMinv_obj_itr = m_hMinv_obj_map.find( chain_name ); - - /// check if histod exist, if yes fill them - if ( hMinv_itr != m_hMinv_map.end() && - hMinv_obj_itr != m_hMinv_obj_map.end() && - m_masses[probe_index].size() == m_masses_obj[probe_index].size() ) { - - // for ( size_t im=0 ; imsecond->Fill( m_masses[probe_index].at(im) ); - // hMinv_obj_itr->second->Fill( m_masses_obj[probe_index].at(im) ); - // } - } } -// ------------------------------------------------------------------ -void TagNProbe::FillMinvHisto( unsigned int probe_index ) { - - if ( m_masses[probe_index].size() == m_masses_obj[probe_index].size() && - m_masses[probe_index].size() > 0 ) { - - // for ( size_t im=0 ; imFill( m_masses[probe_index].at(im) ); - // m_hMinv_obj->Fill( m_masses_obj[probe_index].at(im) ); - // } +TIDA::Chain* TagNProbe2::findChain( const std::string& chainname, std::vector& chains ) const { + for ( size_t i=chains.size() ; i-- ; ) { + if ( chains[i].name() == chainname ) return &chains[i]; } + return 0; } -// ------------------------------------------------------------------ - -void TagNProbe::WriteMinvHisto( TDirectory* foutdir ) { - - foutdir->cd(); - - std::map::iterator hMinv_itr; - for ( hMinv_itr=m_hMinv_map.begin() ; hMinv_itr!=m_hMinv_map.end() ; hMinv_itr++ ) { - - std::string dirname = hMinv_itr->first; - std::replace( dirname.begin(), dirname.end(), '/', '_' ); - std::replace( dirname.begin(), dirname.end(), ':', '_' ); - - std::string dirpath( foutdir->GetPath() ); - dirpath += dirname; - -#if 0 - /// renaming (title and object name) histos - /// setting output TDirectory - /// Write is called in rmain.cxx - hMinv_itr->second->SetTitle( "Tag&Probe invariant mass" ); - hMinv_itr->second->SetName( "Minv_TnP" ); - hMinv_itr->second->SetDirectory( foutdir->GetDirectory( dirpath.c_str() ) ); -#endif - - foutdir->cd(); - } - - std::map::iterator hMinv_obj_itr; - for ( hMinv_obj_itr=m_hMinv_obj_map.begin() ; hMinv_obj_itr!=m_hMinv_obj_map.end() ; hMinv_obj_itr++ ) { - - std::string dirname = hMinv_obj_itr->first; - std::replace( dirname.begin(), dirname.end(), '/', '_' ); - std::replace( dirname.begin(), dirname.end(), ':', '_' ); - - std::string dirpath( foutdir->GetPath() ); - dirpath += dirname; - -#if 0 - /// renaming (title and object name) histos and - /// setting output TDirectory - /// Write is called in rmain.cxx - hMinv_obj_itr->second->SetTitle( "Tag&Probe invariant mass (object-based)" ); - hMinv_obj_itr->second->SetName( "Minv_obj_TnP" ); - hMinv_obj_itr->second->SetDirectory( foutdir->GetDirectory( dirpath.c_str() ) ); -#endif - - foutdir->cd(); - } - -} - -// ------------------------------------------------------------------ - -void TagNProbe::FindTIDAChains( std::vector& chains ) { - - for ( int ic=0 ; ic<(int)(chains.size()) ; ++ic ){ - std::string chainConfig = chains[ic].name() ; - if ( (chainConfig) == m_probeChainName ) m_chain_tnp = &( chains[ic] ) ; - if ( (chainConfig) == m_tagChainName ) m_chain = &( chains[ic] ) ; - } -} diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe2.cxx b/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe2.cxx deleted file mode 100644 index beec1a880b7157cd8343a53293947d778f3b0a5b..0000000000000000000000000000000000000000 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUtils/src/TagNProbe2.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/** - ** @file TagNProbe2.cxx - ** - ** @author mark sutton - ** @date Sat Apr 9 12:55:17 CEST 2022 - ** - ** Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration - **/ - - -#include "TrigInDetAnalysisUtils/TagNProbe2.h" - - -TagNProbe2::TagNProbe2( const std::string& refName, double massMin, double massMax, bool unique_flag ) : - m_particleType(refName), - m_mass(0), - m_massMin(massMin), - m_massMax(massMax), - m_unique(unique_flag) -{ - double muonMass = 0.10565; // GeV - double electronMass = 0.000510; // GeV - double tauMass = 1.77686; // GeV - - if ( m_particleType.find("Muon")!=std::string::npos ) m_mass = muonMass; - else if ( m_particleType.find("Electron")!=std::string::npos ) m_mass = electronMass; - else if ( m_particleType.find("Tau")!=std::string::npos ) m_mass = tauMass; -} - - - -double TagNProbe2::mass_obj( const TIDA::Track* t1, const TIDA::Track* t2, TrigObjectMatcher* tom ) const { - - if ( tom!=0 && tom->status() ) { - return mass( tom->object(t1->id()), tom->object(t2->id()) ); - } - else { - return mass( t1, t2 ); - } - -} - - -TIDA::Chain* TagNProbe2::findChain( const std::string& chainname, std::vector& chains ) const { - for ( size_t i=chains.size() ; i-- ; ) { - if ( chains[i].name() == chainname ) return &chains[i]; - } - return 0; -} - -