CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
StoreESCondition Class Reference

#include <StoreESCondition.h>

Inheritance diagram for StoreESCondition:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void endJob () override
 
std::shared_ptr< ESChannelStatusreadESChannelStatusFromFile (const char *)
 
std::shared_ptr< ESEEIntercalibConstantsreadESEEIntercalibConstantsFromFile (const char *)
 
std::shared_ptr< ESGainreadESGainFromFile (const char *)
 
std::shared_ptr< ESIntercalibConstantsreadESIntercalibConstantsFromFile (const char *)
 
std::shared_ptr< ESMissingEnergyCalibrationreadESMissingEnergyFromFile (const char *)
 
std::shared_ptr< ESPedestalsreadESPedestalsFromFile (const char *)
 
std::shared_ptr< ESRecHitRatioCutsreadESRecHitRatioCutsFromFile (const char *)
 
std::shared_ptr< ESThresholdsreadESThresholdsFromFile (const char *)
 
std::shared_ptr< ESTimeSampleWeightsreadESTimeSampleWeightsFromFile (const char *)
 
 StoreESCondition (const edm::ParameterSet &iConfig)
 
void writeToLogFile (std::string, std::string, unsigned long long)
 
void writeToLogFileResults (char *)
 
 ~StoreESCondition () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void fillHeader (char *)
 
std::string to_string (char value[])
 

Private Attributes

unsigned int esgain_
 
std::vector< std::string > inpFileName_
 
std::vector< std::string > inpFileNameEE_
 
std::string logfile_
 
std::vector< std::string > objectName_
 
std::string prog_name_
 
std::vector< unsigned long long > since_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 31 of file StoreESCondition.h.

Constructor & Destructor Documentation

◆ StoreESCondition()

StoreESCondition::StoreESCondition ( const edm::ParameterSet iConfig)
explicit

Definition at line 17 of file StoreESCondition.cc.

References esgain_, edm::ParameterSet::getParameter(), inpFileName_, logfile_, objectName_, prog_name_, since_, AlCaHLTBitMon_QueryRunRegistry::string, and convertXMLtoSQLite_cfg::toPut.

17  {
18  prog_name_ = "StoreESCondition";
19 
20  logfile_ = iConfig.getParameter<std::string>("logfile");
21 
22  esgain_ = iConfig.getParameter<unsigned int>("gain");
23 
24  typedef std::vector<edm::ParameterSet> Parameters;
25  Parameters toPut = iConfig.getParameter<Parameters>("toPut");
26  for (Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut) {
27  inpFileName_.push_back(itToPut->getUntrackedParameter<std::string>("inputFile"));
28  objectName_.push_back(itToPut->getUntrackedParameter<std::string>("conditionType"));
29  since_.push_back(itToPut->getUntrackedParameter<unsigned int>("since"));
30  }
31 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< unsigned long long > since_
std::string logfile_
std::vector< std::string > inpFileName_
std::vector< std::string > objectName_
unsigned int esgain_
std::vector< AlignmentParameters * > Parameters
Definition: Utilities.h:32
std::string prog_name_

◆ ~StoreESCondition()

StoreESCondition::~StoreESCondition ( )
override

Definition at line 152 of file StoreESCondition.cc.

152 {}

Member Function Documentation

◆ analyze()

void StoreESCondition::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 154 of file StoreESCondition.cc.

154 {}

◆ endJob()

void StoreESCondition::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 33 of file StoreESCondition.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), cond::service::PoolDBOutputService::createOneIOV(), mps_fire::i, inpFileName_, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), objectName_, readESChannelStatusFromFile(), readESEEIntercalibConstantsFromFile(), readESGainFromFile(), readESIntercalibConstantsFromFile(), readESMissingEnergyFromFile(), readESPedestalsFromFile(), readESRecHitRatioCutsFromFile(), readESThresholdsFromFile(), readESTimeSampleWeightsFromFile(), since_, AlCaHLTBitMon_QueryRunRegistry::string, and writeToLogFileResults().

