codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
//////////////// header #ifndef XAODREADER_MONOJETELECTRONSELETIONTOOL_H_ #define XAODREADER_MONOJETELECTRONSELETIONTOOL_H_ // STL include(s): #include <map> #include <string> #include <vector> #include <stdexcept> #include <algorithm> // EDM's include(s): #include "xAODEgamma/ElectronContainer.h" #include "SUSYTools/SUSYObjDef_xAOD.h" #include "xAODCore/ShallowCopy.h" #include "xAODRootAccess/TEvent.h" // Local include(s): #include "xAODReader/MonoJetSelectionCuts.h" typedef std::map<std::string, std::vector<xAOD::Electron*> > MJElectrons; class MonoJetElectrons{ private: MJElectrons m_elFlavor; std::pair<xAOD::ElectronContainer*, xAOD::ShallowAuxContainer*> m_shallow_el; public: MonoJetElectrons(xAOD::TEvent*, ST::SUSYObjDef_xAOD*); ~MonoJetElectrons(); MJElectrons GetElectrons(); }; #endif // XAODREADER_MONOJETELECTRONSELETIONTOOL_H_ ////////////////////// source #include <xAODReader/MonoJetElectronSelectionTool.h> // Standard Constructor: MonoJetElectrons::MonoJetElectrons(xAOD::TEvent *m_event, ST::SUSYObjDef_xAOD *SUSYToolObj){ // Declare electron collection: const xAOD::ElectronContainer *el = 0; // Retrieve Electrons if(!m_event->retrieve(el, "ElectronCollection").isSuccess() ){ throw std::runtime_error("Failed to retrieve Electron container. Exiting"); } // Create ElectronContainer for the electrons that will pass the selection: std::vector<xAOD::Electron*> VetoElectrons; // Reserve enough space for selected electrons: VetoElectrons.reserve(el->size() ); // Make a shallow copy of the container: m_shallow_el = xAOD::shallowCopyContainer(*el); // Loop over all electrons in the shallow container: for(auto el_itr : *(m_shallow_el.first) ){ // SUSYObjDef_xAOD::FillElectron(xAOD::Electron& input, float etcut, float etacut) if(! SUSYToolObj->FillElectron( *el_itr, ElectronCuts::ETCUT, ElectronCuts::ETACUT ).isSuccess() ){ throw std::runtime_error("Failed to calibrate the electrons. Exiting"); } // Apply cut for Veto Electrons: if( el_itr->pt() * .001 > ElectronCuts::VETO_PT && fabs(el_itr->eta() ) < ElectronCuts::VETO_ETA ) VetoElectrons.push_back( el_itr ); } // Sort the electrons by pt: std::sort(std::begin(VetoElectrons), std::end(VetoElectrons), [](xAOD::Electron *e1, xAOD::Electron *e2){ return e1->pt() > e2->pt(); } ); // Make a shallow copy of the container: m_shallow_el = xAOD::shallowCopyContainer(*el); // Loop over all electrons in the shallow container: for(auto el_itr : *(m_shallow_el.first) ){ // SUSYObjDef_xAOD::FillElectron(xAOD::Electron& input, float etcut, float etacut) if(! SUSYToolObj->FillElectron( *el_itr, ElectronCuts::ETCUT, ElectronCuts::ETACUT ).isSuccess() ){ throw std::runtime_error("Failed to calibrate the electrons. Exiting"); } // Apply cut for Veto Electrons: if( el_itr->pt() * .001 > ElectronCuts::VETO_PT && fabs(el_itr->eta() ) < ElectronCuts::VETO_ETA ) VetoElectrons.push_back( el_itr ); } // Sort the electrons by pt: std::sort(std::begin(VetoElectrons), std::end(VetoElectrons), [](xAOD::Electron *e1, xAOD::Electron *e2){ return e1->pt() > e2->pt(); } ); m_elFlavor["Veto"] = VetoElectrons; } // Standard Destructor: MonoJetElectrons::~MonoJetElectrons(){ delete m_shallow_el.first; delete m_shallow_el.second; } // Function to get the electron map: MJElectrons MonoJetElectrons::GetElectrons(){ return m_elFlavor; } // MonoJetElectrons::MonoJetElectrons
Private
[
?
]
Run code
Submit