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")),
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)) {
68 for (std::map<int, TPedValues *>::iterator mapIt =
m_pedValues.begin(); mapIt !=
m_pedValues.end(); ++mapIt)
70 for (std::map<int, TPedResult *>::iterator mapIt =
m_pedResult.begin(); mapIt !=
m_pedResult.end(); ++mapIt)
78 LogDebug(
"EcalPedOffset") <<
"entering beginRun...";
89 LogDebug(
"EcalPedOffset") <<
"entering analyze ...";
96 std::map<int, int> DACvalues;
99 m_run =
event.id().run();
105 int FEDid = 600 + headerItr->id();
107 LogDebug(
"EcalPedOffset") <<
"Found FED: " << FEDid <<
" in DCC header";
110 bool barrelDigisFound =
true;
111 bool endcapDigisFound =
true;
118 <<
"; not reading barrel digis";
119 barrelDigisFound =
false;
122 if (barrelDigis->
empty()) {
123 edm::LogInfo(
"EcalPedOffset") <<
"Size of EBDigiCollection is zero;" 124 <<
" not reading barrel digis";
125 barrelDigisFound =
false;
134 <<
"; not reading endcap digis";
135 endcapDigisFound =
false;
138 if (endcapDigis->
empty()) {
139 edm::LogInfo(
"EcalPedOffset") <<
"Size of EEDigiCollection is zero;" 140 <<
" not reading endcap digis";
141 endcapDigisFound =
false;
144 if (barrelDigisFound)
146 if (endcapDigisFound)
148 if (!barrelDigisFound && !endcapDigisFound)
149 edm::LogError(
"EcalPedOffset") <<
"No digis found in the event!";
155 std::map<int, int> DACvalues = _DACvalues;
161 int FEDid = 600 + elecId.
dccId();
162 int crystalId = detId.
ic();
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" 172 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
179 gainId, crystalId, DACvalues[FEDid], ((
EBDataFrame)(*itdigi)).
sample(iSample).
adc(), crystalId);
188 std::map<int, int> DACvalues = _DACvalues;
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();
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: " 207 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
214 gainId, crystalId, DACvalues[FEDid], ((
EEDataFrame)(*itdigi)).
sample(iSample).
adc(), endcapCrystalId);
224 for (std::map<int, TPedValues *>::const_iterator smPeds =
m_pedValues.begin(); smPeds !=
m_pedValues.end();
242 LogDebug(
"EcalPedOffset") <<
" entering writeDb ...";
247 LogInfo(
"EcalPedOffset") <<
"Opening DB connection with TNS_ADMIN ...";
249 }
catch (std::runtime_error &
e) {
250 LogError(
"EcalPedOffset") << e.what();
253 LogInfo(
"EcalPedOffset") <<
"Opening DB connection without TNS_ADMIN ...";
255 }
catch (std::runtime_error &e) {
256 LogError(
"EcalPedOffset") << e.what();
294 moniov = DBconnection->
fetchMonRunIOV(&runtag, &montag, run, subrun);
295 }
catch (std::runtime_error &e) {
305 LogDebug(
"EcalPedOffset") <<
" creating a new MonRunIOV";
307 edm::LogError(
"EcalPedOffset") <<
" no MonRunIOV existing in the DB";
308 edm::LogError(
"EcalPedOffset") <<
" the result will not be stored into the DB";
318 std::map<EcalLogicID, MonPedestalOffsetsDat> DBdataset;
327 for (
int xtal = 0; xtal < 1700; ++xtal) {
336 int fedid =
result->first;
342 if (fedid >= 601 && fedid <= 609) {
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) {
352 eid = eid + 10000 * (fedid - 600);
353 ecid = DBconnection->
getEcalLogicID(
"EE_elec_crystal_number", eid);
355 LogError(
"EcalPedOffset") <<
"FEDid is out of range 601-654";
357 DBdataset[ecid] = DBtable;
358 }
catch (std::runtime_error &e) {
368 LogDebug(
"EcalPedOffset") <<
"Inserting dataset ... " << std::flush;
369 if (!DBdataset.empty())
371 LogDebug(
"EcalPedOffset") <<
"done.";
372 }
catch (std::runtime_error &e) {
387 for (std::map<int, TPedResult *>::const_iterator smRes =
m_pedResult.begin(); smRes !=
m_pedResult.end(); ++smRes) {
390 thisSMFileName +=
"_";
392 thisSMFileName +=
".xml";
393 std::ofstream xml_outfile;
394 xml_outfile.open(thisSMFileName.c_str());
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;
406 for (
int xtal = 0; xtal < 1700; ++xtal) {
407 int crystalNumber =
m_pedValues[smRes->first]->getCrystalNumber(xtal);
408 if (crystalNumber == 0)
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;
419 xml_outfile <<
" </PEDESTAL_OFFSET_RELEASE>" << std::endl;
420 xml_outfile <<
"</offsets>" << std::endl;
429 LogDebug(
"EcalPedOffset") <<
" entering makePlots ...";
439 for (std::map<int, TPedValues *>::const_iterator smPeds =
m_pedValues.begin(); smPeds !=
m_pedValues.end();
442 char folderName[120];
443 sprintf(folderName,
"FED%02d", smPeds->first);
444 rootFile->mkdir(folderName);
451 LogDebug(
"EcalPedOffset") <<
" DONE";
460 std::ostringstream myStream;
461 myStream << num << std::flush;
462 return (myStream.str());
void setTaskStatus(bool status)
double m_maxChi2OverNDFAllowed_
max chi2/ndf allowed for linearity test
void setRunTypeDef(const RunTypeDef &runTypeDef)
edm::InputTag m_barrelDigiCollection
secondary name given to collection of digis
std::string m_dbHostName
database host name
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
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)
std::vector< T >::const_iterator const_iterator
~EcalPedOffset() override
Destructor.
std::string m_xmlFile
name of the xml file to be saved
const_iterator begin() const
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
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
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
void readDACs(const edm::Handle< EBDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
void makePlots()
create the plots of the DAC pedestal trend
void setSubRunNumber(subrun_t subrun)
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
void setMonVersionDef(const MonVersionDef &ver)
void setSubRunStart(const Tm &start)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
void beginRun(edm::Run const &, edm::EventSetup const &eventSetup) override
BeginRun.
void setLocationDef(const LocationDef &locDef)
std::map< int, TPedResult * > m_pedResult
int ic() const
get ECAL/crystal number inside SM
Namespace of DDCMS conversion namespace.
void writeXMLFiles(std::string fileName)
write the results into xml format
const_iterator end() const
EcalPedOffset(const edm::ParameterSet &ps)
Constructor.
edm::InputTag m_headerCollection
name of module/plugin/producer making headers
void setRunType(std::string runtype)
void setMonRunTag(const MonRunTag &tag)
std::map< int, TPedValues * > m_pedValues
void setMonitoringVersion(std::string ver)
const_iterator end() const
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
const EcalElectronicsMapping * ecalElectronicsMap_
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
void setLocation(std::string loc)
static constexpr int MAXSAMPLES
void setGeneralTag(std::string tag)
double m_maxSlopeAllowed_
max slope (in magnitude) allowed for linearity test
edm::InputTag m_endcapDigiCollection
secondary name given to collection of digis
T const * product() const
const_iterator begin() const
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override
! Analyze