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))
74 for (std::map<int,TPedValues*>::iterator mapIt =
m_pedValues.begin ();
77 delete mapIt->second ;
78 for (std::map<int,TPedResult*>::iterator mapIt =
m_pedResult.begin ();
81 delete mapIt->second ;
91 LogDebug (
"EcalPedOffset") <<
"entering beginRun..." ;
107 LogDebug (
"EcalPedOffset") <<
"entering analyze ...";
114 std::map <int,int> DACvalues;
117 m_run =
event.id().run();
121 headerItr != DCCHeaders->end ();
125 int FEDid = 600+headerItr->id();
127 LogDebug(
"EcalPedOffset") <<
"Found FED: " << FEDid <<
" in DCC header";
130 bool barrelDigisFound =
true;
131 bool endcapDigisFound =
true;
138 edm::LogError (
"EcalPedOffset") <<
"Error! can't get the product "
140 barrelDigisFound =
false;
143 if(barrelDigis->size()==0)
145 edm::LogInfo(
"EcalPedOffset") <<
"Size of EBDigiCollection is zero;"
146 <<
" not reading barrel digis";
147 barrelDigisFound =
false;
156 edm::LogError (
"EcalPedOffset") <<
"Error! can't get the product "
158 endcapDigisFound =
false;
161 if(endcapDigis->size()==0)
163 edm::LogInfo(
"EcalPedOffset") <<
"Size of EEDigiCollection is zero;"
164 <<
" not reading endcap digis";
165 endcapDigisFound =
false;
173 if(!barrelDigisFound && !endcapDigisFound)
174 edm::LogError (
"EcalPedOffset") <<
"No digis found in the event!";
183 const std::map<int,int>& _DACvalues)
185 std::map<int,int> DACvalues = _DACvalues;
188 itdigi != pDigis->end();
194 int FEDid = 600+elecId.
dccId();
195 int crystalId = detId.
ic();
198 if(DACvalues.find(FEDid)==DACvalues.end())
201 <<
"Error! EB DCCid of digi does not match any DCCid found in DCC headers" << FEDid;
206 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
227 const std::map<int,int>& _DACvalues)
229 std::map<int,int> DACvalues = _DACvalues;
232 itdigi != pDigis->end();
239 int FEDid = 600+elecId.
dccId();
240 int crystalId = 25*elecId.towerId()+5*elecId.stripId()+elecId.xtalId();
241 int endcapCrystalId = 100*elecId.towerId()+5*(elecId.stripId()-1)+elecId.xtalId();
244 if(DACvalues.find(FEDid)==DACvalues.end())
247 <<
"Error! EE DCCid of digi does not match any DCCid found in DCC headers: " << FEDid;
252 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
275 for (std::map<int,TPedValues*>::const_iterator smPeds =
m_pedValues.begin ();
298 LogDebug (
"EcalPedOffset") <<
" entering writeDb ..." ;
304 LogInfo(
"EcalPedOffset") <<
"Opening DB connection with TNS_ADMIN ...";
306 }
catch (std::runtime_error &
e) {
307 LogError(
"EcalPedOffset") << e.what();
312 LogInfo(
"EcalPedOffset") <<
"Opening DB connection without TNS_ADMIN ...";
315 }
catch (std::runtime_error &e) {
316 LogError(
"EcalPedOffset") << e.what();
356 moniov = DBconnection->
fetchMonRunIOV(&runtag, &montag, run, subrun);
358 catch (std::runtime_error &e) {
368 LogDebug (
"EcalPedOffset") <<
" creating a new MonRunIOV" ;
371 edm::LogError (
"EcalPedOffset") <<
" no MonRunIOV existing in the DB" ;
372 edm::LogError (
"EcalPedOffset") <<
" the result will not be stored into the DB" ;
373 if ( DBconnection ) {
delete DBconnection;}
380 std::map<EcalLogicID, MonPedestalOffsetsDat> DBdataset ;
391 for (
int xtal = 0 ; xtal<1700 ; ++xtal)
403 int fedid =
result->first;
409 if (fedid >= 601 && fedid <= 609)
412 eid = eid+10000*(fedid-600);
413 ecid = DBconnection->
getEcalLogicID(
"EE_elec_crystal_number", eid);
415 else if (fedid >= 610 && fedid <= 627)
417 ecid = DBconnection->
getEcalLogicID(
"EB_crystal_number", fedid-610+19,
420 else if (fedid >= 628 && fedid <= 645)
422 ecid = DBconnection->
getEcalLogicID(
"EB_crystal_number", fedid-628+1,
425 else if (fedid >= 646 && fedid <= 654)
428 eid = eid+10000*(fedid-600);
429 ecid = DBconnection->
getEcalLogicID(
"EE_elec_crystal_number", eid);
432 LogError(
"EcalPedOffset") <<
"FEDid is out of range 601-654";
434 DBdataset[ecid] = DBtable ;
435 }
catch (std::runtime_error &e) {
443 if ( DBconnection ) {
445 LogDebug (
"EcalPedOffset") <<
"Inserting dataset ... " << std::flush;
446 if ( DBdataset.size() != 0 ) DBconnection->
insertDataSet (&DBdataset, &moniov);
447 LogDebug (
"EcalPedOffset") <<
"done." ;
448 }
catch (std::runtime_error &e) {
453 if ( DBconnection ) {
delete DBconnection;}
464 for (std::map<int,TPedResult*>::const_iterator smRes =
m_pedResult.begin();
472 thisSMFileName+=
".xml";
473 std::ofstream xml_outfile;
474 xml_outfile.open(thisSMFileName.c_str());
477 xml_outfile<<
"<offsets>"<<std::endl;
478 xml_outfile <<
"<PEDESTAL_OFFSET_RELEASE VERSION_ID = \"SM1_VER1\"> \n";
479 xml_outfile <<
" <RELEASE_ID>RELEASE_1</RELEASE_ID>\n";
480 xml_outfile <<
" <SUPERMODULE>";
481 xml_outfile << smRes->first;
482 xml_outfile <<
"</SUPERMODULE>\n";
483 xml_outfile <<
" <TIME_STAMP> 070705 </TIME_STAMP>" << std::endl;
486 for (
int xtal = 0 ; xtal < 1700 ; ++xtal)
488 int crystalNumber =
m_pedValues[smRes->first]->getCrystalNumber(xtal);
491 xml_outfile <<
" <PEDESTAL_OFFSET>\n";
492 xml_outfile <<
" <HIGH>" << ((smRes->second)->m_DACvalue)[0][xtal] <<
"</HIGH>\n";
493 xml_outfile <<
" <MED>" << ((smRes->second)->m_DACvalue)[1][xtal] <<
"</MED>\n";
494 xml_outfile <<
" <LOW>" << ((smRes->second)->m_DACvalue)[2][xtal] <<
"</LOW>\n";
495 xml_outfile <<
" <CRYSTAL> "<< crystalNumber <<
" </CRYSTAL>\n";
496 xml_outfile <<
" </PEDESTAL_OFFSET>" << std::endl;
500 xml_outfile <<
" </PEDESTAL_OFFSET_RELEASE>" << std::endl;
501 xml_outfile <<
"</offsets>" << std::endl;
502 xml_outfile.close ();
515 LogDebug (
"EcalPedOffset") <<
" entering makePlots ..." ;
523 TFile * rootFile =
new TFile(
m_plotting.c_str(),
"RECREATE");
526 for (std::map<int,TPedValues*>::const_iterator smPeds =
m_pedValues.begin();
531 char folderName[120] ;
532 sprintf (folderName,
"FED%02d",smPeds->first);
533 rootFile->mkdir(folderName);
541 LogDebug (
"EcalPedOffset") <<
" DONE";
552 std::ostringstream myStream;
553 myStream << num << std::flush;
554 return(myStream.str());
int adc(sample_type sample)
get the ADC sample (12 bits)
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
int gainId(sample_type sample)
get the gainId (2 bits)
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::map< int, TPedValues * > m_pedValues
std::string m_dbName
database name
void setRunIOV(const RunIOV &iov)
std::string intToString(int num)
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
std::string m_xmlFile
name of the xml file to be saved
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 beginRun(edm::Run const &, edm::EventSetup const &eventSetup)
BeginRun.
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 analyze(edm::Event const &event, edm::EventSetup const &eventSetup)
! Analyze
void makePlots()
create the plots of the DAC pedestal trend
virtual ~EcalPedOffset()
Destructor.
void setSubRunNumber(subrun_t subrun)
void setMonVersionDef(const MonVersionDef &ver)
void setSubRunStart(const Tm &start)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
void setLocationDef(const LocationDef &locDef)
int ic() const
get ECAL/crystal number inside SM
void writeXMLFiles(std::string fileName)
write the results into xml format
std::map< int, TPedResult * > m_pedResult
EcalPedOffset(const edm::ParameterSet &ps)
Constructor.
edm::InputTag m_headerCollection
name of module/plugin/producer making headers
void setRunType(std::string runtype)
T const * product() const
void setMonRunTag(const MonRunTag &tag)
void setMonitoringVersion(std::string ver)
const EcalElectronicsMapping * ecalElectronicsMap_
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
void setLocation(std::string loc)
volatile std::atomic< bool > shutdown_flag false
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
for(const auto &isodef:isoDefs)
static const int MAXSAMPLES