[ create a new paste ] login | about

Link: http://codepad.org/PKpYl8PW    [ raw code | output | fork ]

C++, pasted on Nov 11:
//////////////// 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        


Output:
1
2
3
4
5
6
7
8
Line 41: error: xAODEgamma/ElectronContainer.h: No such file or directory
Line 38: error: SUSYTools/SUSYObjDef_xAOD.h: No such file or directory
Line 33: error: xAODCore/ShallowCopy.h: No such file or directory
Line 34: error: xAODRootAccess/TEvent.h: No such file or directory
Line 44: error: xAODReader/MonoJetSelectionCuts.h: No such file or directory
Line 52: error: xAODReader/MonoJetElectronSelectionTool.h: No such file or directory
Line 22: error: 'xAOD' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: