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::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void endJob () override
 
ESChannelStatusreadESChannelStatusFromFile (const char *)
 
ESEEIntercalibConstantsreadESEEIntercalibConstantsFromFile (const char *)
 
ESGainreadESGainFromFile (const char *)
 
ESIntercalibConstantsreadESIntercalibConstantsFromFile (const char *)
 
ESMissingEnergyCalibrationreadESMissingEnergyFromFile (const char *)
 
ESPedestalsreadESPedestalsFromFile (const char *)
 
ESRecHitRatioCutsreadESRecHitRatioCutsFromFile (const char *)
 
ESThresholdsreadESThresholdsFromFile (const char *)
 
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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices 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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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<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)
 

Detailed Description

Definition at line 31 of file StoreESCondition.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file StoreESCondition.cc.

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

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

Definition at line 161 of file StoreESCondition.cc.

161 {}

Member Function Documentation

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

Definition at line 163 of file StoreESCondition.cc.

163 {}
void StoreESCondition::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 34 of file StoreESCondition.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::endOfTime(), 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().

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

Definition at line 199 of file StoreESCondition.cc.

References ntuplemaker::time, and EnviromentSettings::user.

Referenced by writeToLogFile(), and writeToLogFileResults().

199  {
200  time_t rawtime;
201  struct tm* timeinfo;
202  time(&rawtime);
203  timeinfo = localtime(&rawtime);
204  char user[50];
205  strcpy(user, getlogin());
206  strcpy(header, asctime(timeinfo));
207  strcpy(header, user);
208 }
ESChannelStatus * StoreESCondition::readESChannelStatusFromFile ( const char *  inputFile)

Definition at line 405 of file StoreESCondition.cc.

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

Referenced by endJob().

405  {
406  int z[1000], p[1000], x[1000], y[1000], nsensors;
407  std::ifstream statusFile(edm::FileInPath(inputFile).fullPath().c_str());
408  statusFile >> nsensors;
409  edm::LogInfo("StoreESCondition") << " nsensors " << nsensors << "\n";
410  if (nsensors >= 1000) {
411  edm::LogInfo("StoreESCondition") << " *** value too high, modify the method!***"
412  << "\n";
413  exit(-1);
414  }
415  for (int i = 0; i < nsensors; ++i) {
416  statusFile >> z[i] >> p[i] >> x[i] >> y[i];
417  }
418  ESChannelStatus* ecalStatus = new ESChannelStatus();
419  int Nbstatus = 0, Nbstrip = 0;
420  for (int istrip = ESDetId::ISTRIP_MIN; istrip <= ESDetId::ISTRIP_MAX; istrip++) {
421  for (int ix = ESDetId::IX_MIN; ix <= ESDetId::IX_MAX; ix++) {
422  for (int iy = ESDetId::IY_MIN; iy <= ESDetId::IY_MAX; iy++) {
423  for (int iplane = 1; iplane <= 2; iplane++) {
424  for (int izeta = -1; izeta <= 1; izeta = izeta + 2) {
425  // if (izeta==0) continue;
426  // try {
427 
428  //ESDetId Plane iplane Zside izeta
429  // if(!ESDetId::validDetId(istrip,ix,iy,iplane,izeta)) cout << " Unvalid DetId" << endl;
430  // else {
431  if (ESDetId::validDetId(istrip, ix, iy, iplane, izeta)) {
432  ESDetId anESId(istrip, ix, iy, iplane, izeta);
433  int status = 0;
434  // std::ifstream statusFile(edm::FileInPath(inputFile).fullPath().c_str());
435  Nbstrip++;
436  for (int i = 0; i < nsensors; ++i) {
437  if (izeta == z[i] && iplane == p[i] && ix == x[i] && iy == y[i])
438  status = 1;
439  }
440  if (status == 1) {
441  Nbstatus++;
442  if (istrip == 1)
443  edm::LogInfo("StoreESCondition") << " Bad channel ix " << ix << " iy " << iy << " iplane " << iplane
444  << " iz " << izeta << "\n"; // print only once
445  }
446  ecalStatus->setValue(anESId, status);
447  // statusFile.close();
448  } // valid DetId
449  // catch ( cms::Exception &e ) { }
450  } // loop over z
451  } // loop over plane
452  } // loop over y
453  } // loop over x
454  } // loop over strips
455  edm::LogInfo("StoreESCondition") << " Nb of strips " << Nbstrip << " Number of bad channels " << Nbstatus << "\n";
456  statusFile.close();
457 
458  // overwrite the statuses which are in the file
459  return ecalStatus;
460 }
static const int IY_MAX
Definition: ESDetId.h:67
static const int ISTRIP_MAX
Definition: ESDetId.h:69
ESChannelStatusMap ESChannelStatus
void setValue(const uint32_t id, const Item &item)
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
ESEEIntercalibConstants * StoreESCondition::readESEEIntercalibConstantsFromFile ( const char *  inputFile)

Definition at line 220 of file StoreESCondition.cc.

References contentValuesFiles::fullPath.

Referenced by endJob().

220  {
221  std::ifstream ESEEIntercalibFile(edm::FileInPath(inputFile).fullPath().c_str());
222  float gammaLow0, alphaLow0, gammaHigh0, alphaHigh0, gammaLow1, alphaLow1, gammaHigh1, alphaHigh1, gammaLow2,
223  alphaLow2, gammaHigh2, alphaHigh2, gammaLow3, alphaLow3, gammaHigh3, alphaHigh3;
224  // const float ESEEIntercalibValue[16];
225  // for (int i = 0; i < 16; ++i) {
226  // ESEEIntercalibFile >> ESEEIntercalibValue[i];
227  // }
228  // ESEEIntercalibConstants* eseeIntercalibConstants = new ESEEIntercalibConstants(ESEEIntercalibValue);
229  ESEEIntercalibFile >> gammaLow0;
230  ESEEIntercalibFile >> alphaLow0;
231  ESEEIntercalibFile >> gammaHigh0;
232  ESEEIntercalibFile >> alphaHigh0;
233  ESEEIntercalibFile >> gammaLow1;
234  ESEEIntercalibFile >> alphaLow1;
235  ESEEIntercalibFile >> gammaHigh1;
236  ESEEIntercalibFile >> alphaHigh1;
237  ESEEIntercalibFile >> gammaLow2;
238  ESEEIntercalibFile >> alphaLow2;
239  ESEEIntercalibFile >> gammaHigh2;
240  ESEEIntercalibFile >> alphaHigh2;
241  ESEEIntercalibFile >> gammaLow3;
242  ESEEIntercalibFile >> alphaLow3;
243  ESEEIntercalibFile >> gammaHigh3;
244  ESEEIntercalibFile >> alphaHigh3;
245  ESEEIntercalibConstants* eseeIntercalibConstants = new ESEEIntercalibConstants(gammaLow0,
246  alphaLow0,
247  gammaHigh0,
248  alphaHigh0,
249  gammaLow1,
250  alphaLow1,
251  gammaHigh1,
252  alphaHigh1,
253  gammaLow2,
254  alphaLow2,
255  gammaHigh2,
256  alphaHigh2,
257  gammaLow3,
258  alphaLow3,
259  gammaHigh3,
260  alphaHigh3);
261 
262  return eseeIntercalibConstants;
263 }
ESGain * StoreESCondition::readESGainFromFile ( const char *  inputFile)

Definition at line 351 of file StoreESCondition.cc.

References es_dqm_sourceclient-live_cfg::ESGain, contentValuesFiles::fullPath, and PedestalClient_cfi::gain.

Referenced by endJob().

351  {
352  std::ifstream amplFile(edm::FileInPath(inputFile).fullPath().c_str());
353 
354  int gain;
355  amplFile >> gain;
356  edm::LogInfo("StoreESCondition") << "gain : " << gain << "\n";
357 
358  ESGain* esGain = new ESGain(gain); // 1: LG, 2: HG
359  return esGain;
360 }
Definition: ESGain.h:7
ESIntercalibConstants * StoreESCondition::readESIntercalibConstantsFromFile ( const char *  inputFile)

Definition at line 377 of file StoreESCondition.cc.

References esgain_, contentValuesFiles::fullPath, mps_fire::i, DetId::rawId(), ESCondObjectContainer< T >::setValue(), and ESDetId::validDetId().

Referenced by endJob().

377  {
379 
380  std::ifstream mipFile(edm::FileInPath(inputFile).fullPath().c_str());
381 
382  for (int i = 0; i < 137216; ++i) {
383  int iz, ip, ix, iy, is;
384  double mip;
385  mipFile >> iz >> ip >> ix >> iy >> is >> mip;
386  //if (mip <20 || mip> 70) cout<<iz<<" "<<ip<<" "<<ix<<" "<<iy<<" "<<is<<" "<<mip<<endl; // HG
387  // LG : HG MIP/6/1.14
388  //mip = mip/6/1.14;
389  // LG : HG MIP/6
390  if (esgain_ == 1)
391  mip = mip / 6.; // LG
392  if (mip < 20 || mip > 70)
393  edm::LogInfo("StoreESCondition") << iz << " " << ip << " " << ix << " " << iy << " " << is << " " << mip
394  << "\n"; // LG
395 
396  if (ESDetId::validDetId(is, ix, iy, ip, iz)) {
397  ESDetId esId(is, ix, iy, ip, iz);
398  ical->setValue(esId.rawId(), mip);
399  }
400  }
401 
402  return ical;
403 }
void setValue(const uint32_t id, const Item &item)
ESIntercalibConstantMap ESIntercalibConstants
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_
ESMissingEnergyCalibration * StoreESCondition::readESMissingEnergyFromFile ( const char *  inputFile)

Definition at line 265 of file StoreESCondition.cc.

References contentValuesFiles::fullPath.

Referenced by endJob().

265  {
266  std::ifstream ESMissingEnergyFile(edm::FileInPath(inputFile).fullPath().c_str());
267  float ConstAEta0, ConstBEta0, ConstAEta1, ConstBEta1, ConstAEta2, ConstBEta2, ConstAEta3, ConstBEta3;
268  ESMissingEnergyFile >> ConstAEta0;
269  ESMissingEnergyFile >> ConstBEta0;
270  ESMissingEnergyFile >> ConstAEta1;
271  ESMissingEnergyFile >> ConstBEta1;
272  ESMissingEnergyFile >> ConstAEta2;
273  ESMissingEnergyFile >> ConstBEta2;
274  ESMissingEnergyFile >> ConstAEta3;
275  ESMissingEnergyFile >> ConstBEta3;
277  ConstAEta0, ConstBEta0, ConstAEta1, ConstBEta1, ConstAEta2, ConstBEta2, ConstAEta3, ConstBEta3);
278 
279  return esMissingEnergy;
280 }
ESPedestals * StoreESCondition::readESPedestalsFromFile ( const char *  inputFile)

Definition at line 282 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, mps_fire::i, ESCondObjectContainer< T >::insert(), 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().

282  {
283  ESPedestals* esPedestals = new ESPedestals();
284 
285  // int ped[2][2][40][40][32];
286  // for (int i=0; i<2; ++i)
287  // for (int j=0; j<2; ++j)
288  // for (int k=0; k<40; ++k)
289  // for (int m=0; m<40; ++m)
290  // for (int n=0; n<32; ++n)
291  // ped[i][j][k][m][n] = 0;
292 
294 
295  int iz, ip, ix, iy, is, ped_, zside;
296  std::ifstream pedestalFile(edm::FileInPath(inputFile).fullPath().c_str());
297 
298  for (int i = 0; i < 137216; ++i) {
299  pedestalFile >> iz >> ip >> ix >> iy >> is >> ped_;
300 
301  zside = (iz == -1) ? 1 : 0;
302  ped[zside][ip - 1][ix - 1][iy - 1][is - 1] = ped_;
303  }
304 
305  for (int iz = -1; iz <= 1; ++iz) {
306  if (iz == 0)
307  continue;
308  zside = (iz == -1) ? 1 : 0;
309 
310  for (int iplane = ESDetId::PLANE_MIN; iplane <= ESDetId::PLANE_MAX; ++iplane)
311  for (int ix = ESDetId::IX_MIN; ix <= ESDetId::IX_MAX; ++ix)
312  for (int iy = ESDetId::IY_MIN; iy <= ESDetId::IY_MAX; ++iy)
313  for (int istrip = ESDetId::ISTRIP_MIN; istrip <= ESDetId::ISTRIP_MAX; ++istrip) {
314  ESPedestals::Item ESitem;
315  ESitem.mean = ped[zside][iplane - 1][ix - 1][iy - 1][istrip - 1];
316  ESitem.rms = 3; // LG : 3, HG : 6
317 
318  if (ESDetId::validDetId(istrip, ix, iy, iplane, iz)) {
319  ESDetId esId(istrip, ix, iy, iplane, iz);
320  esPedestals->insert(std::make_pair(esId.rawId(), ESitem));
321  }
322  }
323  }
324 
325  return esPedestals;
326 }
static const int IY_MAX
Definition: ESDetId.h:67
int zside(DetId const &)
static const int ISTRIP_MAX
Definition: ESDetId.h:69
ESPedestalsMap ESPedestals
Definition: ESPedestals.h:29
static const int PLANE_MIN
Definition: ESDetId.h:70
static const int PLANE_MAX
Definition: ESDetId.h:71
void insert(std::pair< uint32_t, Item > const &a)
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
ESRecHitRatioCuts * StoreESCondition::readESRecHitRatioCutsFromFile ( const char *  inputFile)

Definition at line 328 of file StoreESCondition.cc.

References contentValuesFiles::fullPath.

Referenced by endJob().

328  {
329  std::ifstream ESRecHitRatioCutsFile(edm::FileInPath(inputFile).fullPath().c_str());
330 
331  float r12Low, r23Low, r12High, r23High;
332  ESRecHitRatioCutsFile >> r12Low;
333  ESRecHitRatioCutsFile >> r23Low;
334  ESRecHitRatioCutsFile >> r12High;
335  ESRecHitRatioCutsFile >> r23High;
336  ESRecHitRatioCuts* esRecHitRatioCuts = new ESRecHitRatioCuts(r12Low, r23Low, r12High, r23High);
337  // cout<<"We are in RH ratio cut : gain : " << esgain_<<endl;
338 
339  // HG (R12Low, R23Low, R12High, R23High)
340  // ESRecHitRatioCuts* esRecHitRatioCuts;
341  //if (esgain_ == 2) esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.24, 0.61, 2.23);
342  // if (esgain_ == 2) esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.61, 0.24, 2.23); // HG
343  // else esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.2, 0.39, 2.8);
344  // LG (R12Low, R23Low, R12High, R23High)
345  //ESRecHitRatioCuts* esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 99999., -99999., 99999.); // first running
346  //ESRecHitRatioCuts* esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.2, 0.39, 2.8);
347 
348  return esRecHitRatioCuts;
349 }
ESThresholds * StoreESCondition::readESThresholdsFromFile ( const char *  inputFile)

Definition at line 210 of file StoreESCondition.cc.

References contentValuesFiles::fullPath.

Referenced by endJob().

210  {
211  std::ifstream ESThresholdsFile(edm::FileInPath(inputFile).fullPath().c_str());
212  float ts2, zs; //2nd time sample, ZS threshold
213  ESThresholdsFile >> ts2;
214  ESThresholdsFile >> zs;
215  ESThresholds* esThresholds = new ESThresholds(ts2, zs);
216 
217  return esThresholds;
218 }
ESTimeSampleWeights * StoreESCondition::readESTimeSampleWeightsFromFile ( const char *  inputFile)

Definition at line 362 of file StoreESCondition.cc.

References contentValuesFiles::fullPath, dqmdumpme::k, and w.

Referenced by endJob().

362  {
363  std::ifstream amplFile(edm::FileInPath(inputFile).fullPath().c_str());
364 
365  float w[3];
366  for (int k = 0; k < 3; ++k) {
367  float ww;
368  amplFile >> ww;
369  w[k] = ww;
370  edm::LogInfo("StoreESCondition") << "weight : " << k << " " << w[k] << "\n";
371  }
372 
373  ESTimeSampleWeights* esWeights = new ESTimeSampleWeights(w[0], w[1], w[2]);
374  return esWeights;
375 }
const double w
Definition: UKUtility.cc:23
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  }
void StoreESCondition::writeToLogFile ( std::string  ,
std::string  ,
unsigned long  long 
)

Definition at line 165 of file StoreESCondition.cc.

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

165  {
166  FILE* outFile; // output log file for appending
167  outFile = fopen(logfile_.c_str(), "a");
168  if (!outFile) {
169  edm::LogError("StoreESCondition") << "*** Can not open file: " << logfile_;
170  return;
171  }
172  char header[256];
173  fillHeader(header);
174  char appendMode[10];
175  if (since != 0)
176  strcpy(appendMode, "append");
177  else
178  strcpy(appendMode, "create");
179 
180  //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",
181  //header, a.c_str(), b.c_str(), appendMode, (unsigned int)since);
182 
183  fclose(outFile); // close out file
184 }
std::string logfile_
void fillHeader(char *)
void StoreESCondition::writeToLogFileResults ( char *  arg)

Definition at line 186 of file StoreESCondition.cc.

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

Referenced by endJob().

186  {
187  FILE* outFile; // output log file for appending
188  outFile = fopen(logfile_.c_str(), "a");
189  if (!outFile) {
190  edm::LogError("StoreESCondition") << "*** Can not open file: " << logfile_;
191  return;
192  }
193  char header[256];
194  fillHeader(header);
195  fprintf(outFile, "%s %s\n", header, arg);
196  fclose(outFile); // close out file
197 }
A arg
Definition: Factorize.h:36
std::string logfile_
void fillHeader(char *)

Member Data Documentation

unsigned int StoreESCondition::esgain_
private

Definition at line 61 of file StoreESCondition.h.

Referenced by readESIntercalibConstantsFromFile(), and StoreESCondition().

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

Definition at line 55 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().

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

Definition at line 56 of file StoreESCondition.h.

std::string StoreESCondition::logfile_
private

Definition at line 59 of file StoreESCondition.h.

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

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

Definition at line 54 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().

std::string StoreESCondition::prog_name_
private

Definition at line 57 of file StoreESCondition.h.

Referenced by StoreESCondition().

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

Definition at line 58 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().