CMS 3D CMS Logo

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

calculate the best DAC value to obtain a pedestal = 200 More...

#include <EcalPedOffset.h>

Inheritance diagram for EcalPedOffset:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (edm::Event const &event, edm::EventSetup const &eventSetup) override
 ! Analyze More...
 
void beginRun (edm::Run const &, edm::EventSetup const &eventSetup) override
 BeginRun. More...
 
 EcalPedOffset (const edm::ParameterSet &ps)
 Constructor. More...
 
void endJob (void) override
 EndJob. More...
 
void makePlots ()
 create the plots of the DAC pedestal trend More...
 
void writeDb ()
 WriteDB. More...
 
void writeXMLFiles (std::string fileName)
 write the results into xml format More...
 
 ~EcalPedOffset () override
 Destructor. More...
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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

std::string intToString (int num)
 
void readDACs (const edm::Handle< EBDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
 
void readDACs (const edm::Handle< EEDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
 

Private Attributes

const EcalElectronicsMappingecalElectronicsMap_
 
edm::InputTag m_barrelDigiCollection
 secondary name given to collection of digis More...
 
int m_bestPed
 
bool m_create_moniov
 
int m_DACmax
 
int m_DACmin
 
std::string m_dbHostName
 database host name More...
 
int m_dbHostPort
 database More...
 
std::string m_dbName
 database name More...
 
std::string m_dbPassword
 database user password More...
 
std::string m_dbUserName
 database user name More...
 
edm::InputTag m_endcapDigiCollection
 secondary name given to collection of digis More...
 
edm::InputTag m_headerCollection
 name of module/plugin/producer making headers More...
 
std::string m_location
 
double m_maxChi2OverNDFAllowed_
 max chi2/ndf allowed for linearity test More...
 
double m_maxSlopeAllowed_
 max slope (in magnitude) allowed for linearity test More...
 
double m_minSlopeAllowed_
 min slope (in magnitude) allowed for linearity test More...
 
std::map< int, TPedResult * > m_pedResult
 
std::map< int, TPedValues * > m_pedValues
 
std::string m_plotting
 the root file where to store the detail plots More...
 
double m_RMSmax
 
int m_run
 run number More...
 
std::string m_xmlFile
 name of the xml file to be saved More...
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

calculate the best DAC value to obtain a pedestal = 200

Author
P. Govoni (pietr.nosp@m.o.go.nosp@m.voni@.nosp@m.cern.nosp@m.NOSPA.nosp@m.M.ch)

Definition at line 28 of file EcalPedOffset.h.

Constructor & Destructor Documentation

◆ EcalPedOffset()

EcalPedOffset::EcalPedOffset ( const edm::ParameterSet ps)

Constructor.

ctor

Definition at line 38 of file EcalPedOffset.cc.

39  : m_barrelDigiCollection(paramSet.getParameter<edm::InputTag>("EBdigiCollection")),
40  m_endcapDigiCollection(paramSet.getParameter<edm::InputTag>("EEdigiCollection")),
41  m_headerCollection(paramSet.getParameter<edm::InputTag>("headerCollection")),
42  m_xmlFile(paramSet.getParameter<std::string>("xmlFile")),
43  m_DACmin(paramSet.getUntrackedParameter<int>("DACmin", 0)),
44  m_DACmax(paramSet.getUntrackedParameter<int>("DACmax", 256)),
45  m_RMSmax(paramSet.getUntrackedParameter<double>("RMSmax", 2)),
46  m_bestPed(paramSet.getUntrackedParameter<int>("bestPed", 200)),
47  m_dbHostName(paramSet.getUntrackedParameter<std::string>("dbHostName", "0")),
48  m_dbName(paramSet.getUntrackedParameter<std::string>("dbName", "0")),
49  m_dbUserName(paramSet.getUntrackedParameter<std::string>("dbUserName")),
50  m_dbPassword(paramSet.getUntrackedParameter<std::string>("dbPassword")),
51  m_dbHostPort(paramSet.getUntrackedParameter<int>("dbHostPort", 1521)),
52  m_create_moniov(paramSet.getUntrackedParameter<bool>("createMonIOV", false)),
53  m_location(paramSet.getUntrackedParameter<std::string>("location", "H4")),
54  m_run(-1),
55  m_plotting(paramSet.getParameter<std::string>("plotting")),
56  m_maxSlopeAllowed_(paramSet.getUntrackedParameter<double>("maxSlopeAllowed", -29)),
57  m_minSlopeAllowed_(paramSet.getUntrackedParameter<double>("minSlopeAllowed", -18)),
58  m_maxChi2OverNDFAllowed_(paramSet.getUntrackedParameter<double>("maxChi2OverNDF", 5)) {
59  edm::LogInfo("EcalPedOffset") << " reading "
60  << " m_DACmin: " << m_DACmin << " m_DACmax: " << m_DACmax << " m_RMSmax: " << m_RMSmax
61  << " m_bestPed: " << m_bestPed;
62 }

References m_bestPed, m_DACmax, m_DACmin, and m_RMSmax.

◆ ~EcalPedOffset()

EcalPedOffset::~EcalPedOffset ( )
override

Destructor.

dtor

Definition at line 67 of file EcalPedOffset.cc.

67  {
68  for (std::map<int, TPedValues *>::iterator mapIt = m_pedValues.begin(); mapIt != m_pedValues.end(); ++mapIt)
69  delete mapIt->second;
70  for (std::map<int, TPedResult *>::iterator mapIt = m_pedResult.begin(); mapIt != m_pedResult.end(); ++mapIt)
71  delete mapIt->second;
72 }

References cms::cuda::for(), m_pedResult, and m_pedValues.

Member Function Documentation

◆ analyze()

void EcalPedOffset::analyze ( edm::Event const &  event,
edm::EventSetup const &  eventSetup 
)
overridevirtual

! Analyze

perform the analysis

Implements edm::EDAnalyzer.

Definition at line 88 of file EcalPedOffset.cc.

88  {
89  LogDebug("EcalPedOffset") << "entering analyze ...";
90 
91  // get the headers
92  // (one header for each supermodule)
94  event.getByLabel(m_headerCollection, DCCHeaders);
95 
96  std::map<int, int> DACvalues;
97 
98  if (m_run == -1)
99  m_run = event.id().run();
100 
101  // loop over the headers
102  for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
103  ++headerItr) {
104  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
105  int FEDid = 600 + headerItr->id();
106  DACvalues[FEDid] = settings.ped_offset;
107  LogDebug("EcalPedOffset") << "Found FED: " << FEDid << " in DCC header";
108  }
109 
110  bool barrelDigisFound = true;
111  bool endcapDigisFound = true;
112  // get the barrel digis
113  // (one digi for each crystal)
115  event.getByLabel(m_barrelDigiCollection, barrelDigis);
116  if (!barrelDigis.isValid()) {
117  edm::LogError("EcalPedOffset") << "Error! can't get the product " << m_barrelDigiCollection
118  << "; not reading barrel digis";
119  barrelDigisFound = false;
120  }
121 
122  if (barrelDigis->empty()) {
123  edm::LogInfo("EcalPedOffset") << "Size of EBDigiCollection is zero;"
124  << " not reading barrel digis";
125  barrelDigisFound = false;
126  }
127 
128  // get the endcap digis
129  // (one digi for each crystal)
131  event.getByLabel(m_endcapDigiCollection, endcapDigis);
132  if (!endcapDigis.isValid()) {
133  edm::LogError("EcalPedOffset") << "Error! can't get the product " << m_endcapDigiCollection
134  << "; not reading endcap digis";
135  endcapDigisFound = false;
136  }
137 
138  if (endcapDigis->empty()) {
139  edm::LogInfo("EcalPedOffset") << "Size of EEDigiCollection is zero;"
140  << " not reading endcap digis";
141  endcapDigisFound = false;
142  }
143 
144  if (barrelDigisFound)
145  readDACs(barrelDigis, DACvalues);
146  if (endcapDigisFound)
147  readDACs(endcapDigis, DACvalues);
148  if (!barrelDigisFound && !endcapDigisFound)
149  edm::LogError("EcalPedOffset") << "No digis found in the event!";
150 }

References mtdUncalibratedRecHits_cfi::barrelDigis, edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), mtdUncalibratedRecHits_cfi::endcapDigis, LogDebug, m_barrelDigiCollection, m_endcapDigiCollection, m_headerCollection, m_run, EcalDCCHeaderBlock::EcalDCCEventSettings::ped_offset, and readDACs().

◆ beginRun()

void EcalPedOffset::beginRun ( edm::Run const &  ,
edm::EventSetup const &  eventSetup 
)
overridevirtual

BeginRun.

begin the run

Reimplemented from edm::EDAnalyzer.

Definition at line 77 of file EcalPedOffset.cc.

77  {
78  LogDebug("EcalPedOffset") << "entering beginRun...";
79 
81  eventSetup.get<EcalMappingRcd>().get(handle);
82  ecalElectronicsMap_ = handle.product();
83 }

References ecalElectronicsMap_, edm::EventSetup::get(), get, patZpeak::handle, and LogDebug.

◆ endJob()

void EcalPedOffset::endJob ( void  )
overridevirtual

EndJob.

perform the minimization and write results

Reimplemented from edm::EDAnalyzer.

Definition at line 223 of file EcalPedOffset.cc.

223  {
224  for (std::map<int, TPedValues *>::const_iterator smPeds = m_pedValues.begin(); smPeds != m_pedValues.end();
225  ++smPeds) {
226  m_pedResult[smPeds->first] = new TPedResult((smPeds->second)->terminate(m_DACmin, m_DACmax));
227  }
228  edm::LogInfo("EcalPedOffset") << " results map size " << m_pedResult.size();
230 
231  if (m_plotting != '0')
232  makePlots();
233  if (m_dbHostName != '0')
234  writeDb();
235 }

References m_DACmax, m_DACmin, m_dbHostName, m_pedResult, m_pedValues, m_plotting, m_xmlFile, makePlots(), writeDb(), and writeXMLFiles().

Referenced by o2olib.O2ORunMgr::executeJob().

◆ intToString()

std::string EcalPedOffset::intToString ( int  num)
private

Definition at line 457 of file EcalPedOffset.cc.

457  {
458  // outputs the number into the string stream and then flushes
459  // the buffer (makes sure the output is put into the stream)
460  std::ostringstream myStream;
461  myStream << num << std::flush;
462  return (myStream.str()); // returns the string form of the stringstream object
463 }

References EgammaValidation_cff::num.

Referenced by writeXMLFiles().

◆ makePlots()

void EcalPedOffset::makePlots ( )

create the plots of the DAC pedestal trend

Definition at line 428 of file EcalPedOffset.cc.

428  {
429  LogDebug("EcalPedOffset") << " entering makePlots ...";
430 
431  edm::LogInfo("EcalPedOffset") << " map size: " << m_pedValues.size();
432 
433  // create the ROOT file
434  m_plotting += ".root";
435 
436  TFile *rootFile = new TFile(m_plotting.c_str(), "RECREATE");
437 
438  // loop over the supermodules
439  for (std::map<int, TPedValues *>::const_iterator smPeds = m_pedValues.begin(); smPeds != m_pedValues.end();
440  ++smPeds) {
441  // make a folder in the ROOT file
442  char folderName[120];
443  sprintf(folderName, "FED%02d", smPeds->first);
444  rootFile->mkdir(folderName);
446  }
447 
448  rootFile->Close();
449  delete rootFile;
450 
451  LogDebug("EcalPedOffset") << " DONE";
452 }

References ALCARECODTCalibSynchCosmicsDQM_cff::folderName, LogDebug, m_maxChi2OverNDFAllowed_, m_maxSlopeAllowed_, m_minSlopeAllowed_, m_pedValues, m_plotting, and indexGen::rootFile.

Referenced by endJob().

◆ readDACs() [1/2]

void EcalPedOffset::readDACs ( const edm::Handle< EBDigiCollection > &  pDigis,
const std::map< int, int > &  DACvalues 
)
private

Definition at line 154 of file EcalPedOffset.cc.

154  {
155  std::map<int, int> DACvalues = _DACvalues;
156  // loop over the digis
157  for (EBDigiCollection::const_iterator itdigi = pDigis->begin(); itdigi != pDigis->end(); ++itdigi) {
158  int gainId = ((EBDataFrame)(*itdigi)).sample(0).gainId();
159  EBDetId detId = EBDetId(itdigi->id());
161  int FEDid = 600 + elecId.dccId();
162  int crystalId = detId.ic();
163 
164  // TODO: Behavior here
165  if (DACvalues.find(FEDid) == DACvalues.end()) {
166  edm::LogError("EcalPedOffset") << "Error! EB DCCid of digi does not "
167  "match any DCCid found in DCC headers"
168  << FEDid;
169  }
170 
171  if (!m_pedValues.count(FEDid)) {
172  LogDebug("EcalPedOffset") << "Inserting new TPedValues object for FED:" << FEDid;
173  m_pedValues[FEDid] = new TPedValues(m_RMSmax, m_bestPed);
174  }
175 
176  // loop over the samples
177  for (int iSample = 0; iSample < EcalDataFrame::MAXSAMPLES; ++iSample) {
178  m_pedValues[FEDid]->insert(
179  gainId, crystalId, DACvalues[FEDid], ((EBDataFrame)(*itdigi)).sample(iSample).adc(), crystalId);
180  }
181 
182  } // end loop over digis
183 }

References gpuClustering::adc, edm::DataFrameContainer::begin(), EcalElectronicsId::dccId(), ecalElectronicsMap_, edm::DataFrameContainer::end(), ecalLiteDTU::gainId(), EcalElectronicsMapping::getElectronicsId(), EBDetId::ic(), LogDebug, m_bestPed, m_pedValues, m_RMSmax, EcalDataFrame::MAXSAMPLES, and simplePhotonAnalyzer_cfi::sample.

Referenced by analyze().

◆ readDACs() [2/2]

void EcalPedOffset::readDACs ( const edm::Handle< EEDigiCollection > &  pDigis,
const std::map< int, int > &  DACvalues 
)
private

Definition at line 187 of file EcalPedOffset.cc.

187  {
188  std::map<int, int> DACvalues = _DACvalues;
189  // loop over the digis
190  for (EEDigiCollection::const_iterator itdigi = pDigis->begin(); itdigi != pDigis->end(); ++itdigi) {
191  int gainId = ((EEDataFrame)(*itdigi)).sample(0).gainId();
192  // int gainId = itdigi->sample(0).gainId();
193  EEDetId detId = EEDetId(itdigi->id());
195  int FEDid = 600 + elecId.dccId();
196  int crystalId = 25 * elecId.towerId() + 5 * elecId.stripId() + elecId.xtalId();
197  int endcapCrystalId = 100 * elecId.towerId() + 5 * (elecId.stripId() - 1) + elecId.xtalId();
198 
199  // TODO: Behavior here
200  if (DACvalues.find(FEDid) == DACvalues.end()) {
201  edm::LogError("EcalPedOffset") << "Error! EE DCCid of digi does not "
202  "match any DCCid found in DCC headers: "
203  << FEDid;
204  }
205 
206  if (!m_pedValues.count(FEDid)) {
207  LogDebug("EcalPedOffset") << "Inserting new TPedValues object for FED:" << FEDid;
208  m_pedValues[FEDid] = new TPedValues(m_RMSmax, m_bestPed);
209  }
210 
211  // loop over the samples
212  for (int iSample = 0; iSample < EcalDataFrame::MAXSAMPLES; ++iSample) {
213  m_pedValues[FEDid]->insert(
214  gainId, crystalId, DACvalues[FEDid], ((EEDataFrame)(*itdigi)).sample(iSample).adc(), endcapCrystalId);
215  }
216 
217  } // end loop over digis
218 }

References gpuClustering::adc, edm::DataFrameContainer::begin(), EcalElectronicsId::dccId(), ecalElectronicsMap_, edm::DataFrameContainer::end(), ecalLiteDTU::gainId(), EcalElectronicsMapping::getElectronicsId(), LogDebug, m_bestPed, m_pedValues, m_RMSmax, EcalDataFrame::MAXSAMPLES, and simplePhotonAnalyzer_cfi::sample.

◆ writeDb()

void EcalPedOffset::writeDb ( )

WriteDB.

write the m_pedResult in the DB FIXME divide into sub-tasks

Definition at line 241 of file EcalPedOffset.cc.

241  {
242  LogDebug("EcalPedOffset") << " entering writeDb ...";
243 
244  // connect to the database
245  EcalCondDBInterface *DBconnection;
246  try {
247  LogInfo("EcalPedOffset") << "Opening DB connection with TNS_ADMIN ...";
249  } catch (std::runtime_error &e) {
250  LogError("EcalPedOffset") << e.what();
251  if (!m_dbHostName.empty()) {
252  try {
253  LogInfo("EcalPedOffset") << "Opening DB connection without TNS_ADMIN ...";
255  } catch (std::runtime_error &e) {
256  LogError("EcalPedOffset") << e.what();
257  return;
258  }
259  } else
260  return;
261  }
262 
263  // define the query for RunIOV to get the right place in the database
264  RunTag runtag;
265  LocationDef locdef;
266  RunTypeDef rundef;
267  locdef.setLocation(m_location);
268 
269  runtag.setGeneralTag("PEDESTAL-OFFSET");
270  rundef.setRunType("PEDESTAL-OFFSET");
271  // rundef.setRunType ("TEST");
272  // runtag.setGeneralTag ("TEST");
273 
274  runtag.setLocationDef(locdef);
275  runtag.setRunTypeDef(rundef);
276 
277  run_t run = m_run; // FIXME dal config file
278  // RunIOV runiov = DBconnection->fetchRunIOV (&runtag, run);
279  RunIOV runiov = DBconnection->fetchRunIOV(m_location, run);
280 
281  // MonRunIOV
282  MonVersionDef monverdef;
283  monverdef.setMonitoringVersion("test01");
284  MonRunTag montag;
285  montag.setMonVersionDef(monverdef);
286  montag.setGeneralTag("CMSSW");
287 
288  subrun_t subrun = 1; // hardcoded!
289 
290  MonRunIOV moniov;
291 
292  try {
293  runtag = runiov.getRunTag();
294  moniov = DBconnection->fetchMonRunIOV(&runtag, &montag, run, subrun);
295  } catch (std::runtime_error &e) {
296  if (m_create_moniov) {
297  // if not already in the DB create a new MonRunIOV
298  Tm startSubRun;
299  startSubRun.setToCurrentGMTime();
300  // setup the MonIOV
301  moniov.setRunIOV(runiov);
302  moniov.setSubRunNumber(subrun);
303  moniov.setSubRunStart(startSubRun);
304  moniov.setMonRunTag(montag);
305  LogDebug("EcalPedOffset") << " creating a new MonRunIOV";
306  } else {
307  edm::LogError("EcalPedOffset") << " no MonRunIOV existing in the DB";
308  edm::LogError("EcalPedOffset") << " the result will not be stored into the DB";
309  if (DBconnection) {
310  delete DBconnection;
311  }
312  return;
313  }
314  }
315 
316  // create the table to be filled and the map to be inserted
317  EcalLogicID ecid;
318  std::map<EcalLogicID, MonPedestalOffsetsDat> DBdataset;
319  MonPedestalOffsetsDat DBtable;
320 
321  // fill the table
322 
323  // loop over the super-modules
324  for (std::map<int, TPedResult *>::const_iterator result = m_pedResult.begin(); result != m_pedResult.end();
325  ++result) {
326  // loop over the crystals
327  for (int xtal = 0; xtal < 1700; ++xtal) {
328  DBtable.setDACG1(result->second->m_DACvalue[2][xtal]);
329  DBtable.setDACG6(result->second->m_DACvalue[1][xtal]);
330  DBtable.setDACG12(result->second->m_DACvalue[0][xtal]);
331  DBtable.setTaskStatus(true); // FIXME to be set correctly
332 
333  // fill the table
334  if (DBconnection) {
335  try {
336  int fedid = result->first;
337  int eid = m_pedValues[fedid]->getCrystalNumber(xtal);
338  // If eid is zero, that crystal was not present in digis
339  if (eid == 0)
340  continue;
341 
342  if (fedid >= 601 && fedid <= 609) {
343  // Add the FEDid part in for DB
344  eid = eid + 10000 * (fedid - 600);
345  ecid = DBconnection->getEcalLogicID("EE_elec_crystal_number", eid);
346  } else if (fedid >= 610 && fedid <= 627) {
347  ecid = DBconnection->getEcalLogicID("EB_crystal_number", fedid - 610 + 19, eid);
348  } else if (fedid >= 628 && fedid <= 645) {
349  ecid = DBconnection->getEcalLogicID("EB_crystal_number", fedid - 628 + 1, eid);
350  } else if (fedid >= 646 && fedid <= 654) {
351  // Add the FEDid part in for DB
352  eid = eid + 10000 * (fedid - 600);
353  ecid = DBconnection->getEcalLogicID("EE_elec_crystal_number", eid);
354  } else
355  LogError("EcalPedOffset") << "FEDid is out of range 601-654";
356 
357  DBdataset[ecid] = DBtable;
358  } catch (std::runtime_error &e) {
359  edm::LogError("EcalPedOffset") << e.what();
360  }
361  }
362  } // loop over the crystals
363  } // loop over the super-modules
364 
365  // insert the map of tables in the database
366  if (DBconnection) {
367  try {
368  LogDebug("EcalPedOffset") << "Inserting dataset ... " << std::flush;
369  if (!DBdataset.empty())
370  DBconnection->insertDataSet(&DBdataset, &moniov);
371  LogDebug("EcalPedOffset") << "done.";
372  } catch (std::runtime_error &e) {
373  edm::LogError("EcalPedOffset") << e.what();
374  }
375  }
376 
377  if (DBconnection) {
378  delete DBconnection;
379  }
380 }

References MillePedeFileConverter_cfg::e, runTauDisplay::eid, PixelSLinkDataInputSource_cfi::fedid, EcalCondDBInterface::fetchMonRunIOV(), EcalCondDBInterface::fetchRunIOV(), EcalCondDBInterface::getEcalLogicID(), RunIOV::getRunTag(), EcalCondDBInterface::insertDataSet(), LogDebug, m_create_moniov, m_dbHostName, m_dbHostPort, m_dbName, m_dbPassword, m_dbUserName, m_location, m_pedResult, m_pedValues, m_run, mps_fire::result, writedatasetfile::run, test_db_connect::runtag, MonPedestalOffsetsDat::setDACG1(), MonPedestalOffsetsDat::setDACG12(), MonPedestalOffsetsDat::setDACG6(), MonRunTag::setGeneralTag(), LocationDef::setLocation(), MonVersionDef::setMonitoringVersion(), MonRunIOV::setMonRunTag(), MonRunTag::setMonVersionDef(), MonRunIOV::setRunIOV(), RunTypeDef::setRunType(), MonRunIOV::setSubRunNumber(), MonRunIOV::setSubRunStart(), MonPedestalOffsetsDat::setTaskStatus(), and Tm::setToCurrentGMTime().

Referenced by endJob().

◆ writeXMLFiles()

void EcalPedOffset::writeXMLFiles ( std::string  fileName)

write the results into xml format

write the m_pedResults to XML files

Definition at line 385 of file EcalPedOffset.cc.

385  {
386  // loop over the super-modules
387  for (std::map<int, TPedResult *>::const_iterator smRes = m_pedResult.begin(); smRes != m_pedResult.end(); ++smRes) {
388  std::string thisSMFileName = fileName;
389  // open the output stream
390  thisSMFileName += "_";
391  thisSMFileName += intToString(smRes->first);
392  thisSMFileName += ".xml";
393  std::ofstream xml_outfile;
394  xml_outfile.open(thisSMFileName.c_str());
395 
396  // write the header file
397  xml_outfile << "<offsets>" << std::endl;
398  xml_outfile << "<PEDESTAL_OFFSET_RELEASE VERSION_ID = \"SM1_VER1\"> \n";
399  xml_outfile << " <RELEASE_ID>RELEASE_1</RELEASE_ID>\n";
400  xml_outfile << " <SUPERMODULE>";
401  xml_outfile << smRes->first;
402  xml_outfile << "</SUPERMODULE>\n";
403  xml_outfile << " <TIME_STAMP> 070705 </TIME_STAMP>" << std::endl;
404 
405  // loop over the crystals
406  for (int xtal = 0; xtal < 1700; ++xtal) {
407  int crystalNumber = m_pedValues[smRes->first]->getCrystalNumber(xtal);
408  if (crystalNumber == 0)
409  continue;
410  xml_outfile << " <PEDESTAL_OFFSET>\n";
411  xml_outfile << " <HIGH>" << ((smRes->second)->m_DACvalue)[0][xtal] << "</HIGH>\n";
412  xml_outfile << " <MED>" << ((smRes->second)->m_DACvalue)[1][xtal] << "</MED>\n";
413  xml_outfile << " <LOW>" << ((smRes->second)->m_DACvalue)[2][xtal] << "</LOW>\n";
414  xml_outfile << " <CRYSTAL> " << crystalNumber << " </CRYSTAL>\n";
415  xml_outfile << " </PEDESTAL_OFFSET>" << std::endl;
416  }
417 
418  // close the open tags
419  xml_outfile << " </PEDESTAL_OFFSET_RELEASE>" << std::endl;
420  xml_outfile << "</offsets>" << std::endl;
421  xml_outfile.close();
422  } // loop over the super-modules
423 }

References MillePedeFileConverter_cfg::fileName, intToString(), m_pedResult, m_pedValues, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endJob().

Member Data Documentation

◆ ecalElectronicsMap_

const EcalElectronicsMapping* EcalPedOffset::ecalElectronicsMap_
private

Definition at line 55 of file EcalPedOffset.h.

Referenced by beginRun(), and readDACs().

◆ m_barrelDigiCollection

edm::InputTag EcalPedOffset::m_barrelDigiCollection
private

secondary name given to collection of digis

Definition at line 61 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_bestPed

int EcalPedOffset::m_bestPed
private

Definition at line 73 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and readDACs().

◆ m_create_moniov

bool EcalPedOffset::m_create_moniov
private

allow the creation of a new moniov if not existing in the DB by default it is false.

Definition at line 87 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_DACmax

int EcalPedOffset::m_DACmax
private

Definition at line 71 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and endJob().

◆ m_DACmin

int EcalPedOffset::m_DACmin
private

Definition at line 70 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and endJob().

◆ m_dbHostName

std::string EcalPedOffset::m_dbHostName
private

database host name

Definition at line 76 of file EcalPedOffset.h.

Referenced by endJob(), and writeDb().

◆ m_dbHostPort

int EcalPedOffset::m_dbHostPort
private

database

Definition at line 84 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_dbName

std::string EcalPedOffset::m_dbName
private

database name

Definition at line 78 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_dbPassword

std::string EcalPedOffset::m_dbPassword
private

database user password

Definition at line 82 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_dbUserName

std::string EcalPedOffset::m_dbUserName
private

database user name

Definition at line 80 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_endcapDigiCollection

edm::InputTag EcalPedOffset::m_endcapDigiCollection
private

secondary name given to collection of digis

Definition at line 62 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_headerCollection

edm::InputTag EcalPedOffset::m_headerCollection
private

name of module/plugin/producer making headers

Definition at line 63 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_location

std::string EcalPedOffset::m_location
private

Definition at line 89 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_maxChi2OverNDFAllowed_

double EcalPedOffset::m_maxChi2OverNDFAllowed_
private

max chi2/ndf allowed for linearity test

Definition at line 100 of file EcalPedOffset.h.

Referenced by makePlots().

◆ m_maxSlopeAllowed_

double EcalPedOffset::m_maxSlopeAllowed_
private

max slope (in magnitude) allowed for linearity test

Definition at line 96 of file EcalPedOffset.h.

Referenced by makePlots().

◆ m_minSlopeAllowed_

double EcalPedOffset::m_minSlopeAllowed_
private

min slope (in magnitude) allowed for linearity test

Definition at line 98 of file EcalPedOffset.h.

Referenced by makePlots().

◆ m_pedResult

std::map<int, TPedResult *> EcalPedOffset::m_pedResult
private

Definition at line 68 of file EcalPedOffset.h.

Referenced by endJob(), writeDb(), writeXMLFiles(), and ~EcalPedOffset().

◆ m_pedValues

std::map<int, TPedValues *> EcalPedOffset::m_pedValues
private

Definition at line 67 of file EcalPedOffset.h.

Referenced by endJob(), makePlots(), readDACs(), writeDb(), writeXMLFiles(), and ~EcalPedOffset().

◆ m_plotting

std::string EcalPedOffset::m_plotting
private

the root file where to store the detail plots

Definition at line 94 of file EcalPedOffset.h.

Referenced by endJob(), and makePlots().

◆ m_RMSmax

double EcalPedOffset::m_RMSmax
private

Definition at line 72 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and readDACs().

◆ m_run

int EcalPedOffset::m_run
private

run number

Definition at line 91 of file EcalPedOffset.h.

Referenced by analyze(), and writeDb().

◆ m_xmlFile

std::string EcalPedOffset::m_xmlFile
private

name of the xml file to be saved

Definition at line 65 of file EcalPedOffset.h.

Referenced by endJob().

EcalDataFrame::MAXSAMPLES
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
EcalPedOffset::m_create_moniov
bool m_create_moniov
Definition: EcalPedOffset.h:87
LocationDef::setLocation
void setLocation(std::string loc)
Definition: LocationDef.cc:20
EcalCondDBInterface
Definition: EcalCondDBInterface.h:37
EcalPedOffset::m_location
std::string m_location
Definition: EcalPedOffset.h:89
RunIOV
Definition: RunIOV.h:13
ecalLiteDTU::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalLiteDTUSample.h:14
MonVersionDef::setMonitoringVersion
void setMonitoringVersion(std::string ver)
Definition: MonVersionDef.cc:21
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
EcalPedOffset::makePlots
void makePlots()
create the plots of the DAC pedestal trend
Definition: EcalPedOffset.cc:428
subrun_t
int subrun_t
Definition: MODRunIOV.h:11
MonPedestalOffsetsDat::setDACG1
void setDACG1(int dac)
Definition: MonPedestalOffsetsDat.h:21
run_t
int run_t
Definition: CaliIOV.h:11
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
TPedResult
Definition: TPedResult.h:15
mtdUncalibratedRecHits_cfi.barrelDigis
barrelDigis
Definition: mtdUncalibratedRecHits_cfi.py:33
EBDetId::ic
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
patZpeak.handle
handle
Definition: patZpeak.py:23
EBDetId
Definition: EBDetId.h:17
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
EBDataFrame
Definition: EBDataFrame.h:11
RunTag
Definition: RunTag.h:13
LocationDef
Definition: LocationDef.h:12
EcalCondDBInterface::fetchMonRunIOV
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
Definition: EcalCondDBInterface.cc:674
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
EcalElectronicsId::dccId
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Definition: EcalElectronicsId.h:31
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
MonRunIOV::setRunIOV
void setRunIOV(const RunIOV &iov)
Definition: MonRunIOV.cc:36
edm::Handle
Definition: AssociativeIterator.h:50
MonRunTag::setGeneralTag
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:21
EcalPedOffset::m_plotting
std::string m_plotting
the root file where to store the detail plots
Definition: EcalPedOffset.h:94
EcalPedOffset::m_headerCollection
edm::InputTag m_headerCollection
name of module/plugin/producer making headers
Definition: EcalPedOffset.h:63
EcalCondDBInterface::insertDataSet
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
Definition: EcalCondDBInterface.h:260
EcalPedOffset::m_pedValues
std::map< int, TPedValues * > m_pedValues
Definition: EcalPedOffset.h:67
EcalPedOffset::ecalElectronicsMap_
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedOffset.h:55
RunTypeDef::setRunType
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:21
EcalPedOffset::m_bestPed
int m_bestPed
Definition: EcalPedOffset.h:73
EcalPedOffset::m_dbPassword
std::string m_dbPassword
database user password
Definition: EcalPedOffset.h:82
EcalPedOffset::m_dbName
std::string m_dbName
database name
Definition: EcalPedOffset.h:78
MonPedestalOffsetsDat::setDACG6
void setDACG6(int dac)
Definition: MonPedestalOffsetsDat.h:24
EcalPedOffset::m_DACmin
int m_DACmin
Definition: EcalPedOffset.h:70
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
RunIOV::getRunTag
RunTag getRunTag() const
Definition: RunIOV.cc:58
EcalPedOffset::m_DACmax
int m_DACmax
Definition: EcalPedOffset.h:71
indexGen.rootFile
rootFile
Definition: indexGen.py:92
edm::ESHandle< EcalElectronicsMapping >
EcalElectronicsMapping::getElectronicsId
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
Definition: EcalElectronicsMapping.cc:324
EcalLogicID
Definition: EcalLogicID.h:7
MonVersionDef
Definition: MonVersionDef.h:12
EcalPedOffset::m_dbHostName
std::string m_dbHostName
database host name
Definition: EcalPedOffset.h:76
EcalPedOffset::m_endcapDigiCollection
edm::InputTag m_endcapDigiCollection
secondary name given to collection of digis
Definition: EcalPedOffset.h:62
Tm::setToCurrentGMTime
void setToCurrentGMTime()
Definition: Tm.cc:141
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
Tm
Definition: Tm.h:13
TPedValues
Definition: TPedValues.h:19
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalDCCHeaderBlock::EcalDCCEventSettings
Definition: EcalDCCHeaderBlock.h:64
EcalPedOffset::writeDb
void writeDb()
WriteDB.
Definition: EcalPedOffset.cc:241
RunTypeDef
Definition: RunTypeDef.h:12
EcalPedOffset::intToString
std::string intToString(int num)
Definition: EcalPedOffset.cc:457
EcalPedOffset::m_dbHostPort
int m_dbHostPort
database
Definition: EcalPedOffset.h:84
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
MonPedestalOffsetsDat::setDACG12
void setDACG12(int dac)
Definition: MonPedestalOffsetsDat.h:27
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
test_db_connect.runtag
runtag
Definition: test_db_connect.py:16
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
EcalPedOffset::m_xmlFile
std::string m_xmlFile
name of the xml file to be saved
Definition: EcalPedOffset.h:65
MonRunIOV
Definition: MonRunIOV.h:14
MonRunIOV::setSubRunNumber
void setSubRunNumber(subrun_t subrun)
Definition: MonRunIOV.cc:45
MonRunTag
Definition: MonRunTag.h:13
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
MonRunIOV::setMonRunTag
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunIOV.cc:27
PixelSLinkDataInputSource_cfi.fedid
fedid
Definition: PixelSLinkDataInputSource_cfi.py:6
EcalCondDBInterface::getEcalLogicID
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
get
#define get
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:27
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
MonPedestalOffsetsDat::setTaskStatus
void setTaskStatus(bool status)
Definition: MonPedestalOffsetsDat.h:30
EcalDCCHeaderBlock::EcalDCCEventSettings::ped_offset
short ped_offset
Definition: EcalDCCHeaderBlock.h:71
EcalPedOffset::readDACs
void readDACs(const edm::Handle< EBDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
Definition: EcalPedOffset.cc:154
writedatasetfile.run
run
Definition: writedatasetfile.py:27
EcalMappingRcd
Definition: EcalMappingRcd.h:15
MonPedestalOffsetsDat
Definition: MonPedestalOffsetsDat.h:12
EcalPedOffset::m_RMSmax
double m_RMSmax
Definition: EcalPedOffset.h:72
EcalPedOffset::m_minSlopeAllowed_
double m_minSlopeAllowed_
min slope (in magnitude) allowed for linearity test
Definition: EcalPedOffset.h:98
EcalPedOffset::m_barrelDigiCollection
edm::InputTag m_barrelDigiCollection
secondary name given to collection of digis
Definition: EcalPedOffset.h:61
EcalPedOffset::m_run
int m_run
run number
Definition: EcalPedOffset.h:91
EcalPedOffset::m_pedResult
std::map< int, TPedResult * > m_pedResult
Definition: EcalPedOffset.h:68
MonRunIOV::setSubRunStart
void setSubRunStart(const Tm &start)
Definition: MonRunIOV.cc:54
mps_fire.result
result
Definition: mps_fire.py:311
EcalPedOffset::writeXMLFiles
void writeXMLFiles(std::string fileName)
write the results into xml format
Definition: EcalPedOffset.cc:385
MonRunTag::setMonVersionDef
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:30
mtdUncalibratedRecHits_cfi.endcapDigis
endcapDigis
Definition: mtdUncalibratedRecHits_cfi.py:34
EEDataFrame
Definition: EEDataFrame.h:12
EcalCondDBInterface::fetchRunIOV
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
Definition: EcalCondDBInterface.cc:631
EcalPedOffset::m_dbUserName
std::string m_dbUserName
database user name
Definition: EcalPedOffset.h:80
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
edm::InputTag
Definition: InputTag.h:15
EcalPedOffset::m_maxSlopeAllowed_
double m_maxSlopeAllowed_
max slope (in magnitude) allowed for linearity test
Definition: EcalPedOffset.h:96
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
EcalPedOffset::m_maxChi2OverNDFAllowed_
double m_maxChi2OverNDFAllowed_
max chi2/ndf allowed for linearity test
Definition: EcalPedOffset.h:100