1 |
loizides |
1.9 |
// $Id: FillerBasicClusters.cc,v 1.8 2009/07/20 03:19:24 loizides 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.1 |
|
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 |
loizides |
1.9 |
void FillerBasicClusters::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
|
38 |
sixie |
1.1 |
{
|
39 |
|
|
// Add BasicCluster branch and the BasicClusterMap to tree.
|
40 |
|
|
|
41 |
loizides |
1.5 |
tws.AddBranch(mitName_,&basicClusters_);
|
42 |
|
|
OS()->add<BasicClusterArr>(basicClusters_,mitName_);
|
43 |
sixie |
1.1 |
|
44 |
loizides |
1.5 |
if (!basicClusterMapName_.empty()) {
|
45 |
|
|
basicClusterMap_->SetBrName(mitName_);
|
46 |
|
|
OS()->add<BasicClusterMap>(basicClusterMap_,basicClusterMapName_);
|
47 |
|
|
}
|
48 |
sixie |
1.1 |
}
|
49 |
|
|
|
50 |
|
|
//--------------------------------------------------------------------------------------------------
|
51 |
|
|
void FillerBasicClusters::FillDataBlock(const edm::Event &event,
|
52 |
loizides |
1.2 |
const edm::EventSetup &setup)
|
53 |
sixie |
1.1 |
{
|
54 |
loizides |
1.5 |
// Fill the BasicCluster information into our structures.
|
55 |
sixie |
1.1 |
|
56 |
bendavid |
1.3 |
basicClusters_->Delete();
|
57 |
sixie |
1.1 |
basicClusterMap_->Reset();
|
58 |
|
|
|
59 |
bendavid |
1.7 |
Handle<reco::CaloClusterCollection> hBasicClusterProduct;
|
60 |
sixie |
1.1 |
GetProduct(edmName_, hBasicClusterProduct, event);
|
61 |
|
|
basicClusterMap_->SetEdmProductId(hBasicClusterProduct.id().id());
|
62 |
bendavid |
1.7 |
const reco::CaloClusterCollection inBasicClusters = *(hBasicClusterProduct.product());
|
63 |
sixie |
1.1 |
|
64 |
|
|
// loop through all basic clusters
|
65 |
bendavid |
1.7 |
for (reco::CaloClusterCollection::const_iterator inBC = inBasicClusters.begin();
|
66 |
sixie |
1.1 |
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 |
bendavid |
1.4 |
outBasicCluster->SetEnergy(inBC->energy());
|
73 |
sixie |
1.1 |
|
74 |
loizides |
1.8 |
// add basic clusters to the map
|
75 |
bendavid |
1.7 |
reco::CaloClusterPtr thePtr(hBasicClusterProduct, inBC-inBasicClusters.begin());
|
76 |
|
|
basicClusterMap_->Add(thePtr, outBasicCluster);
|
77 |
sixie |
1.1 |
}
|
78 |
|
|
basicClusters_->Trim();
|
79 |
|
|
}
|