File indexing completed on 2024-04-06 11:58:02
0001 #ifndef CalibCalorimetry_EcalTrivialCondModules_EcaLaserCondTools_h
0002 #define CalibCalorimetry_EcalTrivialCondModules_EcaLaserCondTools_h
0003
0004
0005
0006
0007
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0013 #include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatios.h"
0014 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRcd.h"
0015
0016 #include "DataFormats/DetId/interface/DetId.h"
0017
0018 #include <cstdio>
0019 #include <ctime>
0020 #include <string>
0021 #include <vector>
0022
0023
0024 class EcalLaserCondTools : public edm::one::EDAnalyzer<> {
0025
0026
0027
0028
0029 static constexpr int nLmes = 92;
0030
0031
0032 public:
0033
0034
0035
0036 EcalLaserCondTools(const edm::ParameterSet&);
0037
0038
0039
0040 ~EcalLaserCondTools() override;
0041
0042
0043
0044
0045
0046 void analyze(const edm::Event& evt, const edm::EventSetup& es) override;
0047 void from_hdf_to_db();
0048
0049 private:
0050 static std::string toNth(int n);
0051 static std::string timeToString(time_t t);
0052 class CorrReader {
0053 public:
0054 CorrReader() : verb_(0) {}
0055 virtual bool readTime(int& t1, int t2[nLmes], int& t3) { return false; }
0056 virtual bool readPs(DetId& rawdetid, EcalLaserAPDPNRatios::EcalLaserAPDPNpair& corr) { return false; }
0057 virtual ~CorrReader() {}
0058 void setVerbosity(int verb) { verb_ = verb; }
0059
0060 protected:
0061 int verb_;
0062 };
0063
0064 class FileReader : public EcalLaserCondTools::CorrReader {
0065 public:
0066 FileReader(const std::vector<std::string>& fnames) : f_(nullptr), fnames_(fnames), ifile_(-1), iline_(0) {}
0067 bool readTime(int& t1, int t2[EcalLaserCondTools::nLmes], int& t3) override;
0068 bool readPs(DetId& rawdetid, EcalLaserAPDPNRatios::EcalLaserAPDPNpair& corr) override;
0069 ~FileReader() override {}
0070
0071 private:
0072 bool nextFile();
0073 void trim();
0074 FILE* f_;
0075 std::vector<std::string> fnames_;
0076 unsigned ifile_;
0077 int iline_;
0078 };
0079
0080 private:
0081 void fillDb(CorrReader& r);
0082 void dbToAscii(const edm::EventSetup& es);
0083 void processIov(CorrReader& r, int t1, int t2[nLmes], int t3);
0084
0085
0086 private:
0087 edm::ESGetToken<EcalLaserAPDPNRatios, EcalLaserAPDPNRatiosRcd> laserAPDPNRatiosToken_;
0088 FILE* fout_;
0089 FILE* eventList_;
0090 std::string eventListFileName_;
0091 int verb_;
0092 std::string mode_;
0093 std::vector<std::string> fnames_;
0094 edm::Service<cond::service::PoolDBOutputService> db_;
0095 int skipIov_;
0096 int nIovs_;
0097 int fromTime_;
0098 int toTime_;
0099 double minP_, maxP_;
0100 FILE* ferr_;
0101 };
0102
0103 #endif