1 |
bendavid |
1.4 |
// $Id: FillerPileupInfo.cc,v 1.3 2011/03/25 16:52:16 bendavid Exp $
|
2 |
mzanetti |
1.1 |
|
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 |
bendavid |
1.3 |
std::vector<PileupSummaryInfo> inInfos;
|
50 |
|
|
|
51 |
mzanetti |
1.2 |
Handle<std::vector< PileupSummaryInfo > > hPileupInfoProduct;
|
52 |
|
|
event.getByLabel(edmName_, hPileupInfoProduct);
|
53 |
bendavid |
1.3 |
if (hPileupInfoProduct.isValid()) {
|
54 |
|
|
inInfos = *hPileupInfoProduct.product();
|
55 |
bendavid |
1.4 |
//printf("got vector of puinfo\n");
|
56 |
bendavid |
1.3 |
}
|
57 |
|
|
else {
|
58 |
|
|
Handle<PileupSummaryInfo> hSinglePileupInfoProduct;
|
59 |
|
|
event.getByLabel(edmName_, hSinglePileupInfoProduct);
|
60 |
|
|
inInfos.push_back(*hSinglePileupInfoProduct.product());
|
61 |
|
|
}
|
62 |
mzanetti |
1.1 |
|
63 |
bendavid |
1.3 |
for (std::vector<PileupSummaryInfo>::const_iterator edmPUInfo = inInfos.begin(); edmPUInfo != inInfos.end(); ++edmPUInfo) {
|
64 |
bendavid |
1.4 |
//printf("filling puinfo for bx %i with %i interactions\n",edmPUInfo->getBunchCrossing(), edmPUInfo->getPU_NumInteractions());
|
65 |
|
|
//printf("vector sizes: %i, %i, %i, %i, %i\n",int(edmPUInfo->getPU_zpositions().size()),int(edmPUInfo->getPU_sumpT_lowpT().size()),int(edmPUInfo->getPU_sumpT_highpT().size()),int(edmPUInfo->getPU_ntrks_lowpT().size()),int(edmPUInfo->getPU_ntrks_highpT().size()));
|
66 |
mzanetti |
1.2 |
mithep::PileupInfo *puInfo = puInfos_->AddNew();
|
67 |
mzanetti |
1.1 |
|
68 |
mzanetti |
1.2 |
puInfo->SetBunchCrossing(edmPUInfo->getBunchCrossing());
|
69 |
|
|
puInfo->SetPU_NumInteractions(edmPUInfo->getPU_NumInteractions());
|
70 |
|
|
for(int i=0; i<edmPUInfo->getPU_NumInteractions(); i++){
|
71 |
bendavid |
1.4 |
//printf("filling interaction %i\n",i);
|
72 |
|
|
if (uint(i)<edmPUInfo->getPU_zpositions().size()) puInfo->PushPU_zPositions(Double32_t(edmPUInfo->getPU_zpositions()[i])); else puInfo->PushPU_zPositions(-99);
|
73 |
|
|
if (uint(i)<edmPUInfo->getPU_sumpT_lowpT().size()) puInfo->PushPU_sumpT_lowpT(Double32_t(edmPUInfo->getPU_sumpT_lowpT()[i])); else puInfo->PushPU_sumpT_lowpT(-99);
|
74 |
|
|
if (uint(i)<edmPUInfo->getPU_sumpT_highpT().size()) puInfo->PushPU_sumpT_highpT(Double32_t(edmPUInfo->getPU_sumpT_highpT()[i])); else puInfo->PushPU_sumpT_highpT(-99);
|
75 |
|
|
if (uint(i)<edmPUInfo->getPU_ntrks_lowpT().size()) puInfo->PushPU_ntrks_lowpT(Double32_t(edmPUInfo->getPU_ntrks_lowpT()[i])); else puInfo->PushPU_ntrks_lowpT(-99);
|
76 |
|
|
if (uint(i)<edmPUInfo->getPU_ntrks_highpT().size()) puInfo->PushPU_ntrks_highpT(Double32_t(edmPUInfo->getPU_ntrks_highpT()[i])); else puInfo->PushPU_ntrks_highpT(-99);
|
77 |
mzanetti |
1.2 |
}
|
78 |
mzanetti |
1.1 |
}
|
79 |
mzanetti |
1.2 |
|
80 |
mzanetti |
1.1 |
puInfos_->Trim();
|
81 |
|
|
}
|