CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: TPGCheck.cc,v 1.2 2009/03/27 16:38:31 ebecheva Exp $
17 // $Id: TPGCheck.cc,v 1.2 2009/03/27 16:38:31 ebecheva Exp $
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
30 
33 
34 #include <vector>
35 #include <string>
36 
37 #include "TH1I.h"
38 #include "TFile.h"
39 
40 using namespace edm;
41 using namespace std;
42 
43 //
44 // class declaration
45 //
46 
47 class TPGCheck : public edm::EDAnalyzer {
48  public:
49  explicit TPGCheck(const edm::ParameterSet&);
50  ~TPGCheck();
51 
52 
53  private:
54  virtual void beginJob() ;
55  virtual void analyze(const edm::Event&, const edm::EventSetup&);
56  virtual void endJob() ;
57 
58  // ----------member data ---------------------------
59  TH1I *ecal_et_[2];
60  TH1I *ecal_tt_[2];
61  TH1I * ecal_fgvb_[2];
62 
63  TFile *histFile_;
64  std::string label_;
65  std::string producer_;
66  std::vector<std::string> ecal_parts_;
67 };
68 
69 //
70 // constructors and destructor
71 //
73 {
74  //now do what ever initialization is needed
75 
76  ecal_parts_.push_back("Barrel");
77  ecal_parts_.push_back("Endcap");
78 
79  histFile_=new TFile("histos.root","RECREATE");
80  for (unsigned int i=0;i<2;++i) {
81  // Energy
82  char t[30];
83  sprintf(t,"%s_energy",ecal_parts_[i].c_str());
84  ecal_et_[i]=new TH1I(t,"Et",255,0,255);
85 
86  // Trigger Tower flag
87  char titleTTF[30];
88  sprintf(titleTTF,"%s_ttf",ecal_parts_[i].c_str());
89  ecal_tt_[i]=new TH1I(titleTTF,"TTF",10,0,10);
90 
91  // Fain Grain
92  char titleFG[30];
93  sprintf(titleFG,"%s_fgvb",ecal_parts_[i].c_str());
94  ecal_fgvb_[i]=new TH1I(titleFG,"FGVB",10,0,10);
95  }
96 
97  label_= iConfig.getParameter<std::string>("Label");
98  producer_= iConfig.getParameter<std::string>("Producer");
99 
100 }
101 
102 
104 {
105 
106  // do anything here that needs to be done at desctruction time
107  // (e.g. close files, deallocate resources etc.)
108 
109  histFile_->Write();
110  histFile_->Close();
111 
112 }
113 
114 
115 //
116 // member functions
117 //
118 
119 // ------------ method called to for each event ------------
120 void
122 {
123 
124  // Get input
126  iEvent.getByLabel(label_,producer_,tp);
127  for (unsigned int i=0;i<tp.product()->size();i++) {
128  EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
129  int subdet=d.id().subDet()-1;
130  // for endcap, regroup double TP-s that are generated for the 2 interior rings
131  if (subdet==0) {
132  ecal_et_[subdet]->Fill(d.compressedEt());
133  }
134  else {
135  if (d.id().ietaAbs()==27 || d.id().ietaAbs()==28) {
136  if (i%2) ecal_et_[subdet]->Fill(d.compressedEt()*2.);
137  }
138  else ecal_et_[subdet]->Fill(d.compressedEt());
139  }
140  ecal_tt_[subdet]->Fill(d.ttFlag());
141  ecal_fgvb_[subdet]->Fill(d.fineGrain());
142  }
143 }
144 
145 
146 // ------------ method called once each job just before starting event loop ------------
147 void
149 {
150 }
151 
152 // ------------ method called once each job just after ending the event loop ------------
153 void
155  for (unsigned int i=0;i<2;++i) {
156  ecal_et_[i]->Write();
157  ecal_tt_[i]->Write();
158  ecal_fgvb_[i]->Write();
159  }
160 }
161 
162 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::string label_
Definition: TPGCheck.cc:64
TFile * histFile_
Definition: TPGCheck.cc:63
DEFINE_FWK_MODULE(HiMixingModule)
virtual void beginJob()
Definition: TPGCheck.cc:148
void beginJob()
Definition: Breakpoints.cc:15
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: TPGCheck.cc:121
~TPGCheck()
Definition: TPGCheck.cc:103
int compressedEt() const
get the encoded/compressed Et of interesting sample
int iEvent
Definition: GenABIO.cc:243
int ietaAbs() const
get the absolute value of the tower ieta
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const EcalTrigTowerDetId & id() const
T const * product() const
Definition: Handle.h:74
TPGCheck(const edm::ParameterSet &)
Definition: TPGCheck.cc:72
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
bool fineGrain() const
get the fine-grain bit of interesting sample
std::vector< std::string > ecal_parts_
Definition: TPGCheck.cc:66
std::string producer_
Definition: TPGCheck.cc:65
int ttFlag() const
get the Trigger tower Flag of interesting sample
virtual void endJob()
Definition: TPGCheck.cc:154