Tool_TauConstituentSelector.cxx 11.1 KB
Newer Older
1
2
3
4
5
6
7
8
/*
  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/


//! PanTau includes
#include "PanTauAlgs/Tool_TauConstituentSelector.h"

9
#include "PanTauAlgs/TauConstituent.h"
10
#include "PanTauAlgs/HelperFunctions.h"
11
12
13
14
15
16
#include "PanTauAlgs/Tool_InformationStore.h"

#include <math.h>


PanTau::Tool_TauConstituentSelector::Tool_TauConstituentSelector(
17
18
    const std::string& name ) :
        asg::AsgTool(name),
19
20
21
        m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore")
{
    declareProperty("Tool_InformationStore",    m_Tool_InformationStore,   "Link to tool with all information");
22
    declareProperty("Tool_InformationStoreName",    m_Tool_InformationStoreName,   "Link to tool with all information");
23
24
25
26
27
28
29
30
}

PanTau::Tool_TauConstituentSelector::~Tool_TauConstituentSelector() {
}

StatusCode PanTau::Tool_TauConstituentSelector::initialize() {

    ATH_MSG_INFO(" initialize()");
31
    m_init=true;
32
    
33
    ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
34
    ATH_CHECK( m_Tool_InformationStore.retrieve() );
35
    
36
    ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_MaxEta", m_MaxEta) );
37
38
    
    //eta bin edges
39
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_BinEdges_Eta) );
40
41
    
    //et cuts for types used in mode reco
42
43
44
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_Selection_Neutral_EtaBinned_EtCut) );
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut", m_Selection_Pi0Neut_EtaBinned_EtCut) );
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Charged_EtaBinned_EtCut", m_Selection_Charged_EtaBinned_EtCut) );
45
46
    
    //et cuts for types interesting for jet rej.
47
48
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutNeut_EtaBinned_EtCut", m_Selection_OutNeut_EtaBinned_EtCut) );
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_OutChrg_EtaBinned_EtCut", m_Selection_OutChrg_EtaBinned_EtCut) );
49
50
    
    //et cuts for neutral test types with lower et cuts
51
52
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowA_EtaBinned_EtCut", m_Selection_NeutLowA_EtaBinned_EtCut) );
    ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_NeutLowB_EtaBinned_EtCut", m_Selection_NeutLowB_EtaBinned_EtCut) );
53
54
55
56
57
58
    
    
    return StatusCode::SUCCESS;
} 


59
double PanTau::Tool_TauConstituentSelector::getEtCut(double eta, PanTau::TauConstituent2::Type constituentType) const {
60
61
62
63
    
    for(unsigned int iEtaBin=0; iEtaBin<m_BinEdges_Eta.size()-1; iEtaBin++) {
        if(m_BinEdges_Eta[iEtaBin] <= eta && eta < m_BinEdges_Eta[iEtaBin+1]) {
            switch(constituentType) {
64
65
66
67
68
69
70
                case PanTau::TauConstituent2::t_Charged:  return m_Selection_Charged_EtaBinned_EtCut[iEtaBin];
                case PanTau::TauConstituent2::t_Neutral:  return m_Selection_Neutral_EtaBinned_EtCut[iEtaBin];
                case PanTau::TauConstituent2::t_Pi0Neut:  return m_Selection_Pi0Neut_EtaBinned_EtCut[iEtaBin];
                case PanTau::TauConstituent2::t_OutNeut:  return m_Selection_OutNeut_EtaBinned_EtCut[iEtaBin];
                case PanTau::TauConstituent2::t_OutChrg:  return m_Selection_OutChrg_EtaBinned_EtCut[iEtaBin];
                case PanTau::TauConstituent2::t_NeutLowA: return m_Selection_NeutLowA_EtaBinned_EtCut[iEtaBin];
                case PanTau::TauConstituent2::t_NeutLowB: return m_Selection_NeutLowB_EtaBinned_EtCut[iEtaBin];
71
72
73
74
75
76
77
78
79
80
81
82
                default:
                    return 9999999.;
            }
        }
    }
    
    ATH_MSG_WARNING("Eta value of " << eta << " could not be matched to any eta bin!");
    return 9999999.;
}



83
84
85
86
87
88
/**
* Function to further select PFOs of the various categories (basically apply additional ET cuts): 
* 
*/
StatusCode PanTau::Tool_TauConstituentSelector::SelectTauConstituents(  std::vector<TauConstituent2*> inputList,
                                                                        std::vector<TauConstituent2*>& outputList) const {
89
90
91
92
93
94
    
    unsigned int nConst = inputList.size();
    ATH_MSG_DEBUG("Perform tau constituent selection on " << nConst << "constituents");
    for(unsigned int iConst=0; iConst<nConst; iConst++) {
        ATH_MSG_DEBUG("===>Constituent " << iConst << " / " << nConst);
        
95
        PanTau::TauConstituent2*         curConstituent  = inputList[iConst];
96
97
        
        //general preselection:
98
        double curEta = fabs( curConstituent->p4().Eta() );
99
100
101
102
103
104
105
        if(curEta > m_MaxEta) {
            ATH_MSG_DEBUG("\tNot using constituent with eta of " << curEta);
            continue;
        }
        
        bool passesSelection = false;
        ATH_MSG_DEBUG("Before selection, constituent is of type: " << curConstituent->getTypeNameString() );
106
107
108

	// check if constituent is charged:
        if(curConstituent->isOfType(PanTau::TauConstituent2::t_Charged) == true) {
109
110
            passesSelection = passesSelection_ChargedConstituent(curConstituent);
            
111
112
 	// check if constituent is neutral, assign correctly pi0neut and neut flags:
        } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_Neutral) == true) {
113
114
115
116
117
118
119
120
            passesSelection = passesSelection_NeutralConstituent(curConstituent);
            
            //special treatment for the testing neutral flags
            //  a constituent can be a NeutLowA but not a neutral (because neutral Et cut is higher)
            //  => need that the constituent is in the seed for calculating test variables, but need it to NOT be tagged as neutral
            //  => remove the neutral-tag and check if it passes NeutLowA
            //-> repeat those steps for NeutLowB
            if(passesSelection == false) {
121
122
                curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_Neutral);
                curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_Pi0Neut);
123
124
                passesSelection = passesSelection_NeutLowAConstituent(curConstituent);
                if(passesSelection == false) {
125
                    curConstituent->removeTypeFlag(PanTau::TauConstituent2::t_NeutLowA);
126
127
128
129
                    passesSelection = passesSelection_NeutLowBConstituent(curConstituent);
                }
            }
            
130
131
132

 	// apply further selection to constituent in isolation cone:
        } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_OutChrg) == true) {
133
134
            passesSelection = passesSelection_OutChrgConstituent(curConstituent);
            
135
        } else if(curConstituent->isOfType(PanTau::TauConstituent2::t_OutNeut) == true) {
136
137
138
139
140
141
142
143
            passesSelection = passesSelection_OutNeutConstituent(curConstituent);
            
        } else {
            ATH_MSG_WARNING("Unhandled constituent type (" << curConstituent->getTypeNameString() << ") when trying to apply constituent selection - constituent will not be selected!");
            passesSelection = false;
        }
        ATH_MSG_DEBUG("After selection (with result " << passesSelection << "), constituent is of type: " << curConstituent->getTypeNameString() );
        
144
        if(passesSelection == false) continue;
145
146
147
148
149
150
151
152
153
154
155
        
        outputList.push_back(inputList[iConst]);
    }
    
    ATH_MSG_DEBUG("Out of " << nConst << " contituents, " << outputList.size() << " passed the selection");
    
    return StatusCode::SUCCESS;
}



156
bool    PanTau::Tool_TauConstituentSelector::passesSelection_NeutralConstituent(PanTau::TauConstituent2* tauConstituent) const {
157
    ATH_MSG_DEBUG("neutral sel for const at: " << tauConstituent);
158
    TLorentzVector tlv_Constituent = tauConstituent->p4();
159
    
160
161
162
163
164
    double curEta       = tlv_Constituent.Eta();
    double cut_MinEt    = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Neutral);
    double curEt        = tlv_Constituent.Et();
    ATH_MSG_DEBUG("curEt (" << curEt << ") < cut_MinEt (" << cut_MinEt << ") ? ");
