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

Definition at line 150 of file StoreESCondition.cc.

150  {
151 
152 }

Member Function Documentation

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

Definition at line 154 of file StoreESCondition.cc.

154  {
155 }
void StoreESCondition::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 36 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().

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

Definition at line 194 of file StoreESCondition.cc.

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

Referenced by writeToLogFile(), and writeToLogFileResults().

194  {
195  time_t rawtime;
196  struct tm * timeinfo;
197  time ( &rawtime );
198  timeinfo = localtime ( &rawtime );
199  char user[50];
200  strcpy(user,getlogin());
201  strcpy(header,asctime(timeinfo));
202  strcpy(header,user);
203 }
ESChannelStatus * StoreESCondition::readESChannelStatusFromFile ( const char *  inputFile)

Definition at line 396 of file StoreESCondition.cc.

References cmsRelvalreport::exit, 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().

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

Definition at line 216 of file StoreESCondition.cc.

Referenced by endJob().

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

Definition at line 341 of file StoreESCondition.cc.

References muonCSCDigis_cfi::gain.

Referenced by endJob().

341  {
342 
343  std::ifstream amplFile(edm::FileInPath(inputFile).fullPath().c_str());
344 
345  int gain;
346  amplFile >> gain;
347  edm::LogInfo("StoreESCondition") << "gain : "<< gain << "\n";
348 
349  ESGain* esGain = new ESGain(gain); // 1: LG, 2: HG
350  return esGain;
351 }
Definition: ESGain.h:7
ESIntercalibConstants * StoreESCondition::readESIntercalibConstantsFromFile ( const char *  inputFile)

Definition at line 370 of file StoreESCondition.cc.

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

Referenced by endJob().

370  {
371 
373 
374  std::ifstream mipFile(edm::FileInPath(inputFile).fullPath().c_str());
375 
376  for (int i=0; i<137216; ++i) {
377  int iz, ip, ix, iy, is;
378  double mip;
379  mipFile >> iz >> ip >> ix >> iy >> is >> mip;
380  //if (mip <20 || mip> 70) cout<<iz<<" "<<ip<<" "<<ix<<" "<<iy<<" "<<is<<" "<<mip<<endl; // HG
381  // LG : HG MIP/6/1.14
382  //mip = mip/6/1.14;
383  // LG : HG MIP/6
384  if (esgain_ == 1) mip = mip/6.; // LG
385  if (mip <20 || mip> 70) edm::LogInfo("StoreESCondition") <<iz<<" "<<ip<<" "<<ix<<" "<<iy<<" "<<is<<" "<<mip<< "\n"; // LG
386 
387  if(ESDetId::validDetId(is, ix, iy, ip, iz)) {
388  ESDetId esId(is, ix, iy, ip, iz);
389  ical->setValue(esId.rawId(), mip);
390  }
391  }
392 
393  return ical;
394 }
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 251 of file StoreESCondition.cc.

Referenced by endJob().

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

Definition at line 269 of file StoreESCondition.cc.

References 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().

269  {
270 
271  ESPedestals* esPedestals = new ESPedestals();
272 
273  // int ped[2][2][40][40][32];
274  // for (int i=0; i<2; ++i)
275  // for (int j=0; j<2; ++j)
276  // for (int k=0; k<40; ++k)
277  // for (int m=0; m<40; ++m)
278  // for (int n=0; n<32; ++n)
279  // ped[i][j][k][m][n] = 0;
280 
282 
283  int iz, ip, ix, iy, is, ped_, zside;
284  std::ifstream pedestalFile(edm::FileInPath(inputFile).fullPath().c_str());
285 
286  for (int i=0; i<137216; ++i) {
287  pedestalFile >> iz >> ip >> ix >> iy >> is >> ped_;
288 
289  zside = (iz==-1) ? 1 : 0;
290  ped[zside][ip-1][ix-1][iy-1][is-1] = ped_;
291  }
292 
293  for (int iz=-1; iz<=1; ++iz) {
294 
295  if (iz==0) continue;
296  zside = (iz==-1) ? 1 : 0;
297 
298  for (int iplane=ESDetId::PLANE_MIN; iplane<=ESDetId::PLANE_MAX; ++iplane)
299  for (int ix=ESDetId::IX_MIN; ix<=ESDetId::IX_MAX; ++ix)
300  for (int iy=ESDetId::IY_MIN; iy<=ESDetId::IY_MAX; ++iy)
301  for (int istrip=ESDetId::ISTRIP_MIN; istrip<=ESDetId::ISTRIP_MAX; ++istrip) {
302 
303  ESPedestals::Item ESitem;
304  ESitem.mean = ped[zside][iplane-1][ix-1][iy-1][istrip-1];
305  ESitem.rms = 3; // LG : 3, HG : 6
306 
307  if(ESDetId::validDetId(istrip, ix, iy, iplane, iz)) {
308  ESDetId esId(istrip, ix, iy, iplane, iz);
309  esPedestals->insert(std::make_pair(esId.rawId(), ESitem));
310  }
311  }
312  }
313 
314  return esPedestals;
315 }
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:32
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:14
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:15
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 317 of file StoreESCondition.cc.

Referenced by endJob().

317  {
318 
319  std::ifstream ESRecHitRatioCutsFile(edm::FileInPath(inputFile).fullPath().c_str());
320 
321  float r12Low, r23Low, r12High, r23High;
322  ESRecHitRatioCutsFile >> r12Low;
323  ESRecHitRatioCutsFile >> r23Low;
324  ESRecHitRatioCutsFile >> r12High;
325  ESRecHitRatioCutsFile >> r23High;
326  ESRecHitRatioCuts* esRecHitRatioCuts= new ESRecHitRatioCuts(r12Low, r23Low, r12High, r23High);
327  // cout<<"We are in RH ratio cut : gain : " << esgain_<<endl;
328 
329  // HG (R12Low, R23Low, R12High, R23High)
330  // ESRecHitRatioCuts* esRecHitRatioCuts;
331  //if (esgain_ == 2) esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.24, 0.61, 2.23);
332  // if (esgain_ == 2) esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.61, 0.24, 2.23); // HG
333  // else esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.2, 0.39, 2.8);
334  // LG (R12Low, R23Low, R12High, R23High)
335  //ESRecHitRatioCuts* esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 99999., -99999., 99999.); // first running
336  //ESRecHitRatioCuts* esRecHitRatioCuts = new ESRecHitRatioCuts(-99999., 0.2, 0.39, 2.8);
337 
338  return esRecHitRatioCuts;
339 }
ESThresholds * StoreESCondition::readESThresholdsFromFile ( const char *  inputFile)

Definition at line 205 of file StoreESCondition.cc.

Referenced by endJob().

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

Definition at line 353 of file StoreESCondition.cc.

References gen::k, and w.

Referenced by endJob().

353  {
354 
355  std::ifstream amplFile(edm::FileInPath(inputFile).fullPath().c_str());
356 
357  float w[3];
358  for (int k = 0; k < 3; ++k) {
359  float ww;
360  amplFile >> ww;
361  w[k] = ww;
362  edm::LogInfo("StoreESCondition") <<"weight : "<<k<<" "<<w[k]<< "\n";
363  }
364 
365  ESTimeSampleWeights* esWeights = new ESTimeSampleWeights(w[0], w[1], w[2]);
366  return esWeights;
367 
368 }
const double w
Definition: UKUtility.cc:23
int k[5][pyjets_maxn]
std::string StoreESCondition::to_string ( char  value[])
inlineprivate

Definition at line 66 of file StoreESCondition.h.

References relativeConstraints::value.

66  {
67  std::ostringstream streamOut;
68  streamOut << value;
69  return streamOut.str();
70  }
void StoreESCondition::writeToLogFile ( std::string  ,
std::string  ,
unsigned long  long 
)

Definition at line 157 of file StoreESCondition.cc.

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

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

Definition at line 180 of file StoreESCondition.cc.

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

Referenced by endJob().

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

Member Data Documentation

unsigned int StoreESCondition::esgain_
private

Definition at line 64 of file StoreESCondition.h.

Referenced by readESIntercalibConstantsFromFile(), and StoreESCondition().

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

Definition at line 58 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().

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

Definition at line 59 of file StoreESCondition.h.

std::string StoreESCondition::logfile_
private

Definition at line 62 of file StoreESCondition.h.

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

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

Definition at line 57 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().

std::string StoreESCondition::prog_name_
private

Definition at line 60 of file StoreESCondition.h.

Referenced by StoreESCondition().

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

Definition at line 61 of file StoreESCondition.h.

Referenced by endJob(), and StoreESCondition().