00001 #include <memory>
00002 #include <math.h>
00003 #include <iostream>
00004 #include <string>
00005 #include <stdio.h>
00006 #include <sys/time.h>
00007
00008 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00009 #include "DQM/SiPixelHistoricInfoClient/interface/SiPixelHistoricInfoDQMClient.h"
00010
00011
00012 using namespace edm;
00013 using namespace std;
00014
00015
00016 SiPixelHistoricInfoDQMClient::SiPixelHistoricInfoDQMClient(const ParameterSet& parameterSet) {
00017 parameterSet_ = parameterSet;
00018
00019 useSummary_ = parameterSet_.getUntrackedParameter<bool>("useSummary", true);
00020 printDebug_ = parameterSet_.getUntrackedParameter<bool>("printDebug",false);
00021 writeHisto_ = parameterSet_.getUntrackedParameter<bool>("writeHisto",false);
00022
00023 inputFiles_ = parameterSet_.getUntrackedParameter<vstring>("inputFiles");
00024 outputDir_ = parameterSet_.getUntrackedParameter<string>("outputDir",".");
00025 }
00026
00027
00028 void SiPixelHistoricInfoDQMClient::beginJob() {
00029 dbe_ = Service<DQMStore>().operator->();
00030 }
00031
00032
00033 void SiPixelHistoricInfoDQMClient::endRun(const edm::Run& run, const edm::EventSetup& eventSetup) {
00034 for (vector<string>::const_iterator iFile = inputFiles_.begin(); iFile!=inputFiles_.end(); ++iFile) {
00035 unsigned int runNumber=0;
00036 if (iFile->find("R0000",0)!=string::npos) runNumber = atoi(iFile->substr(iFile->find("R0000",0)+5,5).data());
00037 else if (iFile->find("Run",0)!=string::npos) runNumber = atoi(iFile->substr(iFile->find("Run",0)+3,5).data());
00038 else cout << "run number cannot be extracted from file name" << endl;
00039
00040 if (runNumber==run.run()) {
00041 dbe_->open(iFile->data(), true);
00042
00043 performanceSummary = new SiPixelPerformanceSummary();
00044 performanceSummary->setRunNumber(runNumber);
00045
00046 retrieveMEs();
00047 fillPerformanceSummary();
00048 writeDB();
00049
00050 if (writeHisto_) {
00051 ostringstream endRunOutputFile;
00052 endRunOutputFile << outputDir_<<"/SiPixelHistoricInfoDQMClient_"<< runNumber <<".root";
00053 dbe_->save(endRunOutputFile.str());
00054 }
00055 }
00056 }
00057 }
00058
00059
00060 void SiPixelHistoricInfoDQMClient::endJob() {
00061 if (writeHisto_) {
00062 ostringstream endJobOutputFile;
00063 endJobOutputFile << outputDir_ << "/SiPixelHistoricInfoDQMClient_endJob.root";
00064 dbe_->save(endJobOutputFile.str());
00065 }
00066 }
00067
00068
00069 void SiPixelHistoricInfoDQMClient::retrieveMEs() {
00070 mapOfdetIDtoMEs.clear();
00071 bool noModules = true, noSummary = true;
00072
00073 vector<string> listOfMEswithFullPath;
00074 dbe_->getContents(listOfMEswithFullPath);
00075
00076 for (vector<string>::const_iterator iMEstr = listOfMEswithFullPath.begin();
00077 iMEstr!=listOfMEswithFullPath.end(); iMEstr++) {
00078 if (printDebug_) cout << iMEstr->data() << endl;
00079
00080 size_t pathLength = iMEstr->find(":",0);
00081 string thePath = iMEstr->substr(0, pathLength);
00082 string allHists = iMEstr->substr(pathLength+1);
00083
00084 if (thePath.find("Pixel",0)!=string::npos) {
00085 if (thePath.find("FED_",0)!=string::npos) {
00086 size_t histnameLength;
00087 do {
00088 histnameLength = allHists.find(",",0);
00089 string theHist;
00090 if (histnameLength!=string::npos) {
00091 theHist = allHists.substr(0, histnameLength);
00092 allHists.erase(0, histnameLength+1);
00093 }
00094 else theHist = allHists;
00095
00096 string fullPathHist = thePath + "/" + theHist;
00097 MonitorElement* newME = dbe_->get(fullPathHist);
00098 if (newME) {
00099 uint32_t newMEdetID = histogramManager.getRawId(newME->getName());
00100
00101 if (mapOfdetIDtoMEs.find(newMEdetID)==mapOfdetIDtoMEs.end()) {
00102 vector<MonitorElement*> newMEvector;
00103 newMEvector.push_back(newME);
00104 mapOfdetIDtoMEs.insert(make_pair(newMEdetID, newMEvector));
00105 }
00106 else (mapOfdetIDtoMEs.find(newMEdetID)->second).push_back(newME);
00107 }
00108 }
00109 while (histnameLength!=string::npos);
00110 }
00111 if (thePath.find("Module_",0)!=string::npos) {
00112 if (!useSummary_) {
00113 size_t histnameLength;
00114 do {
00115 histnameLength = allHists.find(",",0);
00116 string theHist;
00117 if (histnameLength!=string::npos) {
00118 theHist = allHists.substr(0, histnameLength);
00119 allHists.erase(0, histnameLength+1);
00120 }
00121 else theHist = allHists;
00122
00123 string fullPathHist = thePath + "/" + theHist;
00124 MonitorElement* newME = dbe_->get(fullPathHist);
00125 if (newME) {
00126 uint32_t newMEdetID = histogramManager.getRawId(newME->getName());
00127
00128 if (mapOfdetIDtoMEs.find(newMEdetID)==mapOfdetIDtoMEs.end()) {
00129 vector<MonitorElement*> newMEvector;
00130 newMEvector.push_back(newME);
00131 mapOfdetIDtoMEs.insert(make_pair(newMEdetID, newMEvector));
00132 }
00133 else (mapOfdetIDtoMEs.find(newMEdetID)->second).push_back(newME);
00134 }
00135 }
00136 while(histnameLength!=string::npos);
00137 }
00138 if (noModules) noModules = false;
00139 }
00140 else if( (thePath.find("Layer_",0)!=string::npos ||
00141 (thePath.find("Disk_",0)!=string::npos && thePath.find("Panel_",0)==string::npos)) ) {
00142 if (useSummary_) {
00143 uint32_t newMEdetID = getSummaryRegionID(thePath);
00144 if (printDebug_) cout << thePath.data() <<" in region "<< newMEdetID << endl;
00145 size_t histnameLength;
00146 do {
00147 histnameLength = allHists.find(",",0);
00148 string theHist;
00149 if (histnameLength!=string::npos) {
00150 theHist = allHists.substr(0, histnameLength);
00151 allHists.erase(0, histnameLength+1);
00152 }
00153 else theHist = allHists;
00154
00155 string fullPathHist = thePath + "/" + theHist;
00156 MonitorElement* newME = dbe_->get(fullPathHist);
00157 if (newME) {
00158 if (mapOfdetIDtoMEs.find(newMEdetID)==mapOfdetIDtoMEs.end()) {
00159 vector<MonitorElement*> newMEvector;
00160 newMEvector.push_back(newME);
00161 mapOfdetIDtoMEs.insert(make_pair(newMEdetID, newMEvector));
00162 }
00163 else (mapOfdetIDtoMEs.find(newMEdetID)->second).push_back(newME);
00164 }
00165 }
00166 while (histnameLength!=string::npos);
00167 }
00168 if (noSummary) noSummary = false;
00169 }
00170 if (thePath.find("Track",0)!=string::npos) {
00171 uint32_t newMEdetID = 77;
00172 if (thePath.find("On", 0)!=string::npos) newMEdetID = 78;
00173 if (thePath.find("Off",0)!=string::npos) newMEdetID = 79;
00174
00175 size_t histnameLength;
00176 do {
00177 histnameLength = allHists.find(",",0);
00178 string theHist;
00179 if (histnameLength!=string::npos) {
00180 theHist = allHists.substr(0, histnameLength);
00181 allHists.erase(0, histnameLength+1);
00182 }
00183 else theHist = allHists;
00184
00185 string fullPathHist = thePath + "/" + theHist;
00186 MonitorElement* newME = dbe_->get(fullPathHist);
00187 if (newME) {
00188 if (mapOfdetIDtoMEs.find(newMEdetID)==mapOfdetIDtoMEs.end()) {
00189 vector<MonitorElement*> newMEvector;
00190 newMEvector.push_back(newME);
00191 mapOfdetIDtoMEs.insert(make_pair(newMEdetID, newMEvector));
00192 }
00193 else (mapOfdetIDtoMEs.find(newMEdetID)->second).push_back(newME);
00194 }
00195 }
00196 while (histnameLength!=string::npos);
00197 }
00198 if (thePath.find("EventInfo",0)!=string::npos) {
00199 size_t histnameLength;
00200 do {
00201 histnameLength = allHists.find(",",0);
00202 string theHist;
00203 if (histnameLength!=string::npos) {
00204 theHist = allHists.substr(0, histnameLength);
00205 allHists.erase(0, histnameLength+1);
00206 }
00207 else theHist = allHists;
00208
00209 if (theHist.find("iRun",0)!=string::npos) {
00210 string fullPathHist = thePath + "/" + theHist;
00211 MonitorElement* strME = dbe_->get(fullPathHist);
00212 if (strME) performanceSummary->setRunNumber(strME->getIntValue());
00213 }
00214 if (theHist.find("iLumiSection",0)!=string::npos) {
00215 string fullPathHist = thePath + "/" + theHist;
00216 MonitorElement* strME = dbe_->get(fullPathHist);
00217 if (strME) performanceSummary->setLuminosityBlock(strME->getIntValue());
00218 }
00219 if (theHist.find("processedEvents",0)!=string::npos) {
00220 string fullPathHist = thePath + "/" + theHist;
00221 MonitorElement* strME = dbe_->get(fullPathHist);
00222 if (strME) performanceSummary->setNumberOfEvents(strME->getIntValue());
00223 }
00224 if (theHist.find("eventTimeStamp",0)!=string::npos) {
00225 string fullPathHist = thePath + "/" + theHist;
00226 MonitorElement* strME = dbe_->get(fullPathHist);
00227 if (strME) performanceSummary->setTimeStamp((unsigned long long)strME->getFloatValue());
00228 }
00229 }
00230 while (histnameLength!=string::npos);
00231 }
00232 }
00233 }
00234 if ( useSummary_ && noSummary) cout << endl << "use "<<"summary MEs but NO "<<"summary MEs in the input file" << endl << endl;
00235 if (!useSummary_ && noModules) cout << endl << "use "<< "module MEs but NO "<< "module MEs in the input file" << endl << endl;
00236 }
00237
00238
00239 uint32_t SiPixelHistoricInfoDQMClient::getSummaryRegionID(string thePath) const {
00240 uint32_t regionID = 666;
00241 if (thePath.find("Ladder",0)==string::npos && thePath.find("Blade",0)==string::npos) {
00242 regionID = 100;
00243 if (thePath.find("Barrel",0)!=string::npos) {
00244 regionID += 0;
00245 string shell = thePath.substr(thePath.find("Shell",0)+6,2);
00246 if (shell.compare("mI")==0) regionID += 0;
00247 else if (shell.compare("mO")==0) regionID += 3;
00248 else if (shell.compare("pI")==0) regionID += 6;
00249 else if (shell.compare("pO")==0) regionID += 9;
00250 else cout << "Shell_" << shell.data() << "?!" << endl;
00251 string layer = thePath.substr(thePath.find("Layer",0)+6,1);
00252 regionID += (atoi(layer.data())-1);
00253 }
00254 else if (thePath.find("Endcap",0)!=string::npos) {
00255 regionID += 12;
00256 string halfCylinder = thePath.substr(thePath.find("HalfCylinder",0)+13,2);
00257 if (halfCylinder.compare("mI")==0) regionID += 0;
00258 else if (halfCylinder.compare("mO")==0) regionID += 2;
00259 else if (halfCylinder.compare("pI")==0) regionID += 4;
00260 else if (halfCylinder.compare("pO")==0) regionID += 6;
00261 else cout << "HalfCylinder_" << halfCylinder.data() << "?!" << endl;
00262 string disk = thePath.substr(thePath.find("Disk",0)+5,1);
00263 regionID += (atoi(disk.data())-1);
00264 }
00265 }
00266 else if (thePath.find("Ladder",0)!=string::npos || thePath.find("Blade",0)!=string::npos) {
00267 regionID = 1000;
00268 if (thePath.find("Barrel",0)!=string::npos) {
00269 regionID += 0;
00270 string shell = thePath.substr(thePath.find("Shell",0)+6,2);
00271 if (shell.compare("mI")==0) regionID += 0;
00272 else if (shell.compare("mO")==0) regionID += 48;
00273 else if (shell.compare("pI")==0) regionID += 96;
00274 else if (shell.compare("pO")==0) regionID += 144;
00275 else cout << "Shell_" << shell.data() << "?!" << endl;
00276 string layer = thePath.substr(thePath.find("Layer",0)+6,1);
00277 if (layer.compare("1")==0) regionID += 0;
00278 else if (layer.compare("2")==0) regionID += 10;
00279 else if (layer.compare("3")==0) regionID += 26;
00280 else cout << "Layer_" << layer.data() << "?!" << endl;
00281 string ladder = thePath.substr(thePath.find("Ladder",0)+7,2);
00282 regionID += (atoi(ladder.data())-1);
00283 }
00284 else if (thePath.find("Endcap",0)!=string::npos) {
00285 regionID += 192;
00286 string halfCylinder = thePath.substr(thePath.find("HalfCylinder",0)+13,2);
00287 if (halfCylinder.compare("mI")==0) regionID += 0;
00288 else if (halfCylinder.compare("mO")==0) regionID += 24;
00289 else if (halfCylinder.compare("pI")==0) regionID += 48;
00290 else if (halfCylinder.compare("pO")==0) regionID += 72;
00291 else cout << "HalfCylinder_" << halfCylinder.data() << "?!" << endl;
00292 string disk = thePath.substr(thePath.find("Disk",0)+5,1);
00293 string blade = thePath.substr(thePath.find("Blade",0)+6,2);
00294 regionID += (12*(atoi(disk.data())-1) + atoi(blade.data())-1);
00295 }
00296 }
00297 return regionID;
00298 }
00299
00300
00301 void SiPixelHistoricInfoDQMClient::getSummaryMEmeanRMSnBins(vector<MonitorElement*>::const_iterator iME,
00302 float& mean, float& RMS, float& emPtn) const {
00303 int nBins=0; for (int b=0; b<(*iME)->getNbinsX(); b++) {
00304 float binMean = (*iME)->getBinContent(b+1);
00305 float binRMS = (*iME)->getBinError(b+1);
00306 if (binMean!=0.0 || binRMS!=0.0) { nBins++; mean += binMean; RMS += pow(binRMS,2); }
00307 }
00308 if (nBins>0) {
00309 mean = mean/float(nBins);
00310 RMS = sqrt(RMS/float(nBins));
00311 }
00312 if ((*iME)->getNbinsX()>0) emPtn = 1.0 - float(nBins)/float((*iME)->getNbinsX());
00313 }
00314
00315
00316 void SiPixelHistoricInfoDQMClient::fillPerformanceSummary() const {
00317 for (map< uint32_t, vector<MonitorElement*> >::const_iterator iMEvec = mapOfdetIDtoMEs.begin();
00318 iMEvec!=mapOfdetIDtoMEs.end(); iMEvec++) {
00319 uint32_t theMEdetID = iMEvec->first;
00320 vector<MonitorElement*> theMEvector = iMEvec->second;
00321
00322 if (printDebug_) {
00323 cout << theMEdetID << ":"; for (vector<MonitorElement*>::const_iterator iME = theMEvector.begin();
00324 iME!=theMEvector.end(); iME++) cout << (*iME)->getName() << ","; cout << endl;
00325 }
00326 for (vector<MonitorElement*>::const_iterator iME = theMEvector.begin(); iME!=theMEvector.end(); iME++) {
00327 string theMEname = (*iME)->getName();
00328
00329 if (theMEdetID<50) {
00330
00331 if (theMEname.find("errorType_siPixelDigis")!=string::npos) {
00332 for (int v=25; v<40; v++) {
00333 int b = (*iME)->getTH1()->GetXaxis()->FindBin(v);
00334 performanceSummary->setRawDataErrorType(theMEdetID, v-25, (*iME)->getBinContent(b));
00335 }
00336 }
00337 }
00338
00339 else if (theMEdetID==77) {
00340 if (theMEname.find("ntracks")!=string::npos && theMEname.find("InPixVol")==string::npos) {
00341 float trkMean=0.0, trkRMS=0.0;
00342 if ((*iME)->getBinContent(1)>0.0) {
00343 trkMean = float((*iME)->getBinContent(3))/(*iME)->getBinContent(1);
00344 trkRMS = sqrt(trkMean*(trkMean+1.0)/(*iME)->getBinContent(1));
00345 performanceSummary->setFractionOfTracks(80, trkMean, trkRMS);
00346
00347 trkMean = float((*iME)->getBinContent(4))/(*iME)->getBinContent(1);
00348 trkRMS = sqrt(trkMean*(trkMean+1.0)/(*iME)->getBinContent(1));
00349 performanceSummary->setFractionOfTracks(81, trkMean, trkRMS);
00350 }
00351 }
00352 }
00353 else if (theMEdetID==78) {
00354 if (theMEname.find("nclusters_siPixelClusters")!=string::npos) {
00355 performanceSummary->setNumberOfOnTrackClusters(80, (*iME)->getBinContent(2));
00356 performanceSummary->setNumberOfOnTrackClusters(81, (*iME)->getBinContent(3));
00357 }
00358 if (theMEname.find("charge_siPixelClusters_Barrel")!=string::npos) {
00359 performanceSummary->setClusterChargeOnTrack(80, (*iME)->getMean(), (*iME)->getRMS());
00360 }
00361 if (theMEname.find("charge_siPixelClusters_Endcap")!=string::npos) {
00362 performanceSummary->setClusterChargeOnTrack(81, (*iME)->getMean(), (*iME)->getRMS());
00363 }
00364 if (theMEname.find("size_siPixelClusters_Barrel")!=string::npos) {
00365 performanceSummary->setClusterSizeOnTrack(80, (*iME)->getMean(), (*iME)->getRMS());
00366 }
00367 if (theMEname.find("size_siPixelClusters_Endcap")!=string::npos) {
00368 performanceSummary->setClusterSizeOnTrack(81, (*iME)->getMean(), (*iME)->getRMS());
00369 }
00370 }
00371 else if (theMEdetID==79) {
00372 if (theMEname.find("nclusters_siPixelClusters")!=string::npos) {
00373 performanceSummary->setNumberOfOffTrackClusters(80, (*iME)->getBinContent(2));
00374 performanceSummary->setNumberOfOffTrackClusters(81, (*iME)->getBinContent(3));
00375 }
00376 if (theMEname.find("charge_siPixelClusters_Barrel")!=string::npos) {
00377 performanceSummary->setClusterChargeOffTrack(80, (*iME)->getMean(), (*iME)->getRMS());
00378 }
00379 if (theMEname.find("charge_siPixelClusters_Endcap")!=string::npos) {
00380 performanceSummary->setClusterChargeOffTrack(81, (*iME)->getMean(), (*iME)->getRMS());
00381 }
00382 if (theMEname.find("size_siPixelClusters_Barrel")!=string::npos) {
00383 performanceSummary->setClusterSizeOffTrack(80, (*iME)->getMean(), (*iME)->getRMS());
00384 }
00385 if (theMEname.find("size_siPixelClusters_Endcap")!=string::npos) {
00386 performanceSummary->setClusterSizeOffTrack(81, (*iME)->getMean(), (*iME)->getRMS());
00387 }
00388 }
00389 else {
00390 if (useSummary_) {
00391 if (theMEname.find("SUM")!=string::npos) {
00392
00393 if (theMEname.find("ndigis")!=string::npos && theMEname.find("FREQ")==string::npos) {
00394 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00395 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00396 performanceSummary->setNumberOfDigis(theMEdetID, avgMean, avgRMS, emPtn);
00397 }
00398 if (theMEname.find("adc")!=string::npos) {
00399 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00400 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00401 performanceSummary->setADC(theMEdetID, avgMean, avgRMS, emPtn);
00402 }
00403
00404 if (theMEname.find("nclusters")!=string::npos) {
00405 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00406 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00407 performanceSummary->setNumberOfClusters(theMEdetID, avgMean, avgRMS, emPtn);
00408 }
00409 if (theMEname.find("charge")!=string::npos) {
00410 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00411 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00412 performanceSummary->setClusterCharge(theMEdetID, avgMean, avgRMS, emPtn);
00413 }
00414 if (theMEname.find("size")!=string::npos) {
00415 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00416 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00417 performanceSummary->setClusterSize(theMEdetID, avgMean, avgRMS, emPtn);
00418 }
00419 if (theMEname.find("sizeX")!=string::npos) {
00420 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00421 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00422 performanceSummary->setClusterSizeX(theMEdetID, avgMean, avgRMS, emPtn);
00423 }
00424 if (theMEname.find("sizeY")!=string::npos) {
00425 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00426 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00427 performanceSummary->setClusterSizeY(theMEdetID, avgMean, avgRMS, emPtn);
00428 }
00429
00430 if (theMEname.find("nRecHits")!=string::npos) {
00431 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00432 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00433 performanceSummary->setNumberOfRecHits(theMEdetID, avgMean, avgRMS, emPtn);
00434 }
00435
00436 if (theMEname.find("residualX")!=string::npos) {
00437 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00438 getSummaryMEmeanRMSnBins(iME, avgMean, avgRMS, emPtn);
00439 performanceSummary->setResidualX(theMEdetID, avgMean, avgRMS, emPtn);
00440 }
00441 if (theMEname.find("residualY")!=string::npos) {
00442 float avgMean=0.0, avgRMS=0.0, emPtn=0.0;
00443 performanceSummary->setResidualY(theMEdetID, avgMean, avgRMS, emPtn);
00444 }
00445
00446 if (theMEname.find("OccupancyMap")!=std::string::npos) {
00447 int nNoisyCells=0, nEmptyCells=0;
00448 for (int xBin=0; xBin<(*iME)->getNbinsX(); xBin++) {
00449 for (int yBin=0; yBin<(*iME)->getNbinsY(); yBin++) {
00450 if ((*iME)->getBinContent(xBin+1, yBin+1)>0.01*(*iME)->getEntries()) nNoisyCells++;
00451 if ((*iME)->getBinContent(xBin+1, yBin+1)==.0 && (*iME)->getBinError(xBin+1, yBin+1)==0.0) nEmptyCells++;
00452 }
00453 }
00454 performanceSummary->setNumberOfNoisCells(theMEdetID, float(nNoisyCells));
00455 performanceSummary->setNumberOfDeadCells(theMEdetID, float(nEmptyCells));
00456 }
00457
00458 }
00459 else {
00460
00461 if (theMEname.find("ndigis_siPixelDigis")!=string::npos && theMEname.find("FREQ")==string::npos) {
00462 performanceSummary->setNumberOfDigis(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00463 }
00464 if (theMEname.find("adc_siPixelDigis")!=string::npos) {
00465 performanceSummary->setADC(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00466 }
00467
00468 if (theMEname.find("nclusters_siPixelClusters")!=string::npos) {
00469 performanceSummary->setNumberOfClusters(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00470 }
00471 if (theMEname.find("charge_siPixelClusters")!=string::npos) {
00472 performanceSummary->setClusterCharge(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00473 }
00474 if (theMEname.find("size_siPixelClusters")!=string::npos) {
00475 performanceSummary->setClusterSize(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00476 }
00477 if (theMEname.find("sizeX_siPixelClusters")!=string::npos) {
00478 performanceSummary->setClusterSizeX(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00479 }
00480 if (theMEname.find("sizeY_siPixelClusters")!=string::npos) {
00481 performanceSummary->setClusterSizeY(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00482 }
00483
00484 if (theMEname.find("nRecHits_siPixelRecHits")!=string::npos) {
00485 performanceSummary->setNumberOfRecHits(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00486 }
00487
00488 if (theMEname.find("residualX_siPixelTrackResiduals")!=string::npos) {
00489 performanceSummary->setResidualX(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00490 }
00491 if (theMEname.find("residualY_siPixelTrackResiduals")!=string::npos) {
00492 performanceSummary->setResidualY(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:-99.9));
00493 }
00494 }
00495 }
00496 else {
00497
00498 if (theMEname.find("ndigis_siPixelDigis")!=string::npos && theMEname.find("FREQ")==string::npos) {
00499 performanceSummary->setNumberOfDigis(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00500 }
00501 if (theMEname.find("adc_siPixelDigis")!=string::npos) {
00502 performanceSummary->setADC(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00503 }
00504
00505 if (theMEname.find("nclusters_siPixelClusters")!=string::npos) {
00506 performanceSummary->setNumberOfClusters(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00507 }
00508 if (theMEname.find("charge_siPixelClusters")!=string::npos) {
00509 performanceSummary->setClusterCharge(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00510 }
00511 if (theMEname.find("size_siPixelClusters")!=string::npos) {
00512 performanceSummary->setClusterSize(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00513 }
00514 if (theMEname.find("sizeX_siPixelClusters")!=string::npos) {
00515 performanceSummary->setClusterSizeX(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00516 }
00517 if (theMEname.find("sizeY_siPixelClusters")!=string::npos) {
00518 performanceSummary->setClusterSizeY(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00519 }
00520
00521 if (theMEname.find("nRecHits_siPixelRecHits")!=string::npos) {
00522 performanceSummary->setNumberOfRecHits(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00523 }
00524
00525 if (theMEname.find("residualX_siPixelTrackResiduals")!=string::npos) {
00526 performanceSummary->setResidualX(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00527 }
00528 if (theMEname.find("residualY_siPixelTrackResiduals")!=string::npos) {
00529 performanceSummary->setResidualY(theMEdetID, (*iME)->getMean(), (*iME)->getRMS(), ((*iME)->getEntries()==0.0 ? 1.0:0.0));
00530 }
00531
00532 if (theMEname.find("hitmap_siPixelClusters")!=std::string::npos ||
00533 theMEname.find("hitmap_siPixelDigis")!=std::string::npos) {
00534 int nNoisyCells=0, nEmptyCells=0;
00535 for (int xBin=0; xBin<(*iME)->getNbinsX(); xBin++) {
00536 for (int yBin=0; yBin<(*iME)->getNbinsY(); yBin++) {
00537 if ((*iME)->getBinContent(xBin+1, yBin+1)>0.01*(*iME)->getEntries()) nNoisyCells++;
00538 if ((*iME)->getBinContent(xBin+1, yBin+1)==.0 && (*iME)->getBinError(xBin+1, yBin+1)==0.0) nEmptyCells++;
00539 }
00540 }
00541 performanceSummary->setNumberOfNoisCells(theMEdetID, float(nNoisyCells));
00542 performanceSummary->setNumberOfDeadCells(theMEdetID, float(nEmptyCells));
00543 }
00544
00545 }
00546 }
00547 }
00548 }
00549 }
00550
00551
00552 void SiPixelHistoricInfoDQMClient::writeDB() const {
00553 if (printDebug_) performanceSummary->printAll();
00554 else performanceSummary->print();
00555 cout << "SiPixelHistoricInfoDQMClient::writeDB()" << endl;
00556
00557 Service<cond::service::PoolDBOutputService> mydbservice;
00558 if (mydbservice.isAvailable()) {
00559 if (mydbservice->isNewTagRequest("SiPixelPerformanceSummaryRcd")) {
00560 mydbservice->createNewIOV<SiPixelPerformanceSummary>(performanceSummary,
00561 mydbservice->beginOfTime(),
00562 mydbservice->endOfTime(),
00563 "SiPixelPerformanceSummaryRcd");
00564 }
00565 else {
00566 mydbservice->appendSinceTime<SiPixelPerformanceSummary>(performanceSummary,
00567 mydbservice->currentTime(),
00568 "SiPixelPerformanceSummaryRcd");
00569 }
00570 }
00571 else LogError("writeDB") << "service unavailable" << endl;
00572 }