ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerVertexes.cc
Revision: 1.3
Committed: Thu Feb 26 17:04:03 2009 UTC (16 years, 2 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008pre1
Changes since 1.2: +2 -2 lines
Log Message:
Switch from Reset to Delete calls on arrays, since we now use some heap

File Contents

# User Rev Content
1 bendavid 1.3 // $Id: FillerVertexes.cc,v 1.2 2008/10/23 15:43:15 loizides Exp $
2 bendavid 1.1
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 loizides 1.2 edmName_(Conf().getUntrackedParameter<string>("edmName","PrimaryVertexes")),
18 bendavid 1.1 mitName_(Conf().getUntrackedParameter<string>("mitName","PrimaryVertexes")),
19     vertexMapName_(Conf().getUntrackedParameter<string>("vertexMapName",
20 loizides 1.2 "VertexMap")),
21 bendavid 1.1 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 loizides 1.2 const edm::EventSetup &setup)
50 bendavid 1.1 {
51 loizides 1.2 // Fill the Vertex branch.
52 bendavid 1.1
53 bendavid 1.3 vertexes_->Delete();
54 bendavid 1.1 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 loizides 1.2 outVertex->SetNdof(static_cast<Int_t>(inV->ndof()));
71 bendavid 1.1 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     }