1 |
paus |
1.20 |
// $Id: FillerBasicClusters.cc,v 1.19 2012/04/20 16:07:43 bendavid Exp $
|
2 |
sixie |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerBasicClusters.h"
|
4 |
bendavid |
1.7 |
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
|
5 |
|
|
#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
|
6 |
loizides |
1.6 |
#include "MitAna/DataTree/interface/BasicClusterCol.h"
|
7 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
8 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
9 |
sixie |
1.11 |
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
|
10 |
peveraer |
1.12 |
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
|
11 |
|
|
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
|
12 |
paus |
1.18 |
#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h"
|
13 |
paus |
1.20 |
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
|
14 |
|
|
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
|
15 |
|
|
#include "Geometry/Records/interface/CaloGeometryRecord.h"
|
16 |
|
|
#include "RecoEgamma/EgammaTools/interface/ggPFClusters.h"
|
17 |
sixie |
1.1 |
|
18 |
|
|
using namespace std;
|
19 |
|
|
using namespace edm;
|
20 |
|
|
using namespace mithep;
|
21 |
|
|
|
22 |
|
|
//--------------------------------------------------------------------------------------------------
|
23 |
|
|
FillerBasicClusters::FillerBasicClusters(const ParameterSet &cfg, const char *name, bool active) :
|
24 |
|
|
BaseFiller(cfg,name,active),
|
25 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","hybridSuperClusters")),
|
26 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName","BasicClusters")),
|
27 |
sixie |
1.11 |
barrelEcalRecHitName_(Conf().getUntrackedParameter<string>("barrelEcalRecHitName","")),
|
28 |
|
|
endcapEcalRecHitName_(Conf().getUntrackedParameter<string>("endcapEcalRecHitName","")),
|
29 |
sixie |
1.1 |
basicClusterMapName_(Conf().getUntrackedParameter<string>("basicClusterMapName",
|
30 |
|
|
"BasicClusterMap")),
|
31 |
paus |
1.20 |
pfClusters_(Conf().getUntrackedParameter<bool>("pfClusters",false)),
|
32 |
sixie |
1.1 |
basicClusters_(new mithep::BasicClusterArr(100)),
|
33 |
|
|
basicClusterMap_(new mithep::BasicClusterMap)
|
34 |
|
|
{
|
35 |
|
|
// Constructor.
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
//--------------------------------------------------------------------------------------------------
|
39 |
|
|
FillerBasicClusters::~FillerBasicClusters()
|
40 |
|
|
{
|
41 |
|
|
// Destructor.
|
42 |
|
|
|
43 |
|
|
delete basicClusters_;
|
44 |
|
|
delete basicClusterMap_;
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
//--------------------------------------------------------------------------------------------------
|
48 |
bendavid |
1.10 |
void FillerBasicClusters::BookDataBlock(TreeWriter &tws)
|
49 |
sixie |
1.1 |
{
|
50 |
|
|
// Add BasicCluster branch and the BasicClusterMap to tree.
|
51 |
|
|
|
52 |
loizides |
1.5 |
tws.AddBranch(mitName_,&basicClusters_);
|
53 |
|
|
OS()->add<BasicClusterArr>(basicClusters_,mitName_);
|
54 |
sixie |
1.1 |
|
55 |
loizides |
1.5 |
if (!basicClusterMapName_.empty()) {
|
56 |
|
|
basicClusterMap_->SetBrName(mitName_);
|
57 |
|
|
OS()->add<BasicClusterMap>(basicClusterMap_,basicClusterMapName_);
|
58 |
|
|
}
|
59 |
sixie |
1.1 |
}
|
60 |
|
|
|
61 |
|
|
//--------------------------------------------------------------------------------------------------
|
62 |
|
|
void FillerBasicClusters::FillDataBlock(const edm::Event &event,
|
63 |
loizides |
1.2 |
const edm::EventSetup &setup)
|
64 |
sixie |
1.1 |
{
|
65 |
loizides |
1.5 |
// Fill the BasicCluster information into our structures.
|
66 |
sixie |
1.1 |
|
67 |
bendavid |
1.3 |
basicClusters_->Delete();
|
68 |
sixie |
1.1 |
basicClusterMap_->Reset();
|
69 |
|
|
|
70 |
bendavid |
1.7 |
Handle<reco::CaloClusterCollection> hBasicClusterProduct;
|
71 |
sixie |
1.1 |
GetProduct(edmName_, hBasicClusterProduct, event);
|
72 |
|
|
basicClusterMap_->SetEdmProductId(hBasicClusterProduct.id().id());
|
73 |
paus |
1.20 |
const reco::CaloClusterCollection &inBasicClusters = *(hBasicClusterProduct.product());
|
74 |
sixie |
1.1 |
|
75 |
bendavid |
1.19 |
edm::Handle< EcalRecHitCollection > pEBRecHits;
|
76 |
|
|
event.getByLabel(barrelEcalRecHitName_, pEBRecHits );
|
77 |
|
|
edm::Handle< EcalRecHitCollection > pEERecHits;
|
78 |
|
|
event.getByLabel( endcapEcalRecHitName_, pEERecHits );
|
79 |
bendavid |
1.16 |
|
80 |
paus |
1.20 |
edm::ESHandle<CaloGeometry> pGeometry;
|
81 |
|
|
setup.get<CaloGeometryRecord>().get(pGeometry);
|
82 |
|
|
|
83 |
|
|
const CaloSubdetectorGeometry *geometryEB = pGeometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
|
84 |
|
|
const CaloSubdetectorGeometry *geometryEE = pGeometry->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
|
85 |
|
|
|
86 |
sixie |
1.11 |
EcalClusterLazyTools lazyTools(event, setup, edm::InputTag(barrelEcalRecHitName_),
|
87 |
|
|
edm::InputTag(endcapEcalRecHitName_));
|
88 |
|
|
|
89 |
paus |
1.20 |
ggPFClusters pfclusters(pEBRecHits, pEERecHits, geometryEB, geometryEE);
|
90 |
|
|
|
91 |
bendavid |
1.16 |
EcalClusterLocal local;
|
92 |
|
|
|
93 |
bendavid |
1.19 |
//loop over rechits and make map of energy values
|
94 |
|
|
std::map<DetId,float> hitEnergies;
|
95 |
|
|
|
96 |
|
|
for (EcalRecHitCollection::const_iterator it = pEBRecHits->begin(); it!=pEBRecHits->end(); ++it) {
|
97 |
|
|
hitEnergies.insert(std::pair<DetId,float>(it->id(),it->energy()));
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
for (EcalRecHitCollection::const_iterator it = pEERecHits->begin(); it!=pEERecHits->end(); ++it) {
|
101 |
|
|
hitEnergies.insert(std::pair<DetId,float>(it->id(),it->energy()));
|
102 |
|
|
}
|
103 |
|
|
|
104 |
sixie |
1.1 |
// loop through all basic clusters
|
105 |
bendavid |
1.7 |
for (reco::CaloClusterCollection::const_iterator inBC = inBasicClusters.begin();
|
106 |
sixie |
1.1 |
inBC != inBasicClusters.end(); ++inBC) {
|
107 |
|
|
|
108 |
|
|
mithep::BasicCluster *outBasicCluster = basicClusters_->Allocate();
|
109 |
|
|
new (outBasicCluster) mithep::BasicCluster();
|
110 |
|
|
|
111 |
|
|
outBasicCluster->SetXYZ(inBC->x(),inBC->y(),inBC->z());
|
112 |
bendavid |
1.4 |
outBasicCluster->SetEnergy(inBC->energy());
|
113 |
sixie |
1.11 |
outBasicCluster->SetNHits(inBC->size());
|
114 |
paus |
1.20 |
|
115 |
sixie |
1.11 |
outBasicCluster->SetCovEtaPhi(lazyTools.covariances(*inBC)[1]);
|
116 |
|
|
outBasicCluster->SetCoviEtaiEta(lazyTools.localCovariances(*inBC)[0]);
|
117 |
|
|
outBasicCluster->SetCoviEtaiPhi(lazyTools.localCovariances(*inBC)[1]);
|
118 |
|
|
outBasicCluster->SetCoviPhiiPhi(lazyTools.localCovariances(*inBC)[2]);
|
119 |
|
|
outBasicCluster->SetZernike20(lazyTools.zernike20(*inBC));
|
120 |
|
|
outBasicCluster->SetZernike42(lazyTools.zernike42(*inBC));
|
121 |
paus |
1.20 |
outBasicCluster->SetEtaLat(lazyTools.lat(*inBC)[0]);
|
122 |
|
|
outBasicCluster->SetPhiLat(lazyTools.lat(*inBC)[1]);
|
123 |
|
|
outBasicCluster->SetLat(lazyTools.lat(*inBC)[2]);
|
124 |
|
|
|
125 |
|
|
if (pfClusters_) {
|
126 |
|
|
//recompute many things by hand to work around bugs/etc
|
127 |
|
|
std::vector<std::pair<DetId,float> > rechits = inBC->hitsAndFractions();
|
128 |
|
|
|
129 |
|
|
bool iseb = inBC->hitsAndFractions().at(0).first.subdetId()==EcalBarrel;
|
130 |
|
|
float e5x5m[5][5];
|
131 |
|
|
float E5x5=0; float E3x3=0;
|
132 |
|
|
float emax = -99.;
|
133 |
|
|
float e2nd = -99.;
|
134 |
|
|
for(int i=-2; i<3; ++i) {
|
135 |
|
|
for(int j=-2; j<3; ++j){
|
136 |
|
|
float e=pfclusters.get5x5Element(i, j, rechits, iseb);
|
137 |
|
|
|
138 |
|
|
//float e = 0;
|
139 |
|
|
|
140 |
|
|
if (e>emax) {
|
141 |
|
|
e2nd = emax;
|
142 |
|
|
emax = e;
|
143 |
|
|
}
|
144 |
|
|
else if (e>e2nd) {
|
145 |
|
|
e2nd = e;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
e5x5m[i+2][j+2] = e;
|
149 |
|
|
|
150 |
|
|
if(abs(i)<2)E3x3=E3x3+e;
|
151 |
|
|
E5x5=e+E5x5;
|
152 |
|
|
}
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
float Eseed=e5x5m[2][2];
|
157 |
|
|
|
158 |
|
|
float Etop=e5x5m[2][3];
|
159 |
|
|
float Ebottom=e5x5m[2][1];
|
160 |
|
|
float Eleft=e5x5m[1][2];
|
161 |
|
|
float Eright=e5x5m[3][2];
|
162 |
|
|
|
163 |
|
|
//Fill5x5Map(bcCells, isEb);
|
164 |
|
|
float E3x1=e5x5m[2][2]+e5x5m[1][2]+e5x5m[3][2];
|
165 |
|
|
float E1x3=e5x5m[2][2]+e5x5m[2][1]+e5x5m[2][3];
|
166 |
|
|
float E1x5=e5x5m[2][2]+e5x5m[2][0]+e5x5m[2][1]+e5x5m[2][3]+e5x5m[2][4];
|
167 |
|
|
|
168 |
|
|
float E2x5Top=e5x5m[0][4]+e5x5m[1][4]+e5x5m[2][4]+e5x5m[3][4]+e5x5m[4][4]
|
169 |
|
|
+e5x5m[0][3]+e5x5m[1][3]+e5x5m[2][3]+e5x5m[3][3]+e5x5m[4][3];
|
170 |
|
|
//add up bottom edge of 5x5 2 rows
|
171 |
|
|
float E2x5Bottom=e5x5m[0][0]+e5x5m[1][0]+e5x5m[2][0]+e5x5m[3][0]+e5x5m[4][0]
|
172 |
|
|
+e5x5m[0][1]+e5x5m[1][1]+e5x5m[2][1]+e5x5m[3][1]+e5x5m[4][1];
|
173 |
|
|
//add up left edge of 5x5 2 rows
|
174 |
|
|
float E2x5Left=e5x5m[0][1]+e5x5m[0][1]+e5x5m[0][2]+e5x5m[0][3]+e5x5m[0][4]
|
175 |
|
|
+e5x5m[1][0]+e5x5m[1][1]+e5x5m[1][2]+e5x5m[1][3]+e5x5m[1][4];
|
176 |
|
|
//add up right edge of 5x5 2 rows
|
177 |
|
|
float E2x5Right=e5x5m[4][0]+e5x5m[4][1]+e5x5m[4][2]+e5x5m[4][3]+e5x5m[4][4]
|
178 |
|
|
+e5x5m[3][0]+e5x5m[3][1]+e5x5m[3][2]+e5x5m[3][3]+e5x5m[3][4];
|
179 |
|
|
//find max 2x5 from the center
|
180 |
|
|
float centerstrip=e5x5m[2][2]+e5x5m[2][0]+e5x5m[2][1]+e5x5m[2][3]+e5x5m[2][4];
|
181 |
|
|
float rightstrip=e5x5m[3][2]+e5x5m[3][0]+e5x5m[3][1]+e5x5m[3][3]+e5x5m[3][4];
|
182 |
|
|
float leftstrip=e5x5m[1][2]+e5x5m[1][0]+e5x5m[1][1]+e5x5m[1][3]+e5x5m[1][4];
|
183 |
|
|
float E2x5Max=0;
|
184 |
|
|
if(rightstrip>leftstrip)E2x5Max=rightstrip+centerstrip;
|
185 |
|
|
else E2x5Max=leftstrip+centerstrip;
|
186 |
|
|
|
187 |
|
|
outBasicCluster->SetE1x3(E1x3);
|
188 |
|
|
outBasicCluster->SetE3x1(E3x1);
|
189 |
|
|
outBasicCluster->SetE1x5(E1x5);
|
190 |
|
|
outBasicCluster->SetE2x2(-99.);
|
191 |
|
|
outBasicCluster->SetE3x2(-99.);
|
192 |
|
|
outBasicCluster->SetE3x3(E3x3);
|
193 |
|
|
outBasicCluster->SetE4x4(-99.);
|
194 |
|
|
outBasicCluster->SetE5x5(E5x5);
|
195 |
|
|
outBasicCluster->SetE2x5Right(E2x5Right);
|
196 |
|
|
outBasicCluster->SetE2x5Left(E2x5Left);
|
197 |
|
|
outBasicCluster->SetE2x5Top(E2x5Top);
|
198 |
|
|
outBasicCluster->SetE2x5Bottom(E2x5Bottom);
|
199 |
|
|
outBasicCluster->SetE2x5Max(E2x5Max);
|
200 |
|
|
outBasicCluster->SetELeft(Eleft);
|
201 |
|
|
outBasicCluster->SetERight(Eright);
|
202 |
|
|
outBasicCluster->SetETop(Etop);
|
203 |
|
|
outBasicCluster->SetEBottom(Ebottom);
|
204 |
|
|
outBasicCluster->SetEMax(emax);
|
205 |
|
|
outBasicCluster->SetE2nd(e2nd);
|
206 |
|
|
|
207 |
|
|
std::vector<reco::CaloCluster> clustv;
|
208 |
|
|
clustv.push_back(*inBC);
|
209 |
|
|
|
210 |
|
|
outBasicCluster->SetCovEtaEta(pfclusters.ClusterWidth(clustv).first);
|
211 |
|
|
outBasicCluster->SetCovPhiPhi(pfclusters.ClusterWidth(clustv).second);
|
212 |
|
|
|
213 |
|
|
//raw rechit energy sum, since stored cluster energy is bogus for some PF Clusters
|
214 |
|
|
double esum = 0.0;
|
215 |
|
|
for (std::vector< std::pair<DetId, float> >::const_iterator it = inBC->hitsAndFractions().begin();
|
216 |
|
|
it != inBC->hitsAndFractions().end(); ++it) {
|
217 |
|
|
|
218 |
|
|
esum += hitEnergies[it->first]*it->second;
|
219 |
|
|
}
|
220 |
|
|
outBasicCluster->SetEnergy(esum);
|
221 |
|
|
|
222 |
sixie |
1.1 |
|
223 |
paus |
1.20 |
}
|
224 |
|
|
else {
|
225 |
|
|
outBasicCluster->SetE1x3(lazyTools.e1x3(*inBC));
|
226 |
|
|
outBasicCluster->SetE3x1(lazyTools.e3x1(*inBC));
|
227 |
|
|
outBasicCluster->SetE1x5(lazyTools.e1x5(*inBC));
|
228 |
|
|
outBasicCluster->SetE2x2(lazyTools.e2x2(*inBC));
|
229 |
|
|
outBasicCluster->SetE3x2(lazyTools.e3x2(*inBC));
|
230 |
|
|
outBasicCluster->SetE3x3(lazyTools.e3x3(*inBC));
|
231 |
|
|
outBasicCluster->SetE4x4(lazyTools.e4x4(*inBC));
|
232 |
|
|
outBasicCluster->SetE5x5(lazyTools.e5x5(*inBC));
|
233 |
|
|
outBasicCluster->SetE2x5Right(lazyTools.e2x5Right(*inBC));
|
234 |
|
|
outBasicCluster->SetE2x5Left(lazyTools.e2x5Left(*inBC));
|
235 |
|
|
outBasicCluster->SetE2x5Top(lazyTools.e2x5Top(*inBC));
|
236 |
|
|
outBasicCluster->SetE2x5Bottom(lazyTools.e2x5Bottom(*inBC));
|
237 |
|
|
outBasicCluster->SetE2x5Max(lazyTools.e2x5Max(*inBC));
|
238 |
|
|
outBasicCluster->SetELeft(lazyTools.eLeft(*inBC));
|
239 |
|
|
outBasicCluster->SetERight(lazyTools.eRight(*inBC));
|
240 |
|
|
outBasicCluster->SetETop(lazyTools.eTop(*inBC));
|
241 |
|
|
outBasicCluster->SetEBottom(lazyTools.eBottom(*inBC));
|
242 |
|
|
outBasicCluster->SetEMax(lazyTools.eMax(*inBC));
|
243 |
|
|
outBasicCluster->SetE2nd(lazyTools.e2nd(*inBC));
|
244 |
|
|
outBasicCluster->SetCovEtaEta(lazyTools.covariances(*inBC)[0]);
|
245 |
|
|
outBasicCluster->SetCovPhiPhi(lazyTools.covariances(*inBC)[2]);
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
//ecal timing information
|
249 |
|
|
const reco::BasicCluster *inbcd = dynamic_cast<const reco::BasicCluster*>(&*inBC);
|
250 |
|
|
|
251 |
|
|
if (inbcd) {
|
252 |
|
|
outBasicCluster->SetTime(lazyTools.BasicClusterTime(*inbcd, event));
|
253 |
|
|
outBasicCluster->SetSeedTime(lazyTools.BasicClusterSeedTime(*inbcd));
|
254 |
|
|
}
|
255 |
bendavid |
1.19 |
|
256 |
bendavid |
1.16 |
//local coordinates
|
257 |
paus |
1.20 |
if (inBC->hitsAndFractions().at(0).first.subdetId()==EcalBarrel) {
|
258 |
bendavid |
1.17 |
float etacry, phicry, thetatilt, phitilt;
|
259 |
bendavid |
1.16 |
int ieta, iphi;
|
260 |
bendavid |
1.17 |
local.localCoordsEB(*inBC,setup,etacry,phicry,ieta,iphi,thetatilt,phitilt);
|
261 |
bendavid |
1.16 |
outBasicCluster->SetEtaCry(etacry);
|
262 |
|
|
outBasicCluster->SetPhiCry(phicry);
|
263 |
|
|
outBasicCluster->SetIEta(ieta);
|
264 |
|
|
outBasicCluster->SetIPhi(iphi);
|
265 |
bendavid |
1.17 |
outBasicCluster->SetThetaAxis(thetatilt);
|
266 |
|
|
outBasicCluster->SetPhiAxis(phitilt);
|
267 |
paus |
1.20 |
|
268 |
|
|
EBDetId edet(inBC->hitsAndFractions().at(0).first);
|
269 |
|
|
|
270 |
|
|
outBasicCluster->SetSeedIEta(edet.ieta());
|
271 |
|
|
outBasicCluster->SetSeedIPhi(edet.iphi());
|
272 |
|
|
|
273 |
bendavid |
1.16 |
}
|
274 |
|
|
else {
|
275 |
bendavid |
1.17 |
float xcry, ycry, thetatilt, phitilt;
|
276 |
bendavid |
1.16 |
int ix, iy;
|
277 |
bendavid |
1.17 |
local.localCoordsEE(*inBC,setup,xcry,ycry,ix,iy,thetatilt,phitilt);
|
278 |
bendavid |
1.16 |
outBasicCluster->SetXCry(xcry);
|
279 |
|
|
outBasicCluster->SetYCry(ycry);
|
280 |
|
|
outBasicCluster->SetIX(ix);
|
281 |
bendavid |
1.17 |
outBasicCluster->SetIY(iy);
|
282 |
|
|
outBasicCluster->SetThetaAxis(thetatilt);
|
283 |
paus |
1.20 |
outBasicCluster->SetPhiAxis(phitilt);
|
284 |
|
|
|
285 |
|
|
EEDetId edet(inBC->hitsAndFractions().at(0).first);
|
286 |
|
|
|
287 |
|
|
outBasicCluster->SetSeedIX(edet.ix());
|
288 |
|
|
outBasicCluster->SetSeedIY(edet.iy());
|
289 |
|
|
|
290 |
bendavid |
1.16 |
}
|
291 |
|
|
|
292 |
loizides |
1.8 |
// add basic clusters to the map
|
293 |
bendavid |
1.7 |
reco::CaloClusterPtr thePtr(hBasicClusterProduct, inBC-inBasicClusters.begin());
|
294 |
|
|
basicClusterMap_->Add(thePtr, outBasicCluster);
|
295 |
peveraer |
1.12 |
|
296 |
sixie |
1.1 |
}
|
297 |
|
|
basicClusters_->Trim();
|
298 |
|
|
}
|