CMS 3D CMS Logo

TPGCheck.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TPGCheck
4 // Class: TPGCheck
5 //
13 //
14 // Original Author: Muriel Cerutti
15 // Created: Thu Oct 26 10:47:17 CEST 2006
16 //
17 
18 // system include files
19 #include <memory>
20 
21 // user include files
27 
30 
31 #include <string>
32 #include <vector>
33 
34 #include "TFile.h"
35 #include "TH1I.h"
36 
37 using namespace edm;
38 using namespace std;
39 
40 //
41 // class declaration
42 //
43 
44 class TPGCheck : public edm::EDAnalyzer {
45 public:
46  explicit TPGCheck(const edm::ParameterSet &);
47  ~TPGCheck() override;
48 
49 private:
50  void beginJob() override;
51  void analyze(const edm::Event &, const edm::EventSetup &) override;
52  void endJob() override;
53 
54  // ----------member data ---------------------------
55  TH1I *ecal_et_[2];
56  TH1I *ecal_tt_[2];
57  TH1I *ecal_fgvb_[2];
58 
59  TFile *histFile_;
62  std::vector<std::string> ecal_parts_;
63  // fix for consumes
65 };
66 
67 //
68 // constructors and destructor
69 //
71  // now do what ever initialization is needed
72 
73  ecal_parts_.push_back("Barrel");
74  ecal_parts_.push_back("Endcap");
75 
76  histFile_ = new TFile("histos.root", "RECREATE");
77  for (unsigned int i = 0; i < 2; ++i) {
78  // Energy
79  char t[30];
80  sprintf(t, "%s_energy", ecal_parts_[i].c_str());
81  ecal_et_[i] = new TH1I(t, "Et", 255, 0, 255);
82 
83  // Trigger Tower flag
84  char titleTTF[30];
85  sprintf(titleTTF, "%s_ttf", ecal_parts_[i].c_str());
86  ecal_tt_[i] = new TH1I(titleTTF, "TTF", 10, 0, 10);
87 
88  // Fain Grain
89  char titleFG[30];
90  sprintf(titleFG, "%s_fgvb", ecal_parts_[i].c_str());
91  ecal_fgvb_[i] = new TH1I(titleFG, "FGVB", 10, 0, 10);
92  }
93 
94  label_ = iConfig.getParameter<std::string>("Label");
95  producer_ = iConfig.getParameter<std::string>("Producer");
96  ecal_tp_token_ = consumes<EcalTrigPrimDigiCollection>(edm::InputTag(label_, producer_));
97 }
98 
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 
103  histFile_->Write();
104  histFile_->Close();
105 }
106 
107 //
108 // member functions
109 //
110 
111 // ------------ method called to for each event ------------
112 void TPGCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
113  // Get input
115  iEvent.getByToken(ecal_tp_token_, tp);
116  for (unsigned int i = 0; i < tp.product()->size(); i++) {
117  EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
118  int subdet = d.id().subDet() - 1;
119  // for endcap, regroup double TP-s that are generated for the 2 interior
120  // rings
121  if (subdet == 0) {
122  ecal_et_[subdet]->Fill(d.compressedEt());
123  } else {
124  if (d.id().ietaAbs() == 27 || d.id().ietaAbs() == 28) {
125  if (i % 2)
126  ecal_et_[subdet]->Fill(d.compressedEt() * 2.);
127  } else
128  ecal_et_[subdet]->Fill(d.compressedEt());
129  }
130  ecal_tt_[subdet]->Fill(d.ttFlag());
131  ecal_fgvb_[subdet]->Fill(d.fineGrain());
132  }
133 }
134 
135 // ------------ method called once each job just before starting event loop
136 // ------------
138 
139 // ------------ method called once each job just after ending the event loop
140 // ------------
142  for (unsigned int i = 0; i < 2; ++i) {
143  ecal_et_[i]->Write();
144  ecal_tt_[i]->Write();
145  ecal_fgvb_[i]->Write();
146  }
147 }
148 
149 // define this as a plug-in
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
TPGCheck::ecal_tp_token_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecal_tp_token_
Definition: TPGCheck.cc:64
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TPGCheck::~TPGCheck
~TPGCheck() override
Definition: TPGCheck.cc:99
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
MakerMacros.h
TPGCheck::endJob
void endJob() override
Definition: TPGCheck.cc:141
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EcalDigiCollections.h
OrderedSet.t
t
Definition: OrderedSet.py:90
TPGCheck::TPGCheck
TPGCheck(const edm::ParameterSet &)
Definition: TPGCheck.cc:70
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TPGCheck::ecal_parts_
std::vector< std::string > ecal_parts_
Definition: TPGCheck.cc:62
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
TPGCheck::producer_
std::string producer_
Definition: TPGCheck.cc:61
TPGCheck::beginJob
void beginJob() override
Definition: TPGCheck.cc:137
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
TPGCheck
Definition: TPGCheck.cc:44
ztail.d
d
Definition: ztail.py:151
ParameterSet.h
TPGCheck::histFile_
TFile * histFile_
Definition: TPGCheck.cc:59
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
TPGCheck::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TPGCheck.cc:112
TPGCheck::label_
std::string label_
Definition: TPGCheck.cc:60