32 : m_barrelDigiCollection(paramSet.getParameter<
edm::
InputTag>(
"EBdigiCollection")),
33 m_endcapDigiCollection(paramSet.getParameter<
edm::
InputTag>(
"EEdigiCollection")),
34 m_headerCollection(paramSet.getParameter<
edm::
InputTag>(
"headerCollection")),
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")),
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)) {
65 for (std::map<int, TPedValues *>::iterator mapIt =
m_pedValues.begin(); mapIt !=
m_pedValues.end(); ++mapIt)
75 LogDebug(
"EcalPedOffset") <<
"entering beginRun...";
91 LogDebug(
"EcalPedOffset") <<
"entering analyze ...";
98 std::map<int, int> DACvalues;
101 m_run =
event.id().run();
107 int FEDid = 600 + headerItr->id();
109 LogDebug(
"EcalPedOffset") <<
"Found FED: " << FEDid <<
" in DCC header";
112 bool barrelDigisFound =
true;
113 bool endcapDigisFound =
true;
120 <<
"; not reading barrel digis";
121 barrelDigisFound =
false;
125 edm::LogInfo(
"EcalPedOffset") <<
"Size of EBDigiCollection is zero;" 126 <<
" not reading barrel digis";
127 barrelDigisFound =
false;
136 <<
"; not reading endcap digis";
137 endcapDigisFound =
false;
141 edm::LogInfo(
"EcalPedOffset") <<
"Size of EEDigiCollection is zero;" 142 <<
" not reading endcap digis";
143 endcapDigisFound =
false;
146 if (barrelDigisFound)
148 if (endcapDigisFound)
150 if (!barrelDigisFound && !endcapDigisFound)
151 edm::LogError(
"EcalPedOffset") <<
"No digis found in the event!";
157 std::map<int, int> DACvalues = _DACvalues;
163 int FEDid = 600 + elecId.
dccId();
164 int crystalId = detId.
ic();
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" 174 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
190 std::map<int, int> DACvalues = _DACvalues;
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();
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: " 209 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
226 for (std::map<int, TPedValues *>::const_iterator smPeds =
m_pedValues.begin(); smPeds !=
m_pedValues.end();
244 LogDebug(
"EcalPedOffset") <<
" entering writeDb ...";
249 LogInfo(
"EcalPedOffset") <<
"Opening DB connection with TNS_ADMIN ...";
251 }
catch (std::runtime_error &
e) {
255 LogInfo(
"EcalPedOffset") <<
"Opening DB connection without TNS_ADMIN ...";
257 }
catch (std::runtime_error &
e) {
271 runtag.setGeneralTag(
"PEDESTAL-OFFSET");
276 runtag.setLocationDef(locdef);
277 runtag.setRunTypeDef(rundef);
297 }
catch (std::runtime_error &
e) {
307 LogDebug(
"EcalPedOffset") <<
" creating a new MonRunIOV";
309 edm::LogError(
"EcalPedOffset") <<
" no MonRunIOV existing in the DB";
310 edm::LogError(
"EcalPedOffset") <<
" the result will not be stored into the DB";
320 std::map<EcalLogicID, MonPedestalOffsetsDat> DBdataset;
329 for (
int xtal = 0; xtal < 1700; ++xtal) {
357 LogError(
"EcalPedOffset") <<
"FEDid is out of range 601-654";
359 DBdataset[ecid] = DBtable;
360 }
catch (std::runtime_error &
e) {
370 LogDebug(
"EcalPedOffset") <<
"Inserting dataset ... " << std::flush;
371 if (!DBdataset.empty())
373 LogDebug(
"EcalPedOffset") <<
"done.";
374 }
catch (std::runtime_error &
e) {
389 for (std::map<int, TPedResult *>::const_iterator smRes =
m_pedResult.begin(); smRes !=
m_pedResult.end(); ++smRes) {
392 thisSMFileName +=
"_";
394 thisSMFileName +=
".xml";
395 std::ofstream xml_outfile;
396 xml_outfile.open(thisSMFileName.c_str());
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;
408 for (
int xtal = 0; xtal < 1700; ++xtal) {
409 int crystalNumber =
m_pedValues[smRes->first]->getCrystalNumber(xtal);
410 if (crystalNumber == 0)
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;
421 xml_outfile <<
" </PEDESTAL_OFFSET_RELEASE>" << std::endl;
422 xml_outfile <<
"</offsets>" << std::endl;
431 LogDebug(
"EcalPedOffset") <<
" entering makePlots ...";
438 TFile *rootFile =
new TFile(
m_plotting.c_str(),
"RECREATE");
441 for (std::map<int, TPedValues *>::const_iterator smPeds =
m_pedValues.begin(); smPeds !=
m_pedValues.end();
445 sprintf(
folderName,
"FED%02d", smPeds->first);
453 LogDebug(
"EcalPedOffset") <<
" DONE";
462 std::ostringstream myStream;
463 myStream <<
num << std::flush;
464 return (myStream.str());
void setTaskStatus(bool status)
double m_maxChi2OverNDFAllowed_
max chi2/ndf allowed for linearity test
std::string m_dbHostName
database host name
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
const edm::InputTag m_barrelDigiCollection
secondary name given to collection of digis
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::string m_dbName
database name
void setRunIOV(const RunIOV &iov)
std::string intToString(int num)
const edm::EDGetTokenT< EcalRawDataCollection > m_rawDataToken
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
const edm::InputTag m_endcapDigiCollection
secondary name given to collection of digis
std::vector< T >::const_iterator const_iterator
~EcalPedOffset() override
Destructor.
void endRun(edm::Run const &, edm::EventSetup const &) override
EndRun.
std::string m_xmlFile
name of the xml file to be saved
Log< level::Error, false > LogError
double m_minSlopeAllowed_
min slope (in magnitude) allowed for linearity test
void setToCurrentGMTime()
void setGeneralTag(std::string tag)
std::string m_dbPassword
database user password
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > m_mappingToken
std::string m_plotting
the root file where to store the detail plots
void endJob(void) override
EndJob.
std::string m_dbUserName
database user name
void readDACs(const edm::Handle< EBDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
int ic() const
get ECAL/crystal number inside SM
void makePlots()
create the plots of the DAC pedestal trend
void setSubRunNumber(subrun_t subrun)
const_iterator begin() const
void setMonVersionDef(const MonVersionDef &ver)
void setSubRunStart(const Tm &start)
void beginRun(edm::Run const &, edm::EventSetup const &eventSetup) override
BeginRun.
std::map< int, TPedResult * > m_pedResult
const_iterator end() const
Namespace of DDCMS conversion namespace.
const_iterator end() const
void writeXMLFiles(std::string fileName)
write the results into xml format
const edm::EDGetTokenT< EEDigiCollection > m_eeDigiToken
Log< level::Info, false > LogInfo
EcalPedOffset(const edm::ParameterSet &ps)
Constructor.
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.
void setRunType(std::string runtype)
void setMonRunTag(const MonRunTag &tag)
std::map< int, TPedValues * > m_pedValues
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void setMonitoringVersion(std::string ver)
const EcalElectronicsMapping * ecalElectronicsMap_
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
void setLocation(std::string loc)
static constexpr int MAXSAMPLES
double m_maxSlopeAllowed_
max slope (in magnitude) allowed for linearity test
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override
! Analyze
const edm::EDGetTokenT< EBDigiCollection > m_ebDigiToken