ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerVertexes.cc
Revision: 1.7
Committed: Wed Nov 4 16:30:38 2009 UTC (15 years, 6 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012
Changes since 1.6: +2 -2 lines
Log Message:
Adjust def name.

File Contents

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