ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/JetCleaningMod.cc
(Generate patch)

Comparing UserCode/MitPhysics/Mods/src/JetCleaningMod.cc (file contents):
Revision 1.1 by loizides, Wed Oct 15 06:05:00 2008 UTC vs.
Revision 1.4 by loizides, Fri Nov 28 09:13:50 2008 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitPhysics/Mods/interface/JetCleaningMod.h"
4 #include "MitAna/DataTree/interface/Names.h"
5 #include "MitAna/DataCont/interface/ObjArray.h"
6 #include "MitPhysics/Utils/interface/IsolationTools.h"
4   #include "MitCommon/MathTools/interface/MathUtils.h"
5 + #include "MitPhysics/Init/interface/ModNames.h"
6  
7   using namespace mithep;
8  
9   ClassImp(mithep::JetCleaningMod)
10  
11   //--------------------------------------------------------------------------------------------------
12 <  JetCleaningMod::JetCleaningMod(const char *name, const char *title) :
12 > JetCleaningMod::JetCleaningMod(const char *name, const char *title) :
13    BaseMod(name,title),
14 <  fPrintDebug(false),
15 <  fCleanElectronsName(Names::gkCleanElectronsName),        
16 <  fGoodJetsName(Names::gkGoodJetsName),        
19 <  fCleanJetsName(Names::gkCleanJetsName),        
20 <  fElectrons(0),
21 <  fJets(0),
22 <  fNEventsProcessed(0)
14 >  fCleanElectronsName(ModNames::gkCleanElectronsName),        
15 >  fGoodJetsName(ModNames::gkGoodJetsName),        
16 >  fCleanJetsName(ModNames::gkCleanJetsName)
17   {
18    // Constructor.
19   }
20  
21   //--------------------------------------------------------------------------------------------------
28 void JetCleaningMod::Begin()
29 {
30  // Run startup code on the client machine. For this module, we dont do
31  // anything here.
32 }
33
34 //--------------------------------------------------------------------------------------------------
22   void JetCleaningMod::Process()
23   {
24 <  // Process entries of the tree. For this module, we just load the branches and
25 <  //output debug info or not  
24 >  // Process entries of the tree.
25 >
26 >  // get input collections
27 >  ElectronOArr *CleanElectrons = GetObjThisEvt<ElectronOArr>(fCleanElectronsName);
28 >  JetOArr *GoodJets = GetObjThisEvt<JetOArr>(fGoodJetsName);
29  
30 <  fNEventsProcessed++;
31 <
32 <  if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
43 <    time_t systime;
44 <    systime = time(NULL);
45 <
46 <    cerr << endl << "JetCleaningMod : Process Event " << fNEventsProcessed << "  Time: " << ctime(&systime) << endl;  
47 <  }  
48 <
49 <  //Get Clean Electrons
50 <  ObjArray<Electron> *CleanElectrons = dynamic_cast<ObjArray<Electron>* >
51 <    (FindObjThisEvt(fCleanElectronsName.Data()));
52 <  //Get Good Jets
53 <  ObjArray<Jet> *GoodJets = dynamic_cast<ObjArray<Jet>* >
54 <    (FindObjThisEvt(fGoodJetsName.Data()));  
55 <  ObjArray<Jet> *CleanJets = new ObjArray<Jet>;
30 >  // create output collection
31 >  JetOArr *CleanJets = new JetOArr;
32 >  CleanJets->SetName(fCleanJetsName);
33  
34 <  //remove any jet that overlaps in eta phi with an isolated electron
34 >  // Remove any jet that overlaps in eta, phi with an isolated electron.
35    for (UInt_t i=0; i<GoodJets->GetEntries(); ++i) {
36 <    Jet *jet = GoodJets->At(i);        
37 <    bool isElectronOverlap =  false;
36 >    const Jet *jet = GoodJets->At(i);        
37 >
38 >    Bool_t isElectronOverlap =  false;
39      
40      //Check for overlap with an electron
41 <    for (UInt_t j=0; j<CleanElectrons->GetEntries(); j++) {
42 <      double deltaR = MathUtils::DeltaR(CleanElectrons->At(j)->Mom(),jet->Mom());  
41 >    for (UInt_t j=0; j<CleanElectrons->Entries(); j++) {
42 >      Double_t deltaR = MathUtils::DeltaR(CleanElectrons->At(j)->Mom(),jet->Mom());  
43        if (deltaR < 0.3) {
44 <        isElectronOverlap = true;                      
44 >        isElectronOverlap = kTRUE;
45          break;          
46        }      
47      }
70    //Save Clean Jets
71    if (!isElectronOverlap) {
72      CleanJets->Add(jet);    
73    }
74  }
75
76  //Final Summary Debug Output  
77  if ( fPrintDebug ) {
78    cerr << "Event Dump: " << fNEventsProcessed << endl;
79    cerr << "GoodJets : " <<
80    cerr << "Clean  Jets" << endl;
81    for (UInt_t i = 0; i < CleanJets->GetEntries(); i++) {
82      cerr << i << " " << CleanJets->At(i)->Pt() << " "
83           << CleanJets->At(i)->Eta() << " " << CleanJets->At(i)->Phi() << endl;    
84    }
85  }  
86  
87  //Save Objects for Other Modules to use
88  AddObjThisEvt(CleanJets, fCleanJetsName.Data());
89 }
48  
49 +    if (isElectronOverlap)
50 +      continue;
51  
52 < //--------------------------------------------------------------------------------------------------
53 < void JetCleaningMod::SlaveBegin()
94 < {
95 <  // Run startup code on the computer (slave) doing the actual analysis. Here,
96 <  // we typically initialize histograms and other analysis objects and request
97 <  // branches. For this module, we request a branch of the MitTree.
98 <
99 < }
100 <
101 < //--------------------------------------------------------------------------------------------------
102 < void JetCleaningMod::SlaveTerminate()
103 < {
104 <  // Run finishing code on the computer (slave) that did the analysis. For this
105 <  // module, we dont do anything here.
106 <
107 < }
52 >    CleanJets->Add(jet);    
53 >  }
54  
55 < //--------------------------------------------------------------------------------------------------
56 < void JetCleaningMod::Terminate()
111 < {
112 <  // Run finishing code on the client computer. For this module, we dont do
113 <  // anything here.
55 >  // add to event for other modules to use
56 >  AddObjThisEvt(CleanJets);
57   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines