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::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase 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 endRun (edm::Run const &, edm::EventSetup const &) override
 EndRun. 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::one::EDAnalyzer< edm::one::WatchRuns >
 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

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_
 
const 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...
 
const edm::EDGetTokenT< EBDigiCollectionm_ebDigiToken
 
const edm::EDGetTokenT< EEDigiCollectionm_eeDigiToken
 
const edm::InputTag m_endcapDigiCollection
 secondary name given to collection of digis More...
 
const edm::InputTag m_headerCollection
 name of module/plugin/producer making headers More...
 
std::string m_location
 
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcdm_mappingToken
 
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...
 
const edm::EDGetTokenT< EcalRawDataCollectionm_rawDataToken
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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 31 of file EcalPedOffset.cc.

References m_bestPed, m_DACmax, m_DACmin, and m_RMSmax.

32  : m_barrelDigiCollection(paramSet.getParameter<edm::InputTag>("EBdigiCollection")),
33  m_endcapDigiCollection(paramSet.getParameter<edm::InputTag>("EEdigiCollection")),
34  m_headerCollection(paramSet.getParameter<edm::InputTag>("headerCollection")),
35  m_rawDataToken(consumes<EcalRawDataCollection>(m_headerCollection)),
36  m_ebDigiToken(consumes<EBDigiCollection>(m_barrelDigiCollection)),
37  m_eeDigiToken(consumes<EEDigiCollection>(m_endcapDigiCollection)),
39  m_xmlFile(paramSet.getParameter<std::string>("xmlFile")),
40  m_DACmin(paramSet.getUntrackedParameter<int>("DACmin", 0)),
41  m_DACmax(paramSet.getUntrackedParameter<int>("DACmax", 256)),
42  m_RMSmax(paramSet.getUntrackedParameter<double>("RMSmax", 2)),
43  m_bestPed(paramSet.getUntrackedParameter<int>("bestPed", 200)),
44  m_dbHostName(paramSet.getUntrackedParameter<std::string>("dbHostName", "0")),
45  m_dbName(paramSet.getUntrackedParameter<std::string>("dbName", "0")),
46  m_dbUserName(paramSet.getUntrackedParameter<std::string>("dbUserName")),
47  m_dbPassword(paramSet.getUntrackedParameter<std::string>("dbPassword")),
48  m_dbHostPort(paramSet.getUntrackedParameter<int>("dbHostPort", 1521)),
49  m_create_moniov(paramSet.getUntrackedParameter<bool>("createMonIOV", false)),
50  m_location(paramSet.getUntrackedParameter<std::string>("location", "H4")),
51  m_run(-1),
52  m_plotting(paramSet.getParameter<std::string>("plotting")),
53  m_maxSlopeAllowed_(paramSet.getUntrackedParameter<double>("maxSlopeAllowed", -29)),
54  m_minSlopeAllowed_(paramSet.getUntrackedParameter<double>("minSlopeAllowed", -18)),
55  m_maxChi2OverNDFAllowed_(paramSet.getUntrackedParameter<double>("maxChi2OverNDF", 5)) {
56  edm::LogInfo("EcalPedOffset") << " reading "
57  << " m_DACmin: " << m_DACmin << " m_DACmax: " << m_DACmax << " m_RMSmax: " << m_RMSmax
58  << " m_bestPed: " << m_bestPed;
59 }
double m_maxChi2OverNDFAllowed_
max chi2/ndf allowed for linearity test
std::string m_dbHostName
database host name
Definition: EcalPedOffset.h:84
const edm::InputTag m_barrelDigiCollection
secondary name given to collection of digis
Definition: EcalPedOffset.h:64
std::string m_dbName
database name
Definition: EcalPedOffset.h:86
const edm::EDGetTokenT< EcalRawDataCollection > m_rawDataToken
Definition: EcalPedOffset.h:68
const edm::InputTag m_endcapDigiCollection
secondary name given to collection of digis
Definition: EcalPedOffset.h:65
std::string m_xmlFile
name of the xml file to be saved
Definition: EcalPedOffset.h:73
double m_minSlopeAllowed_
min slope (in magnitude) allowed for linearity test
std::string m_dbPassword
database user password
Definition: EcalPedOffset.h:90
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > m_mappingToken
Definition: EcalPedOffset.h:71
std::string m_plotting
the root file where to store the detail plots
int m_dbHostPort
database
Definition: EcalPedOffset.h:92
std::string m_dbUserName
database user name
Definition: EcalPedOffset.h:88
const edm::InputTag m_headerCollection
name of module/plugin/producer making headers
Definition: EcalPedOffset.h:66
bool m_create_moniov
Definition: EcalPedOffset.h:95
const edm::EDGetTokenT< EEDigiCollection > m_eeDigiToken
Definition: EcalPedOffset.h:70
Log< level::Info, false > LogInfo
int m_run
run number
Definition: EcalPedOffset.h:99
std::string m_location
Definition: EcalPedOffset.h:97
double m_maxSlopeAllowed_
max slope (in magnitude) allowed for linearity test
const edm::EDGetTokenT< EBDigiCollection > m_ebDigiToken
Definition: EcalPedOffset.h:69