33  {
35  if (!mydbservice.isAvailable()) {
36  edm::LogError("StoreESCondition") << "PoolDBOutputService is unavailable"
37  << "\n";
38  return;
39  }
40 
41  bool toAppend = false;
42  // copy a string to the char *
43  std::string message = "finished OK\n";
44  size_t messageSize = message.size() + 1;
45  char* messChar = new char[messageSize];
46  strncpy(messChar, message.c_str(), messageSize);
47 
48  for (unsigned int i = 0; i < objectName_.size(); i++) {
49  cond::Time_t newTime;
50 
51  if (mydbservice->isNewTagRequest(objectName_[i] + std::string("Rcd"))) {
52  // This is the first object for this tag.
53  // Append mode should be off.
54  // newTime is the end of this new objects IOV.
55  newTime = mydbservice->beginOfTime();
56  } else {
57  // There should already be an object in the DB for this tag.
58  // Append IOV mode should be on.
59  // newTime is the beginning of this new objects IOV.
60  toAppend = true;
61  newTime = (cond::Time_t)since_[i];
62  }
63  edm::LogInfo("StoreESCondition") << "Reading " << objectName_[i] << " from file and writing to DB with newTime "
64  << newTime << "\n";
65  if (objectName_[i] == "ESChannelStatus") {
66  edm::LogInfo("StoreESCondition") << " ESChannelStatus file " << inpFileName_[i] << "\n";
67  const auto mycali = readESChannelStatusFromFile(inpFileName_[i].c_str());
68  edm::LogInfo("StoreESCondition") << " ESChannelStatus file read "
69  << "\n";
70  if (!toAppend) {
71  edm::LogInfo("StoreESCondition") << " before create "
72  << "\n";
73  mydbservice->createOneIOV<ESChannelStatus>(*mycali, newTime, "ESChannelStatusRcd");
74  edm::LogInfo("StoreESCondition") << " after create "
75  << "\n";
76  } else {
77  edm::LogInfo("StoreESCondition") << " before append "
78  << "\n";
79  mydbservice->appendOneIOV<ESChannelStatus>(*mycali, newTime, "ESChannelStatusRcd");
80  edm::LogInfo("StoreESCondition") << " after append "
81  << "\n";
82  }
83  } else if (objectName_[i] == "ESIntercalibConstants") {
84  const auto myintercalib = readESIntercalibConstantsFromFile(inpFileName_[i].c_str());
85  if (!toAppend) {
86  mydbservice->createOneIOV<ESIntercalibConstants>(*myintercalib, newTime, "ESIntercalibConstantsRcd");
87  } else {
88  mydbservice->appendOneIOV<ESIntercalibConstants>(*myintercalib, newTime, "ESIntercalibConstantsRcd");
89  }
90  } else if (objectName_[i] == "ESTimeSampleWeights") {
91  const auto myintercalib = readESTimeSampleWeightsFromFile(inpFileName_[i].c_str());
92  if (!toAppend) {
93  mydbservice->createOneIOV<ESTimeSampleWeights>(*myintercalib, newTime, "ESTimeSampleWeightsRcd");
94  } else {
95  mydbservice->appendOneIOV<ESTimeSampleWeights>(*myintercalib, newTime, "ESTimeSampleWeightsRcd");
96  }
97  } else if (objectName_[i] == "ESGain") {
98  const auto myintercalib = readESGainFromFile(inpFileName_[i].c_str());
99  if (!toAppend) {
100  mydbservice->createOneIOV<ESGain>(*myintercalib, newTime, "ESGainRcd");
101  } else {
102  mydbservice->appendOneIOV<ESGain>(*myintercalib, newTime, "ESGainRcd");
103  }
104  } else if (objectName_[i] == "ESMissingEnergyCalibration") {
105  const auto myintercalib = readESMissingEnergyFromFile(inpFileName_[i].c_str());
106  if (!toAppend) {
107  mydbservice->createOneIOV<ESMissingEnergyCalibration>(*myintercalib, newTime, "ESMissingEnergyCalibrationRcd");
108  } else {
109  mydbservice->appendOneIOV<ESMissingEnergyCalibration>(*myintercalib, newTime, "ESMissingEnergyCalibrationRcd");
110  }
111  } else if (objectName_[i] == "ESRecHitRatioCuts") {
112  const auto myintercalib = readESRecHitRatioCutsFromFile(inpFileName_[i].c_str());
113  if (!toAppend) {
114  mydbservice->createOneIOV<ESRecHitRatioCuts>(*myintercalib, newTime, "ESRecHitRatioCutsRcd");
115  } else {
116  mydbservice->appendOneIOV<ESRecHitRatioCuts>(*myintercalib, newTime, "ESRecHitRatioCutsRcd");
117  }
118  } else if (objectName_[i] == "ESThresholds") {
119  const auto myintercalib = readESThresholdsFromFile(inpFileName_[i].c_str());
120  if (!toAppend) {
121  mydbservice->createOneIOV<ESThresholds>(*myintercalib, newTime, "ESThresholdsRcd");
122  } else {
123  mydbservice->appendOneIOV<ESThresholds>(*myintercalib, newTime, "ESThresholdsRcd");
124  }
125  } else if (objectName_[i] == "ESPedestals") {
126  const auto myintercalib = readESPedestalsFromFile(inpFileName_[i].c_str());
127  if (!toAppend) {
128  mydbservice->createOneIOV<ESPedestals>(*myintercalib, newTime, "ESPedestalsRcd");
129  } else {
130  mydbservice->appendOneIOV<ESPedestals>(*myintercalib, newTime, "ESPedestalsRcd");
131  }
132  } else if (objectName_[i] == "ESEEIntercalibConstants") {
133  const auto myintercalib = readESEEIntercalibConstantsFromFile(inpFileName_[i].c_str());
134  if (!toAppend) {
135  mydbservice->createOneIOV<ESEEIntercalibConstants>(*myintercalib, newTime, "ESEEIntercalibConstantsRcd");
136  } else {
137  mydbservice->appendOneIOV<ESEEIntercalibConstants>(*myintercalib, newTime, "ESEEIntercalibConstantsRcd");
138  }
139  } else {
140  edm::LogError("StoreESCondition") << "Object " << objectName_[i] << " is not supported by this program.";
141  }
142  // if more records write here else if ....
143 
144  writeToLogFileResults(messChar);
145 
146  edm::LogInfo("StoreESCondition") << "Finished endJob";
147  }
148 
149  delete[] messChar;
150 }
std::shared_ptr< ESTimeSampleWeights > readESTimeSampleWeightsFromFile(const char *)
std::shared_ptr< ESGain > readESGainFromFile(const char *)
std::shared_ptr< ESThresholds > readESThresholdsFromFile(const char *)
Definition: ESGain.h:7
std::vector< unsigned long long > since_
Log< level::Error, false > LogError
std::shared_ptr< ESMissingEnergyCalibration > readESMissingEnergyFromFile(const char *)
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
std::vector< std::string > inpFileName_
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
std::shared_ptr< ESRecHitRatioCuts > readESRecHitRatioCutsFromFile(const char *)
std::shared_ptr< ESPedestals > readESPedestalsFromFile(const char *)
std::shared_ptr< ESIntercalibConstants > readESIntercalibConstantsFromFile(const char *)
void writeToLogFileResults(char *)
std::shared_ptr< ESEEIntercalibConstants > readESEEIntercalibConstantsFromFile(const char *)
Log< level::Info, false > LogInfo
std::vector< std::string > objectName_
std::shared_ptr< ESChannelStatus > readESChannelStatusFromFile(const char *)
bool isAvailable() const
Definition: Service.h:40

◆ fillHeader()

void StoreESCondition::fillHeader ( char *  header)
private

Definition at line 190 of file StoreESCondition.cc.

References RecoTauValidation_cfi::header, hcalRecHitTable_cff::time, and EnviromentSettings::user.

Referenced by writeToLogFile(), and writeToLogFileResults().

190  {
191  time_t rawtime;
192  struct tm* timeinfo;
193  time(&rawtime);
194  timeinfo = localtime(&rawtime);
195  char user[50];
196  strcpy(user, getlogin());
197  strcpy(header, asctime(timeinfo));
198  strcpy(header, user);
199 }

◆ readESChannelStatusFromFile()

std::shared_ptr< ESChannelStatus > StoreESCondition::readESChannelStatusFromFile ( const char *  inputFile)

Definition at line 381 of file StoreESCondition.cc.

References beamvalidation::exit(), contentValuesFiles::fullPath, mps_fire::i, makeListRunsInFiles::inputFile, ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, ESDetId::IY_MIN, AlCaHLTBitMon_ParallelJobs::p, mps_update::status, ESDetId::validDetId(), x, y, and z.

Referenced by endJob().

381  {
382  int z[1000], p[1000], x[1000], y[1000], nsensors;
383  std::ifstream statusFile(edm::FileInPath(inputFile).fullPath().c_str());
384  statusFile >> nsensors;
385  edm::LogInfo("StoreESCondition") << " nsensors " << nsensors << "\n";
386  if (nsensors >= 1000) {
387  edm::LogInfo("StoreESCondition") << " *** value too high, modify the method!***"
388  << "\n";
389  exit(-1);
390  }
391  for (int i = 0; i < nsensors; ++i) {
392  statusFile >> z[i] >> p[i] >> x[i] >> y[i];
393  }
394  auto ecalStatus = std::make_shared<ESChannelStatus>();
395  int Nbstatus = 0, Nbstrip = 0;
396  for (int istrip = ESDetId::ISTRIP_MIN; istrip <= ESDetId::ISTRIP_MAX; istrip++) {
397  for (int ix = ESDetId::IX_MIN; ix <= ESDetId::IX_MAX; ix++) {
398  for (int iy = ESDetId::IY_MIN; iy <= ESDetId::IY_MAX; iy++) {
399  for (int iplane = 1; iplane <= 2; iplane++) {
400  for (int izeta = -1; izeta <= 1; izeta = izeta + 2) {
401  // if (izeta==0) continue;
402  // try {
403 
404  //ESDetId Plane iplane Zside izeta
405  // if(!ESDetId::validDetId(istrip,ix,iy,iplane,izeta)) cout << " Unvalid DetId" << endl;
406  // else {
407  if (ESDetId::validDetId(istrip, ix, iy, iplane, izeta)) {
408  ESDetId anESId(istrip, ix, iy, iplane, izeta);
409  int status = 0;
410  // std::ifstream statusFile(edm::FileInPath(inputFile).fullPath().c_str());
411  Nbstrip++;
412  for (int i = 0; i < nsensors; ++i) {
413  if (izeta == z[i] && iplane == p[i] && ix == x[i] && iy == y[i])
414  status = 1;
415  }
416  if (status == 1) {
417  Nbstatus++;
418  if (istrip == 1)
419  edm::LogInfo("StoreESCondition") << " Bad channel ix " << ix << " iy " << iy << " iplane " << iplane
420  << " iz " << izeta << "\n"; // print only once
421  }
422  ecalStatus->setValue(anESId, status);
423  // statusFile.close();
424  } // valid DetId
425  // catch ( cms::Exception &e ) { }
426  } // loop over z
427  } // loop over plane
428  } // loop over y
429  } // loop over x
430  } // loop over strips
431  edm::LogInfo("StoreESCondition") << " Nb of strips " << Nbstrip << " Number of bad channels " << Nbstatus << "\n";
432  statusFile.close();
433 
434  // overwrite the statuses which are in the file
435  return ecalStatus;
436 }
static const int IY_MAX
Definition: ESDetId.h:67
static const int ISTRIP_MAX
Definition: ESDetId.h:69
Log< level::Info, false > LogInfo
static const int IY_MIN
Definition: ESDetId.h:65
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:15
static const int IX_MAX
Definition: ESDetId.h:66
static const int ISTRIP_MIN
Definition: ESDetId.h:68
def exit(msg="")
static const int IX_MIN
Definition: ESDetId.h:64

◆ readESEEIntercalibConstantsFromFile()

std::shared_ptr< ESEEIntercalibConstants > StoreESCondition::readESEEIntercalibConstantsFromFile ( const char *  inputFile)

Definition at line 211 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, and makeListRunsInFiles::inputFile.

Referenced by endJob().

211  {
212  std::ifstream ESEEIntercalibFile(edm::FileInPath(inputFile).fullPath().c_str());
213  float gammaLow0, alphaLow0, gammaHigh0, alphaHigh0, gammaLow1, alphaLow1, gammaHigh1, alphaHigh1, gammaLow2,
214  alphaLow2, gammaHigh2, alphaHigh2, gammaLow3, alphaLow3, gammaHigh3, alphaHigh3;
215  ESEEIntercalibFile >> gammaLow0;
216  ESEEIntercalibFile >> alphaLow0;
217  ESEEIntercalibFile >> gammaHigh0;
218  ESEEIntercalibFile >> alphaHigh0;
219  ESEEIntercalibFile >> gammaLow1;
220  ESEEIntercalibFile >> alphaLow1;
221  ESEEIntercalibFile >> gammaHigh1;
222  ESEEIntercalibFile >> alphaHigh1;
223  ESEEIntercalibFile >> gammaLow2;
224  ESEEIntercalibFile >> alphaLow2;
225  ESEEIntercalibFile >> gammaHigh2;
226  ESEEIntercalibFile >> alphaHigh2;
227  ESEEIntercalibFile >> gammaLow3;
228  ESEEIntercalibFile >> alphaLow3;
229  ESEEIntercalibFile >> gammaHigh3;
230  ESEEIntercalibFile >> alphaHigh3;
231  auto eseeIntercalibConstants = std::make_shared<ESEEIntercalibConstants>(gammaLow0,
232  alphaLow0,
233  gammaHigh0,
234  alphaHigh0,
235  gammaLow1,
236  alphaLow1,
237  gammaHigh1,
238  alphaHigh1,
239  gammaLow2,
240  alphaLow2,
241  gammaHigh2,
242  alphaHigh2,
243  gammaLow3,
244  alphaLow3,
245  gammaHigh3,
246  alphaHigh3);
247 
248  return eseeIntercalibConstants;
249 }

◆ readESGainFromFile()

std::shared_ptr< ESGain > StoreESCondition::readESGainFromFile ( const char *  inputFile)

Definition at line 327 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, PedestalClient_cfi::gain, and makeListRunsInFiles::inputFile.

Referenced by endJob().

327  {
328  std::ifstream amplFile(edm::FileInPath(inputFile).fullPath().c_str());
329 
330  int gain;
331  amplFile >> gain;
332  edm::LogInfo("StoreESCondition") << "gain : " << gain << "\n";
333 
334  auto esGain = std::make_shared<ESGain>(gain); // 1: LG, 2: HG
335  return esGain;
336 }
Log< level::Info, false > LogInfo

◆ readESIntercalibConstantsFromFile()

std::shared_ptr< ESIntercalibConstants > StoreESCondition::readESIntercalibConstantsFromFile ( const char *  inputFile)

Definition at line 353 of file StoreESCondition.cc.

References esgain_, contentValuesFiles::fullPath, mps_fire::i, makeListRunsInFiles::inputFile, DetId::rawId(), and ESDetId::validDetId().

Referenced by endJob().

353  {
354  auto ical = std::make_shared<ESIntercalibConstants>();
355 
356  std::ifstream mipFile(edm::FileInPath(inputFile).fullPath().c_str());
357 
358  for (int i = 0; i < 137216; ++i) {
359  int iz, ip, ix, iy, is;
360  double mip;
361  mipFile >> iz >> ip >> ix >> iy >> is >> mip;
362  //if (mip <20 || mip> 70) cout<<iz<<" "<<ip<<" "<<ix<<" "<<iy<<" "<<is<<" "<<mip<<endl; // HG
363  // LG : HG MIP/6/1.14
364  //mip = mip/6/1.14;
365  // LG : HG MIP/6
366  if (esgain_ == 1)
367  mip = mip / 6.; // LG
368  if (mip < 20 || mip > 70)
369  edm::LogInfo("StoreESCondition") << iz << " " << ip << " " << ix << " " << iy << " " << is << " " << mip
370  << "\n"; // LG
371 
372  if (ESDetId::validDetId(is, ix, iy, ip, iz)) {
373  ESDetId esId(is, ix, iy, ip, iz);
374  ical->setValue(esId.rawId(), mip);
375  }
376  }
377 
378  return ical;
379 }
Log< level::Info, false > LogInfo
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:15
unsigned int esgain_

