ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerBasicClusters.cc
Revision: 1.8
Committed: Mon Jul 20 03:19:24 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_011, Mit_010a, Mit_010
Changes since 1.7: +2 -2 lines
Log Message:
Cleanup

File Contents

# Content
1 // $Id: FillerBasicClusters.cc,v 1.7 2009/06/18 23:04:24 bendavid Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerBasicClusters.h"
4 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
5 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
6 #include "MitAna/DataTree/interface/BasicClusterCol.h"
7 #include "MitAna/DataTree/interface/Names.h"
8 #include "MitProd/ObjectService/interface/ObjectService.h"
9
10 using namespace std;
11 using namespace edm;
12 using namespace mithep;
13
14 //--------------------------------------------------------------------------------------------------
15 FillerBasicClusters::FillerBasicClusters(const ParameterSet &cfg, const char *name, bool active) :
16 BaseFiller(cfg,name,active),
17 edmName_(Conf().getUntrackedParameter<string>("edmName","hybridSuperClusters")),
18 mitName_(Conf().getUntrackedParameter<string>("mitName","BasicClusters")),
19 basicClusterMapName_(Conf().getUntrackedParameter<string>("basicClusterMapName",
20 "BasicClusterMap")),
21 basicClusters_(new mithep::BasicClusterArr(100)),
22 basicClusterMap_(new mithep::BasicClusterMap)
23 {
24 // Constructor.
25 }
26
27 //--------------------------------------------------------------------------------------------------
28 FillerBasicClusters::~FillerBasicClusters()
29 {
30 // Destructor.
31
32 delete basicClusters_;
33 delete basicClusterMap_;
34 }
35
36 //--------------------------------------------------------------------------------------------------
37 void FillerBasicClusters::BookDataBlock(TreeWriter &tws)
38 {
39 // Add BasicCluster branch and the BasicClusterMap to tree.
40
41 tws.AddBranch(mitName_,&basicClusters_);
42 OS()->add<BasicClusterArr>(basicClusters_,mitName_);
43
44 if (!basicClusterMapName_.empty()) {
45 basicClusterMap_->SetBrName(mitName_);
46 OS()->add<BasicClusterMap>(basicClusterMap_,basicClusterMapName_);
47 }
48 }
49
50 //--------------------------------------------------------------------------------------------------
51 void FillerBasicClusters::FillDataBlock(const edm::Event &event,
52 const edm::EventSetup &setup)
53 {
54 // Fill the BasicCluster information into our structures.
55
56 basicClusters_->Delete();
57 basicClusterMap_->Reset();
58
59 Handle<reco::CaloClusterCollection> hBasicClusterProduct;
60 GetProduct(edmName_, hBasicClusterProduct, event);
61 basicClusterMap_->SetEdmProductId(hBasicClusterProduct.id().id());
62 const reco::CaloClusterCollection inBasicClusters = *(hBasicClusterProduct.product());
63
64 // loop through all basic clusters
65 for (reco::CaloClusterCollection::const_iterator inBC = inBasicClusters.begin();
66 inBC != inBasicClusters.end(); ++inBC) {
67
68 mithep::BasicCluster *outBasicCluster = basicClusters_->Allocate();
69 new (outBasicCluster) mithep::BasicCluster();
70
71 outBasicCluster->SetXYZ(inBC->x(),inBC->y(),inBC->z());
72 outBasicCluster->SetEnergy(inBC->energy());
73
74 // add basic clusters to the map
75 reco::CaloClusterPtr thePtr(hBasicClusterProduct, inBC-inBasicClusters.begin());
76 basicClusterMap_->Add(thePtr, outBasicCluster);
77 }
78 basicClusters_->Trim();
79 }