CMS 3D CMS Logo

EcalTBHodoscopeRawInfoDumper.cc
Go to the documentation of this file.
7 
8 #include <TFile.h>
11 
13  rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
14  rawInfoProducer_ = ps.getParameter<std::string>("rawInfoProducer");
15  rootfile_ = ps.getUntrackedParameter<std::string>("rootfile", "ecalHodoscopeRawInfoPlots.root");
16 }
17 
19 
20 //========================================================================
22  //========================================================================
23 
24  char histoName[100];
25  char histoTitle[100];
26 
27  for (int i = 0; i < 4; i++) {
28  sprintf(histoName, "h_numberOfFiredHits_%d", i);
29  sprintf(histoTitle, "NumberOfFiredHits Plane %d", i);
30  h_numberOfFiredHits_[i] = new TH1F(histoName, histoTitle, 10, 0., 10.);
31  }
32 
33  for (int i = 0; i < 4; i++) {
34  sprintf(histoName, "h_firedHits_%d", i);
35  sprintf(histoTitle, "firedHits Plane %d", i);
36  h_firedHits_[i] = new TH1F(histoName, histoTitle, 64, -0.5, 63.5);
37  }
38 }
39 
40 //========================================================================
42  //========================================================================
43 
44  TFile f(rootfile_.c_str(), "RECREATE");
45 
46  for (int i = 0; i < 4; i++)
47  h_numberOfFiredHits_[i]->Write();
48 
49  for (int i = 0; i < 4; i++)
50  h_firedHits_[i]->Write();
51 
52  f.Close();
53 }
54 
56  // Get input
57  edm::Handle<EcalTBHodoscopeRawInfo> ecalRawHodoscope;
58  const EcalTBHodoscopeRawInfo* hodoscopeRawInfo = nullptr;
59  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
60  e.getByLabel(rawInfoProducer_, ecalRawHodoscope);
61  if (!ecalRawHodoscope.isValid()) {
62  edm::LogError("EcalTBHodoscopeRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str();
63  } else {
64  hodoscopeRawInfo = ecalRawHodoscope.product();
65  }
66 
67  if (hodoscopeRawInfo)
68  for (int i = 0; i < 4; i++) {
69  std::ostringstream str;
70  str << " Hits ";
71  std::vector<int> firedHits;
72  h_numberOfFiredHits_[i]->Fill((*hodoscopeRawInfo)[i].numberOfFiredHits());
73  for (int j = 0; j < 64; j++)
74  if ((*hodoscopeRawInfo)[i][j]) {
75  h_firedHits_[i]->Fill(j);
76  firedHits.push_back(j);
77  str << j << " ";
78  }
79  LogDebug("EcalTBHodoscope") << "Looking plane " << i << " number of hits "
80  << (*hodoscopeRawInfo)[i].numberOfFiredHits() << str.str();
81  }
82  // Create empty output
83 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void analyze(const edm::Event &, const edm::EventSetup &) override
T const * product() const
Definition: Handle.h:70
EcalTBHodoscopeRawInfoDumper(const edm::ParameterSet &ps)
Log< level::Error, false > LogError
T getUntrackedParameter(std::string const &, T const &) const
double f[11][100]
bool isValid() const
Definition: HandleBase.h:70
#define str(s)
#define LogDebug(id)