ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerVertexes.cc
Revision: 1.1
Committed: Tue Sep 30 13:03:42 2008 UTC (16 years, 7 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_005, Mit_004
Log Message:
added vertex filler

File Contents

# Content
1 // $Id: FillerVertexes.cc,v 1.2 2008/09/10 03:30:23 loizides Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerVertexes.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/VertexReco/interface/Vertex.h"
8 #include "DataFormats/VertexReco/interface/VertexFwd.h"
9
10 using namespace std;
11 using namespace edm;
12 using namespace mithep;
13
14 //--------------------------------------------------------------------------------------------------
15 FillerVertexes::FillerVertexes(const ParameterSet &cfg, const char *name, bool active) :
16 BaseFiller(cfg,name,active),
17 edmName_(Conf().getUntrackedParameter<string>("edmName","")),
18 mitName_(Conf().getUntrackedParameter<string>("mitName","PrimaryVertexes")),
19 vertexMapName_(Conf().getUntrackedParameter<string>("vertexMapName",
20 "VertexMap")),
21 vertexes_(new mithep::VertexArr(100)),
22 vertexMap_(new mithep::VertexMap)
23 {
24 // Constructor.
25 }
26
27 //--------------------------------------------------------------------------------------------------
28 FillerVertexes::~FillerVertexes()
29 {
30 // Destructor.
31
32 delete vertexes_;
33 delete vertexMap_;
34 }
35
36 //--------------------------------------------------------------------------------------------------
37 void FillerVertexes::BookDataBlock(TreeWriter &tws)
38 {
39 // Add Vertex branch and the VertexMap to tree.
40
41 tws.AddBranch(mitName_.c_str(),&vertexes_);
42 OS()->add<VertexMap>(vertexMap_,vertexMapName_.c_str());
43 OS()->add<VertexArr>(vertexes_,mitName_.c_str());
44
45 }
46
47 //--------------------------------------------------------------------------------------------------
48 void FillerVertexes::FillDataBlock(const edm::Event &event,
49 const edm::EventSetup &setup)
50 {
51 // Fill the BasicCluster Data Block
52
53 vertexes_->Reset();
54 vertexMap_->Reset();
55
56 Handle<reco::VertexCollection> hVertexProduct;
57 GetProduct(edmName_, hVertexProduct, event);
58 vertexMap_->SetEdmProductId(hVertexProduct.id().id());
59 const reco::VertexCollection inVertexes = *(hVertexProduct.product());
60
61 // loop through all vertexes
62 for (reco::VertexCollection::const_iterator inV = inVertexes.begin();
63 inV != inVertexes.end(); ++inV) {
64
65 mithep::Vertex *outVertex = vertexes_->Allocate();
66 new (outVertex) mithep::Vertex(inV->x(), inV->y(), inV->z(),
67 inV->xError(), inV->yError(), inV->zError());
68
69 outVertex->SetChi2(inV->chi2());
70 outVertex->SetNdof(inV->ndof());
71 outVertex->SetNTracks(inV->tracksSize());
72
73 //add vertex to the map
74 mitedm::VertexPtr thePtr(hVertexProduct, inV-inVertexes.begin());
75 vertexMap_->Add(thePtr, outVertex);
76
77 }
78
79 vertexes_->Trim();
80 }