1 |
mzanetti |
1.1 |
// $Id: FillerPileupInfo.cc,v 1.5 2010/03/18 20:21:00 bendavid Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerPileupInfo.h"
|
4 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
|
7 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
8 |
|
|
#include "MitAna/DataTree/interface/PileupInfoCol.h"
|
9 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
10 |
|
|
|
11 |
|
|
using namespace std;
|
12 |
|
|
using namespace edm;
|
13 |
|
|
using namespace mithep;
|
14 |
|
|
|
15 |
|
|
//--------------------------------------------------------------------------------------------------
|
16 |
|
|
FillerPileupInfo::FillerPileupInfo(const ParameterSet &cfg, const char *name, bool active) :
|
17 |
|
|
BaseFiller(cfg,name,active),
|
18 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","addPileupInfo")),
|
19 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPileupInfoBrn)),
|
20 |
|
|
puInfos_(new mithep::PileupInfoArr)
|
21 |
|
|
{
|
22 |
|
|
// Constructor.
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
//--------------------------------------------------------------------------------------------------
|
26 |
|
|
FillerPileupInfo::~FillerPileupInfo()
|
27 |
|
|
{
|
28 |
|
|
// Destructor.
|
29 |
|
|
|
30 |
|
|
delete puInfos_;
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
//--------------------------------------------------------------------------------------------------
|
34 |
|
|
void FillerPileupInfo::BookDataBlock(TreeWriter &tws)
|
35 |
|
|
{
|
36 |
|
|
// Add pileup branch to tree.
|
37 |
|
|
tws.AddBranch(mitName_,&puInfos_);
|
38 |
|
|
OS()->add<mithep::PileupInfoArr>(puInfos_,mitName_);
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
//--------------------------------------------------------------------------------------------------
|
42 |
|
|
void FillerPileupInfo::FillDataBlock(const edm::Event &event,
|
43 |
|
|
const edm::EventSetup &setup)
|
44 |
|
|
{
|
45 |
|
|
// Fill missing energy from edm collection into our collection.
|
46 |
|
|
|
47 |
|
|
puInfos_->Delete();
|
48 |
|
|
|
49 |
|
|
Handle<PileupSummaryInfo> hPileupInfoProduct;
|
50 |
|
|
GetProduct(edmName_, hPileupInfoProduct, event);
|
51 |
|
|
|
52 |
|
|
mithep::PileupInfo *puInfo = puInfos_->AddNew();
|
53 |
|
|
|
54 |
|
|
puInfo->SetPU_NumInteractions(hPileupInfoProduct->getPU_NumInteractions());
|
55 |
|
|
|
56 |
|
|
for(int i=0; i<hPileupInfoProduct->getPU_NumInteractions(); i++){
|
57 |
|
|
puInfo->PushPU_zPositions(Double32_t(hPileupInfoProduct->getPU_zpositions()[i]));
|
58 |
|
|
puInfo->PushPU_sumpT_lowpT(Double32_t(hPileupInfoProduct->getPU_sumpT_lowpT()[i]));
|
59 |
|
|
puInfo->PushPU_sumpT_highpT(Double32_t(hPileupInfoProduct->getPU_sumpT_highpT()[i]));
|
60 |
|
|
puInfo->PushPU_ntrks_lowpT(Double32_t(hPileupInfoProduct->getPU_ntrks_lowpT()[i]));
|
61 |
|
|
puInfo->PushPU_ntrks_highpT(Double32_t(hPileupInfoProduct->getPU_ntrks_highpT()[i]));
|
62 |
|
|
}
|
63 |
|
|
puInfos_->Trim();
|
64 |
|
|
}
|