CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTBHodoscopeRawInfoDumper.cc
Go to the documentation of this file.
8 
9 #include <TFile.h>
12 
14 {
15  rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
16  rawInfoProducer_ = ps.getParameter<std::string>("rawInfoProducer");
17  rootfile_ = ps.getUntrackedParameter<std::string>("rootfile","ecalHodoscopeRawInfoPlots.root");
18 }
19 
21 }
22 
23 //========================================================================
24 void
26 //========================================================================
27 
28  char histoName[100];
29  char histoTitle[100];
30 
31  for (int i=0; i<4; i++)
32  {
33  sprintf(histoName,"h_numberOfFiredHits_%d",i);
34  sprintf(histoTitle,"NumberOfFiredHits Plane %d",i);
35  h_numberOfFiredHits_[i]=new TH1F(histoName,histoTitle,10,0.,10.);
36  }
37 
38  for (int i=0; i<4; i++)
39  {
40  sprintf(histoName,"h_firedHits_%d",i);
41  sprintf(histoTitle,"firedHits Plane %d",i);
42  h_firedHits_[i]=new TH1F(histoName,histoTitle,64,-0.5,63.5);
43  }
44 }
45 
46 //========================================================================
47 void
49 //========================================================================
50 
51  TFile f(rootfile_.c_str(),"RECREATE");
52 
53  for (int i=0; i<4; i++)
54  h_numberOfFiredHits_[i]->Write();
55 
56  for (int i=0; i<4; i++)
57  h_firedHits_[i]->Write();
58 
59  f.Close();
60 }
61 
63 {
64  // Get input
65  edm::Handle<EcalTBHodoscopeRawInfo> ecalRawHodoscope;
66  const EcalTBHodoscopeRawInfo* hodoscopeRawInfo = 0;
67  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
68  e.getByLabel( rawInfoProducer_, ecalRawHodoscope);
69  if (!ecalRawHodoscope.isValid()) {
70  edm::LogError("EcalTBHodoscopeRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
71  } else {
72  hodoscopeRawInfo = ecalRawHodoscope.product();
73  }
74 
75  if (hodoscopeRawInfo)
76  for (int i=0; i<4; i++)
77  {
78  std::ostringstream str;
79  str << " Hits " ;
80  std::vector<int> firedHits;
81  h_numberOfFiredHits_[i]->Fill((*hodoscopeRawInfo)[i].numberOfFiredHits());
82  for (int j=0;j<64;j++)
83  if ((*hodoscopeRawInfo)[i][j])
84  {
85  h_firedHits_[i]->Fill(j);
86  firedHits.push_back(j);
87  str << j << " " ;
88  }
89  LogDebug("EcalTBHodoscope") << "Looking plane " << i << " number of hits " << (*hodoscopeRawInfo)[i].numberOfFiredHits() << str.str();
90  }
91  // Create empty output
92 }
93 
94 
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
EcalTBHodoscopeRawInfoDumper(const edm::ParameterSet &ps)
int j
Definition: DBlmapReader.cc:9
double f[11][100]
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T const * product() const
Definition: Handle.h:74