ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerBasicClusters.cc
Revision: 1.19
Committed: Fri Apr 20 16:07:43 2012 UTC (13 years ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.18: +25 -7 lines
Log Message:
Add Particle Flow photons

File Contents

# User Rev Content
1 bendavid 1.19 // $Id: FillerBasicClusters.cc,v 1.18 2012/03/30 01:08:40 paus 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 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.19 edm::Handle< EcalRecHitCollection > pEBRecHits;
71     event.getByLabel(barrelEcalRecHitName_, pEBRecHits );
72     edm::Handle< EcalRecHitCollection > pEERecHits;
73     event.getByLabel( endcapEcalRecHitName_, pEERecHits );
74 bendavid 1.16
75 sixie 1.11 EcalClusterLazyTools lazyTools(event, setup, edm::InputTag(barrelEcalRecHitName_),
76     edm::InputTag(endcapEcalRecHitName_));
77    
78 bendavid 1.16 EcalClusterLocal local;
79    
80 bendavid 1.19 //loop over rechits and make map of energy values
81     std::map<DetId,float> hitEnergies;
82    
83     for (EcalRecHitCollection::const_iterator it = pEBRecHits->begin(); it!=pEBRecHits->end(); ++it) {
84     hitEnergies.insert(std::pair<DetId,float>(it->id(),it->energy()));
85     }
86    
87     for (EcalRecHitCollection::const_iterator it = pEERecHits->begin(); it!=pEERecHits->end(); ++it) {
88     hitEnergies.insert(std::pair<DetId,float>(it->id(),it->energy()));
89     }
90    
91 sixie 1.1 // loop through all basic clusters
92 bendavid 1.7 for (reco::CaloClusterCollection::const_iterator inBC = inBasicClusters.begin();
93 sixie 1.1 inBC != inBasicClusters.end(); ++inBC) {
94    
95     mithep::BasicCluster *outBasicCluster = basicClusters_->Allocate();
96     new (outBasicCluster) mithep::BasicCluster();
97    
98     outBasicCluster->SetXYZ(inBC->x(),inBC->y(),inBC->z());
99 bendavid 1.4 outBasicCluster->SetEnergy(inBC->energy());
100 sixie 1.11 outBasicCluster->SetNHits(inBC->size());
101     outBasicCluster->SetE1x3(lazyTools.e1x3(*inBC));
102     outBasicCluster->SetE3x1(lazyTools.e3x1(*inBC));
103     outBasicCluster->SetE1x5(lazyTools.e1x5(*inBC));
104     outBasicCluster->SetE2x2(lazyTools.e2x2(*inBC));
105     outBasicCluster->SetE3x2(lazyTools.e3x2(*inBC));
106     outBasicCluster->SetE3x3(lazyTools.e3x3(*inBC));
107     outBasicCluster->SetE4x4(lazyTools.e4x4(*inBC));
108     outBasicCluster->SetE5x5(lazyTools.e5x5(*inBC));
109     outBasicCluster->SetE2x5Right(lazyTools.e2x5Right(*inBC));
110     outBasicCluster->SetE2x5Left(lazyTools.e2x5Left(*inBC));
111     outBasicCluster->SetE2x5Top(lazyTools.e2x5Top(*inBC));
112     outBasicCluster->SetE2x5Bottom(lazyTools.e2x5Bottom(*inBC));
113     outBasicCluster->SetE2x5Max(lazyTools.e2x5Max(*inBC));
114     outBasicCluster->SetELeft(lazyTools.eLeft(*inBC));
115     outBasicCluster->SetERight(lazyTools.eRight(*inBC));
116     outBasicCluster->SetETop(lazyTools.eTop(*inBC));
117     outBasicCluster->SetEBottom(lazyTools.eBottom(*inBC));
118     outBasicCluster->SetEMax(lazyTools.eMax(*inBC));
119     outBasicCluster->SetE2nd(lazyTools.e2nd(*inBC));
120     outBasicCluster->SetEtaLat(lazyTools.lat(*inBC)[0]);
121     outBasicCluster->SetPhiLat(lazyTools.lat(*inBC)[1]);
122     outBasicCluster->SetLat(lazyTools.lat(*inBC)[2]);
123     outBasicCluster->SetCovEtaEta(lazyTools.covariances(*inBC)[0]);
124     outBasicCluster->SetCovEtaPhi(lazyTools.covariances(*inBC)[1]);
125     outBasicCluster->SetCovPhiPhi(lazyTools.covariances(*inBC)[2]);
126     outBasicCluster->SetCoviEtaiEta(lazyTools.localCovariances(*inBC)[0]);
127     outBasicCluster->SetCoviEtaiPhi(lazyTools.localCovariances(*inBC)[1]);
128     outBasicCluster->SetCoviPhiiPhi(lazyTools.localCovariances(*inBC)[2]);
129     outBasicCluster->SetZernike20(lazyTools.zernike20(*inBC));
130     outBasicCluster->SetZernike42(lazyTools.zernike42(*inBC));
131 sixie 1.1
132 bendavid 1.19 //raw rechit energy sum, since stored cluster energy is bogus for some PF Clusters
133     double esum = 0.0;
134     for (std::vector< std::pair<DetId, float> >::const_iterator it = inBC->hitsAndFractions().begin();
135     it != inBC->hitsAndFractions().end(); ++it) {
136    
137     esum += hitEnergies[it->first]*it->second;
138     }
139     outBasicCluster->SetSumRecHitEnergy(esum);
140    
141 bendavid 1.16 //local coordinates
142     if (std::abs(inBC->eta())<1.48) {
143 bendavid 1.17 float etacry, phicry, thetatilt, phitilt;
144 bendavid 1.16 int ieta, iphi;
145 bendavid 1.17 local.localCoordsEB(*inBC,setup,etacry,phicry,ieta,iphi,thetatilt,phitilt);
146 bendavid 1.16 outBasicCluster->SetEtaCry(etacry);
147     outBasicCluster->SetPhiCry(phicry);
148     outBasicCluster->SetIEta(ieta);
149     outBasicCluster->SetIPhi(iphi);
150 bendavid 1.17 outBasicCluster->SetThetaAxis(thetatilt);
151     outBasicCluster->SetPhiAxis(phitilt);
152 bendavid 1.16 }
153     else {
154 bendavid 1.17 float xcry, ycry, thetatilt, phitilt;
155 bendavid 1.16 int ix, iy;
156 bendavid 1.17 local.localCoordsEE(*inBC,setup,xcry,ycry,ix,iy,thetatilt,phitilt);
157 bendavid 1.16 outBasicCluster->SetXCry(xcry);
158     outBasicCluster->SetYCry(ycry);
159     outBasicCluster->SetIX(ix);
160 bendavid 1.17 outBasicCluster->SetIY(iy);
161     outBasicCluster->SetThetaAxis(thetatilt);
162     outBasicCluster->SetPhiAxis(phitilt);
163 bendavid 1.16 }
164    
165 loizides 1.8 // add basic clusters to the map
166 bendavid 1.7 reco::CaloClusterPtr thePtr(hBasicClusterProduct, inBC-inBasicClusters.begin());
167     basicClusterMap_->Add(thePtr, outBasicCluster);
168 peveraer 1.12
169 sixie 1.1 }
170     basicClusters_->Trim();
171     }