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)
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;
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;
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;
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;
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) {
253 LogInfo(
"EcalPedOffset") <<
"Opening DB connection without TNS_ADMIN ...";
255 }
catch (std::runtime_error &
e) {
269 runtag.setGeneralTag(
"PEDESTAL-OFFSET");
274 runtag.setLocationDef(locdef);
275 runtag.setRunTypeDef(rundef);
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) {
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 ...";
436 TFile *rootFile =
new TFile(
m_plotting.c_str(),
"RECREATE");
439 for (std::map<int, TPedValues *>::const_iterator smPeds =
m_pedValues.begin(); smPeds !=
m_pedValues.end();
443 sprintf(
folderName,
"FED%02d", smPeds->first);
451 LogDebug(
"EcalPedOffset") <<
" DONE";
460 std::ostringstream myStream;
461 myStream <<
num << std::flush;
462 return (myStream.str());