1 |
// $Id: ElectronCleaningMod.cc,v 1.8 2009/02/18 15:52:33 loizides Exp $
|
2 |
|
3 |
#include "MitPhysics/Mods/interface/ElectronCleaningMod.h"
|
4 |
#include "MitCommon/MathTools/interface/MathUtils.h"
|
5 |
#include "MitAna/DataTree/interface/ElectronCol.h"
|
6 |
#include "MitAna/DataTree/interface/MuonCol.h"
|
7 |
#include "MitAna/DataTree/interface/Track.h"
|
8 |
#include "MitPhysics/Init/interface/ModNames.h"
|
9 |
|
10 |
using namespace mithep;
|
11 |
|
12 |
ClassImp(mithep::ElectronCleaningMod)
|
13 |
|
14 |
//--------------------------------------------------------------------------------------------------
|
15 |
ElectronCleaningMod::ElectronCleaningMod(const char *name, const char *title) :
|
16 |
BaseMod(name,title),
|
17 |
fGoodElectronsName(ModNames::gkGoodElectronsName),
|
18 |
fCleanMuonsName(ModNames::gkCleanMuonsName),
|
19 |
fCleanElectronsName(ModNames::gkCleanElectronsName)
|
20 |
{
|
21 |
// Constructor.
|
22 |
}
|
23 |
|
24 |
//--------------------------------------------------------------------------------------------------
|
25 |
void ElectronCleaningMod::Process()
|
26 |
{
|
27 |
// Process entries of the tree.
|
28 |
|
29 |
// get input collection
|
30 |
const MuonCol *CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
|
31 |
const ElectronCol *GoodElectrons = GetObjThisEvt<ElectronCol>(fGoodElectronsName);
|
32 |
|
33 |
// Go through all electrons and remove electron overlaps with muons and duplicates.
|
34 |
std::vector<const Electron*> CleanElTemp;
|
35 |
for (UInt_t i=0; i<GoodElectrons->GetEntries(); ++i) {
|
36 |
const Electron *e = GoodElectrons->At(i);
|
37 |
|
38 |
FourVectorM mom(e->Mom());
|
39 |
const Track *trtrack = e->TrackerTrk();
|
40 |
|
41 |
// Check whether it overlaps with a good muon: If the muon and electron both have
|
42 |
// tracker tracks then compare the tracks, otherwise
|
43 |
Bool_t isMuonOverlap = kFALSE;
|
44 |
UInt_t n = CleanMuons->GetEntries();
|
45 |
for (UInt_t j=0; j<n; ++j) {
|
46 |
|
47 |
if (trtrack && CleanMuons->At(j)->TrackerTrk()) {
|
48 |
if (CleanMuons->At(j)->TrackerTrk() == trtrack) {
|
49 |
isMuonOverlap = kTRUE;
|
50 |
break;
|
51 |
}
|
52 |
} else {
|
53 |
Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), mom);
|
54 |
if (deltaR < 0.1) {
|
55 |
isMuonOverlap = kTRUE;
|
56 |
break;
|
57 |
}
|
58 |
}
|
59 |
}
|
60 |
|
61 |
if (isMuonOverlap)
|
62 |
continue;
|
63 |
|
64 |
// Check whether it overlaps with another electron candidate:
|
65 |
// Here I check whether we have two electron candidates with the same super cluster
|
66 |
// or two electron candidates with the same track. At the end we also check deltaR
|
67 |
// to be sure. If there is a duplicate we swap the old one with the new one if the new
|
68 |
// one has E/P closer to 1.0.
|
69 |
bool isElectronOverlap = kFALSE;
|
70 |
for (UInt_t j=0; j<CleanElTemp.size(); ++j) {
|
71 |
|
72 |
if (e->SCluster() == CleanElTemp[j]->SCluster() ||
|
73 |
e->Trk() == CleanElTemp[j]->Trk())
|
74 |
isElectronOverlap = kTRUE;
|
75 |
|
76 |
if (!isElectronOverlap) {
|
77 |
Double_t deltaR = MathUtils::DeltaR(CleanElTemp[j]->Mom(), mom);
|
78 |
if (deltaR < 0.1)
|
79 |
isElectronOverlap = kTRUE;
|
80 |
}
|
81 |
|
82 |
if (isElectronOverlap) {
|
83 |
if (TMath::Abs(CleanElTemp[j]->ESuperClusterOverP() - 1) >
|
84 |
TMath::Abs(e->ESuperClusterOverP() - 1)) {
|
85 |
CleanElTemp[j] = e;
|
86 |
}
|
87 |
break;
|
88 |
}
|
89 |
}
|
90 |
|
91 |
if (isElectronOverlap)
|
92 |
continue;
|
93 |
|
94 |
// if no overlaps then add to clean electrons
|
95 |
CleanElTemp.push_back(GoodElectrons->At(i));
|
96 |
}
|
97 |
|
98 |
// Fill the electron array with the contents of the vector:
|
99 |
ElectronOArr *CleanElectrons = new ElectronOArr;
|
100 |
CleanElectrons->SetName(fCleanElectronsName);
|
101 |
|
102 |
for (UInt_t j=0; j<CleanElTemp.size(); ++j)
|
103 |
CleanElectrons->Add(CleanElTemp[j]);
|
104 |
CleanElectrons->Sort();
|
105 |
|
106 |
// add to event for other modules to use
|
107 |
AddObjThisEvt(CleanElectrons);
|
108 |
}
|