CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
StoreEcalCondition Class Reference

#include <StoreEcalCondition.h>

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

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
int convertFromConstructionSMToSlot (int, int)
 
void endJob () override
 
std::shared_ptr
< EcalADCToGeVConstant
readEcalADCToGeVConstantFromFile (const char *)
 
std::shared_ptr
< EcalChannelStatus
readEcalChannelStatusFromFile (const char *)
 
std::shared_ptr< EcalGainRatiosreadEcalGainRatiosFromFile (const char *)
 
std::shared_ptr
< EcalIntercalibConstants
readEcalIntercalibConstantsFromFile (const char *, const char *)
 
std::shared_ptr
< EcalIntercalibConstantsMC
readEcalIntercalibConstantsMCFromFile (const char *, const char *)
 
std::shared_ptr
< EcalPFRecHitThresholds
readEcalPFRecHitThresholdsFromFile (const char *, const char *)
 
std::shared_ptr< EcalTBWeightsreadEcalTBWeightsFromFile (const char *)
 
std::shared_ptr
< EcalWeightXtalGroups
readEcalWeightXtalGroupsFromFile (const char *)
 
 StoreEcalCondition (const edm::ParameterSet &iConfig)
 
void writeToLogFile (std::string, std::string, unsigned long long)
 
void writeToLogFileResults (char *)
 
 ~StoreEcalCondition () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

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_
 
int sm_constr_
 
int sm_slot_
 

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< B > consumes (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 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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 39 of file StoreEcalCondition.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file StoreEcalCondition.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), inpFileName_, inpFileNameEE_, logfile_, objectName_, prog_name_, since_, sm_constr_, sm_slot_, AlCaHLTBitMon_QueryRunRegistry::string, and convertXMLtoSQLite_cfg::toPut.

18  {
19  prog_name_ = "StoreEcalCondition";
20 
21  logfile_ = iConfig.getParameter<std::string>("logfile");
22  sm_slot_ = iConfig.getUntrackedParameter<unsigned int>("smSlot", 1);
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  inpFileNameEE_.push_back(itToPut->getUntrackedParameter<std::string>("inputFileEE"));
29  objectName_.push_back(itToPut->getUntrackedParameter<std::string>("conditionType"));
30  since_.push_back(itToPut->getUntrackedParameter<unsigned int>("since"));
31  }
32 
33  sm_constr_ = -1;
34 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > inpFileName_
std::vector< std::string > inpFileNameEE_
vector< ParameterSet > Parameters
std::vector< unsigned long long > since_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::string > objectName_
StoreEcalCondition::~StoreEcalCondition ( )
override

Definition at line 138 of file StoreEcalCondition.cc.

138 {}

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 141 of file StoreEcalCondition.cc.

141  {
142  //-------------------------------------------------------------
143 }
int StoreEcalCondition::convertFromConstructionSMToSlot ( int  sm_constr,
int  sm_slot 
)

Definition at line 896 of file StoreEcalCondition.cc.

References mps_fire::result.

Referenced by readEcalIntercalibConstantsFromFile(), and readEcalIntercalibConstantsMCFromFile().

896  {
897  // input either cosntruction number or slot number and returns the other
898  // the slots are numbered first EB+ slot 1 ...18 then EB- 1... 18
899  // the slots start at 1 and the SM start at 0
900  //-------------------------------------------------------------
901  int slot_to_constr[37] = {-1, 12, 17, 10, 1, 8, 4, 27, 20, 23, 25, 6, 34, 35, 15, 18, 30, 21, 9,
902  24, 22, 13, 31, 26, 16, 2, 11, 5, 0, 29, 28, 14, 33, 32, 3, 7, 19};
903  int constr_to_slot[36] = {28, 4, 25, 34, 6, 27, 11, 35, 5, 18, 3, 26, 1, 21, 31, 14, 24, 2,
904  15, 36, 8, 17, 20, 9, 19, 10, 23, 7, 30, 29, 16, 22, 33, 32, 12, 13};
905 
906  int result = 0;
907  if (sm_constr != -1) {
908  result = constr_to_slot[sm_constr];
909  } else if (sm_slot != -1) {
910  result = slot_to_constr[sm_slot];
911  }
912  return result;
913 }
tuple result
Definition: mps_fire.py:311
void StoreEcalCondition::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 36 of file StoreEcalCondition.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), cond::service::PoolDBOutputService::createOneIOV(), mps_fire::i, inpFileName_, inpFileNameEE_, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), objectName_, readEcalADCToGeVConstantFromFile(), readEcalChannelStatusFromFile(), readEcalGainRatiosFromFile(), readEcalIntercalibConstantsFromFile(), readEcalIntercalibConstantsMCFromFile(), readEcalPFRecHitThresholdsFromFile(), readEcalTBWeightsFromFile(), readEcalWeightXtalGroupsFromFile(), since_, AlCaHLTBitMon_QueryRunRegistry::string, and writeToLogFileResults().

36  {
38  if (!mydbservice.isAvailable()) {
39  edm::LogError("StoreEcalCondition") << "PoolDBOutputService is unavailable";
40  return;
41  }
42 
43  bool toAppend = false;
44  // copy a string to the char *
45  std::string message = "finished OK\n";
46  size_t messageSize = message.size() + 1;
47  char* messChar = new char[messageSize];
48  strncpy(messChar, message.c_str(), messageSize);
49 
50  for (unsigned int i = 0; i < objectName_.size(); i++) {
51  cond::Time_t newTime;
52 
53  if (mydbservice->isNewTagRequest(objectName_[i] + std::string("Rcd"))) {
54  // This is the first object for this tag.
55  // Append mode should be off.
56  // newTime is the end of this new objects IOV.
57  newTime = mydbservice->beginOfTime();
58  } else {
59  // There should already be an object in the DB for this tag.
60  // Append IOV mode should be on.
61  // newTime is the beginning of this new objects IOV.
62  toAppend = true;
63  newTime = (cond::Time_t)since_[i];
64  }
65  edm::LogInfo("StoreEcalCondition") << "Reading " << objectName_[i] << " from file and writing to DB with newTime "
66  << newTime;
67 
68  if (objectName_[i] == "EcalWeightXtalGroups") {
69  const auto mycali = readEcalWeightXtalGroupsFromFile(inpFileName_[i].c_str());
70  if (!toAppend) {
71  mydbservice->createOneIOV<EcalWeightXtalGroups>(*mycali, newTime, "EcalWeightXtalGroupsRcd");
72  } else {
73  mydbservice->appendOneIOV<EcalWeightXtalGroups>(*mycali, newTime, "EcalWeightXtalGroupsRcd");
74  }
75  } else if (objectName_[i] == "EcalTBWeights") {
76  const auto mycali = readEcalTBWeightsFromFile(inpFileName_[i].c_str());
77  if (!toAppend) {
78  mydbservice->createOneIOV<EcalTBWeights>(*mycali, newTime, "EcalTBWeightsRcd");
79  } else {
80  mydbservice->appendOneIOV<EcalTBWeights>(*mycali, newTime, "EcalTBWeightsRcd");
81  }
82  } else if (objectName_[i] == "EcalADCToGeVConstant") {
83  const auto mycali = readEcalADCToGeVConstantFromFile(inpFileName_[i].c_str());
84  if (!toAppend) {
85  mydbservice->createOneIOV<EcalADCToGeVConstant>(*mycali, newTime, "EcalADCToGeVConstantRcd");
86  } else {
87  mydbservice->appendOneIOV<EcalADCToGeVConstant>(*mycali, newTime, "EcalADCToGeVConstantRcd");
88  }
89  } else if (objectName_[i] == "EcalIntercalibConstants") {
90  const auto mycali = readEcalIntercalibConstantsFromFile(inpFileName_[i].c_str(), inpFileNameEE_[i].c_str());
91  if (!toAppend) {
92  mydbservice->createOneIOV<EcalIntercalibConstants>(*mycali, newTime, "EcalIntercalibConstantsRcd");
93  } else {
94  mydbservice->appendOneIOV<EcalIntercalibConstants>(*mycali, newTime, "EcalIntercalibConstantsRcd");
95  }
96  } else if (objectName_[i] == "EcalPFRecHitThresholds") {
97  const auto mycali = readEcalPFRecHitThresholdsFromFile(inpFileName_[i].c_str(), inpFileNameEE_[i].c_str());
98  if (!toAppend) {
99  mydbservice->createOneIOV<EcalPFRecHitThresholds>(*mycali, newTime, "EcalPFRecHitThresholdsRcd");
100  } else {
101  mydbservice->appendOneIOV<EcalPFRecHitThresholds>(*mycali, newTime, "EcalPFRecHitThresholdsRcd");
102  }
103  } else if (objectName_[i] == "EcalIntercalibConstantsMC") {
104  const auto mycali = readEcalIntercalibConstantsMCFromFile(inpFileName_[i].c_str(), inpFileNameEE_[i].c_str());
105  if (!toAppend) {
106  mydbservice->createOneIOV<EcalIntercalibConstantsMC>(*mycali, newTime, "EcalIntercalibConstantsMCRcd");
107  } else {
108  mydbservice->appendOneIOV<EcalIntercalibConstantsMC>(*mycali, newTime, "EcalIntercalibConstantsMCRcd");
109  }
110  } else if (objectName_[i] == "EcalGainRatios") {
111  const auto mycali = readEcalGainRatiosFromFile(inpFileName_[i].c_str());
112  if (!toAppend) {
113  mydbservice->createOneIOV<EcalGainRatios>(*mycali, newTime, "EcalGainRatiosRcd");
114  } else {
115  mydbservice->appendOneIOV<EcalGainRatios>(*mycali, newTime, "EcalGainRatiosRcd");
116  }
117  } else if (objectName_[i] == "EcalChannelStatus") {
118  const auto mycali = readEcalChannelStatusFromFile(inpFileName_[i].c_str());
119  if (!toAppend) {
120  mydbservice->createOneIOV<EcalChannelStatus>(*mycali, newTime, "EcalChannelStatusRcd");
121  } else {
122  mydbservice->appendOneIOV<EcalChannelStatus>(*mycali, newTime, "EcalChannelStatusRcd");
123  }
124  } else {
125  edm::LogError("StoreEcalCondition") << "Object " << objectName_[i] << " is not supported by this program.";
126  }
127 
128  // writeToLogFile(objectName_[i], inpFileName_[i], since_[i]);
129  //writeToLogFileResults("finished OK\n");
130  writeToLogFileResults(messChar);
131 
132  edm::LogInfo("StoreEcalCondition") << "Finished endJob";
133  }
134 
135  delete[] messChar;
136 }
void writeToLogFileResults(char *)
std::vector< std::string > inpFileName_
std::vector< std::string > inpFileNameEE_
std::shared_ptr< EcalChannelStatus > readEcalChannelStatusFromFile(const char *)
std::shared_ptr< EcalIntercalibConstants > readEcalIntercalibConstantsFromFile(const char *, const char *)
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
std::shared_ptr< EcalADCToGeVConstant > readEcalADCToGeVConstantFromFile(const char *)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
std::vector< unsigned long long > since_
bool isAvailable() const
Definition: Service.h:40
std::shared_ptr< EcalTBWeights > readEcalTBWeightsFromFile(const char *)
std::shared_ptr< EcalIntercalibConstantsMC > readEcalIntercalibConstantsMCFromFile(const char *, const char *)
Log< level::Info, false > LogInfo
std::shared_ptr< EcalWeightXtalGroups > readEcalWeightXtalGroupsFromFile(const char *)
std::shared_ptr< EcalGainRatios > readEcalGainRatiosFromFile(const char *)
std::shared_ptr< EcalPFRecHitThresholds > readEcalPFRecHitThresholdsFromFile(const char *, const char *)
std::vector< std::string > objectName_
void StoreEcalCondition::fillHeader ( char *  header)
private

Definition at line 192 of file StoreEcalCondition.cc.

References EnviromentSettings::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  sprintf(user, "%s", getlogin());
201  sprintf(header, "%s %s:", asctime(timeinfo), user);
202 }
std::shared_ptr< EcalADCToGeVConstant > StoreEcalCondition::readEcalADCToGeVConstantFromFile ( const char *  inputFile)

Definition at line 450 of file StoreEcalCondition.cc.

References writeEcalDQMStatus::inputFile, geometryCSVtoXML::line, LogDebug, sm_constr_, str, and to_string().

Referenced by endJob().

450  {
451  //-------------------------------------------------------------
452 
453  FILE* inpFile; // input file
454  inpFile = fopen(inputFile, "r");
455  if (!inpFile) {
456  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
457  return nullptr;
458  }
459 
460  char line[256];
461 
462  std::ostringstream str;
463 
464  fgets(line, 255, inpFile);
465  int sm_number = atoi(line);
466  str << "sm= " << sm_number << "\n";
467 
468  fgets(line, 255, inpFile);
469  //int nevents=atoi(line); // not necessary here just for online conddb
470 
471  fgets(line, 255, inpFile);
472  string gen_tag = to_string(line);
473  str << "gen tag " << gen_tag << "\n"; // should I use this?
474 
475  fgets(line, 255, inpFile);
476  string cali_method = to_string(line);
477  str << "cali method " << cali_method << "\n"; // not important
478 
479  fgets(line, 255, inpFile);
480  string cali_version = to_string(line);
481  str << "cali version " << cali_version << "\n"; // not important
482 
483  fgets(line, 255, inpFile);
484  string cali_type = to_string(line);
485  str << "cali type " << cali_type << "\n"; // not important
486 
487  edm::LogInfo("StoreEcalCondition") << "ADCToGeV file " << str.str();
488 
489  fgets(line, 255, inpFile);
490  float adc_to_gev = 0;
491  sscanf(line, "%f", &adc_to_gev);
492  LogDebug("StoreEcalCondition") << " calib=" << adc_to_gev;
493  fgets(line, 255, inpFile);
494  float adc_to_gev_ee = 0;
495  sscanf(line, "%f", &adc_to_gev_ee);
496  LogDebug("StoreEcalCondition") << " calib=" << adc_to_gev_ee;
497 
498  fclose(inpFile); // close inp. file
499 
500  sm_constr_ = sm_number;
501 
502  // barrel and endcaps the same
503  auto agc = std::make_shared<EcalADCToGeVConstant>(adc_to_gev, adc_to_gev_ee);
504  edm::LogInfo("StoreEcalCondition") << "ADCtoGeV scale written into the DB";
505  return agc;
506 }
Log< level::Error, false > LogError
Log< level::Info, false > LogInfo
std::string to_string(char value[])
#define str(s)
#define LogDebug(id)
std::shared_ptr< EcalChannelStatus > StoreEcalCondition::readEcalChannelStatusFromFile ( const char *  inputFile)

Definition at line 1057 of file StoreEcalCondition.cc.

References Exception, ecalpyutils::hashedIndex(), compare_using_db::ifile, cuy::ii, writeEcalDQMStatus::inputFile, ecalpyutils::ism(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, geometryCSVtoXML::line, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EBDetId::SMCRYSTALMODE, mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, EBDetId::unhashIndex(), EEDetId::unhashIndex(), EBDetId::validDetId(), and EEDetId::validDetId().

Referenced by endJob().

1057  {
1058  auto status = std::make_shared<EcalChannelStatus>();
1059  // barrel
1060  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1061  if (ieta == 0)
1062  continue;
1063  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1064  if (EBDetId::validDetId(ieta, iphi)) {
1065  EBDetId ebid(ieta, iphi);
1066  status->setValue(ebid, 0);
1067  }
1068  }
1069  }
1070  // endcap
1071  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1072  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1073  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1074  if (EEDetId::validDetId(iX, iY, 1)) {
1075  EEDetId eedetidpos(iX, iY, 1);
1076  status->setValue(eedetidpos, 0);
1077  }
1078  if (EEDetId::validDetId(iX, iY, -1)) {
1079  EEDetId eedetidneg(iX, iY, -1);
1080  status->setValue(eedetidneg, 0);
1081  }
1082  }
1083  }
1084 
1085  edm::LogInfo("StoreEcalCondition") << "Reading channel status from file " << inputFile;
1086  FILE* ifile = fopen(inputFile, "r");
1087  if (!ifile)
1088  throw cms::Exception("Cannot open ECAL channel status file");
1089 
1090  char line[256];
1091 
1092  fgets(line, 255, ifile);
1093  std::string gen_tag = line;
1094  edm::LogVerbatim("StoreEcalCondition") << "Gen tag " << gen_tag << "\n";
1095 
1096  fgets(line, 255, ifile);
1097  std::string comment = line;
1098  edm::LogVerbatim("StoreEcalCondition") << "Gen comment " << comment << "\n";
1099 
1100  int iovRunStart(0);
1101  fgets(line, 255, ifile);
1102  sscanf(line, "%d", &iovRunStart);
1103  edm::LogVerbatim("StoreEcalCondition") << "IOV START " << iovRunStart << "\n";
1104  //if -1 start of time
1105 
1106  int iovRunEnd(0);
1107  fgets(line, 255, ifile);
1108  sscanf(line, "%d", &iovRunEnd);
1109  edm::LogVerbatim("StoreEcalCondition") << "IOV END " << iovRunEnd << "\n";
1110  //if -1 end of time
1111 
1112  int ii = 0;
1113  while (fgets(line, 255, ifile)) {
1114  std::string EBorEE;
1115  int hashedIndex(0);
1116  int chStatus(0);
1117  std::stringstream aStrStream;
1118  aStrStream << line;
1119  aStrStream >> EBorEE >> hashedIndex >> chStatus;
1120  // if(ii==0)
1121  edm::LogVerbatim("StoreEcalCondition")
1122  << EBorEE << " hashedIndex " << hashedIndex << " status " << chStatus << "\n";
1123 
1124  if (EBorEE == "EB") {
1126  status->setValue(aEBDetId, chStatus);
1127  } else if (EBorEE == "EE") {
1128  // chStatus=1;
1130  status->setValue(aEEDetId, chStatus);
1131  } else if (EBorEE == "EBTT") {
1132  int ism = hashedIndex;
1133  int itt = chStatus;
1134 
1135  int ixtt = (itt - 1) % 4;
1136  int iytt = (itt - 1) / 4;
1137  int ixmin = ixtt * 5;
1138  int iymin = iytt * 5;
1139  int ixmax = (ixtt + 1) * 5 - 1;
1140  int iymax = (iytt + 1) * 5 - 1;
1141  for (int ieta = iymin; ieta <= iymax; ieta++) {
1142  for (int iphi = ixmin; iphi <= ixmax; iphi++) {
1143  int ixt = ieta * 20 + iphi + 1;
1144  edm::LogVerbatim("StoreEcalCondition") << "killing crystal " << ism << "/" << ixt << "\n";
1145  EBDetId ebid(ism, ixt, EBDetId::SMCRYSTALMODE);
1146  status->setValue(ebid, 1);
1147  }
1148  }
1149  }
1150 
1151  ii++;
1152  }
1153 
1154  fclose(ifile);
1155 
1156  /*
1157  std::cout <<"KILLING CHANNELS FOR CRAFT EB+16 AND EB+7"<<endl;
1158 
1159  int ism=7;
1160  for(int ixt=1; ixt<=500; ixt++) {
1161  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1162  status->setValue( ebid, 1 );
1163  }
1164  for(int ixt=501; ixt<=900; ixt++) {
1165  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1166  if( ((ixt)%20==0) || ((ixt)%20>10) ){
1167  status->setValue( ebid, 1 );
1168  }
1169  }
1170  ism=16;
1171  for(int ixt=501; ixt<=900; ixt++) {
1172  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1173  if( ((ixt)%20==0) || ((ixt)%20>10) ){
1174  status->setValue( ebid, 1 );
1175  }
1176  }
1177 
1178  */
1179 
1180  return status;
1181 }
Log< level::Info, true > LogVerbatim
static const int MIN_IPHI
Definition: EBDetId.h:135
list status
Definition: mps_update.py:107
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
int ii
Definition: cuy.py:589
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:36
static const int IX_MAX
Definition: EEDetId.h:298
Log< level::Info, false > LogInfo
static const int MAX_IPHI
Definition: EBDetId.h:137
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:136
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
static const int IY_MAX
Definition: EEDetId.h:302
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:49
std::shared_ptr< EcalGainRatios > StoreEcalCondition::readEcalGainRatiosFromFile ( const char *  inputFile)

Definition at line 916 of file StoreEcalCondition.cc.

References PVValHelper::eta, EBDetId::ETAPHIMODE, mps_fire::i, cuy::ii, writeEcalDQMStatus::inputFile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, geometryCSVtoXML::line, phi, DetId::rawId(), EcalMGPAGainRatio::setGain12Over6(), EcalMGPAGainRatio::setGain6Over1(), sm_constr_, sm_slot_, EBDetId::SMCRYSTALMODE, str, to_string(), and EEDetId::validDetId().

Referenced by endJob().

916  {
917  //-------------------------------------------------------------
918 
919  // create gain ratios
920  auto gratio = std::make_shared<EcalGainRatios>();
921 
922  FILE* inpFile; // input file
923  inpFile = fopen(inputFile, "r");
924  if (!inpFile) {
925  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
926  return nullptr;
927  }
928 
929  char line[256];
930  std::ostringstream str;
931 
932  fgets(line, 255, inpFile);
933  string sm_or_all = to_string(line);
934  int sm_number = 0;
935  sm_number = atoi(line);
936  str << "sm= " << sm_number << "\n";
937 
938  fgets(line, 255, inpFile);
939  //int nevents=atoi(line);
940 
941  fgets(line, 255, inpFile);
942  string gen_tag = to_string(line);
943  str << "gen tag " << gen_tag << "\n";
944 
945  fgets(line, 255, inpFile);
946  string cali_method = to_string(line);
947  str << "cali method " << cali_method << "\n";
948 
949  fgets(line, 255, inpFile);
950  string cali_version = to_string(line);
951  str << "cali version " << cali_version << "\n";
952 
953  fgets(line, 255, inpFile);
954  string cali_type = to_string(line);
955 
956  str << "cali type " << cali_type << "\n";
957 
958  edm::LogInfo("StoreEcalCondition") << "GainRatio file " << str.str();
959 
960  int cry_num[61200] = {0};
961  float g1_g12[61200] = {0};
962  float g6_g12[61200] = {0};
963  int calib_status[61200] = {0};
964  int dummy1 = 0;
965  int dummy2 = 0;
966  int hash1 = 0;
967 
968  int ii = 0;
969 
970  if (sm_number != -1) {
971  while (fgets(line, 255, inpFile)) {
972  sscanf(line, "%d %d %d %f %f %d", &dummy1, &dummy2, &cry_num[ii], &g1_g12[ii], &g6_g12[ii], &calib_status[ii]);
973  ii++;
974  }
975 
976  fclose(inpFile); // close inp. file
977 
978  edm::LogInfo("StoreEcalCondition") << "Read gainRatios for " << ii << " xtals ";
979  if (ii != 1700)
980  edm::LogWarning("StoreEcalCondition") << " Missing crystals:: missing channels will be set to 0";
981 
982  // Get channel ID
983  sm_constr_ = sm_number;
984 
985  for (int i = 0; i < 1700; i++) {
986  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
987  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
988  EBDetId ebid(sm_slot_, cry_num[i], EBDetId::SMCRYSTALMODE);
990  gr.setGain12Over6(g6_g12[i]);
991  gr.setGain6Over1(g1_g12[i] / g6_g12[i]);
992  gratio->setValue(ebid.rawId(), gr);
993  } // loop over channels
994 
995  } else {
996  // this is for the whole Barrel
997  edm::LogInfo("StoreEcalCondition") << "mode ALL BARREL";
998  while (fgets(line, 255, inpFile)) {
999  int eta = 0;
1000  int phi = 0;
1001  sscanf(line, "%d %d %d %f %f", &hash1, &eta, &phi, &g1_g12[ii], &g6_g12[ii]);
1002  if (ii < 20)
1003  edm::LogVerbatim("StoreEcalCondition")
1004  << "crystal eta/phi=" << eta << "/" << phi << " g1_12/g6_12= " << g1_g12[ii] << "/" << g6_g12[ii] << "\n";
1005 
1006  if (g1_g12[ii] < 9 || g1_g12[ii] > 15)
1007  g1_g12[ii] = 12.0;
1008  if (g6_g12[ii] < 1 || g6_g12[ii] > 3)
1009  g6_g12[ii] = 2.0;
1010 
1011  if (eta < -85 || eta > 85 || eta == 0)
1012  edm::LogVerbatim("StoreEcalCondition") << "error!!!\n";
1013  if (phi < 1 || phi > 360)
1014  edm::LogVerbatim("StoreEcalCondition") << "error!!!\n";
1015 
1016  EBDetId ebid(eta, phi, EBDetId::ETAPHIMODE);
1017  EcalMGPAGainRatio gr;
1018  gr.setGain12Over6(g6_g12[ii]);
1019  gr.setGain6Over1(g1_g12[ii] / g6_g12[ii]);
1020  gratio->setValue(ebid.rawId(), gr);
1021 
1022  ii++;
1023  }
1024 
1025  fclose(inpFile); // close inp. file
1026  if (ii != 61200)
1027  edm::LogWarning("StoreEcalCondition") << " Missing crystals !!!!!!!";
1028 
1029  edm::LogInfo("StoreEcalCondition") << "number of crystals read:" << ii;
1030  }
1031 
1032  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1033  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1034  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1035  EcalMGPAGainRatio gr;
1036  gr.setGain12Over6(2.);
1037  gr.setGain6Over1(6.);
1038 
1039  if (EEDetId::validDetId(iX, iY, 1)) {
1040  EEDetId eedetidpos(iX, iY, 1);
1041  gratio->setValue(eedetidpos.rawId(), gr);
1042  }
1043  if (EEDetId::validDetId(iX, iY, -1)) {
1044  EEDetId eedetidneg(iX, iY, -1);
1045  gratio->setValue(eedetidneg.rawId(), gr);
1046  }
1047  }
1048  }
1049 
1050  edm::LogInfo("StoreEcalCondition") << " gratio pointer=" << gratio;
1051 
1052  edm::LogInfo("StoreEcalCondition") << "now leaving";
1053 
1054  return gratio;
1055 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
int ii
Definition: cuy.py:589
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
void setGain12Over6(const float &g)
static const int ETAPHIMODE
Definition: EBDetId.h:158
static const int IX_MAX
Definition: EEDetId.h:298
Log< level::Info, false > LogInfo
std::string to_string(char value[])
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int IY_MAX
Definition: EEDetId.h:302
Log< level::Warning, false > LogWarning
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
void setGain6Over1(const float &g)
std::shared_ptr< EcalIntercalibConstants > StoreEcalCondition::readEcalIntercalibConstantsFromFile ( const char *  inputFile,
const char *  inputFileEE 
)

Definition at line 578 of file StoreEcalCondition.cc.

References convertFromConstructionSMToSlot(), mps_fire::i, cuy::ii, writeEcalDQMStatus::inputFile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, geometryCSVtoXML::line, DetId::rawId(), sm_constr_, EBDetId::SMCRYSTALMODE, str, to_string(), and EEDetId::validDetId().

Referenced by endJob().

579  {
580  //-------------------------------------------------------------
581 
582  auto ical = std::make_shared<EcalIntercalibConstants>();
583 
584  FILE* inpFile; // input file
585  inpFile = fopen(inputFile, "r");
586  if (!inpFile) {
587  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
588  return nullptr;
589  }
590 
591  char line[256];
592 
593  std::ostringstream str;
594 
595  fgets(line, 255, inpFile);
596  string sm_or_all = to_string(line);
597  int sm_number = 0;
598  int nchan = 1700;
599  sm_number = atoi(line);
600  str << "sm= " << sm_number << "\n";
601  if (sm_number != -1) {
602  nchan = 1700;
603  } else {
604  nchan = 61200;
605  }
606 
607  fgets(line, 255, inpFile);
608  //int nevents=atoi(line); // not necessary here just for online conddb
609 
610  fgets(line, 255, inpFile);
611  string gen_tag = to_string(line);
612  str << "gen tag " << gen_tag << "\n"; // should I use this?
613 
614  fgets(line, 255, inpFile);
615  string cali_method = to_string(line);
616  str << "cali method " << cali_method << "\n"; // not important
617 
618  fgets(line, 255, inpFile);
619  string cali_version = to_string(line);
620  str << "cali version " << cali_version << "\n"; // not important
621 
622  fgets(line, 255, inpFile);
623  string cali_type = to_string(line);
624  str << "cali type " << cali_type << "\n"; // not important
625 
626  edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str();
627 
628  int sm_num[61200] = {0};
629  int cry_num[61200] = {0};
630  float calib[61200] = {0};
631  float calib_rms[61200] = {0};
632  int calib_nevents[61200] = {0};
633  int calib_status[61200] = {0};
634 
635  int ii = 0;
636  if (sm_number != -1) {
637  while (fgets(line, 255, inpFile)) {
638  sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii]);
639  // if(ii<10) { // print out only the first ten channels
640  // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
641  // }
642  sm_num[ii] = sm_number;
643  ii++;
644  }
645  } else {
646  // this is for the whole Barrel
647  edm::LogInfo("StoreEcalCondition") << "mode ALL BARREL";
648  while (fgets(line, 255, inpFile)) {
649  sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii]);
650  if (ii == 0)
651  edm::LogVerbatim("StoreEcalCondition")
652  << "crystal " << cry_num[ii] << " of sm " << sm_num[ii] << " cali= " << calib[ii] << "\n";
653  ii++;
654  }
655  }
656 
657  // inf.close(); // close inp. file
658  fclose(inpFile); // close inp. file
659 
660  edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals ";
661 
662  if (ii != nchan)
663  edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0";
664 
665  // Get channel ID
666 
667  sm_constr_ = sm_number;
668 
669  // Set the data
670  for (int i = 0; i < nchan; i++) {
671  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
672  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
673 
674  int slot_num = convertFromConstructionSMToSlot(sm_num[i], -1);
675  EBDetId ebid(slot_num, cry_num[i], EBDetId::SMCRYSTALMODE);
676 
677  ical->setValue(ebid.rawId(), calib[i]);
678 
679  if (i == 0)
680  edm::LogVerbatim("StoreEcalCondition") << "crystal " << cry_num[i] << " of sm " << sm_num[i] << " in slot "
681  << slot_num << " calib= " << calib[i] << "\n";
682 
683  } // loop over channels
684 
685  edm::LogInfo("StoreEcalCondition") << "loop on channels done";
686 
687  FILE* inpFileEE; // input file
688  inpFileEE = fopen(inputFileEE, "r");
689  if (!inpFileEE) {
690  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
691 
692  // dummy endcap data
693 
694  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
695  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
696  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
697  if (EEDetId::validDetId(iX, iY, 1)) {
698  EEDetId eedetidpos(iX, iY, 1);
699  ical->setValue(eedetidpos, 1.0);
700  }
701  if (EEDetId::validDetId(iX, iY, -1)) {
702  EEDetId eedetidneg(iX, iY, -1);
703  ical->setValue(eedetidneg, 1.0);
704  }
705  }
706  }
707 
708  } else {
709  edm::LogInfo("StoreEcalCondition") << "... now reading EE file ...";
710 
711  int ii = 0;
712  while (fgets(line, 255, inpFileEE)) {
713  int iz, ix, iy;
714  float calibee;
715  sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee);
716  if (ii <= 0)
717  edm::LogVerbatim("StoreEcalCondition")
718  << "crystal " << iz << "/" << ix << "/" << iy << " cali=" << calibee << "\n";
719 
720  if (EEDetId::validDetId(ix, iy, iz)) {
721  EEDetId eedetid(ix, iy, iz);
722  ical->setValue(eedetid, calibee);
723  }
724 
725  ii++;
726  }
727 
728  fclose(inpFileEE); // close inp. file
729  }
730 
731  edm::LogInfo("StoreEcalCondition") << "loop on EE channels done";
732 
733  return ical;
734 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
int ii
Definition: cuy.py:589
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
static const int IX_MAX
Definition: EEDetId.h:298
Log< level::Info, false > LogInfo
std::string to_string(char value[])
int convertFromConstructionSMToSlot(int, int)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int IY_MAX
Definition: EEDetId.h:302
Log< level::Warning, false > LogWarning
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
std::shared_ptr< EcalIntercalibConstantsMC > StoreEcalCondition::readEcalIntercalibConstantsMCFromFile ( const char *  inputFile,
const char *  inputFileEE 
)

Definition at line 737 of file StoreEcalCondition.cc.

References convertFromConstructionSMToSlot(), mps_fire::i, cuy::ii, writeEcalDQMStatus::inputFile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, geometryCSVtoXML::line, DetId::rawId(), sm_constr_, EBDetId::SMCRYSTALMODE, str, to_string(), and EEDetId::validDetId().

Referenced by endJob().

738  {
739  //-------------------------------------------------------------
740 
741  auto ical = std::make_shared<EcalIntercalibConstantsMC>();
742 
743  FILE* inpFile; // input file
744  inpFile = fopen(inputFile, "r");
745  if (!inpFile) {
746  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
747  return nullptr;
748  }
749 
750  char line[256];
751 
752  std::ostringstream str;
753 
754  fgets(line, 255, inpFile);
755  string sm_or_all = to_string(line);
756  int sm_number = 0;
757  int nchan = 1700;
758  sm_number = atoi(line);
759  str << "sm= " << sm_number << "\n";
760  if (sm_number != -1) {
761  nchan = 1700;
762  } else {
763  nchan = 61200;
764  }
765 
766  fgets(line, 255, inpFile);
767  //int nevents=atoi(line); // not necessary here just for online conddb
768 
769  fgets(line, 255, inpFile);
770  string gen_tag = to_string(line);
771  str << "gen tag " << gen_tag << "\n"; // should I use this?
772 
773  fgets(line, 255, inpFile);
774  string cali_method = to_string(line);
775  str << "cali method " << cali_method << "\n"; // not important
776 
777  fgets(line, 255, inpFile);
778  string cali_version = to_string(line);
779  str << "cali version " << cali_version << "\n"; // not important
780 
781  fgets(line, 255, inpFile);
782  string cali_type = to_string(line);
783  str << "cali type " << cali_type << "\n"; // not important
784 
785  edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str();
786 
787  int sm_num[61200] = {0};
788  int cry_num[61200] = {0};
789  float calib[61200] = {0};
790  float calib_rms[61200] = {0};
791  int calib_nevents[61200] = {0};
792  int calib_status[61200] = {0};
793 
794  int ii = 0;
795  if (sm_number != -1) {
796  while (fgets(line, 255, inpFile)) {
797  sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii]);
798  // if(ii<10) { // print out only the first ten channels
799  // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
800  // }
801  sm_num[ii] = sm_number;
802  ii++;
803  }
804  } else {
805  // this is for the whole Barrel
806  edm::LogInfo("StoreEcalCondition") << "mode ALL BARREL";
807  while (fgets(line, 255, inpFile)) {
808  sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii]);
809  if (ii == 0)
810  edm::LogVerbatim("StoreEcalCondition")
811  << "crystal " << cry_num[ii] << " of sm " << sm_num[ii] << " cali= " << calib[ii] << "\n";
812  ii++;
813  }
814  }
815 
816  // inf.close(); // close inp. file
817  fclose(inpFile); // close inp. file
818 
819  edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals ";
820 
821  if (ii != nchan)
822  edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0";
823 
824  // Get channel ID
825 
826  sm_constr_ = sm_number;
827 
828  // Set the data
829  for (int i = 0; i < nchan; i++) {
830  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
831  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
832 
833  int slot_num = convertFromConstructionSMToSlot(sm_num[i], -1);
834  EBDetId ebid(slot_num, cry_num[i], EBDetId::SMCRYSTALMODE);
835 
836  ical->setValue(ebid.rawId(), calib[i]);
837 
838  if (i == 0)
839  edm::LogVerbatim("StoreEcalCondition") << "crystal " << cry_num[i] << " of sm " << sm_num[i] << " in slot "
840  << slot_num << " calib= " << calib[i] << "\n";
841 
842  } // loop over channels
843 
844  edm::LogInfo("StoreEcalCondition") << "loop on channels done";
845 
846  FILE* inpFileEE; // input file
847  inpFileEE = fopen(inputFileEE, "r");
848  if (!inpFileEE) {
849  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
850 
851  // dummy endcap data
852 
853  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
854  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
855  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
856  if (EEDetId::validDetId(iX, iY, 1)) {
857  EEDetId eedetidpos(iX, iY, 1);
858  ical->setValue(eedetidpos, 1.0);
859  }
860  if (EEDetId::validDetId(iX, iY, -1)) {
861  EEDetId eedetidneg(iX, iY, -1);
862  ical->setValue(eedetidneg, 1.0);
863  }
864  }
865  }
866 
867  } else {
868  edm::LogInfo("StoreEcalCondition") << "... now reading EE file ...";
869 
870  int ii = 0;
871  while (fgets(line, 255, inpFileEE)) {
872  int iz, ix, iy;
873  float calibee;
874  sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee);
875  if (ii <= 0)
876  edm::LogVerbatim("StoreEcalCondition")
877  << "crystal " << iz << "/" << ix << "/" << iy << " cali=" << calibee << "\n";
878 
879  if (EEDetId::validDetId(ix, iy, iz)) {
880  EEDetId eedetid(ix, iy, iz);
881  ical->setValue(eedetid, calibee);
882  }
883 
884  ii++;
885  }
886 
887  fclose(inpFileEE); // close inp. file
888  }
889 
890  edm::LogInfo("StoreEcalCondition") << "loop on EE channels done";
891 
892  return ical;
893 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
int ii
Definition: cuy.py:589
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
static const int IX_MAX
Definition: EEDetId.h:298
Log< level::Info, false > LogInfo
std::string to_string(char value[])
int convertFromConstructionSMToSlot(int, int)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int IY_MAX
Definition: EEDetId.h:302
Log< level::Warning, false > LogWarning
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
std::shared_ptr< EcalPFRecHitThresholds > StoreEcalCondition::readEcalPFRecHitThresholdsFromFile ( const char *  inputFile,
const char *  inputFileEE 
)

Definition at line 509 of file StoreEcalCondition.cc.

References cuy::ii, writeEcalDQMStatus::inputFile, geometryCSVtoXML::line, DetId::rawId(), GOODCOLL_filter_cfg::thresh, EBDetId::validDetId(), and EEDetId::validDetId().

Referenced by endJob().

510  {
511  //-------------------------------------------------------------
512 
513  auto ical = std::make_shared<EcalPFRecHitThresholds>();
514 
515  FILE* inpFile; // input file
516  inpFile = fopen(inputFile, "r");
517  if (!inpFile) {
518  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
519  return nullptr;
520  }
521 
522  char line[256];
523 
524  int ieta = 0;
525  int iphi = 0;
526  int ix = 0;
527  int iy = 0;
528  int iz = 0;
529 
530  float thresh = 0;
531 
532  int ii = 0;
533  while (fgets(line, 255, inpFile)) {
534  sscanf(line, "%d %d %f ", &ieta, &iphi, &thresh);
535  if (ii == 0)
536  edm::LogVerbatim("StoreEcalCondition") << "crystal " << ieta << "/" << iphi << " Thresh= " << thresh << "\n";
537 
538  if (EBDetId::validDetId(ieta, iphi)) {
539  EBDetId ebid(ieta, iphi);
540  ical->setValue(ebid.rawId(), thresh);
541  ii++;
542  }
543  }
544 
545  // inf.close(); // close inp. file
546  fclose(inpFile); // close inp. file
547 
548  edm::LogInfo("StoreEcalCondition") << "Read PF RecHits for " << ii << " xtals ";
549 
550  FILE* inpFileEE; // input file
551  inpFileEE = fopen(inputFileEE, "r");
552  if (!inpFileEE) {
553  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFileEE;
554  return nullptr;
555  }
556  ii = 0;
557  while (fgets(line, 255, inpFileEE)) {
558  sscanf(line, "%d %d %d %f ", &ix, &iy, &iz, &thresh);
559  if (ii == 0)
560  edm::LogVerbatim("StoreEcalCondition")
561  << "crystal " << ix << "/" << iy << "/" << iz << " Thresh= " << thresh << "\n";
562  if (EEDetId::validDetId(ix, iy, iz)) {
563  EEDetId eeid(ix, iy, iz);
564  ical->setValue(eeid.rawId(), thresh);
565  ii++;
566  }
567  }
568 
569  // inf.close(); // close inp. file
570  fclose(inpFileEE); // close inp. file
571 
572  edm::LogInfo("StoreEcalCondition") << "loop on EE channels done - number of crystals =" << ii;
573 
574  return ical;
575 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
int ii
Definition: cuy.py:589
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
Log< level::Info, false > LogInfo
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::shared_ptr< EcalTBWeights > StoreEcalCondition::readEcalTBWeightsFromFile ( const char *  inputFile)

Definition at line 302 of file StoreEcalCondition.cc.

References EcalWeightSet::getChi2WeightsAfterGainSwitch(), EcalWeightSet::getChi2WeightsBeforeGainSwitch(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), mps_fire::i, writeEcalDQMStatus::inputFile, dqmiolumiharvest::j, isotrackApplyRegressor::k, LogDebug, hgc_digi::nSamples, sm_constr_, str, and groupFilesInBlocks::temp.

Referenced by endJob().

302  {
303  //-------------------------------------------------------------
304 
305  // Zabi code to be written here
306 
307  auto tbwgt = std::make_shared<EcalTBWeights>();
308 
309  std::ifstream WeightsFileTB(inputFile);
310  if (!WeightsFileTB.is_open()) {
311  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
312  return nullptr;
313  }
314 
315  int smnumber = -99999;
316 
317  std::ostringstream str;
318  WeightsFileTB >> smnumber;
319  if (smnumber == -99999)
320  return nullptr;
321 
322  str << "sm= " << smnumber << "\n";
323 
324  char temp[256];
325  //Reading the other 5 header lines containing various informations
326  for (int i = 0; i <= 5; i++) {
327  WeightsFileTB.getline(temp, 255);
328  str << temp << "\n";
329  }
330 
331  edm::LogInfo("StoreEcalCondition") << "Weights file " << str.str();
332 
333  int ngroups = 0;
334  while (WeightsFileTB.good()) {
335  int igroup_ID = -99999;
336  int nSamples = -99999;
337  int nTdcBins = -99999;
338 
339  WeightsFileTB >> igroup_ID >> nSamples >> nTdcBins;
340  if (igroup_ID == -99999 || nSamples == -99999 || nTdcBins == -99999)
341  break;
342 
343  std::ostringstream str;
344  str << "Igroup=" << igroup_ID << " Nsamples=" << nSamples << " NTdcBins=" << nTdcBins << "\n";
345 
346  for (int iTdcBin = 0; iTdcBin < nTdcBins; iTdcBin++) {
347  EcalWeightSet wgt; // one set of weights
352 
353  // std::vector<EcalWeight> wamp, wped, wtime; //weights before gain switch
354  // std::vector<EcalWeight> wamp2, wped2, wtime2; //weights after gain switch
355 
356  //WEIGHTS BEFORE GAIN SWITCH
357  //Amplitude weights
358  for (int j = 0; j < nSamples; ++j) {
359  double ww = 0.0;
360  WeightsFileTB >> ww;
361  wgt1(0, j) = ww;
362  str << ww << " ";
363  } // loop Samples
364  str << "\n";
365 
366  //Pedestal weights
367  for (int j = 0; j < nSamples; ++j) {
368  double ww = 0.0;
369  WeightsFileTB >> ww;
370  wgt1(1, j) = ww;
371  str << ww << " ";
372  } //loop Samples
373  str << "\n";
374 
375  //Timing weights
376  for (int j = 0; j < nSamples; ++j) {
377  double ww = 0.0;
378  WeightsFileTB >> ww;
379  wgt1(2, j) = ww;
380  str << ww << " ";
381  } //loop Samples
382  str << "\n";
383 
384  for (int j = 0; j < nSamples; ++j) {
385  // fill chi2 matrix
386  //std::vector<EcalWeight> vChi2; // row of chi2 matrix
387  for (int k = 0; k < nSamples; ++k) {
388  double ww = 0.0;
389  WeightsFileTB >> ww;
390  chisq1(j, k) = ww;
391  str << ww << " ";
392  } //loop samples
393  str << "\n";
394  } //loop lines
395 
396  //WEIGHTS AFTER GAIN SWITCH
397  for (int j = 0; j < nSamples; ++j) {
398  double ww = 0.0;
399  WeightsFileTB >> ww;
400  wgt2(0, j) = ww;
401  str << ww << " ";
402  } // loop Samples
403  str << "\n";
404 
405  //Pedestal weights
406  for (int j = 0; j < nSamples; ++j) {
407  double ww = 0.0;
408  WeightsFileTB >> ww;
409  wgt2(1, j) = ww;
410  str << ww << " ";
411  } //loop Samples
412  str << "\n";
413 
414  //Timing weights
415  for (int j = 0; j < nSamples; ++j) {
416  double ww = 0.0;
417  WeightsFileTB >> ww;
418  wgt2(2, j) = ww;
419  str << ww << " ";
420  } //loop Samples
421  str << "\n";
422 
423  for (int j = 0; j < nSamples; ++j) {
424  // fill chi2 matrix
425  //std::vector<EcalWeight> vChi2; // row of chi2 matrix
426  for (int k = 0; k < nSamples; ++k) {
427  double ww = 0.0;
428  WeightsFileTB >> ww;
429  chisq2(j, k) = ww;
430  str << ww << " ";
431  } //loop samples
432  str << "\n";
433  } //loop lines
434 
435  LogDebug("StoreEcalCondition") << str.str();
436 
437  //modif-27-07-06 tdcid should start from 1
438  tbwgt->setValue(std::make_pair(igroup_ID, iTdcBin + 1), wgt);
439  } //loop Tdc bins
440  ngroups++;
441  } //loop groupID
442 
443  sm_constr_ = smnumber;
444 
445  edm::LogInfo("StoreEcalCondition") << "Weights for " << ngroups << " groups written into DB";
446  return tbwgt;
447 }
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:28
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:20
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
Log< level::Error, false > LogError
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
Definition: EcalWeightSet.h:29
constexpr size_t nSamples
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
Log< level::Info, false > LogInfo
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
#define str(s)
#define LogDebug(id)
std::shared_ptr< EcalWeightXtalGroups > StoreEcalCondition::readEcalWeightXtalGroupsFromFile ( const char *  inputFile)

Definition at line 236 of file StoreEcalCondition.cc.

References mps_fire::i, writeEcalDQMStatus::inputFile, LogDebug, DetId::rawId(), sm_constr_, sm_slot_, EBDetId::SMCRYSTALMODE, str, and groupFilesInBlocks::temp.

Referenced by endJob().

236  {
237  //-------------------------------------------------------------
238 
239  // Code taken from EcalWeightTools/test/MakeOfflineDbFromAscii.cpp
240 
241  auto xtalGroups = std::make_shared<EcalWeightXtalGroups>();
242  std::ifstream groupid_in(inputFile);
243 
244  if (!groupid_in.is_open()) {
245  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
246  return nullptr;
247  }
248 
249  int smnumber = -99999;
250 
251  std::ostringstream str;
252  groupid_in >> smnumber;
253  if (smnumber == -99999) {
254  edm::LogError("StoreEcalCondition") << "ERROR: SM number not found in file";
255  return nullptr;
256  }
257  str << "sm= " << smnumber << "\n";
258  sm_constr_ = smnumber;
259 
260  char temp[256];
261  //Reading the other 5 header lines containing various informations
262  for (int i = 0; i <= 5; i++) {
263  groupid_in.getline(temp, 255);
264  str << temp << "\n";
265  }
266 
267  // Skip the nGroup/Mean line
268  groupid_in.getline(temp, 255);
269  str << temp << "\n";
270 
271  edm::LogInfo("StoreEcalCondition") << "GROUPID file " << str.str();
272 
273  int xtals = 0;
274  int xtal, ietaf, iphif, groupID;
275  while (groupid_in.good()) {
276  groupid_in >> xtal >> ietaf >> iphif >> groupID;
277  if (groupid_in.eof()) {
278  break;
279  }
280 
281  LogDebug("StoreEcalCondition") << "XTAL=" << xtal << " ETA=" << ietaf << " PHI=" << iphif << " GROUP=" << groupID;
282 
283  //EBDetId ebid(ieta,iphi);
285  // xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( ebid.hashedIndex()) );
286  xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(groupID));
287  xtals++;
288  } //loop iphi
289 
290  if (xtals != 1700) {
291  edm::LogError("StoreEcalCondition") << "ERROR: GROUPID file did not contain data for 1700 crystals";
292  return nullptr;
293  }
294 
295  edm::LogInfo("StoreEcalCondition") << "Groups for " << xtals << " xtals written into DB";
296  sm_constr_ = smnumber;
297 
298  return xtalGroups;
299 }
Log< level::Error, false > LogError
Log< level::Info, false > LogInfo
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
#define LogDebug(id)
std::string StoreEcalCondition::to_string ( char  value[])
inlineprivate

Definition at line 72 of file StoreEcalCondition.h.

References relativeConstraints::value.

Referenced by readEcalADCToGeVConstantFromFile(), readEcalGainRatiosFromFile(), readEcalIntercalibConstantsFromFile(), and readEcalIntercalibConstantsMCFromFile().

72  {
73  std::ostringstream streamOut;
74  streamOut << value;
75  return streamOut.str();
76  }
void StoreEcalCondition::writeToLogFile ( std::string  ,
std::string  ,
unsigned long  long 
)

Definition at line 146 of file StoreEcalCondition.cc.

References fillHeader(), logfile_, produceTPGParameters_beamv6_transparency_spikekill_2016_script::outFile, sm_constr_, and sm_slot_.

146  {
147  //-------------------------------------------------------------
148 
149  FILE* outFile; // output log file for appending
150  outFile = fopen(logfile_.c_str(), "a");
151  if (!outFile) {
152  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << logfile_;
153  return;
154  }
155  char header[256];
156  fillHeader(header);
157  char appendMode[10];
158  if (since != 0)
159  sprintf(appendMode, "append");
160  else
161  sprintf(appendMode, "create");
162 
163  fprintf(outFile,
164  "%s %s condition from file %s written into DB for SM %d (mapped to SM %d) in %s mode (since run %u)\n",
165  header,
166  a.c_str(),
167  b.c_str(),
168  sm_constr_,
169  sm_slot_,
170  appendMode,
171  (unsigned int)since);
172 
173  fclose(outFile); // close out file
174 }
Log< level::Error, false > LogError
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
void StoreEcalCondition::writeToLogFileResults ( char *  arg)

Definition at line 176 of file StoreEcalCondition.cc.

References fillHeader(), logfile_, and produceTPGParameters_beamv6_transparency_spikekill_2016_script::outFile.

Referenced by endJob().

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

Member Data Documentation

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

Definition at line 64 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

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

Definition at line 65 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

std::string StoreEcalCondition::logfile_
private

Definition at line 70 of file StoreEcalCondition.h.

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

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

Definition at line 62 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

std::string StoreEcalCondition::prog_name_
private

Definition at line 66 of file StoreEcalCondition.h.

Referenced by StoreEcalCondition().

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

Definition at line 69 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

int StoreEcalCondition::sm_constr_
private
int StoreEcalCondition::sm_slot_
private