ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerBeamSpot.cc
Revision: 1.1
Committed: Wed Nov 12 18:21:28 2008 UTC (16 years, 5 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006b, Mit_006a, Mit_006
Log Message:
Added BeamSpot filler

File Contents

# User Rev Content
1 bendavid 1.1 // $Id: FillerBeamSpot.cc,v 1.2 2008/10/23 15:43:15 loizides Exp $
2    
3     #include "MitProd/TreeFiller/interface/FillerBeamSpot.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/BeamSpot/interface/BeamSpot.h"
8    
9     using namespace std;
10     using namespace edm;
11     using namespace mithep;
12    
13     //--------------------------------------------------------------------------------------------------
14     FillerBeamSpot::FillerBeamSpot(const ParameterSet &cfg, const char *name, bool active) :
15     BaseFiller(cfg,name,active),
16     edmName_(Conf().getUntrackedParameter<string>("edmName","offlineBeamSpot")),
17     mitName_(Conf().getUntrackedParameter<string>("mitName","BeamSpot")),
18     beamSpot_(new mithep::BeamSpot)
19     {
20     // Constructor.
21     }
22    
23     //--------------------------------------------------------------------------------------------------
24     FillerBeamSpot::~FillerBeamSpot()
25     {
26     // Destructor.
27    
28     delete beamSpot_;
29     }
30    
31     //--------------------------------------------------------------------------------------------------
32     void FillerBeamSpot::BookDataBlock(TreeWriter &tws)
33     {
34     // Add Vertex branch and the VertexMap to tree.
35    
36     tws.AddBranch(mitName_.c_str(),&beamSpot_);
37     OS()->add<mithep::BeamSpot>(beamSpot_,mitName_.c_str());
38    
39     }
40    
41     //--------------------------------------------------------------------------------------------------
42     void FillerBeamSpot::FillDataBlock(const edm::Event &event,
43     const edm::EventSetup &setup)
44     {
45     // Fill the BeamSpot branch.
46    
47     Handle<reco::BeamSpot> hBeamSpotProduct;
48     GetProduct(edmName_, hBeamSpotProduct, event);
49     const reco::BeamSpot *inBeamSpot = hBeamSpotProduct.product();
50    
51     new (beamSpot_) mithep::BeamSpot(inBeamSpot->x0(),
52     inBeamSpot->y0(),
53     inBeamSpot->z0(),
54     inBeamSpot->x0Error(),
55     inBeamSpot->y0Error(),
56     inBeamSpot->z0Error()
57     );
58    
59     beamSpot_->SetSigmaZ(inBeamSpot->sigmaZ());
60     beamSpot_->SetBeamWidth(inBeamSpot->BeamWidth());
61     beamSpot_->SetDxDz(inBeamSpot->dxdz());
62     beamSpot_->SetDyDz(inBeamSpot->dydz());
63    
64     beamSpot_->SetSigmaZErr(inBeamSpot->sigmaZ0Error());
65     beamSpot_->SetBeamWidthErr(inBeamSpot->BeamWidthError());
66     beamSpot_->SetDxDzErr(inBeamSpot->dxdzError());
67     beamSpot_->SetDyDzErr(inBeamSpot->dydzError());
68    
69     }