ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/ElectronIDMod.cc
Revision: 1.3
Committed: Tue Nov 11 21:22:54 2008 UTC (16 years, 5 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.2: +2 -2 lines
Log Message:
adding some plots, fixing details

File Contents

# User Rev Content
1 ceballos 1.3 // $Id: ElectronIDMod.cc,v 1.2 2008/11/05 14:06:09 ceballos Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/ElectronIDMod.h"
4     #include "MitAna/DataTree/interface/Names.h"
5     #include "MitAna/DataCont/interface/ObjArray.h"
6     #include "MitPhysics/Utils/interface/IsolationTools.h"
7     #include "MitCommon/MathTools/interface/MathUtils.h"
8    
9     using namespace mithep;
10    
11     ClassImp(mithep::ElectronIDMod)
12    
13     //--------------------------------------------------------------------------------------------------
14     ElectronIDMod::ElectronIDMod(const char *name, const char *title) :
15     BaseMod(name,title),
16     fPrintDebug(false),
17     fElectronName(Names::gkElectronBrn),
18     fGoodElectronsName(Names::gkGoodElectronsName),
19     fElectronIDType("Tight"),
20     fElectronIsoType("TrackCalo"),
21     fElectrons(0),
22     fElectronPtMin(10),
23     fIDLikelihoodCut(0.9),
24     fTrackIsolationCut(5.0),
25     fCaloIsolationCut(5.0),
26     fEcalJurassicIsolationCut(5.0),
27     fHcalJurassicIsolationCut(5.0),
28     fNEventsProcessed(0)
29     {
30     // Constructor.
31     }
32    
33     //--------------------------------------------------------------------------------------------------
34     void ElectronIDMod::Begin()
35     {
36     // Run startup code on the client machine. For this module, we dont do
37     // anything here.
38     }
39    
40     //--------------------------------------------------------------------------------------------------
41     void ElectronIDMod::Process()
42     {
43     // Process entries of the tree.
44    
45     fNEventsProcessed++;
46    
47 ceballos 1.3 if (fNEventsProcessed % 1000000 == 0 || fPrintDebug) {
48 loizides 1.1 time_t systime;
49     systime = time(NULL);
50    
51     cerr << endl << "ElectronIDMod : Process Event " << fNEventsProcessed << " Time: " << ctime(&systime) << endl;
52     }
53    
54     //Get Electrons
55     LoadBranch(fElectronName);
56    
57     ObjArray<Electron> *GoodElectrons = new ObjArray<Electron>;
58     for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
59     Electron *e = fElectrons->At(i);
60    
61     bool allCuts = false;
62    
63     //Decide which ID scheme to use
64     if(fElectronIDType.CompareTo("Tight") == 0)
65     allCuts = e->PassTightID();
66     else if (fElectronIDType.CompareTo("Loose") == 0)
67     allCuts = e->PassLooseID();
68     else if (fElectronIDType.CompareTo("IDLikelihood") == 0)
69     allCuts = (e->IDLikelihood() > fIDLikelihoodCut);
70     else if (fElectronIDType.CompareTo("CustomMitCuts") == 0)
71     allCuts = false; //we don't have these yet. will have to wait for Phil and Pieter
72     else {
73     cerr << "The specified electron ID type : " << fElectronIDType.Data()
74     << " is invalid. Please specify a correct ID type. " << endl;
75     allCuts = false;
76     }
77    
78     //isolation Cuts
79     bool passTrackIsolation = (e->TrackIsolation() < fTrackIsolationCut);
80     bool passCaloIsolation = (e->CaloIsolation() < fCaloIsolationCut);
81     bool passEcalJurassicIsolation = (e->EcalJurassicIsolation() < fEcalJurassicIsolationCut);
82     bool passHcalJurassicIsolation = (e->HcalJurassicIsolation() < fHcalJurassicIsolationCut);
83     //Decide which Isolation cut to use
84     if (fElectronIsoType.CompareTo("TrackCalo") == 0 )
85     allCuts = (allCuts && passTrackIsolation && passCaloIsolation);
86     else if (fElectronIsoType.CompareTo( "TrackJurassic" ) == 0) {
87     allCuts = (allCuts && passTrackIsolation &&
88     passEcalJurassicIsolation && passHcalJurassicIsolation);
89     }else if (fElectronIsoType.CompareTo("NoIso") == 0 ) {
90     //Do Nothing here
91     } else {
92     cerr << "The specified electron Isolation type : " << fElectronIDType.Data()
93     << "is invalid. Please specify a correct isolation type. " << endl;
94     allCuts = false;
95     }
96    
97     //Pt Cut
98 ceballos 1.2 if(e->Pt() <= fElectronPtMin) allCuts = false;
99 loizides 1.1
100     //These are Good Electrons
101     if ( allCuts ) {
102     GoodElectrons->Add(fElectrons->At(i));
103     }
104     }
105    
106     //Final Summary Debug Output
107     if ( fPrintDebug ) {
108     cerr << "Event Dump: " << fNEventsProcessed << endl;
109    
110     //print out event content to text
111     cerr << "Electrons" << endl;
112     for (UInt_t i = 0; i < GoodElectrons->GetEntries(); i++) {
113     cerr << i << " " << GoodElectrons->At(i)->Pt() << " " << GoodElectrons->At(i)->Eta()
114     << " " << GoodElectrons->At(i)->Phi() << " "
115     << GoodElectrons->At(i)->ESuperClusterOverP() << endl;
116     }
117     }
118    
119     //Save Objects for Other Modules to use
120     AddObjThisEvt(GoodElectrons, fGoodElectronsName.Data());
121     }
122    
123    
124     //--------------------------------------------------------------------------------------------------
125     void ElectronIDMod::SlaveBegin()
126     {
127     // Run startup code on the computer (slave) doing the actual analysis. Here,
128     // we typically initialize histograms and other analysis objects and request
129     // branches. For this module, we request a branch of the MitTree.
130    
131     ReqBranch(fElectronName, fElectrons);
132     }
133    
134     //--------------------------------------------------------------------------------------------------
135     void ElectronIDMod::SlaveTerminate()
136     {
137     // Run finishing code on the computer (slave) that did the analysis. For this
138     // module, we dont do anything here.
139    
140     }
141    
142     //--------------------------------------------------------------------------------------------------
143     void ElectronIDMod::Terminate()
144     {
145     // Run finishing code on the client computer. For this module, we dont do
146     // anything here.
147     }