◆ readESMissingEnergyFromFile()

std::shared_ptr< ESMissingEnergyCalibration > StoreESCondition::readESMissingEnergyFromFile ( const char *  inputFile)

Definition at line 251 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, and makeListRunsInFiles::inputFile.

Referenced by endJob().

251  {
252  std::ifstream ESMissingEnergyFile(edm::FileInPath(inputFile).fullPath().c_str());
253  float ConstAEta0, ConstBEta0, ConstAEta1, ConstBEta1, ConstAEta2, ConstBEta2, ConstAEta3, ConstBEta3;
254  ESMissingEnergyFile >> ConstAEta0;
255  ESMissingEnergyFile >> ConstBEta0;
256  ESMissingEnergyFile >> ConstAEta1;
257  ESMissingEnergyFile >> ConstBEta1;
258  ESMissingEnergyFile >> ConstAEta2;
259  ESMissingEnergyFile >> ConstBEta2;
260  ESMissingEnergyFile >> ConstAEta3;
261  ESMissingEnergyFile >> ConstBEta3;
262  auto esMissingEnergy = std::make_shared<ESMissingEnergyCalibration>(
263  ConstAEta0, ConstBEta0, ConstAEta1, ConstBEta1, ConstAEta2, ConstBEta2, ConstAEta3, ConstBEta3);
264 
265  return esMissingEnergy;
266 }

◆ readESPedestalsFromFile()

std::shared_ptr< ESPedestals > StoreESCondition::readESPedestalsFromFile ( const char *  inputFile)

Definition at line 268 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, mps_fire::i, makeListRunsInFiles::inputFile, ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, ESDetId::IY_MIN, ESDetId::IZ_NUM, ESPedestal::mean, ESDetId::PLANE_MAX, ESDetId::PLANE_MIN, DetId::rawId(), ESPedestal::rms, ESDetId::validDetId(), and ecaldqm::zside().

Referenced by endJob().

268  {
269  auto esPedestals = std::make_shared<ESPedestals>();
270 
271  // int ped[2][2][40][40][32];
272  // for (int i=0; i<2; ++i)
273  // for (int j=0; j<2; ++j)
274  // for (int k=0; k<40; ++k)
275  // for (int m=0; m<40; ++m)
276  // for (int n=0; n<32; ++n)
277  // ped[i][j][k][m][n] = 0;
278 
280 
281  int iz, ip, ix, iy, is, ped_, zside;
282  std::ifstream pedestalFile(edm::FileInPath(inputFile).fullPath().c_str());
283 
284  for (int i = 0; i < 137216; ++i) {
285  pedestalFile >> iz >> ip >> ix >> iy >> is >> ped_;
286 
287  zside = (iz == -1) ? 1 : 0;
288  ped[zside][ip - 1][ix - 1][iy - 1][is - 1] = ped_;
289  }
290 
291  for (int iz = -1; iz <= 1; ++iz) {
292  if (iz == 0)
293  continue;
294  zside = (iz == -1) ? 1 : 0;
295 
296  for (int iplane = ESDetId::PLANE_MIN; iplane <= ESDetId::PLANE_MAX; ++iplane)
297  for (int ix = ESDetId::IX_MIN; ix <= ESDetId::IX_MAX; ++ix)
298  for (int iy = ESDetId::IY_MIN; iy <= ESDetId::IY_MAX; ++iy)
299  for (int istrip = ESDetId::ISTRIP_MIN; istrip <= ESDetId::ISTRIP_MAX; ++istrip) {
300  ESPedestals::Item ESitem;
301  ESitem.mean = ped[zside][iplane - 1][ix - 1][iy - 1][istrip - 1];
302  ESitem.rms = 3; // LG : 3, HG : 6
303 
304  if (ESDetId::validDetId(istrip, ix, iy, iplane, iz)) {
305  ESDetId esId(istrip, ix, iy, iplane, iz);
306  esPedestals->insert(std::make_pair(esId.rawId(), ESitem));
307  }
308  }
309  }
310 
311  return esPedestals;
312 }
static const int IY_MAX
Definition: ESDetId.h:67
int zside(DetId const &)
static const int ISTRIP_MAX
Definition: ESDetId.h:69
static const int PLANE_MIN
Definition: ESDetId.h:70
static const int PLANE_MAX
Definition: ESDetId.h:71
float mean
Definition: ESPedestals.h:16
static const int IY_MIN
Definition: ESDetId.h:65
static const int IZ_NUM
Definition: ESDetId.h:72
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:15
static const int IX_MAX
Definition: ESDetId.h:66
float rms
Definition: ESPedestals.h:17
static const int ISTRIP_MIN
Definition: ESDetId.h:68
static const int IX_MIN
Definition: ESDetId.h:64

◆ readESRecHitRatioCutsFromFile()

std::shared_ptr< ESRecHitRatioCuts > StoreESCondition::readESRecHitRatioCutsFromFile ( const char *  inputFile)

Definition at line 314 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, and makeListRunsInFiles::inputFile.

Referenced by endJob().

314  {
315  std::ifstream ESRecHitRatioCutsFile(edm::FileInPath(inputFile).fullPath().c_str());
316 
317  float r12Low, r23Low, r12High, r23High;
318  ESRecHitRatioCutsFile >> r12Low;
319  ESRecHitRatioCutsFile >> r23Low;
320  ESRecHitRatioCutsFile >> r12High;
321  ESRecHitRatioCutsFile >> r23High;
322  auto esRecHitRatioCuts = std::make_shared<ESRecHitRatioCuts>(r12Low, r23Low, r12High, r23High);
323 
324  return esRecHitRatioCuts;
325 }

◆ readESThresholdsFromFile()

std::shared_ptr< ESThresholds > StoreESCondition::readESThresholdsFromFile ( const char *  inputFile)

Definition at line 201 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, and makeListRunsInFiles::inputFile.

Referenced by endJob().

201  {
202  std::ifstream ESThresholdsFile(edm::FileInPath(inputFile).fullPath().c_str());
203  float ts2, zs; //2nd time sample, ZS threshold
204  ESThresholdsFile >> ts2;
205  ESThresholdsFile >> zs;
206  auto esThresholds = std::make_shared<ESThresholds>(ts2, zs);
207 
208  return esThresholds;
209 }

◆ readESTimeSampleWeightsFromFile()

std::shared_ptr< ESTimeSampleWeights > StoreESCondition::readESTimeSampleWeightsFromFile ( const char *  inputFile)

Definition at line 338 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, makeListRunsInFiles::inputFile, dqmdumpme::k, and w().

Referenced by endJob().

338  {
339  std::ifstream amplFile(edm::FileInPath(inputFile).fullPath().c_str());
340 
341  float w[3];
342  for (int k = 0; k < 3; ++k) {
343  float ww;
344  amplFile >> ww;
345  w[k] = ww;
346  edm::LogInfo("StoreESCondition") << "weight : " << k << " " << w[k] << "\n";
347  }
348 
349  auto esWeights = std::make_shared<ESTimeSampleWeights>(w[0], w[1], w[2]);
350  return esWeights;
351 }
T w() const
Log< level::Info, false > LogInfo

◆ to_string()

std::string StoreESCondition::to_string ( char  value[])
inlineprivate

Definition at line 63 of file StoreESCondition.h.

References relativeConstraints::value.

63  {
64  std::ostringstream streamOut;
65  streamOut << value;
66  return streamOut.str();
67  }

◆ writeToLogFile()

void StoreESCondition::writeToLogFile ( std::string  ,
std::string  ,
unsigned long  long 
)

Definition at line 156 of file StoreESCondition.cc.

References fillHeader(), RecoTauValidation_cfi::header, logfile_, L1TdeCSCTF_cfi::outFile, and SiStripBadComponentsDQMServiceTemplate_cfg::since.

156  {
157  FILE* outFile; // output log file for appending
158  outFile = fopen(logfile_.c_str(), "a");
159  if (!outFile) {
160  edm::LogError("StoreESCondition") << "*** Can not open file: " << logfile_;
161  return;
162  }
163  char header[256];
165  char appendMode[10];
166  if (since != 0)
167  strcpy(appendMode, "append");
168  else
169  strcpy(appendMode, "create");
170 
171  //fprintf(outFile, "%s %s condition from file %s written into DB for SM %d (mapped to SM %d) in %s mode (since run %u)\n",
172  //header, a.c_str(), b.c_str(), appendMode, (unsigned int)since);
173 
174  fclose(outFile); // close out file
175 }
Log< level::Error, false > LogError
std::string logfile_
void fillHeader(char *)

◆ writeToLogFileResults()

void StoreESCondition::writeToLogFileResults ( char *  arg)

Definition at line 177 of file StoreESCondition.cc.

References fillHeader(), RecoTauValidation_cfi::header, logfile_, and L1TdeCSCTF_cfi::outFile.

Referenced by endJob().

177  {
178  FILE* outFile; // output log file for appending
179  outFile = fopen(logfile_.c_str(), "a");
180  if (!outFile) {
181  edm::LogError("StoreESCondition") << "*** Can not open file: " << logfile_;
182  return;
183  }
184  char header[256];
186  fprintf(outFile, "%s %s\n", header, arg);
187  fclose(outFile); // close out file
188 }
Log< level::Error, false > LogError
A arg
Definition: Factorize.h:31
std::string logfile_
void fillHeader(char *)

Member Data Documentation

◆ esgain_

unsigned int StoreESCondition::esgain_
private

Definition at line 61 of file StoreESCondition.h.

Referenced by readESIntercalibConstantsFromFile(), and StoreESCondition().

◆ inpFileName_

std::vector<std::string> StoreESCondition::inpFileName_
private

Definition at line 55 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().

◆ inpFileNameEE_

std::vector<std::string> StoreESCondition::inpFileNameEE_
private

Definition at line 56 of file StoreESCondition.h.

◆ logfile_

std::string StoreESCondition::logfile_
private

Definition at line 59 of file StoreESCondition.h.

Referenced by StoreESCondition(), writeToLogFile(), and writeToLogFileResults().

◆ objectName_

std::vector<std::string> StoreESCondition::objectName_
private

Definition at line 54 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().

◆ prog_name_

std::string StoreESCondition::prog_name_
private

Definition at line 57 of file StoreESCondition.h.

Referenced by StoreESCondition().

◆ since_

std::vector<unsigned long long> StoreESCondition::since_
private

Definition at line 58 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().