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