1 |
loizides |
1.3 |
// $Id: FillerBeamSpot.cc,v 1.2 2009/03/03 17:05:09 loizides Exp $
|
2 |
bendavid |
1.1 |
|
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 |
loizides |
1.2 |
beamSpots_(new mithep::BeamSpotArr)
|
19 |
bendavid |
1.1 |
{
|
20 |
|
|
// Constructor.
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
//--------------------------------------------------------------------------------------------------
|
24 |
|
|
FillerBeamSpot::~FillerBeamSpot()
|
25 |
|
|
{
|
26 |
|
|
// Destructor.
|
27 |
|
|
|
28 |
loizides |
1.2 |
delete beamSpots_;
|
29 |
bendavid |
1.1 |
}
|
30 |
|
|
|
31 |
|
|
//--------------------------------------------------------------------------------------------------
|
32 |
|
|
void FillerBeamSpot::BookDataBlock(TreeWriter &tws)
|
33 |
|
|
{
|
34 |
|
|
// Add Vertex branch and the VertexMap to tree.
|
35 |
|
|
|
36 |
loizides |
1.3 |
tws.AddBranch(mitName_,&beamSpots_);
|
37 |
|
|
OS()->add<mithep::BeamSpotArr>(beamSpots_,mitName_);
|
38 |
bendavid |
1.1 |
}
|
39 |
|
|
|
40 |
|
|
//--------------------------------------------------------------------------------------------------
|
41 |
|
|
void FillerBeamSpot::FillDataBlock(const edm::Event &event,
|
42 |
|
|
const edm::EventSetup &setup)
|
43 |
|
|
{
|
44 |
|
|
// Fill the BeamSpot branch.
|
45 |
|
|
|
46 |
loizides |
1.2 |
beamSpots_->Delete();
|
47 |
|
|
|
48 |
bendavid |
1.1 |
Handle<reco::BeamSpot> hBeamSpotProduct;
|
49 |
|
|
GetProduct(edmName_, hBeamSpotProduct, event);
|
50 |
|
|
const reco::BeamSpot *inBeamSpot = hBeamSpotProduct.product();
|
51 |
|
|
|
52 |
loizides |
1.2 |
mithep::BeamSpot *bs = beamSpots_->AddNew();
|
53 |
|
|
bs->SetErrors(inBeamSpot->x0Error(),inBeamSpot->y0Error(),inBeamSpot->z0Error());
|
54 |
|
|
bs->SetPosition(inBeamSpot->x0(),inBeamSpot->y0(),inBeamSpot->z0());
|
55 |
bendavid |
1.1 |
}
|