ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerBasicClusters.cc
Revision: 1.1
Committed: Fri Aug 8 11:12:38 2008 UTC (16 years, 8 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: MITHEP_2_0_x
Log Message:
Add BasicCluster and SuperCluster objects into the Data Tree, and their Fillers.

File Contents

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