CMS 3D CMS Logo

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&);
60  ~BigEventsDebugger() override;
61 
62 
63  private:
64  void analyze(const edm::Event&, const edm::EventSetup&) override;
65 
66  // ----------member data ---------------------------
67 
71  bool m_folded;
75 
76  std::vector<std::string> m_labels;
77  std::vector<TH1F*> m_hist;
78  std::vector<TProfile*> m_hprof;
79  std::vector<TH2F*> m_hist2d;
80 
81 };
82 
83 //
84 // constants, enums and typedefs
85 //
86 
87 //
88 // static data member definitions
89 //
90 
91 //
92 // constructors and destructor
93 //
94 template <class T>
96  m_digiprofiler(iConfig),
97  m_collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collection"))),
98  m_singleevents(iConfig.getParameter<bool>("singleEvents")),
99  m_folded(iConfig.getUntrackedParameter<bool>("foldedStrips",false)),
100  m_want1dHisto(iConfig.getUntrackedParameter<bool>("want1dHisto",true)),
101  m_wantProfile(iConfig.getUntrackedParameter<bool>("wantProfile",true)),
102  m_want2dHisto(iConfig.getUntrackedParameter<bool>("want2dHisto",false))
103 
104 {
105  //now do what ever initialization is needed
106 
107  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
108 
109  for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
110  m_labels.push_back(selconfig->getParameter<std::string>("label"));
111  }
112 
113 
115 
116  if(!m_singleevents) {
117  char dirname[500];
118  sprintf(dirname,"Summary");
119  TFileDirectory subd = tfserv->mkdir(dirname);
120 
121  //book histos
122 
123  unsigned int nbins =768;
124  if(m_folded) nbins=256;
125 
126  for(std::vector<std::string>::const_iterator label=m_labels.begin(); label!=m_labels.end(); ++label) {
127  if(m_want1dHisto) {
128  std::string hname = *label + "hist";
129  std::string htitle = *label + " occupancy";
130  m_hist.push_back(subd.make<TH1F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
131  }
132  if(m_wantProfile) {
133  std::string hname = *label + "prof";
134  std::string htitle = *label + " charge profile";
135  m_hprof.push_back(subd.make<TProfile>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
136  }
137  if(m_want2dHisto) {
138  std::string hname = *label + "hist2d";
139  std::string htitle = *label + " charge distribution";
140  m_hist2d.push_back(subd.make<TH2F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5,257,-0.5,256.5));
141  }
142  }
143  }
144 }
145 
146 template <class T>
148 {
149 
150 
151  // do anything here that needs to be done at desctruction time
152  // (e.g. close files, deallocate resources etc.)
153 
154 }
155 
156 
157 //
158 // member functions
159 //
160 
161 // ------------ method called to for each event ------------
162 template <class T>
163 void
165 {
166  using namespace edm;
167 
169 
170  // create a folder for each event
171 
172  if(m_singleevents) {
173 
174  m_hist.clear(); m_hprof.clear(); m_hist2d.clear();
175 
176  char dirname[500];
177  sprintf(dirname,"event_%u_%llu",iEvent.run(),iEvent.id().event());
178  TFileDirectory subd = tfserv->mkdir(dirname);
179 
180  //book histos
181 
182  unsigned int nbins =768;
183  if(m_folded) nbins=256;
184 
185  for(std::vector<std::string>::const_iterator label=m_labels.begin(); label!=m_labels.end(); ++label) {
186  if(m_want1dHisto) {
187  std::string hname = *label + "hist";
188  std::string htitle = *label + " occupancy";
189  m_hist.push_back(subd.make<TH1F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
190  }
191  if(m_wantProfile) {
192  std::string hname = *label + "prof";
193  std::string htitle = *label + " charge profile";
194  m_hprof.push_back(subd.make<TProfile>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5));
195  }
196  if(m_want2dHisto) {
197  std::string hname = *label + "hist2d";
198  std::string htitle = *label + " charge distribution";
199  m_hist2d.push_back(subd.make<TH2F>(hname.c_str(),htitle.c_str(),nbins,-0.5,nbins-0.5,257,-0.5,256.5));
200  }
201  }
202 
203  }
204 
205  //analyze event
206 
207  Handle<T> digis;
208  iEvent.getByToken(m_collectionToken,digis);
210 
211 }
212 
213 
217 
218 //define this as a plug-in
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
std::vector< TH1F * > m_hist
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< TH2F * > m_hist2d
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
~BigEventsDebugger() override
BigEventsDebugger< edm::DetSetVector< SiStripDigi > > DigiBigEventsDebugger
char const * label
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
DigiCollectionProfiler< T > m_digiprofiler
std::vector< TProfile * > m_hprof
RunNumber_t run() const
Definition: Event.h:101
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
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
std::vector< std::string > m_labels
long double T
BigEventsDebugger< edm::DetSetVector< SiStripRawDigi > > RawDigiBigEventsDebugger
BigEventsDebugger< edmNew::DetSetVector< SiStripCluster > > ClusterBigEventsDebugger