61 std::cout <<
"EcalPedestals Source handler constructor\n" << std::endl;
70 std::cout << m_sid<<
"/"<<m_user<<
"/"<<m_pass<<
"/"<<m_location<<
"/"<<m_gentag << std::endl;
72 vector<int> listDefaults;
73 listDefaults.push_back(-1);
83 cout <<
"ANALYSIS FINISHED" << endl;
90 cout <<
"Entering beginRun" << endl;
117 TH1F** hMean =
new TH1F*[15];
118 TH1F** hRMS =
new TH1F*[15];
119 TFile
f(
"PedHist.root",
"RECREATE");
133 TTree* tPedChan =
new TTree(
"PedChan",
"Channels");
134 tPedChan->Branch(
"Channels", &Chan.iChannel,
"iChannel/I");
135 tPedChan->Branch(
"x", &Chan.ix,
"ix/I");
136 tPedChan->Branch(
"y", &Chan.iy,
"iy/I");
137 tPedChan->Branch(
"z", &Chan.iz,
"iz/I");
138 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
139 Chan.iChannel = iChannel;
141 Chan.ix = myEBDetId.
ieta();
142 Chan.iy = myEBDetId.
iphi();
144 if(iChannel%10000 == 0)
cout <<
" EB channel " << iChannel <<
" eta " << Chan.ix <<
" phi " << Chan.iy << endl;
147 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
148 Chan.iChannel = iChannel;
150 Chan.ix = myEEDetId.
ix();
151 Chan.iy = myEEDetId.
iy();
152 Chan.iz = myEEDetId.
zside();
153 if(iChannel%1000 == 0)
cout <<
" EE channel " << iChannel <<
" x " << Chan.ix <<
" y " << Chan.iy <<
" z " << Chan.iz << endl;
166 for (
int iChannel = 0; iChannel <
kChannels; iChannel++) {
167 PedVal.Mean[iChannel] = -1.;
168 PedVal.RMS[iChannel] = -1.;
170 TTree* tPedHist =
new TTree(
"PedHist",
"Pedestal History");
171 tPedHist->Branch(
"Pedestals", &PedVal.Run,
"Run/I");
172 tPedHist->Branch(
"Mean", PedVal.Mean,
"Mean[75848]/D");
173 tPedHist->Branch(
"RMS", PedVal.RMS,
"RMS[75848]/D");
176 std::cout <<
"Retrieving run list from ONLINE DB ... " << std::endl;
178 std::cout <<
"Connection done" << std::endl;
180 std::cout <<
" Problem with OMDS: connection parameters " <<m_sid <<
"/"<<m_user<<
"/"<<m_pass<<std::endl;
207 unsigned int min_run = 0, max_since = 0;
208 if(m_firstRun < max_since) {
214 unsigned int max_run=m_lastRun;
215 mon_list=econn->fetchMonRunList(my_runtag, mon_tag,min_run,max_run );
217 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
218 int mon_runs = mon_run_vec.size();
219 std::cout <<
"number of Mon runs is : " << mon_runs<< std::endl;
223 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
224 if(iChannel%10000 == 1) {
225 hMean[NbChan] =
new TH1F(Form(
"Mean_%i",NbChan),Form(
"Mean EB %i",iChannel), mon_runs, 0., mon_runs);
226 hRMS[NbChan] =
new TH1F(Form(
"RMS_%i",NbChan),Form(
"RMS EB %i",iChannel), mon_runs, 0., mon_runs);
230 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
231 if(iChannel%2000 == 1) {
232 hMean[NbChan] =
new TH1F(Form(
"Mean_%i",NbChan),Form(
"Mean EE %i",iChannel), mon_runs, 0., mon_runs);
233 hRMS[NbChan] =
new TH1F(Form(
"RMS_%i",NbChan),Form(
"RMS EE %i",iChannel), mon_runs, 0., mon_runs);
239 int krmax = mon_runs;
240 for(
int kr = 0; kr < krmax; kr++){
241 std::cout <<
"-kr------: "<< kr << std::endl;
243 unsigned int irun =
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
244 std::cout <<
"retrieve the data for run number: "<< irun << std::endl;
245 if (mon_run_vec[kr].getSubRunNumber() <=1){
248 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
250 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
251 econn->fetchDataSet(&dataset_mon, &mon_run_vec[kr]);
252 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
253 int nEB = 0, nEE = 0, nEBbad = 0, nEEbad =0;
254 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
260 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
263 int sm_num = ecid_xt.
getID1();
264 int xt_num = ecid_xt.
getID2();
265 int yt_num = ecid_xt.
getID3();
278 if(nbad < 10)
std::cout <<
"BAD LIST: channel " << sm_num <<
"/" << xt_num <<
"/"<< yt_num
281 if(ecid_xt.
getName()==
"EB_crystal_number") {
283 if(!result ) nEBbad++;
287 if(!result ) nEEbad++;
293 if(nbad < (dataset_mon.size()*0.05) && (nEB > 10200 || nEE > 2460)) {
296 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
299 int sm_num = ecid_xt.
getID1();
300 int xt_num = ecid_xt.
getID2();
301 int yt_num = ecid_xt.
getID3();
303 if(ecid_xt.
getName()==
"EB_crystal_number") {
306 if(iChannel < 0 || iChannel > 61200)
cout <<
" SM " << sm_num <<
" Chan in SM " << xt_num
307 <<
" IChannel " << iChannel << endl;
308 if(iChannel%10000 == 1) {
315 if(iChannel%10000 == 0)
cout <<
" channel " << iChannel <<
" mean " << PedVal.Mean[iChannel] <<
" RMS " << PedVal.RMS[iChannel] << endl;
319 EEDetId eedetid(xt_num,yt_num,sm_num);
321 if(iChannel < 0 || iChannel > 14648)
cout <<
" x " << sm_num <<
" y " << xt_num <<
" z " << yt_num
322 <<
" IChannel " << iChannel << endl;
323 if(iChannel%2000 == 1) {
328 int iChanEE = kEBChannels + iChannel;
336 cout <<
" We got a good run " << irun << endl;
341 cout <<
"Exiting beginRun" << endl;
342 for(
int NbChan = 0; NbChan < 15; NbChan++) {
343 if(hMean[NbChan]->GetEntries() > 0.) {
344 hMean[NbChan]->Write();
345 hRMS[NbChan]->Write();
358 cout <<
"Entering beginJob" << endl;
360 cout <<
"Exiting beginJob" << endl;
368 cout <<
"Entering endJob" << endl;
369 cout <<
"Exiting endJob" << endl;
382 if(ECALType_ ==
"EB" || ECALType_ ==
"EA") {
385 else if(ECALType_ ==
"EE" || ECALType_ ==
"EA") {
389 cout <<
" strange ECALtype : " << ECALType_ <<
" abort " << endl;
405 cout <<
"Exiting analyze" << endl;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
T getUntrackedParameter(std::string const &, T const &) const
int hashedIndex() const
get a compact index for arrays
float getPedRMSG1() const
static EEDetId unhashIndex(int hi)
void setGeneralTag(std::string tag)
void setRunTag(const RunTag &tag)
int iphi() const
get the crystal iphi
std::string getName() const
#define DEFINE_FWK_MODULE(type)
float getPedMeanG12() const
EcalPedestalHistory(const edm::ParameterSet &)
float getPedRMSG12() const
int ieta() const
get the crystal ieta
void setMonVersionDef(const MonVersionDef &ver)
void setLocationDef(const LocationDef &locDef)
~EcalPedestalHistory() override
Namespace of DDCMS conversion namespace.
std::vector< MonRunIOV > getRuns()
void setRunType(std::string runtype)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
void setMonRunTag(const MonRunTag &tag)
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
float getPedMeanG6() const
void setLocation(std::string loc)
void analyze(const edm::Event &, const edm::EventSetup &) override
void setGeneralTag(std::string tag)
void beginRun(edm::Run const &, edm::EventSetup const &) override
static const int SMCRYSTALMODE
float getPedRMSG6() const