1 |
bendavid |
1.16 |
// $Id: FillerBasicClusters.cc,v 1.15 2011/04/23 19:13:14 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 |
bendavid |
1.16 |
#include "HiggsAnalysis/HiggsToGammaGamma/interface/EcalClusterLocal.h"
|
13 |
sixie |
1.1 |
|
14 |
|
|
using namespace std;
|
15 |
|
|
using namespace edm;
|
16 |
|
|
using namespace mithep;
|
17 |
|
|
|
18 |
|
|
//--------------------------------------------------------------------------------------------------
|
19 |
|
|
FillerBasicClusters::FillerBasicClusters(const ParameterSet &cfg, const char *name, bool active) :
|
20 |
|
|
BaseFiller(cfg,name,active),
|
21 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","hybridSuperClusters")),
|
22 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName","BasicClusters")),
|
23 |
sixie |
1.11 |
barrelEcalRecHitName_(Conf().getUntrackedParameter<string>("barrelEcalRecHitName","")),
|
24 |
|
|
endcapEcalRecHitName_(Conf().getUntrackedParameter<string>("endcapEcalRecHitName","")),
|
25 |
sixie |
1.1 |
basicClusterMapName_(Conf().getUntrackedParameter<string>("basicClusterMapName",
|
26 |
|
|
"BasicClusterMap")),
|
27 |
|
|
basicClusters_(new mithep::BasicClusterArr(100)),
|
28 |
|
|
basicClusterMap_(new mithep::BasicClusterMap)
|
29 |
|
|
{
|
30 |
|
|
// Constructor.
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
//--------------------------------------------------------------------------------------------------
|
34 |
|
|
FillerBasicClusters::~FillerBasicClusters()
|
35 |
|
|
{
|
36 |
|
|
// Destructor.
|
37 |
|
|
|
38 |
|
|
delete basicClusters_;
|
39 |
|
|
delete basicClusterMap_;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
//--------------------------------------------------------------------------------------------------
|
43 |
bendavid |
1.10 |
void FillerBasicClusters::BookDataBlock(TreeWriter &tws)
|
44 |
sixie |
1.1 |
{
|
45 |
|
|
// Add BasicCluster branch and the BasicClusterMap to tree.
|
46 |
|
|
|
47 |
loizides |
1.5 |
tws.AddBranch(mitName_,&basicClusters_);
|
48 |
|
|
OS()->add<BasicClusterArr>(basicClusters_,mitName_);
|
49 |
sixie |
1.1 |
|
50 |
loizides |
1.5 |
if (!basicClusterMapName_.empty()) {
|
51 |
|
|
basicClusterMap_->SetBrName(mitName_);
|
52 |
|
|
OS()->add<BasicClusterMap>(basicClusterMap_,basicClusterMapName_);
|
53 |
|
|
}
|
54 |
sixie |
1.1 |
}
|
55 |
|
|
|
56 |
|
|
//--------------------------------------------------------------------------------------------------
|
57 |
|
|
void FillerBasicClusters::FillDataBlock(const edm::Event &event,
|
58 |
loizides |
1.2 |
const edm::EventSetup &setup)
|
59 |
sixie |
1.1 |
{
|
60 |
loizides |
1.5 |
// Fill the BasicCluster information into our structures.
|
61 |
sixie |
1.1 |
|
62 |
bendavid |
1.3 |
basicClusters_->Delete();
|
63 |
sixie |
1.1 |
basicClusterMap_->Reset();
|
64 |
|
|
|
65 |
bendavid |
1.7 |
Handle<reco::CaloClusterCollection> hBasicClusterProduct;
|
66 |
sixie |
1.1 |
GetProduct(edmName_, hBasicClusterProduct, event);
|
67 |
|
|
basicClusterMap_->SetEdmProductId(hBasicClusterProduct.id().id());
|
68 |
bendavid |
1.7 |
const reco::CaloClusterCollection inBasicClusters = *(hBasicClusterProduct.product());
|
69 |
sixie |
1.1 |
|
70 |
bendavid |
1.16 |
// edm::Handle< EcalRecHitCollection > pEBRecHits;
|
71 |
|
|
// event.getByLabel(barrelEcalRecHitName_, pEBRecHits );
|
72 |
|
|
// const EcalRecHitCollection * ebRecHits_ = pEBRecHits.product();
|
73 |
|
|
// edm::Handle< EcalRecHitCollection > pEERecHits;
|
74 |
|
|
// event.getByLabel( endcapEcalRecHitName_, pEERecHits );
|
75 |
|
|
// const EcalRecHitCollection * eeRecHits_ = pEERecHits.product();
|
76 |
|
|
|
77 |
sixie |
1.11 |
EcalClusterLazyTools lazyTools(event, setup, edm::InputTag(barrelEcalRecHitName_),
|
78 |
|
|
edm::InputTag(endcapEcalRecHitName_));
|
79 |
|
|
|
80 |
bendavid |
1.16 |
EcalClusterLocal local;
|
81 |
|
|
|
82 |
sixie |
1.1 |
// loop through all basic clusters
|
83 |
bendavid |
1.7 |
for (reco::CaloClusterCollection::const_iterator inBC = inBasicClusters.begin();
|
84 |
sixie |
1.1 |
inBC != inBasicClusters.end(); ++inBC) {
|
85 |
|
|
|
86 |
|
|
mithep::BasicCluster *outBasicCluster = basicClusters_->Allocate();
|
87 |
|
|
new (outBasicCluster) mithep::BasicCluster();
|
88 |
|
|
|
89 |
|
|
outBasicCluster->SetXYZ(inBC->x(),inBC->y(),inBC->z());
|
90 |
bendavid |
1.4 |
outBasicCluster->SetEnergy(inBC->energy());
|
91 |
sixie |
1.11 |
outBasicCluster->SetNHits(inBC->size());
|
92 |
|
|
outBasicCluster->SetE1x3(lazyTools.e1x3(*inBC));
|
93 |
|
|
outBasicCluster->SetE3x1(lazyTools.e3x1(*inBC));
|
94 |
|
|
outBasicCluster->SetE1x5(lazyTools.e1x5(*inBC));
|
95 |
|
|
outBasicCluster->SetE2x2(lazyTools.e2x2(*inBC));
|
96 |
|
|
outBasicCluster->SetE3x2(lazyTools.e3x2(*inBC));
|
97 |
|
|
outBasicCluster->SetE3x3(lazyTools.e3x3(*inBC));
|
98 |
|
|
outBasicCluster->SetE4x4(lazyTools.e4x4(*inBC));
|
99 |
|
|
outBasicCluster->SetE5x5(lazyTools.e5x5(*inBC));
|
100 |
|
|
outBasicCluster->SetE2x5Right(lazyTools.e2x5Right(*inBC));
|
101 |
|
|
outBasicCluster->SetE2x5Left(lazyTools.e2x5Left(*inBC));
|
102 |
|
|
outBasicCluster->SetE2x5Top(lazyTools.e2x5Top(*inBC));
|
103 |
|
|
outBasicCluster->SetE2x5Bottom(lazyTools.e2x5Bottom(*inBC));
|
104 |
|
|
outBasicCluster->SetE2x5Max(lazyTools.e2x5Max(*inBC));
|
105 |
|
|
outBasicCluster->SetELeft(lazyTools.eLeft(*inBC));
|
106 |
|
|
outBasicCluster->SetERight(lazyTools.eRight(*inBC));
|
107 |
|
|
outBasicCluster->SetETop(lazyTools.eTop(*inBC));
|
108 |
|
|
outBasicCluster->SetEBottom(lazyTools.eBottom(*inBC));
|
109 |
|
|
outBasicCluster->SetEMax(lazyTools.eMax(*inBC));
|
110 |
|
|
outBasicCluster->SetE2nd(lazyTools.e2nd(*inBC));
|
111 |
|
|
outBasicCluster->SetEtaLat(lazyTools.lat(*inBC)[0]);
|
112 |
|
|
outBasicCluster->SetPhiLat(lazyTools.lat(*inBC)[1]);
|
113 |
|
|
outBasicCluster->SetLat(lazyTools.lat(*inBC)[2]);
|
114 |
|
|
outBasicCluster->SetCovEtaEta(lazyTools.covariances(*inBC)[0]);
|
115 |
|
|
outBasicCluster->SetCovEtaPhi(lazyTools.covariances(*inBC)[1]);
|
116 |
|
|
outBasicCluster->SetCovPhiPhi(lazyTools.covariances(*inBC)[2]);
|
117 |
|
|
outBasicCluster->SetCoviEtaiEta(lazyTools.localCovariances(*inBC)[0]);
|
118 |
|
|
outBasicCluster->SetCoviEtaiPhi(lazyTools.localCovariances(*inBC)[1]);
|
119 |
|
|
outBasicCluster->SetCoviPhiiPhi(lazyTools.localCovariances(*inBC)[2]);
|
120 |
|
|
outBasicCluster->SetZernike20(lazyTools.zernike20(*inBC));
|
121 |
|
|
outBasicCluster->SetZernike42(lazyTools.zernike42(*inBC));
|
122 |
sixie |
1.1 |
|
123 |
bendavid |
1.16 |
//local coordinates
|
124 |
|
|
if (std::abs(inBC->eta())<1.48) {
|
125 |
|
|
float etacry, phicry;
|
126 |
|
|
int ieta, iphi;
|
127 |
|
|
local.localCoordsEB(*inBC,setup,etacry,phicry,ieta,iphi);
|
128 |
|
|
outBasicCluster->SetEtaCry(etacry);
|
129 |
|
|
outBasicCluster->SetPhiCry(phicry);
|
130 |
|
|
outBasicCluster->SetIEta(ieta);
|
131 |
|
|
outBasicCluster->SetIPhi(iphi);
|
132 |
|
|
}
|
133 |
|
|
else {
|
134 |
|
|
float xcry, ycry;
|
135 |
|
|
int ix, iy;
|
136 |
|
|
local.localCoordsEE(*inBC,setup,xcry,ycry,ix,iy);
|
137 |
|
|
outBasicCluster->SetXCry(xcry);
|
138 |
|
|
outBasicCluster->SetYCry(ycry);
|
139 |
|
|
outBasicCluster->SetIX(ix);
|
140 |
|
|
outBasicCluster->SetIY(iy);
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
//
|
145 |
|
|
// DetId id = ((*inBC).hitsAndFractions()[0]).first;
|
146 |
|
|
// const EcalRecHitCollection *recHits = 0;
|
147 |
|
|
// if ( id.subdetId() == EcalBarrel ) {
|
148 |
|
|
// recHits = ebRecHits_;
|
149 |
|
|
// } else if ( id.subdetId() == EcalEndcap ) {
|
150 |
|
|
// recHits = eeRecHits_;
|
151 |
|
|
// }
|
152 |
|
|
// float max = 0;
|
153 |
|
|
// DetId idmax(0);
|
154 |
|
|
// for ( size_t i = 0; i < (*inBC).hitsAndFractions().size(); ++i ) {
|
155 |
|
|
// float energy=0;
|
156 |
|
|
// if ((*inBC).hitsAndFractions()[i].first!=DetId(0)) energy= (*(recHits->find( (*inBC).hitsAndFractions()[i].first))).energy() * (((*inBC).hitsAndFractions())[i].second);
|
157 |
|
|
// if ( energy > max ) {
|
158 |
|
|
// max = energy;
|
159 |
|
|
// idmax = ((*inBC).hitsAndFractions())[i].first;
|
160 |
|
|
// }
|
161 |
|
|
// }
|
162 |
peveraer |
1.13 |
|
163 |
bendavid |
1.15 |
//outBasicCluster->SetSwissCross(EcalSeverityLevelAlgo::swissCross(idmax,*recHits,0.));
|
164 |
peveraer |
1.13 |
|
165 |
peveraer |
1.12 |
|
166 |
loizides |
1.8 |
// add basic clusters to the map
|
167 |
bendavid |
1.7 |
reco::CaloClusterPtr thePtr(hBasicClusterProduct, inBC-inBasicClusters.begin());
|
168 |
|
|
basicClusterMap_->Add(thePtr, outBasicCluster);
|
169 |
peveraer |
1.12 |
|
170 |
sixie |
1.1 |
}
|
171 |
|
|
basicClusters_->Trim();
|
172 |
|
|
}
|