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.3 by loizides, Thu Nov 27 16:30:27 2008 UTC vs.
Revision 1.14 by sixie, Mon Nov 2 12:15:00 2009 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitPhysics/Mods/interface/JetCleaningMod.h"
4 < #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  
# Line 10 | Line 14 | using namespace mithep;
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),
15  fPrintDebug(false),
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 <  fElectrons(0),
26 <  fJets(0),
27 <  fNEventsProcessed(0)
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   //--------------------------------------------------------------------------------------------------
27 void JetCleaningMod::Begin()
28 {
29  // Run startup code on the client machine. For this module, we dont do
30  // anything here.
31 }
32
33 //--------------------------------------------------------------------------------------------------
35   void JetCleaningMod::Process()
36   {
37 <  // Process entries of the tree. For this module, we just load the branches and
37 <  //output debug info or not  
37 >  // Process entries of the tree.
38  
39 <  fNEventsProcessed++;
40 <
41 <  if (fNEventsProcessed % 1000000 == 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)->SCluster()->Eta(),
68 >                                            CleanElectrons->At(j)->SCluster()->Phi(),
69 >                                            jet->Eta(), jet->Phi());  
70 >        if (deltaR < fMinDeltaRToElectron) {
71 >          isElectronOverlap = kTRUE;
72 >          break;                
73 >        }      
74 >      }
75      }
76 <    //Save Clean Jets
77 <    if (!isElectronOverlap) {
78 <      CleanJets->Add(jet);    
76 >
77 >    if (isElectronOverlap) continue;
78 >
79 >    // check for overlap with an Muon
80 >    Bool_t isMuonOverlap = kFALSE;
81 >    if (CleanMuons) {
82 >      UInt_t n = CleanMuons->GetEntries();
83 >      for (UInt_t j=0; j<n; ++j) {
84 >        Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(),jet->Mom());  
85 >        if (deltaR < fMinDeltaRToMuon) {
86 >          isMuonOverlap = kTRUE;
87 >          break;                
88 >        }      
89 >      }
90      }
73  }
91  
92 <  //Final Summary Debug Output  
93 <  if ( fPrintDebug ) {
94 <    cerr << "Event Dump: " << fNEventsProcessed << endl;
95 <    cerr << "GoodJets : " <<
96 <    cerr << "Clean  Jets" << endl;
97 <    for (UInt_t i = 0; i < CleanJets->GetEntries(); i++) {
98 <      cerr << i << " " << CleanJets->At(i)->Pt() << " "
99 <           << CleanJets->At(i)->Eta() << " " << CleanJets->At(i)->Phi() << endl;    
92 >    if (isMuonOverlap) continue;
93 >
94 >    // check for overlap with a photon
95 >    Bool_t isPhotonOverlap = kFALSE;
96 >    if (CleanPhotons) {
97 >      UInt_t n = CleanPhotons->GetEntries();
98 >      for (UInt_t j=0; j<n; ++j) {
99 >        Double_t deltaR = MathUtils::DeltaR(CleanPhotons->At(j)->Mom(),jet->Mom());  
100 >        if (deltaR < fMinDeltaRToPhoton) {
101 >          isPhotonOverlap = kTRUE;
102 >          break;                
103 >        }      
104 >      }
105      }
84  }  
85  
86  //Save Objects for Other Modules to use
87  AddObjThisEvt(CleanJets, fCleanJetsName.Data());
88 }
106  
107 +    if (isPhotonOverlap) continue;
108  
109 < //--------------------------------------------------------------------------------------------------
110 < void JetCleaningMod::SlaveBegin()
111 < {
112 <  // Run startup code on the computer (slave) doing the actual analysis. Here,
113 <  // we typically initialize histograms and other analysis objects and request
114 <  // branches. For this module, we request a branch of the MitTree.
109 >    // check for overlap with a tau
110 >    Bool_t isTauOverlap = kFALSE;
111 >    if (fApplyTauRemoval && CleanTaus) {
112 >      UInt_t n = CleanTaus->GetEntries();
113 >      for (UInt_t j=0; j<n; ++j) {
114 >        Double_t deltaR = MathUtils::DeltaR(CleanTaus->At(j)->Mom(),jet->Mom());  
115 >        if (deltaR < fMinDeltaRToTau) {
116 >          isTauOverlap = kTRUE;
117 >          break;                
118 >        }      
119 >      }
120 >    }
121  
122 < }
122 >    if (isTauOverlap) continue;
123  
124 < //--------------------------------------------------------------------------------------------------
125 < void JetCleaningMod::SlaveTerminate()
102 < {
103 <  // Run finishing code on the computer (slave) that did the analysis. For this
104 <  // module, we dont do anything here.
124 >    CleanJets->Add(jet);
125 >  }
126  
127 < }
127 >  // sort according to pt
128 >  CleanJets->Sort();
129  
130 < //--------------------------------------------------------------------------------------------------
131 < void JetCleaningMod::Terminate()
110 < {
111 <  // Run finishing code on the client computer. For this module, we dont do
112 <  // anything here.
130 >  // add to event for other modules to use
131 >  AddObjThisEvt(CleanJets);
132   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines