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.8 by loizides, Wed Dec 10 21:18:50 2008 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitPhysics/Mods/interface/JetCleaningMod.h"
4 #include "MitPhysics/Utils/interface/IsolationTools.h"
4   #include "MitCommon/MathTools/interface/MathUtils.h"
5   #include "MitPhysics/Init/interface/ModNames.h"
6  
# Line 10 | Line 9 | using namespace mithep;
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),
15  fPrintDebug(false),
14    fCleanElectronsName(ModNames::gkCleanElectronsName),        
15 +  fCleanPhotonsName(ModNames::gkCleanPhotonsName),        
16    fGoodJetsName(ModNames::gkGoodJetsName),        
17 <  fCleanJetsName(ModNames::gkCleanJetsName),        
18 <  fElectrons(0),
19 <  fJets(0),
21 <  fNEventsProcessed(0)
17 >  fCleanJetsName(ModNames::gkCleanJetsName),
18 >  fMinDeltaRToElectron(0.3),
19 >  fMinDeltaRToPhoton(0.3)
20   {
21    // Constructor.
22   }
23  
24   //--------------------------------------------------------------------------------------------------
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 //--------------------------------------------------------------------------------------------------
25   void JetCleaningMod::Process()
26   {
27 <  // Process entries of the tree. For this module, we just load the branches and
37 <  //output debug info or not  
27 >  // Process entries of the tree.
28  
29 <  fNEventsProcessed++;
30 <
31 <  if (fNEventsProcessed % 1000000 == 0 || fPrintDebug) {
32 <    time_t systime;
33 <    systime = time(NULL);
34 <
35 <    cerr << endl << "JetCleaningMod : Process Event " << fNEventsProcessed << "  Time: " << ctime(&systime) << endl;  
36 <  }  
37 <
38 <  //Get Clean Electrons
39 <  ObjArray<Electron> *CleanElectrons = dynamic_cast<ObjArray<Electron>* >
40 <    (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>;
29 >  // get input collections
30 >  const JetCol      *GoodJets       = GetObjThisEvt<JetCol>(fGoodJetsName);
31 >  const ElectronCol *CleanElectrons = 0;
32 >  if (!fCleanElectronsName.IsNull())
33 >    CleanElectrons = GetObjThisEvt<ElectronCol>(fCleanElectronsName);
34 >  const PhotonCol   *CleanPhotons   = 0;
35 >  if (!fCleanPhotonsName.IsNull())
36 >  CleanPhotons    = GetObjThisEvt<PhotonCol>(fCleanPhotonsName);
37 >
38 >  // create output collection
39 >  JetOArr *CleanJets = new JetOArr;
40 >  CleanJets->SetName(fCleanJetsName);
41  
42 <  //remove any jet that overlaps in eta phi with an isolated electron
42 >  // remove any jet that overlaps in eta, phi with an isolated electron.    
43    for (UInt_t i=0; i<GoodJets->GetEntries(); ++i) {
44 <    Jet *jet = GoodJets->At(i);        
59 <    bool isElectronOverlap =  false;
60 <    
61 <    //Check for overlap with an electron
62 <    for (UInt_t j=0; j<CleanElectrons->GetEntries(); j++) {
63 <      double deltaR = MathUtils::DeltaR(CleanElectrons->At(j)->Mom(),jet->Mom());  
64 <      if (deltaR < 0.3) {
65 <        isElectronOverlap = true;                      
66 <        break;          
67 <      }      
68 <    }
69 <    //Save Clean Jets
70 <    if (!isElectronOverlap) {
71 <      CleanJets->Add(jet);    
72 <    }
73 <  }
44 >    const Jet *jet = GoodJets->At(i);        
45  
46 <  //Final Summary Debug Output  
47 <  if ( fPrintDebug ) {
48 <    cerr << "Event Dump: " << fNEventsProcessed << endl;
49 <    cerr << "GoodJets : " <<
50 <    cerr << "Clean  Jets" << endl;
51 <    for (UInt_t i = 0; i < CleanJets->GetEntries(); i++) {
52 <      cerr << i << " " << CleanJets->At(i)->Pt() << " "
53 <           << CleanJets->At(i)->Eta() << " " << CleanJets->At(i)->Phi() << endl;    
46 >    // check for overlap with an electron
47 >    Bool_t isElectronOverlap = kFALSE;
48 >    if (CleanElectrons) {
49 >      UInt_t n = CleanElectrons->GetEntries();
50 >      for (UInt_t j=0; j<n; ++j) {
51 >        Double_t deltaR = MathUtils::DeltaR(CleanElectrons->At(j)->Mom(),jet->Mom());  
52 >        if (deltaR < fMinDeltaRToElectron) {
53 >          isElectronOverlap = kTRUE;
54 >          break;                
55 >        }      
56 >      }
57      }
84  }  
85  
86  //Save Objects for Other Modules to use
87  AddObjThisEvt(CleanJets, fCleanJetsName.Data());
88 }
58  
59 +    if (isElectronOverlap) continue;
60  
61 < //--------------------------------------------------------------------------------------------------
62 < void JetCleaningMod::SlaveBegin()
63 < {
64 <  // Run startup code on the computer (slave) doing the actual analysis. Here,
65 <  // we typically initialize histograms and other analysis objects and request
66 <  // branches. For this module, we request a branch of the MitTree.
61 >    // check for overlap with a photon
62 >    Bool_t isPhotonOverlap = kFALSE;
63 >    if (CleanPhotons) {
64 >      UInt_t n = CleanPhotons->GetEntries();
65 >      for (UInt_t j=0; j<n; ++j) {
66 >        Double_t deltaR = MathUtils::DeltaR(CleanPhotons->At(j)->Mom(),jet->Mom());  
67 >        if (deltaR < fMinDeltaRToPhoton) {
68 >          isPhotonOverlap = kTRUE;
69 >          break;                
70 >        }      
71 >      }
72 >    }
73  
74 < }
74 >    if (isPhotonOverlap) continue;
75  
76 < //--------------------------------------------------------------------------------------------------
77 < 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.
76 >    CleanJets->Add(jet);    
77 >  }
78  
79 < }
79 >  // sort according to pt
80 >  CleanJets->Sort();
81  
82 < //--------------------------------------------------------------------------------------------------
83 < void JetCleaningMod::Terminate()
110 < {
111 <  // Run finishing code on the client computer. For this module, we dont do
112 <  // anything here.
82 >  // add to event for other modules to use
83 >  AddObjThisEvt(CleanJets);
84   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines