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.13 by loizides, Mon Jun 15 15:00:21 2009 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 "MitAna/DataTree/interface/JetCol.h"
5 > #include "MitAna/DataTree/interface/PhotonCol.h"
6 > #include "MitAna/DataTree/interface/MuonCol.h"
7 > #include "MitAna/DataTree/interface/ElectronCol.h"
8 > #include "MitAna/DataTree/interface/TauCol.h"
9   #include "MitCommon/MathTools/interface/MathUtils.h"
10 + #include "MitPhysics/Init/interface/ModNames.h"
11  
12   using namespace mithep;
13  
14   ClassImp(mithep::JetCleaningMod)
15  
16   //--------------------------------------------------------------------------------------------------
17 <  JetCleaningMod::JetCleaningMod(const char *name, const char *title) :
17 > JetCleaningMod::JetCleaningMod(const char *name, const char *title) :
18    BaseMod(name,title),
19 <  fPrintDebug(false),
20 <  fCleanElectronsName(Names::gkCleanElectronsName),        
21 <  fGoodJetsName(Names::gkGoodJetsName),        
22 <  fCleanJetsName(Names::gkCleanJetsName),        
23 <  fElectrons(0),
24 <  fJets(0),
25 <  fNEventsProcessed(0)
19 >  fCleanElectronsName(ModNames::gkCleanElectronsName),        
20 >  fCleanMuonsName(ModNames::gkCleanMuonsName),        
21 >  fCleanPhotonsName(ModNames::gkCleanPhotonsName),        
22 >  fCleanTausName(ModNames::gkCleanTausName),        
23 >  fGoodJetsName(ModNames::gkGoodJetsName),        
24 >  fCleanJetsName(ModNames::gkCleanJetsName),
25 >  fMinDeltaRToElectron(0.3),
26 >  fMinDeltaRToMuon(0.3),
27 >  fMinDeltaRToPhoton(0.3),
28 >  fMinDeltaRToTau(0.3),
29 >  fApplyTauRemoval(kFALSE)
30   {
31    // Constructor.
32   }
33  
34   //--------------------------------------------------------------------------------------------------
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 //--------------------------------------------------------------------------------------------------
35   void JetCleaningMod::Process()
36   {
37 <  // Process entries of the tree. For this module, we just load the branches and
38 <  //output debug info or not  
37 >  // Process entries of the tree.
38  
39 <  fNEventsProcessed++;
40 <
41 <  if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
42 <    time_t systime;
43 <    systime = time(NULL);
44 <
45 <    cerr << endl << "JetCleaningMod : Process Event " << fNEventsProcessed << "  Time: " << ctime(&systime) << endl;  
46 <  }  
47 <
48 <  //Get Clean Electrons
49 <  ObjArray<Electron> *CleanElectrons = dynamic_cast<ObjArray<Electron>* >
50 <    (FindObjThisEvt(fCleanElectronsName.Data()));
51 <  //Get Good Jets
52 <  ObjArray<Jet> *GoodJets = dynamic_cast<ObjArray<Jet>* >
53 <    (FindObjThisEvt(fGoodJetsName.Data()));  
54 <  ObjArray<Jet> *CleanJets = new ObjArray<Jet>;
39 >  // get input collections
40 >  const JetCol  *GoodJets       = GetObjThisEvt<JetCol>(fGoodJetsName);
41 >  const ElectronCol *CleanElectrons = 0;
42 >  if (!fCleanElectronsName.IsNull())
43 >    CleanElectrons = GetObjThisEvt<ElectronCol>(fCleanElectronsName);
44 >  const MuonCol *CleanMuons = 0;
45 >  if (!fCleanMuonsName.IsNull())
46 >    CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
47 >  const PhotonCol   *CleanPhotons   = 0;
48 >  if (!fCleanPhotonsName.IsNull())
49 >    CleanPhotons    = GetObjThisEvt<PhotonCol>(fCleanPhotonsName);
50 >  const TauCol   *CleanTaus   = 0;
51 >  if (fApplyTauRemoval && !fCleanTausName.IsNull())
52 >    CleanTaus    = GetObjThisEvt<TauCol>(fCleanTausName);
53 >
54 >  // create output collection
55 >  JetOArr *CleanJets = new JetOArr;
56 >  CleanJets->SetName(fCleanJetsName);
57  
58 <  //remove any jet that overlaps in eta phi with an isolated electron
58 >  // remove any jet that overlaps in eta, phi with an isolated electron.    
59    for (UInt_t i=0; i<GoodJets->GetEntries(); ++i) {
60 <    Jet *jet = GoodJets->At(i);        
61 <    bool isElectronOverlap =  false;
62 <    
63 <    //Check for overlap with an electron
64 <    for (UInt_t j=0; j<CleanElectrons->GetEntries(); j++) {
65 <      double deltaR = MathUtils::DeltaR(CleanElectrons->At(j)->Mom(),jet->Mom());  
66 <      if (deltaR < 0.3) {
67 <        isElectronOverlap = true;                      
68 <        break;          
69 <      }      
60 >    const Jet *jet = GoodJets->At(i);        
61 >
62 >    // check for overlap with an Electron
63 >    Bool_t isElectronOverlap = kFALSE;
64 >    if (CleanElectrons) {
65 >      UInt_t n = CleanElectrons->GetEntries();
66 >      for (UInt_t j=0; j<n; ++j) {
67 >        Double_t deltaR = MathUtils::DeltaR(CleanElectrons->At(j)->Mom(),jet->Mom());  
68 >        if (deltaR < fMinDeltaRToElectron) {
69 >          isElectronOverlap = kTRUE;
70 >          break;                
71 >        }      
72 >      }
73      }
74 <    //Save Clean Jets
75 <    if (!isElectronOverlap) {
76 <      CleanJets->Add(jet);    
74 >
75 >    if (isElectronOverlap) continue;
76 >
77 >    // check for overlap with an Muon
78 >    Bool_t isMuonOverlap = kFALSE;
79 >    if (CleanMuons) {
80 >      UInt_t n = CleanMuons->GetEntries();
81 >      for (UInt_t j=0; j<n; ++j) {
82 >        Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(),jet->Mom());  
83 >        if (deltaR < fMinDeltaRToMuon) {
84 >          isMuonOverlap = kTRUE;
85 >          break;                
86 >        }      
87 >      }
88      }
74  }
89  
90 <  //Final Summary Debug Output  
91 <  if ( fPrintDebug ) {
92 <    cerr << "Event Dump: " << fNEventsProcessed << endl;
93 <    cerr << "GoodJets : " <<
94 <    cerr << "Clean  Jets" << endl;
95 <    for (UInt_t i = 0; i < CleanJets->GetEntries(); i++) {
96 <      cerr << i << " " << CleanJets->At(i)->Pt() << " "
97 <           << CleanJets->At(i)->Eta() << " " << CleanJets->At(i)->Phi() << endl;    
90 >    if (isMuonOverlap) continue;
91 >
92 >    // check for overlap with a photon
93 >    Bool_t isPhotonOverlap = kFALSE;
94 >    if (CleanPhotons) {
95 >      UInt_t n = CleanPhotons->GetEntries();
96 >      for (UInt_t j=0; j<n; ++j) {
97 >        Double_t deltaR = MathUtils::DeltaR(CleanPhotons->At(j)->Mom(),jet->Mom());  
98 >        if (deltaR < fMinDeltaRToPhoton) {
99 >          isPhotonOverlap = kTRUE;
100 >          break;                
101 >        }      
102 >      }
103      }
85  }  
86  
87  //Save Objects for Other Modules to use
88  AddObjThisEvt(CleanJets, fCleanJetsName.Data());
89 }
104  
105 +    if (isPhotonOverlap) continue;
106  
107 < //--------------------------------------------------------------------------------------------------
108 < void JetCleaningMod::SlaveBegin()
109 < {
110 <  // Run startup code on the computer (slave) doing the actual analysis. Here,
111 <  // we typically initialize histograms and other analysis objects and request
112 <  // branches. For this module, we request a branch of the MitTree.
107 >    // check for overlap with a tau
108 >    Bool_t isTauOverlap = kFALSE;
109 >    if (fApplyTauRemoval && CleanTaus) {
110 >      UInt_t n = CleanTaus->GetEntries();
111 >      for (UInt_t j=0; j<n; ++j) {
112 >        Double_t deltaR = MathUtils::DeltaR(CleanTaus->At(j)->Mom(),jet->Mom());  
113 >        if (deltaR < fMinDeltaRToTau) {
114 >          isTauOverlap = kTRUE;
115 >          break;                
116 >        }      
117 >      }
118 >    }
119  
120 < }
120 >    if (isTauOverlap) continue;
121  
122 < //--------------------------------------------------------------------------------------------------
123 < 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.
122 >    CleanJets->Add(jet);
123 >  }
124  
125 < }
125 >  // sort according to pt
126 >  CleanJets->Sort();
127  
128 < //--------------------------------------------------------------------------------------------------
129 < void JetCleaningMod::Terminate()
111 < {
112 <  // Run finishing code on the client computer. For this module, we dont do
113 <  // anything here.
128 >  // add to event for other modules to use
129 >  AddObjThisEvt(CleanJets);
130   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines