ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/JetIDMod.cc
Revision: 1.1
Committed: Tue Sep 30 16:36:52 2008 UTC (16 years, 7 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_004
Log Message:
Add Jet ID module

File Contents

# User Rev Content
1 sixie 1.1 // $Id: $
2    
3     #include "MitAna/TreeMod/interface/JetIDMod.h"
4     #include "MitAna/DataTree/interface/Names.h"
5     #include "MitAna/DataCont/interface/ObjArray.h"
6     #include "MitCommon/MathTools/interface/MathUtils.h"
7    
8    
9     using namespace mithep;
10    
11     ClassImp(mithep::JetIDMod)
12    
13     //--------------------------------------------------------------------------------------------------
14     JetIDMod::JetIDMod(const char *name, const char *title) :
15     BaseMod(name,title),
16     fPrintDebug(false),
17     fJetName(Names::gkCaloJetBrn),
18     fGoodJetsName(Names::gkGoodJetsName),
19     fJetIDType("HWWJets"),
20     fJets(0)
21     {
22     // Constructor.
23     }
24    
25     //--------------------------------------------------------------------------------------------------
26     void JetIDMod::Begin()
27     {
28     // Run startup code on the client machine. For this module, we dont do
29     // anything here.
30     }
31    
32     //--------------------------------------------------------------------------------------------------
33     void JetIDMod::Process()
34     {
35     // Process entries of the tree.
36    
37     fNEventsProcessed++;
38    
39     if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
40     time_t systime;
41     systime = time(NULL);
42    
43     cerr << endl << "JetIDMod : Process Event " << fNEventsProcessed << " Time: " << ctime(&systime) << endl;
44     }
45    
46     //Get Jets
47     LoadBranch(fJetName);
48     ObjArray<Jet> *GoodJets = new ObjArray<Jet>;
49    
50     for (UInt_t i=0; i<fJets->GetEntries(); ++i) {
51     Jet *jet = fJets->At(i);
52    
53     const int nCuts = 3;
54     double cutValue[nCuts] = {15., 5.0, 0.2};
55     bool passCut[nCuts] = {false, false, false};
56    
57     if(jet->Et() > cutValue[0]) passCut[0] = true;
58     if(fabs(jet->Eta()) < cutValue[1]) passCut[1] = true;
59     if(jet->Alpha() > cutValue[2] ||
60     jet->Et() > 20.)
61     passCut[2] = true;
62    
63     // Final decision
64     bool passAllCuts = true;
65     for(int i=0; i<nCuts; i++) {
66     passAllCuts = passAllCuts && passCut[i];
67     }
68    
69     //Save Good Jets
70     if (passAllCuts)
71     GoodJets->Add(jet);
72     }
73    
74     //Final Summary Debug Output
75     if ( fPrintDebug ) {
76     cerr << "Event Dump: " << fNEventsProcessed << endl;
77     cerr << "Central Jets" << endl;
78     for (UInt_t i = 0; i < GoodJets->GetEntries(); i++) {
79     cerr << i << " " << GoodJets->At(i)->Pt() << " "
80     << GoodJets->At(i)->Eta() << " " << GoodJets->At(i)->Phi() << endl;
81     }
82     }
83    
84     //Save Objects for Other Modules to use
85     AddObjThisEvt(GoodJets, fGoodJetsName.Data());
86     }
87    
88     //--------------------------------------------------------------------------------------------------
89     void JetIDMod::SlaveBegin()
90     {
91     // Run startup code on the computer (slave) doing the actual analysis. Here,
92     // we typically initialize histograms and other analysis objects and request
93     // branches. For this module, we request a branch of the MitTree.
94    
95     ReqBranch(fJetName, fJets);
96     }
97    
98     //--------------------------------------------------------------------------------------------------
99     void JetIDMod::SlaveTerminate()
100     {
101     // Run finishing code on the computer (slave) that did the analysis. For this
102     // module, we dont do anything here.
103    
104     }
105    
106     //--------------------------------------------------------------------------------------------------
107     void JetIDMod::Terminate()
108     {
109     // Run finishing code on the client computer. For this module, we dont do
110     // anything here.
111     }