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