Skip to content

Commit

Permalink
Add electron and muon charge (#1278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntadej authored and kratsg committed Nov 21, 2018
1 parent 5bdd190 commit 33fbde6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Root/ElectronContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ElectronContainer::ElectronContainer(const std::string& name, const std::string&

if ( m_infoSwitch.m_kinematic ) {
m_caloCluster_eta = new std::vector<float> ();
m_charge = new std::vector<float> ();
}

if ( m_infoSwitch.m_trigger ){
Expand Down Expand Up @@ -100,6 +101,7 @@ ElectronContainer::~ElectronContainer()
{
if ( m_infoSwitch.m_kinematic ) {
delete m_caloCluster_eta;
delete m_charge;
}

if ( m_infoSwitch.m_trigger ){
Expand Down Expand Up @@ -191,6 +193,7 @@ void ElectronContainer::setTree(TTree *tree)

if ( m_infoSwitch.m_kinematic ) {
connectBranch<float>(tree,"caloCluster_eta", &m_caloCluster_eta);
connectBranch<float>(tree,"charge", &m_charge);
}

if ( m_infoSwitch.m_trigger ){
Expand Down Expand Up @@ -305,6 +308,7 @@ void ElectronContainer::updateParticle(uint idx, Electron& elec)

if ( m_infoSwitch.m_kinematic ) {
elec.caloCluster_eta = m_caloCluster_eta -> at(idx);
elec.charge = m_charge -> at(idx);
}

// trigger
Expand Down Expand Up @@ -422,6 +426,7 @@ void ElectronContainer::setBranches(TTree *tree)

if ( m_infoSwitch.m_kinematic ) {
setBranch<float>(tree,"caloCluster_eta", m_caloCluster_eta);
setBranch<float>(tree,"charge", m_charge);
}

if ( m_infoSwitch.m_trigger ){
Expand Down Expand Up @@ -531,6 +536,7 @@ void ElectronContainer::clear()

if ( m_infoSwitch.m_kinematic ) {
m_caloCluster_eta ->clear();
m_charge ->clear();
}

if ( m_infoSwitch.m_trigger ){
Expand Down Expand Up @@ -645,6 +651,8 @@ void ElectronContainer::FillElectron( const xAOD::IParticle* particle, const xAO
if ( m_infoSwitch.m_kinematic ) {
float calo_eta = ( elec->caloCluster() ) ? elec->caloCluster()->etaBE(2) : -999.0;
m_caloCluster_eta->push_back( calo_eta );

m_charge->push_back( elec->charge() );
}

if ( m_infoSwitch.m_trigger ) {
Expand Down
27 changes: 27 additions & 0 deletions Root/MuonContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ MuonContainer::MuonContainer(const std::string& name, const std::string& detailS
: ParticleContainer(name, detailStr, units, mc, true, storeSystSFs)
{

if ( m_infoSwitch.m_kinematic ) {
m_charge = new std::vector<float> ();
}

// trigger
if ( m_infoSwitch.m_trigger ) {
m_isTrigMatched = new vector<int> ();
Expand Down Expand Up @@ -107,6 +111,9 @@ MuonContainer::MuonContainer(const std::string& name, const std::string& detailS

MuonContainer::~MuonContainer()
{
if ( m_infoSwitch.m_kinematic ) {
delete m_charge;
}

// trigger
if ( m_infoSwitch.m_trigger ) {
Expand Down Expand Up @@ -209,6 +216,10 @@ void MuonContainer::setTree(TTree *tree)
// Connect branches
ParticleContainer::setTree(tree);

if ( m_infoSwitch.m_kinematic ) {
connectBranch<float>(tree, "charge", &m_charge);
}

if ( m_infoSwitch.m_trigger ){
connectBranch<int> (tree, "isTrigMatched", &m_isTrigMatched);
connectBranch<vector<int> >(tree, "isTrigMatchedToChain", &m_isTrigMatchedToChain );
Expand Down Expand Up @@ -325,6 +336,10 @@ void MuonContainer::updateParticle(uint idx, Muon& muon)
{
ParticleContainer::updateParticle(idx,muon);

if ( m_infoSwitch.m_kinematic ) {
muon.charge = m_charge->at(idx);
}

// trigger
if ( m_infoSwitch.m_trigger ) {
muon.isTrigMatched = m_isTrigMatched ->at(idx);
Expand Down Expand Up @@ -442,6 +457,10 @@ void MuonContainer::setBranches(TTree *tree)

ParticleContainer::setBranches(tree);

if ( m_infoSwitch.m_kinematic ) {
setBranch<float>(tree, "charge", m_charge);
}

if ( m_infoSwitch.m_trigger ){
// this is true if there's a match for at least one trigger chain
setBranch<int>(tree,"isTrigMatched", m_isTrigMatched);
Expand Down Expand Up @@ -558,6 +577,10 @@ void MuonContainer::clear()

ParticleContainer::clear();

if ( m_infoSwitch.m_kinematic ) {
m_charge->clear();
}

if ( m_infoSwitch.m_trigger ) {
m_isTrigMatched->clear();
m_isTrigMatchedToChain->clear();
Expand Down Expand Up @@ -671,6 +694,10 @@ void MuonContainer::FillMuon( const xAOD::IParticle* particle, const xAOD::Verte

const xAOD::Muon* muon=dynamic_cast<const xAOD::Muon*>(particle);

if ( m_infoSwitch.m_kinematic ) {
m_charge->push_back( muon->charge() );
}

if ( m_infoSwitch.m_trigger ) {

// retrieve map<string,char> w/ <chain,isMatched>
Expand Down
1 change: 1 addition & 0 deletions xAODAnaHelpers/Electron.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace xAH {

// kinematics
float caloCluster_eta;
float charge;

// trigger
int isTrigMatched;
Expand Down
1 change: 1 addition & 0 deletions xAODAnaHelpers/ElectronContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace xAH {

// kinematics
std::vector<float>* m_caloCluster_eta;
std::vector<float>* m_charge;

// trigger
std::vector<int>* m_isTrigMatched;
Expand Down
3 changes: 3 additions & 0 deletions xAODAnaHelpers/Muon.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace xAH {
//Muon() {};
//virtual ~Muon() { };

// kinematics
float charge;

// trigger
int isTrigMatched;
std::vector<int> isTrigMatchedToChain;
Expand Down
3 changes: 3 additions & 0 deletions xAODAnaHelpers/MuonContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace xAH {

private:

// kinematic
std::vector<float> *m_charge;

// trigger
std::vector<int> *m_isTrigMatched;
std::vector<std::vector<int> > *m_isTrigMatchedToChain;
Expand Down

0 comments on commit 33fbde6

Please sign in to comment.