◆ ~EcalPedOffset()

EcalPedOffset::~EcalPedOffset ( )
override

Destructor.

dtor

Definition at line 64 of file EcalPedOffset.cc.

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

64  {
65  for (std::map<int, TPedValues *>::iterator mapIt = m_pedValues.begin(); mapIt != m_pedValues.end(); ++mapIt)
66  delete mapIt->second;
67  for (std::map<int, TPedResult *>::iterator mapIt = m_pedResult.begin(); mapIt != m_pedResult.end(); ++mapIt)
68  delete mapIt->second;
69 }
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
std::map< int, TPedResult * > m_pedResult
Definition: EcalPedOffset.h:76
std::map< int, TPedValues * > m_pedValues
Definition: EcalPedOffset.h:75

Member Function Documentation

◆ analyze()

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

! Analyze

perform the analysis

Implements edm::one::EDAnalyzerBase.

Definition at line 90 of file EcalPedOffset.cc.

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

90  {
91  LogDebug("EcalPedOffset") << "entering analyze ...";
92 
93  // get the headers
94  // (one header for each supermodule)
96  event.getByToken(m_rawDataToken, DCCHeaders);
97 
98  std::map<int, int> DACvalues;
99 
100  if (m_run == -1)
101  m_run = event.id().run();
102 
103  // loop over the headers
104  for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
105  ++headerItr) {
106  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
107  int FEDid = 600 + headerItr->id();
108  DACvalues[FEDid] = settings.ped_offset;
109  LogDebug("EcalPedOffset") << "Found FED: " << FEDid << " in DCC header";
110  }
111 
112  bool barrelDigisFound = true;
113  bool endcapDigisFound = true;
114  // get the barrel digis
115  // (one digi for each crystal)
117  event.getByToken(m_ebDigiToken, barrelDigis);
118  if (!barrelDigis.isValid()) {
119  edm::LogError("EcalPedOffset") << "Error! can't get the product " << m_barrelDigiCollection
120  << "; not reading barrel digis";
121  barrelDigisFound = false;
122  }
123 
124  if (barrelDigis->empty()) {
125  edm::LogInfo("EcalPedOffset") << "Size of EBDigiCollection is zero;"
126  << " not reading barrel digis";
127  barrelDigisFound = false;
128  }
129 
130  // get the endcap digis
131  // (one digi for each crystal)
133  event.getByToken(m_eeDigiToken, endcapDigis);
134  if (!endcapDigis.isValid()) {
135  edm::LogError("EcalPedOffset") << "Error! can't get the product " << m_endcapDigiCollection
136  << "; not reading endcap digis";
137  endcapDigisFound = false;
138  }
139 
140  if (endcapDigis->empty()) {
141  edm::LogInfo("EcalPedOffset") << "Size of EEDigiCollection is zero;"
142  << " not reading endcap digis";
143  endcapDigisFound = false;
144  }
145 
146  if (barrelDigisFound)
147  readDACs(barrelDigis, DACvalues);
148  if (endcapDigisFound)
149  readDACs(endcapDigis, DACvalues);
150  if (!barrelDigisFound && !endcapDigisFound)
151  edm::LogError("EcalPedOffset") << "No digis found in the event!";
152 }
const edm::InputTag m_barrelDigiCollection
secondary name given to collection of digis
Definition: EcalPedOffset.h:64
const edm::EDGetTokenT< EcalRawDataCollection > m_rawDataToken
Definition: EcalPedOffset.h:68
const edm::InputTag m_endcapDigiCollection
secondary name given to collection of digis
Definition: EcalPedOffset.h:65
std::vector< T >::const_iterator const_iterator
Log< level::Error, false > LogError
void readDACs(const edm::Handle< EBDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
const_iterator begin() const
const_iterator end() const
const edm::EDGetTokenT< EEDigiCollection > m_eeDigiToken
Definition: EcalPedOffset.h:70
Log< level::Info, false > LogInfo
int m_run
run number
Definition: EcalPedOffset.h:99
const edm::EDGetTokenT< EBDigiCollection > m_ebDigiToken
Definition: EcalPedOffset.h:69
#define LogDebug(id)

◆ beginRun()

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

BeginRun.

begin the run

Definition at line 74 of file EcalPedOffset.cc.

References ecalElectronicsMap_, options_cfi::eventSetup, LogDebug, and m_mappingToken.

74  {
75  LogDebug("EcalPedOffset") << "entering beginRun...";
76 
77  // get the electronics map
78  const auto mappingHandle = eventSetup.getHandle(m_mappingToken);
79  ecalElectronicsMap_ = mappingHandle.product();
80 }
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > m_mappingToken
Definition: EcalPedOffset.h:71
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedOffset.h:58
#define LogDebug(id)

◆ endJob()

void EcalPedOffset::endJob ( void  )
overridevirtual

EndJob.

perform the minimization and write results

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 225 of file EcalPedOffset.cc.

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

Referenced by o2olib.O2ORunMgr::executeJob().

225  {
226  for (std::map<int, TPedValues *>::const_iterator smPeds = m_pedValues.begin(); smPeds != m_pedValues.end();
227  ++smPeds) {
228  m_pedResult[smPeds->first] = new TPedResult((smPeds->second)->terminate(m_DACmin, m_DACmax));
229  }
230  edm::LogInfo("EcalPedOffset") << " results map size " << m_pedResult.size();
232 
233  if (m_plotting != '0')
234  makePlots();
235  if (m_dbHostName != '0')
236  writeDb();
237 }
std::string m_dbHostName
database host name
Definition: EcalPedOffset.h:84
std::string m_xmlFile
name of the xml file to be saved
Definition: EcalPedOffset.h:73
std::string m_plotting
the root file where to store the detail plots
void writeDb()
WriteDB.
void makePlots()
create the plots of the DAC pedestal trend
std::map< int, TPedResult * > m_pedResult
Definition: EcalPedOffset.h:76
void writeXMLFiles(std::string fileName)
write the results into xml format
Log< level::Info, false > LogInfo
std::map< int, TPedValues * > m_pedValues
Definition: EcalPedOffset.h:75

◆ endRun()

void EcalPedOffset::endRun ( edm::Run const &  ,
edm::EventSetup const &  eventSetup 
)
override

EndRun.

end the run

Definition at line 85 of file EcalPedOffset.cc.

85 {}

◆ intToString()

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

Definition at line 459 of file EcalPedOffset.cc.

References EgammaValidation_cff::num.

Referenced by writeXMLFiles().

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

◆ makePlots()

void EcalPedOffset::makePlots ( )

create the plots of the DAC pedestal trend

Definition at line 430 of file EcalPedOffset.cc.

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

Referenced by endJob().

430  {
431  LogDebug("EcalPedOffset") << " entering makePlots ...";
432 
433  edm::LogInfo("EcalPedOffset") << " map size: " << m_pedValues.size();
434 
435  // create the ROOT file
436  m_plotting += ".root";
437 
438  TFile *rootFile = new TFile(m_plotting.c_str(), "RECREATE");
439 
440  // loop over the supermodules
441  for (std::map<int, TPedValues *>::const_iterator smPeds = m_pedValues.begin(); smPeds != m_pedValues.end();
442  ++smPeds) {
443  // make a folder in the ROOT file
444  char folderName[120];
445  sprintf(folderName, "FED%02d", smPeds->first);
446  rootFile->mkdir(folderName);
447  smPeds->second->makePlots(rootFile, folderName, m_maxSlopeAllowed_, m_minSlopeAllowed_, m_maxChi2OverNDFAllowed_);
448  }
449 
450  rootFile->Close();
451  delete rootFile;
452 
453  LogDebug("EcalPedOffset") << " DONE";
454 }
double m_maxChi2OverNDFAllowed_
max chi2/ndf allowed for linearity test
double m_minSlopeAllowed_
min slope (in magnitude) allowed for linearity test
std::string m_plotting
the root file where to store the detail plots
Log< level::Info, false > LogInfo
std::map< int, TPedValues * > m_pedValues
Definition: EcalPedOffset.h:75
double m_maxSlopeAllowed_
max slope (in magnitude) allowed for linearity test
#define LogDebug(id)

◆ readDACs() [1/2]

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

Definition at line 156 of file EcalPedOffset.cc.

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 ecalGpuTask_cfi::sample.

Referenced by analyze().

156  {
157  std::map<int, int> DACvalues = _DACvalues;
158  // loop over the digis
159  for (EBDigiCollection::const_iterator itdigi = pDigis->begin(); itdigi != pDigis->end(); ++itdigi) {
160  int gainId = ((EBDataFrame)(*itdigi)).sample(0).gainId();
161  EBDetId detId = EBDetId(itdigi->id());
163  int FEDid = 600 + elecId.dccId();
164  int crystalId = detId.ic();
165 
166  // TODO: Behavior here
167  if (DACvalues.find(FEDid) == DACvalues.end()) {
168  edm::LogError("EcalPedOffset") << "Error! EB DCCid of digi does not "
169  "match any DCCid found in DCC headers"
170  << FEDid;
171  }
172 
173  if (!m_pedValues.count(FEDid)) {
174  LogDebug("EcalPedOffset") << "Inserting new TPedValues object for FED:" << FEDid;
175  m_pedValues[FEDid] = new TPedValues(m_RMSmax, m_bestPed);
176  }
177 
178  // loop over the samples
179  for (int iSample = 0; iSample < EcalDataFrame::MAXSAMPLES; ++iSample) {
180  m_pedValues[FEDid]->insert(
181  gainId, crystalId, DACvalues[FEDid], ((EBDataFrame)(*itdigi)).sample(iSample).adc(), crystalId);
182  }
183 
184  } // end loop over digis
185 }
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Log< level::Error, false > LogError
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
const_iterator end() const
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
const_iterator begin() const
The iterator returned can not safely be used across threads.
std::map< int, TPedValues * > m_pedValues
Definition: EcalPedOffset.h:75
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedOffset.h:58
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
uint16_t *__restrict__ uint16_t const *__restrict__ adc
#define LogDebug(id)

◆ readDACs() [2/2]

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

Definition at line 189 of file EcalPedOffset.cc.

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 ecalGpuTask_cfi::sample.

189  {
190  std::map<int, int> DACvalues = _DACvalues;
191  // loop over the digis
192  for (EEDigiCollection::const_iterator itdigi = pDigis->begin(); itdigi != pDigis->end(); ++itdigi) {
193  int gainId = ((EEDataFrame)(*itdigi)).sample(0).gainId();
194  // int gainId = itdigi->sample(0).gainId();
195  EEDetId detId = EEDetId(itdigi->id());
197  int FEDid = 600 + elecId.dccId();
198  int crystalId = 25 * elecId.towerId() + 5 * elecId.stripId() + elecId.xtalId();
199  int endcapCrystalId = 100 * elecId.towerId() + 5 * (elecId.stripId() - 1) + elecId.xtalId();
200 
201  // TODO: Behavior here
202  if (DACvalues.find(FEDid) == DACvalues.end()) {
203  edm::LogError("EcalPedOffset") << "Error! EE DCCid of digi does not "
204  "match any DCCid found in DCC headers: "
205  << FEDid;
206  }
207 
208  if (!m_pedValues.count(FEDid)) {
209  LogDebug("EcalPedOffset") << "Inserting new TPedValues object for FED:" << FEDid;
210  m_pedValues[FEDid] = new TPedValues(m_RMSmax, m_bestPed);
211  }
212 
213  // loop over the samples
214  for (int iSample = 0; iSample < EcalDataFrame::MAXSAMPLES; ++iSample) {
215  m_pedValues[FEDid]->insert(
216  gainId, crystalId, DACvalues[FEDid], ((EEDataFrame)(*itdigi)).sample(iSample).adc(), endcapCrystalId);
217  }
218 
219  } // end loop over digis
220 }
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Log< level::Error, false > LogError
const_iterator end() const
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
const_iterator begin() const
The iterator returned can not safely be used across threads.
std::map< int, TPedValues * > m_pedValues
Definition: EcalPedOffset.h:75
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedOffset.h:58
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
uint16_t *__restrict__ uint16_t const *__restrict__ adc
#define LogDebug(id)

◆ writeDb()

void EcalPedOffset::writeDb ( )

WriteDB.

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

Definition at line 243 of file EcalPedOffset.cc.

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

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

◆ writeXMLFiles()

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

write the results into xml format

write the m_pedResults to XML files

Definition at line 387 of file EcalPedOffset.cc.

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

Referenced by endJob().

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

Member Data Documentation

◆ ecalElectronicsMap_

const EcalElectronicsMapping* EcalPedOffset::ecalElectronicsMap_
private

Definition at line 58 of file EcalPedOffset.h.

Referenced by beginRun(), and readDACs().

◆ m_barrelDigiCollection

const edm::InputTag EcalPedOffset::m_barrelDigiCollection
private

secondary name given to collection of digis

Definition at line 64 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_bestPed

int EcalPedOffset::m_bestPed
private

Definition at line 81 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 95 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_DACmax

int EcalPedOffset::m_DACmax
private

Definition at line 79 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and endJob().

◆ m_DACmin

int EcalPedOffset::m_DACmin
private

Definition at line 78 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and endJob().

◆ m_dbHostName

std::string EcalPedOffset::m_dbHostName
private

database host name

Definition at line 84 of file EcalPedOffset.h.

Referenced by endJob(), and writeDb().

◆ m_dbHostPort

int EcalPedOffset::m_dbHostPort
private

database

Definition at line 92 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_dbName

std::string EcalPedOffset::m_dbName
private

database name

Definition at line 86 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_dbPassword

std::string EcalPedOffset::m_dbPassword
private

database user password

Definition at line 90 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_dbUserName

std::string EcalPedOffset::m_dbUserName
private

database user name

Definition at line 88 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_ebDigiToken

const edm::EDGetTokenT<EBDigiCollection> EcalPedOffset::m_ebDigiToken
private

Definition at line 69 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_eeDigiToken

const edm::EDGetTokenT<EEDigiCollection> EcalPedOffset::m_eeDigiToken
private

Definition at line 70 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_endcapDigiCollection

const edm::InputTag EcalPedOffset::m_endcapDigiCollection
private

secondary name given to collection of digis

Definition at line 65 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_headerCollection

const edm::InputTag EcalPedOffset::m_headerCollection
private

name of module/plugin/producer making headers

Definition at line 66 of file EcalPedOffset.h.

◆ m_location

std::string EcalPedOffset::m_location
private

Definition at line 97 of file EcalPedOffset.h.

Referenced by writeDb().

◆ m_mappingToken

const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> EcalPedOffset::m_mappingToken
private

Definition at line 71 of file EcalPedOffset.h.

Referenced by beginRun().

◆ m_maxChi2OverNDFAllowed_

double EcalPedOffset::m_maxChi2OverNDFAllowed_
private

max chi2/ndf allowed for linearity test

Definition at line 108 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 104 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 106 of file EcalPedOffset.h.

Referenced by makePlots().

◆ m_pedResult

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

Definition at line 76 of file EcalPedOffset.h.

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

◆ m_pedValues

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

Definition at line 75 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 102 of file EcalPedOffset.h.

Referenced by endJob(), and makePlots().

◆ m_rawDataToken

const edm::EDGetTokenT<EcalRawDataCollection> EcalPedOffset::m_rawDataToken
private

Definition at line 68 of file EcalPedOffset.h.

Referenced by analyze().

◆ m_RMSmax

double EcalPedOffset::m_RMSmax
private

Definition at line 80 of file EcalPedOffset.h.

Referenced by EcalPedOffset(), and readDACs().

◆ m_run

int EcalPedOffset::m_run
private

run number

Definition at line 99 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 73 of file EcalPedOffset.h.

Referenced by endJob().