ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPileupInfo.cc
Revision: 1.5
Committed: Sat Oct 22 15:05:28 2011 UTC (13 years, 6 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, HEAD
Branch point for: Mit_025c_branch
Changes since 1.4: +2 -1 lines
Error occurred while calculating annotation data.
Log Message:
add poisson mean to pileupinfo

File Contents

# Content
1 // $Id: FillerPileupInfo.cc,v 1.4 2011/06/15 20:01:55 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 std::vector<PileupSummaryInfo> inInfos;
50
51 Handle<std::vector< PileupSummaryInfo > > hPileupInfoProduct;
52 event.getByLabel(edmName_, hPileupInfoProduct);
53 if (hPileupInfoProduct.isValid()) {
54 inInfos = *hPileupInfoProduct.product();
55 //printf("got vector of puinfo\n");
56 }
57 else {
58 Handle<PileupSummaryInfo> hSinglePileupInfoProduct;
59 event.getByLabel(edmName_, hSinglePileupInfoProduct);
60 inInfos.push_back(*hSinglePileupInfoProduct.product());
61 }
62
63 for (std::vector<PileupSummaryInfo>::const_iterator edmPUInfo = inInfos.begin(); edmPUInfo != inInfos.end(); ++edmPUInfo) {
64 //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 mithep::PileupInfo *puInfo = puInfos_->AddNew();
67
68 puInfo->SetBunchCrossing(edmPUInfo->getBunchCrossing());
69 puInfo->SetPU_NumInteractions(edmPUInfo->getPU_NumInteractions());
70 puInfo->SetPU_NumMean(edmPUInfo->getTrueNumInteractions());
71 for(int i=0; i<edmPUInfo->getPU_NumInteractions(); i++){
72 //printf("filling interaction %i\n",i);
73 if (uint(i)<edmPUInfo->getPU_zpositions().size()) puInfo->PushPU_zPositions(Double32_t(edmPUInfo->getPU_zpositions()[i])); else puInfo->PushPU_zPositions(-99);
74 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);
75 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);
76 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);
77 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);
78 }
79 }
80
81 puInfos_->Trim();
82 }