CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BigEventsDebugger.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: BigEventsDebugger
4 // Class: BigEventsDebugger
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Sun Nov 16 16:04:44 CET 2008
16 // $Id: BigEventsDebugger.cc,v 1.2 2012/12/05 21:51:54 venturia Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
31 
33 
34 #include <vector>
35 #include "TH1F.h"
36 #include "TH2F.h"
37 #include "TProfile.h"
38 
40 
43 
49 
51 
52 //
53 // class decleration
54 //
55 
56 template <class T>
58  public:
59  explicit BigEventsDebugger(const edm::ParameterSet&);
61 
62 
63  private:
64  virtual void beginJob(const edm::EventSetup&) ;
65  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
66  virtual void endJob() override ;
67 
68  // ----------member data ---------------------------
69 
73  bool m_folded;
77 
78  std::vector<std::string> m_labels;
79  std::vector<TH1F*> m_hist;
80  std::vector<TProfile*> m_hprof;
81  std::vector<TH2F*> m_hist2d;
82 
83 };
84 
85 //
86 // constants, enums and typedefs
87 //
88 
89 //
90 // static data member definitions
91 //
92 
93 //
94 // constructors and destructor
95 //
96 template <class T>
98  m_digiprofiler(iConfig),
99  m_collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collection"))),
100  m_singleevents(iConfig.getParameter<bool>("singleEvents")),
101  m_folded(iConfig.getUntrackedParameter<bool>("foldedStrips",false)),
102  m_want1dHisto(iConfig.getUntrackedParameter<bool>("want1dHisto",true)),
103  m_wantProfile(iConfig.getUntrackedParameter<bool>("wantProfile",true)),
104  m_want2dHisto(iConfig.getUntrackedParameter<bool>("want2dHisto",false))
105 
106 {
107  //now do what ever initialization is needed
108 
109  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
110 
111  for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
112  m_labels.push_back(selconfig->getParameter<std::string>("label"));
113  }
114 
115 
117 
118  if(!m_singleevents) {
119  char dirname[500];
120  sprintf(dirname,"Summary");
121  TFileDirectory subd = tfserv->mkdir(dirname);
122 
123  //book histos
124 
125  unsigned int nbins =768;
126  if(m_folded) nbins=256;
127 
128  for(std::vector<std::string>::const_iterator label=m_labels.begin(); label!=m_labels.end(); ++label) {
129  if(m_want1dHisto) {
130  std::string hname = *label + "hist";
131  std::string htitle = *label + " occupancy";
132  m_hist.push_back(subd.make<TH1F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
133  }
134  if(m_wantProfile) {
135  std::string hname = *label + "prof";
136  std::string htitle = *label + " charge profile";
137  m_hprof.push_back(subd.make<TProfile>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
138  }
139  if(m_want2dHisto) {
140  std::string hname = *label + "hist2d";
141  std::string htitle = *label + " charge distribution";
142  m_hist2d.push_back(subd.make<TH2F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5,257,-0.5,256.5));
143  }
144  }
145  }
146 }
147 
148 template <class T>
150 {
151 
152 
153  // do anything here that needs to be done at desctruction time
154  // (e.g. close files, deallocate resources etc.)
155 
156 }
157 
158 
159 //
160 // member functions
161 //
162 
163 // ------------ method called to for each event ------------
164 template <class T>
165 void
167 {
168  using namespace edm;
169 
171 
172  // create a folder for each event
173 
174  if(m_singleevents) {
175 
176  m_hist.clear(); m_hprof.clear(); m_hist2d.clear();
177 
178  char dirname[500];
179  sprintf(dirname,"event_%u_%llu",iEvent.run(),iEvent.id().event());
180  TFileDirectory subd = tfserv->mkdir(dirname);
181 
182  //book histos
183 
184  unsigned int nbins =768;
185  if(m_folded) nbins=256;
186 
187  for(std::vector<std::string>::const_iterator label=m_labels.begin(); label!=m_labels.end(); ++label) {
188  if(m_want1dHisto) {
189  std::string hname = *label + "hist";
190  std::string htitle = *label + " occupancy";
191  m_hist.push_back(subd.make<TH1F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
192  }
193  if(m_wantProfile) {
194  std::string hname = *label + "prof";
195  std::string htitle = *label + " charge profile";
196  m_hprof.push_back(subd.make<TProfile>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
197  }
198  if(m_want2dHisto) {
199  std::string hname = *label + "hist2d";
200  std::string htitle = *label + " charge distribution";
201  m_hist2d.push_back(subd.make<TH2F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5,257,-0.5,256.5));
202  }
203  }
204 
205  }
206 
207  //analyze event
208 
209  Handle<T> digis;
210  iEvent.getByToken(m_collectionToken,digis);
211  m_digiprofiler.fill(digis,m_hist,m_hprof,m_hist2d);
212 
213 }
214 
215 
216 // ------------ method called once each job just before starting event loop ------------
217 template <class T>
218 void
220 {
221 }
222 
223 // ------------ method called once each job just after ending the event loop ------------
224 template <class T>
225 void
227 }
228 
232 
233 //define this as a plug-in
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
virtual void beginJob()
Definition: EDAnalyzer.h:72
std::vector< TH1F * > m_hist
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< TH2F * > m_hist2d
BigEventsDebugger< edm::DetSetVector< SiStripDigi > > DigiBigEventsDebugger
int iEvent
Definition: GenABIO.cc:230
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
DigiCollectionProfiler< T > m_digiprofiler
std::vector< TProfile * > m_hprof
RunNumber_t run() const
Definition: Event.h:92
T * make(const Args &...args) const
make new ROOT object
BigEventsDebugger(const edm::ParameterSet &)
edm::EDGetTokenT< T > m_collectionToken
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
edm::EventID id() const
Definition: EventBase.h:60
std::vector< std::string > m_labels
volatile std::atomic< bool > shutdown_flag false
long double T
BigEventsDebugger< edm::DetSetVector< SiStripRawDigi > > RawDigiBigEventsDebugger
BigEventsDebugger< edmNew::DetSetVector< SiStripCluster > > ClusterBigEventsDebugger
virtual void endJob() override