CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalLedAnalyzer.cc
Go to the documentation of this file.
3 
5 //#include "CondTools/Hcal/interface/HcalDbTool.h"
7 
8 
9 
10 namespace {
11  bool defaultsFile (const std::string fParam) {
12  return fParam == "defaults";
13  }
14 
15  bool asciiFile (const std::string fParam) {
16  return fParam.find (':') == std::string::npos && std::string (fParam, fParam.length () - 4) == ".txt";
17  }
18 
19  bool xmlFile (const std::string fParam) {
20  return fParam.find (':') == std::string::npos && std::string (fParam, fParam.length () - 4) == ".xml";
21  }
22 
23  bool dbFile (const std::string fParam) {
24  return fParam.find (':') != std::string::npos;
25  }
26 
27  template <class T>
28  bool getObject (T* fObject, const std::string& fDb, const std::string& fTag, int fRun) {
29  if (!fObject) return false;
30  if (fDb.empty ()) return false;
31  if (asciiFile (fDb)) {
32  std::cout << "HcalLedAnalyzer-> USE INPUT: ASCII " << std::endl;
33  std::ifstream stream (fDb.c_str ());
34  HcalDbASCIIIO::getObject (stream, fObject);
35  return true;
36  }
37  else if (dbFile (fDb)) {
38  std::cout << "HcalLedAnalyzer-> USE INPUT: Pool " << fDb << std::endl;
39  std::cout << "HcalPedestalAnalyzer-> Pool interface is not supportet since 1.3.0" << fDb << std::endl;
40  return false;
41 // HcalDbTool poolDb (fDb);
42 // return poolDb.getObject (fObject, fTag, fRun);
43  }
44  else {
45  std::cerr << "HcalLedAnalyzer-> Unknown input type " << fDb << std::endl;
46  return false;
47  }
48  }
49 
50 }
51 
53  m_ledAnal = new HcalLedAnalysis(ps);
54  m_ledAnal->LedSetup(ps.getUntrackedParameter<std::string>("outputFileHist", "HcalLedAnalyzer.root"));
55 // m_startSample = ps.getUntrackedParameter<int>("firstSample", 0);
56 // m_endSample = ps.getUntrackedParameter<int>("lastSample", 19);
57  m_inputPedestals_source = ps.getUntrackedParameter<std::string>("inputPedestalsSource", "");
58  m_inputPedestals_tag = ps.getUntrackedParameter<std::string>("inputPedsTag", "");
59  m_inputPedestals_run = ps.getUntrackedParameter<int>("inputPedsRun", 1);
60 
61  // CORAL required variables to be set, even if not needed
62  const char* foo1 = "CORAL_AUTH_USER=blah";
63  const char* foo2 = "CORAL_AUTH_PASSWORD=blah";
64  if (!::getenv("CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1));
65  if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2));
66 }
67 
69 // delete m_ledAnal;
70 }
71 
73  m_ievt = 0;
74  led_sample = 1;
75  HcalPedestals* inputPeds=0;
76 // get pedestals
77  if (!m_inputPedestals_source.empty ()) {
78  inputPeds = new HcalPedestals ();
80  std::cerr << "HcalLedAnalyzer-> Failed to get pedestal values" << std::endl;
81  }
82  //m_ledAnal->doPeds(inputPeds);
83  delete inputPeds;
84  }
85 }
86 
88  m_ledAnal->LedDone();
89  std::cout<<"Getting out"<<std::endl;
90 }
91 
92 void HcalLedAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& eventSetup){
93 
94  m_ievt++;
95 
100 
101  // get calib digis
103 
104  // get testbeam specific laser info from the TDC. This probably will not work
105  // outside of the testbeam, but it should be easy to modify the Handle/getByType
106  // to get the correct stuff
107 
108  //edm::Handle<HcalTBTiming> timing; e.getByType(timing);
109 
110  // get conditions
111  edm::ESHandle<HcalDbService> conditions;
112  eventSetup.get<HcalDbRecord>().get(conditions);
113 
114 // int runNumber = e.id().run();
115 // m_ledAnal->processLedEvent(*hbhe, *ho, *hf, *calib, *conditions, *runNumber);
116 
117  m_ledAnal->processLedEvent(*hbhe, *ho, *hf, *calib, *conditions);
118 
119 
120  if(m_ievt%1000 == 0)
121  std::cout << "HcalLedAnalyzer: analyzed " << m_ievt << " events" << std::endl;
122 
123  return;
124 }
125 
std::string m_inputPedestals_source
T getUntrackedParameter(std::string const &, T const &) const
HcalLedAnalysis * m_ledAnal
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
Definition: compareHists.cc:44
void LedSetup(const std::string &m_outputFileROOT)
bool defaultsFile(const std::string fParam)
~HcalLedAnalyzer()
Destructor.
void processLedEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection calib, const HcalDbService &cond)
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
HcalLedAnalyzer(const edm::ParameterSet &ps)
Constructor.
bool dbFile(const std::string fParam)
const T & get() const
Definition: EventSetup.h:55
bool xmlFile(const std::string fParam)
bool getObject(std::istream &fInput, HcalPedestals *fObject)
std::string m_inputPedestals_tag
bool asciiFile(const std::string fParam)
tuple cout
Definition: gather_cfg.py:121
long double T