//    ATH_MSG_DEBUG("curEt (" << curEt << ") < cut_MinEt (" << cut_MinEt << ") ? --- with curEta=" << curEta << "PanTau::TauConstituent2::t_Neutral=" << PanTau::TauConstituent2::t_Neutral);
165
166
167
168
    if(curEt < cut_MinEt) {
        ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt);
        return false;
    }
169
170

    ATH_MSG_DEBUG("Passed!");
171
172
173
174
175
176
    
    return true;
}



177
bool    PanTau::Tool_TauConstituentSelector::passesSelection_Pi0NeutConstituent(PanTau::TauConstituent2* tauConstituent) const {
178
    ATH_MSG_DEBUG("pi0neut sel for const at: " << tauConstituent);
179
    TLorentzVector tlv_Constituent = tauConstituent->p4();
180
    
181
182
183
    double curEta       = tlv_Constituent.Eta();
    double cut_MinEt    = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Pi0Neut);
    double curEt        = tlv_Constituent.Et();
184
185
186
187
188
189
190
191
192
193
    if(curEt < cut_MinEt) {
        ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt);
        return false;
    }
    
    return true;
}



194
195
bool    PanTau::Tool_TauConstituentSelector::passesSelection_ChargedConstituent(PanTau::TauConstituent2* tauConstituent) const {
    TLorentzVector tlv_Constituent = tauConstituent->p4();
196
    
197
198
199
    double curEta       = tlv_Constituent.Eta();
    double cut_MinEt    = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_Charged);
    double curEt        = tlv_Constituent.Pt();
200
201
202
203
204
205
206
207
208
209
210
    
    if(curEt < cut_MinEt) {
        ATH_MSG_DEBUG("\tNot using constituent at eta " << curEta << " with et of " << curEt);
        return false;
    }
    
    return true;
}



211
212
bool    PanTau::Tool_TauConstituentSelector::passesSelection_OutNeutConstituent(TauConstituent2* TauConstituent) const {
    TLorentzVector tlv_Constituent = TauConstituent->p4();
213
    
214
215
216
    double curEta    = tlv_Constituent.Eta();
    double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_OutNeut);
    double curEt     = tlv_Constituent.Et();
217
218
219
220
221
222
    
    if(curEt < cut_MinEt) return false;
    return true;
}


223
224
bool    PanTau::Tool_TauConstituentSelector::passesSelection_OutChrgConstituent(TauConstituent2* TauConstituent) const {
    TLorentzVector tlv_Constituent = TauConstituent->p4();
225
    
226
227
228
    double curEta    = tlv_Constituent.Eta();
    double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_OutChrg);
    double curEt     = tlv_Constituent.Pt();
229
230
231
232
233
234
235
    
    if(curEt < cut_MinEt) return false;
    return true;
}



236
237
bool    PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowAConstituent(TauConstituent2* TauConstituent) const {
    TLorentzVector tlv_Constituent = TauConstituent->p4();
238
    
239
240
241
    double curEta    = tlv_Constituent.Eta();
    double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_NeutLowA);
    double curEt     = tlv_Constituent.Pt();
242
243
244
245
246
247
248
    
    if(curEt < cut_MinEt) return false;
    return true;
}



249
250
bool    PanTau::Tool_TauConstituentSelector::passesSelection_NeutLowBConstituent(TauConstituent2* TauConstituent) const {
    TLorentzVector tlv_Constituent = TauConstituent->p4();
251
    
252
253
254
    double curEta    = tlv_Constituent.Eta();
    double cut_MinEt = getEtCut(fabs(curEta), PanTau::TauConstituent2::t_NeutLowB);
    double curEt     = tlv_Constituent.Pt();
255
256
257
258
259
260
261
    
    if(curEt < cut_MinEt) return false;
    return true;
}