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  hbheDigiCollectionTag_(ps.getParameter<edm::InputTag>("hbheDigiCollectionTag")),
54  hoDigiCollectionTag_(ps.getParameter<edm::InputTag>("hoDigiCollectionTag")),
55  hfDigiCollectionTag_(ps.getParameter<edm::InputTag>("hfDigiCollectionTag")),
56  hcalCalibDigiCollectionTag_ (ps.getParameter<edm::InputTag>("hcalCalibDigiCollectionTag")) {
57 
58  m_ledAnal = new HcalLedAnalysis(ps);
59  m_ledAnal->LedSetup(ps.getUntrackedParameter<std::string>("outputFileHist", "HcalLedAnalyzer.root"));
60 // m_startSample = ps.getUntrackedParameter<int>("firstSample", 0);
61 // m_endSample = ps.getUntrackedParameter<int>("lastSample", 19);
62  m_inputPedestals_source = ps.getUntrackedParameter<std::string>("inputPedestalsSource", "");
63  m_inputPedestals_tag = ps.getUntrackedParameter<std::string>("inputPedsTag", "");
64  m_inputPedestals_run = ps.getUntrackedParameter<int>("inputPedsRun", 1);
65 
66  // CORAL required variables to be set, even if not needed
67  const char* foo1 = "CORAL_AUTH_USER=blah";
68  const char* foo2 = "CORAL_AUTH_PASSWORD=blah";
69  if (!::getenv("CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1));
70  if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2));
71 }
72 
74 // delete m_ledAnal;
75 }
76 
78  m_ievt = 0;
79  led_sample = 1;
80 }
81 
83  m_ledAnal->LedDone();
84  std::cout<<"Getting out"<<std::endl;
85 }
86 
87 void HcalLedAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& eventSetup){
88 
89  m_ievt++;
90 
95 
96  // get calib digis
98 
99  // get testbeam specific laser info from the TDC. This probably will not work
100  // outside of the testbeam, but it should be easy to modify the Handle/getByType
101  // to get the correct stuff
102 
103  //edm::Handle<HcalTBTiming> timing; e.getByType(timing);
104 
105  // get conditions
106  edm::ESHandle<HcalDbService> conditions;
107  eventSetup.get<HcalDbRecord>().get(conditions);
108 
109 // int runNumber = e.id().run();
110 // m_ledAnal->processLedEvent(*hbhe, *ho, *hf, *calib, *conditions, *runNumber);
111 
112  m_ledAnal->processLedEvent(*hbhe, *ho, *hf, *calib, *conditions);
113 
114 
115  if(m_ievt%1000 == 0)
116  std::cout << "HcalLedAnalyzer: analyzed " << m_ievt << " events" << std::endl;
117 
118  return;
119 }
120 
std::string m_inputPedestals_source
T getUntrackedParameter(std::string const &, T const &) const
HcalLedAnalysis * m_ledAnal
edm::InputTag hfDigiCollectionTag_
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)
edm::InputTag hbheDigiCollectionTag_
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
HcalLedAnalyzer(const edm::ParameterSet &ps)
Constructor.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool dbFile(const std::string fParam)
edm::InputTag hoDigiCollectionTag_
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
edm::InputTag hcalCalibDigiCollectionTag_
long double T