41 m_barrelDigiCollection (paramSet.getParameter<edm::
InputTag> (
"EBdigiCollection")),
42 m_endcapDigiCollection (paramSet.getParameter<edm::
InputTag> (
"EEdigiCollection")),
43 m_headerCollection (paramSet.getParameter<edm::
InputTag> (
"headerCollection")),
44 m_xmlFile (paramSet.getParameter<std::
string> (
"xmlFile")),
45 m_DACmin (paramSet.getUntrackedParameter<int> (
"DACmin",0)),
46 m_DACmax (paramSet.getUntrackedParameter<int> (
"DACmax",256)),
47 m_RMSmax (paramSet.getUntrackedParameter<double> (
"RMSmax",2)),
48 m_bestPed (paramSet.getUntrackedParameter<int> (
"bestPed",200)),
49 m_dbHostName (paramSet.getUntrackedParameter<std::
string> (
"dbHostName",
"0")),
50 m_dbName (paramSet.getUntrackedParameter<std::
string> (
"dbName",
"0")),
51 m_dbUserName (paramSet.getUntrackedParameter<std::
string> (
"dbUserName")),
52 m_dbPassword (paramSet.getUntrackedParameter<std::
string> (
"dbPassword")),
53 m_dbHostPort (paramSet.getUntrackedParameter<int> (
"dbHostPort",1521)),
54 m_create_moniov (paramSet.getUntrackedParameter<bool>(
"createMonIOV",
false)),
55 m_location (paramSet.getUntrackedParameter<std::
string>(
"location",
"H4")),
57 m_plotting (paramSet.getParameter<std::
string> (
"plotting")),
58 m_maxSlopeAllowed_ (paramSet.getUntrackedParameter<double> (
"maxSlopeAllowed",-29)),
59 m_minSlopeAllowed_ (paramSet.getUntrackedParameter<double> (
"minSlopeAllowed",-18)),
60 m_maxChi2OverNDFAllowed_ (paramSet.getUntrackedParameter<double> (
"maxChi2OverNDF",5))
76 for (std::map<int,TPedValues*>::iterator mapIt =
m_pedValues.begin ();
79 delete mapIt->second ;
80 for (std::map<int,TPedResult*>::iterator mapIt =
m_pedResult.begin ();
83 delete mapIt->second ;
93 LogDebug (
"EcalPedOffset") <<
"entering beginRun..." ;
109 LogDebug (
"EcalPedOffset") <<
"entering analyze ...";
116 std::map <int,int> DACvalues;
119 m_run =
event.id().run();
123 headerItr != DCCHeaders->end ();
127 int FEDid = 600+headerItr->id();
129 LogDebug(
"EcalPedOffset") <<
"Found FED: " << FEDid <<
" in DCC header";
132 bool barrelDigisFound =
true;
133 bool endcapDigisFound =
true;
140 edm::LogError (
"EcalPedOffset") <<
"Error! can't get the product "
142 barrelDigisFound =
false;
145 if(barrelDigis->size()==0)
147 edm::LogInfo(
"EcalPedOffset") <<
"Size of EBDigiCollection is zero;"
148 <<
" not reading barrel digis";
149 barrelDigisFound =
false;
158 edm::LogError (
"EcalPedOffset") <<
"Error! can't get the product "
160 endcapDigisFound =
false;
163 if(endcapDigis->size()==0)
165 edm::LogInfo(
"EcalPedOffset") <<
"Size of EEDigiCollection is zero;"
166 <<
" not reading endcap digis";
167 endcapDigisFound =
false;
175 if(!barrelDigisFound && !endcapDigisFound)
176 edm::LogError (
"EcalPedOffset") <<
"No digis found in the event!";
185 const std::map<int,int>& _DACvalues)
187 std::map<int,int> DACvalues = _DACvalues;
190 itdigi != pDigis->end();
196 int FEDid = 600+elecId.
dccId();
197 int crystalId = detId.
ic();
200 if(DACvalues.find(FEDid)==DACvalues.end())
203 <<
"Error! EB DCCid of digi does not match any DCCid found in DCC headers" << FEDid;
208 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
229 const std::map<int,int>& _DACvalues)
231 std::map<int,int> DACvalues = _DACvalues;
234 itdigi != pDigis->end();
241 int FEDid = 600+elecId.
dccId();
242 int crystalId = 25*elecId.towerId()+5*elecId.stripId()+elecId.xtalId();
243 int endcapCrystalId = 100*elecId.towerId()+5*(elecId.stripId()-1)+elecId.xtalId();
246 if(DACvalues.find(FEDid)==DACvalues.end())
249 <<
"Error! EE DCCid of digi does not match any DCCid found in DCC headers: " << FEDid;
254 LogDebug(
"EcalPedOffset") <<
"Inserting new TPedValues object for FED:" << FEDid;
277 for (std::map<int,TPedValues*>::const_iterator smPeds =
m_pedValues.begin ();
300 LogDebug (
"EcalPedOffset") <<
" entering writeDb ..." ;
306 LogInfo(
"EcalPedOffset") <<
"Opening DB connection with TNS_ADMIN ...";
308 }
catch (std::runtime_error &
e) {
309 LogError(
"EcalPedOffset") << e.what();
314 LogInfo(
"EcalPedOffset") <<
"Opening DB connection without TNS_ADMIN ...";
317 }
catch (std::runtime_error &e) {
318 LogError(
"EcalPedOffset") << e.what();
358 moniov = DBconnection->
fetchMonRunIOV(&runtag, &montag, run, subrun);
360 catch (std::runtime_error &e) {
370 LogDebug (
"EcalPedOffset") <<
" creating a new MonRunIOV" ;
373 edm::LogError (
"EcalPedOffset") <<
" no MonRunIOV existing in the DB" ;
374 edm::LogError (
"EcalPedOffset") <<
" the result will not be stored into the DB" ;
375 if ( DBconnection ) {
delete DBconnection;}
382 std::map<EcalLogicID, MonPedestalOffsetsDat> DBdataset ;
393 for (
int xtal = 0 ; xtal<1700 ; ++xtal)
405 int fedid =
result->first;
406 int eid =
m_pedValues[fedid]->getCrystalNumber(xtal);
411 if (fedid >= 601 && fedid <= 609)
414 eid = eid+10000*(fedid-600);
415 ecid = DBconnection->
getEcalLogicID(
"EE_elec_crystal_number", eid);
417 else if (fedid >= 610 && fedid <= 627)
419 ecid = DBconnection->
getEcalLogicID(
"EB_crystal_number", fedid-610+19,
422 else if (fedid >= 628 && fedid <= 645)
424 ecid = DBconnection->
getEcalLogicID(
"EB_crystal_number", fedid-628+1,
427 else if (fedid >= 646 && fedid <= 654)
430 eid = eid+10000*(fedid-600);
431 ecid = DBconnection->
getEcalLogicID(
"EE_elec_crystal_number", eid);
434 LogError(
"EcalPedOffset") <<
"FEDid is out of range 601-654";
436 DBdataset[ecid] = DBtable ;
437 }
catch (std::runtime_error &e) {
445 if ( DBconnection ) {
447 LogDebug (
"EcalPedOffset") <<
"Inserting dataset ... " << std::flush;
448 if ( DBdataset.size() != 0 ) DBconnection->
insertDataSet (&DBdataset, &moniov);
449 LogDebug (
"EcalPedOffset") <<
"done." ;
450 }
catch (std::runtime_error &e) {
455 if ( DBconnection ) {
delete DBconnection;}
466 for (std::map<int,TPedResult*>::const_iterator smRes =
m_pedResult.begin();
474 thisSMFileName+=
".xml";
475 std::ofstream xml_outfile;
476 xml_outfile.open(thisSMFileName.c_str());
479 xml_outfile<<
"<offsets>"<<std::endl;
480 xml_outfile <<
"<PEDESTAL_OFFSET_RELEASE VERSION_ID = \"SM1_VER1\"> \n";
481 xml_outfile <<
" <RELEASE_ID>RELEASE_1</RELEASE_ID>\n";
482 xml_outfile <<
" <SUPERMODULE>";
483 xml_outfile << smRes->first;
484 xml_outfile <<
"</SUPERMODULE>\n";
485 xml_outfile <<
" <TIME_STAMP> 070705 </TIME_STAMP>" << std::endl;
488 for (
int xtal = 0 ; xtal < 1700 ; ++xtal)
490 int crystalNumber =
m_pedValues[smRes->first]->getCrystalNumber(xtal);
493 xml_outfile <<
" <PEDESTAL_OFFSET>\n";
494 xml_outfile <<
" <HIGH>" << ((smRes->second)->m_DACvalue)[0][xtal] <<
"</HIGH>\n";
495 xml_outfile <<
" <MED>" << ((smRes->second)->m_DACvalue)[1][xtal] <<
"</MED>\n";
496 xml_outfile <<
" <LOW>" << ((smRes->second)->m_DACvalue)[2][xtal] <<
"</LOW>\n";
497 xml_outfile <<
" <CRYSTAL> "<< crystalNumber <<
" </CRYSTAL>\n";
498 xml_outfile <<
" </PEDESTAL_OFFSET>" << std::endl;
502 xml_outfile <<
" </PEDESTAL_OFFSET_RELEASE>" << std::endl;
503 xml_outfile <<
"</offsets>" << std::endl;
504 xml_outfile.close ();
517 LogDebug (
"EcalPedOffset") <<
" entering makePlots ..." ;
525 TFile * rootFile =
new TFile(
m_plotting.c_str(),
"RECREATE");
528 for (std::map<int,TPedValues*>::const_iterator smPeds =
m_pedValues.begin();
533 char folderName[120] ;
534 sprintf (folderName,
"FED%02d",smPeds->first);
535 rootFile->mkdir(folderName);
543 LogDebug (
"EcalPedOffset") <<
" DONE";
554 std::ostringstream myStream;
555 myStream << num << std::flush;
556 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
edm::InputTag m_barrelDigiCollection
secondary name given to collection of digis
void setLocationDef(const LocationDef locDef)
std::string m_dbHostName
database host name
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int gainId(sample_type sample)
get the gainId (2 bits)
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
std::string intToString(int num)
std::vector< T >::const_iterator const_iterator
RunIOV fetchRunIOV(RunTag *tag, run_t run)
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 setRunIOV(RunIOV iov)
void readDACs(const edm::Handle< EBDigiCollection > &pDigis, const std::map< int, int > &DACvalues)
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup)
! Analyze
void setSubRunStart(Tm start)
void setRunTypeDef(const RunTypeDef runTypeDef)
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="")
void makePlots()
create the plots of the DAC pedestal trend
virtual ~EcalPedOffset()
Destructor.
void setSubRunNumber(subrun_t subrun)
void setMonVersionDef(MonVersionDef ver)
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
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
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun)
void setMonitoringVersion(std::string ver)
const EcalElectronicsMapping * ecalElectronicsMap_
void setLocation(std::string loc)
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
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
static const int MAXSAMPLES
void setMonRunTag(MonRunTag tag)