00001 #include "DQM/SiPixelMonitorDigi/interface/SiPixelDigiModule.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006
00007 #include <vector>
00008 #include <memory>
00009 #include <string>
00010 #include <iostream>
00011 #include <stdlib.h>
00012 #include <sstream>
00013 #include <cstdio>
00014
00015
00016 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00017 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00018 #include "DataFormats/DetId/interface/DetId.h"
00019 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00020
00021
00022
00023
00024 SiPixelDigiModule::SiPixelDigiModule() : id_(0),
00025 ncols_(416),
00026 nrows_(160)
00027 {
00028 }
00030 SiPixelDigiModule::SiPixelDigiModule(const uint32_t& id) :
00031 id_(id),
00032 ncols_(416),
00033 nrows_(160)
00034 {
00035 }
00037 SiPixelDigiModule::SiPixelDigiModule(const uint32_t& id, const int& ncols, const int& nrows) :
00038 id_(id),
00039 ncols_(ncols),
00040 nrows_(nrows)
00041 {
00042 }
00043
00044
00045
00046 SiPixelDigiModule::~SiPixelDigiModule() {}
00047
00048
00049
00050 void SiPixelDigiModule::book(const edm::ParameterSet& iConfig, int type, bool twoD, bool hiRes, bool reducedSet, bool additInfo) {
00051 bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00052 bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00053 bool isHalfModule = false;
00054 if(barrel){
00055 isHalfModule = PixelBarrelName(DetId(id_)).isHalfModule();
00056 }
00057
00058 std::string hid;
00059
00060 edm::InputTag src = iConfig.getParameter<edm::InputTag>( "src" );
00061
00062
00063
00064 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00065
00066 int nbinx=ncols_/2, nbiny=nrows_/2;
00067 std::string twodtitle = "Number of Digis (1bin=four pixels)";
00068 std::string pxtitle = "Number of Digis (1bin=two columns)";
00069 std::string pytitle = "Number of Digis (1bin=two rows)";
00070 std::string twodroctitle = "ROC Occupancy (1bin=one ROC)";
00071 if(hiRes){
00072 nbinx = ncols_;
00073 nbiny = nrows_;
00074 twodtitle = "Number of Digis (1bin=one pixel)";
00075 pxtitle = "Number of Digis (1bin=one column)";
00076 pytitle = "Number of Digis (1bin=one row)";
00077 }
00078 if(type==0){
00079 SiPixelHistogramId* theHistogramId = new SiPixelHistogramId( src.label() );
00080
00081 hid = theHistogramId->setHistoId("ndigis",id_);
00082 meNDigis_ = theDMBE->book1D(hid,"Number of Digis",25,0.,25.);
00083 meNDigis_->setAxisTitle("Number of digis",1);
00084
00085 hid = theHistogramId->setHistoId("adc",id_);
00086 meADC_ = theDMBE->book1D(hid,"Digi charge",128,0.,256.);
00087 meADC_->setAxisTitle("ADC counts",1);
00088 if(!reducedSet)
00089 {
00090 if(twoD){
00091 if(additInfo){
00092
00093 hid = theHistogramId->setHistoId("hitmap",id_);
00094 mePixDigis_ = theDMBE->book2D(hid,twodtitle,nbinx,0.,float(ncols_),nbiny,0.,float(nrows_));
00095 mePixDigis_->setAxisTitle("Columns",1);
00096 mePixDigis_->setAxisTitle("Rows",2);
00097
00098 }
00099 }
00100 else{
00101
00102 hid = theHistogramId->setHistoId("hitmap",id_);
00103 mePixDigis_px_ = theDMBE->book1D(hid+"_px",pxtitle,nbinx,0.,float(ncols_));
00104 mePixDigis_py_ = theDMBE->book1D(hid+"_py",pytitle,nbiny,0.,float(nrows_));
00105 mePixDigis_px_->setAxisTitle("Columns",1);
00106 mePixDigis_py_->setAxisTitle("Rows",1);
00107 }
00108 }
00109 delete theHistogramId;
00110
00111 }
00112
00113 if(type==1 && barrel){
00114 uint32_t DBladder = PixelBarrelName(DetId(id_)).ladderName();
00115 char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00116 hid = src.label() + "_" + sladder;
00117 if(isHalfModule) hid += "H";
00118 else hid += "F";
00119
00120 meNDigisLad_ = theDMBE->book1D("ndigis_"+hid,"Number of Digis",25,0.,25.);
00121 meNDigisLad_->setAxisTitle("Number of digis",1);
00122
00123 meADCLad_ = theDMBE->book1D("adc_" + hid,"Digi charge",128,0.,256.);
00124 meADCLad_->setAxisTitle("ADC counts",1);
00125 if(!reducedSet)
00126 {
00127 if(twoD){
00128
00129 mePixDigisLad_ = theDMBE->book2D("hitmap_"+hid,twodtitle,nbinx,0.,float(ncols_),nbiny,0.,float(nrows_));
00130 mePixDigisLad_->setAxisTitle("Columns",1);
00131 mePixDigisLad_->setAxisTitle("Rows",2);
00132
00133 }
00134 else{
00135
00136 mePixDigisLad_px_ = theDMBE->book1D("hitmap_"+hid+"_px",pxtitle,nbinx,0.,float(ncols_));
00137 mePixDigisLad_py_ = theDMBE->book1D("hitmap_"+hid+"_py",pytitle,nbiny,0.,float(nrows_));
00138 mePixDigisLad_px_->setAxisTitle("Columns",1);
00139 mePixDigisLad_py_->setAxisTitle("Rows",1);
00140 }
00141 }
00142 }
00143 if(type==2 && barrel){
00144 uint32_t DBlayer = PixelBarrelName(DetId(id_)).layerName();
00145 char slayer[80]; sprintf(slayer,"Layer_%i",DBlayer);
00146 hid = src.label() + "_" + slayer;
00147 if(!additInfo){
00148
00149 meNDigisLay_ = theDMBE->book1D("ndigis_"+hid,"Number of Digis",25,0.,25.);
00150 meNDigisLay_->setAxisTitle("Number of digis",1);
00151
00152 meADCLay_ = theDMBE->book1D("adc_" + hid,"Digi charge",128,0.,256.);
00153 meADCLay_->setAxisTitle("ADC counts",1);
00154 }
00155 if(!reducedSet){
00156 if(twoD || additInfo){
00157
00158 if(isHalfModule){
00159 mePixDigisLay_ = theDMBE->book2D("hitmap_"+hid,twodtitle,nbinx,0.,float(ncols_),2*nbiny,0.,float(2*nrows_));
00160 }
00161 else{
00162 mePixDigisLay_ = theDMBE->book2D("hitmap_"+hid,twodtitle,nbinx,0.,float(ncols_),nbiny,0.,float(nrows_));
00163
00164 }
00165 mePixDigisLay_->setAxisTitle("Columns",1);
00166 mePixDigisLay_->setAxisTitle("Rows",2);
00167
00168
00169 int yROCbins[3] = {18,30,42};
00170 mePixRocsLay_ = theDMBE->book2D("rocmap_"+hid,twodroctitle,32,0.,32.,yROCbins[DBlayer-1],1.5,1.5+float(yROCbins[DBlayer-1]/2));
00171 mePixRocsLay_->setAxisTitle("ROCs per Module",1);
00172 mePixRocsLay_->setAxisTitle("ROCs per 1/2 Ladder",2);
00173 }
00174 if(!twoD && !additInfo){
00175
00176 mePixDigisLay_px_ = theDMBE->book1D("hitmap_"+hid+"_px",pxtitle,nbinx,0.,float(ncols_));
00177 if(isHalfModule){
00178 mePixDigisLay_py_ = theDMBE->book1D("hitmap_"+hid+"_py",pytitle,2*nbiny,0.,float(2*nrows_));
00179 }
00180 else{
00181 mePixDigisLay_py_ = theDMBE->book1D("hitmap_"+hid+"_py",pytitle,nbiny,0.,float(nrows_));
00182 }
00183 mePixDigisLay_px_->setAxisTitle("Columns",1);
00184 mePixDigisLay_py_->setAxisTitle("Rows",1);
00185 }
00186 }
00187 }
00188 if(type==3 && barrel){
00189 uint32_t DBmodule = PixelBarrelName(DetId(id_)).moduleName();
00190 char smodule[80]; sprintf(smodule,"Ring_%i",DBmodule);
00191 hid = src.label() + "_" + smodule;
00192
00193 meNDigisPhi_ = theDMBE->book1D("ndigis_"+hid,"Number of Digis",25,0.,25.);
00194 meNDigisPhi_->setAxisTitle("Number of digis",1);
00195
00196 meADCPhi_ = theDMBE->book1D("adc_" + hid,"Digi charge",128,0.,256.);
00197 meADCPhi_->setAxisTitle("ADC counts",1);
00198 if(!reducedSet)
00199 {
00200 if(twoD){
00201
00202
00203 if(isHalfModule){
00204 mePixDigisPhi_ = theDMBE->book2D("hitmap_"+hid,twodtitle,nbinx,0.,float(ncols_),2*nbiny,0.,float(2*nrows_));
00205 }
00206 else {
00207 mePixDigisPhi_ = theDMBE->book2D("hitmap_"+hid,twodtitle,nbinx,0.,float(ncols_),nbiny,0.,float(nrows_));
00208 }
00209 mePixDigisPhi_->setAxisTitle("Columns",1);
00210 mePixDigisPhi_->setAxisTitle("Rows",2);
00211
00212 }
00213 else{
00214
00215 mePixDigisPhi_px_ = theDMBE->book1D("hitmap_"+hid+"_px",pxtitle,nbinx,0.,float(ncols_));
00216 if(isHalfModule){
00217 mePixDigisPhi_py_ = theDMBE->book1D("hitmap_"+hid+"_py",pytitle,2*nbiny,0.,float(2*nrows_));
00218 }
00219 else{
00220 mePixDigisPhi_py_ = theDMBE->book1D("hitmap_"+hid+"_py",pytitle,nbiny,0.,float(nrows_));
00221 }
00222 mePixDigisPhi_px_->setAxisTitle("Columns",1);
00223 mePixDigisPhi_py_->setAxisTitle("Rows",1);
00224 }
00225 }
00226 }
00227 if(type==4 && endcap){
00228 uint32_t blade= PixelEndcapName(DetId(id_)).bladeName();
00229
00230 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00231 hid = src.label() + "_" + sblade;
00232
00233 meNDigisBlade_ = theDMBE->book1D("ndigis_"+hid,"Number of Digis",25,0.,25.);
00234 meNDigisBlade_->setAxisTitle("Number of digis",1);
00235
00236 meADCBlade_ = theDMBE->book1D("adc_" + hid,"Digi charge",128,0.,256.);
00237 meADCBlade_->setAxisTitle("ADC counts",1);
00238 }
00239 if(type==5 && endcap){
00240 uint32_t disk = PixelEndcapName(DetId(id_)).diskName();
00241
00242 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00243 hid = src.label() + "_" + sdisk;
00244 if(!additInfo){
00245
00246 meNDigisDisk_ = theDMBE->book1D("ndigis_"+hid,"Number of Digis",25,0.,25.);
00247 meNDigisDisk_->setAxisTitle("Number of digis",1);
00248
00249 meADCDisk_ = theDMBE->book1D("adc_" + hid,"Digi charge",128,0.,256.);
00250 meADCDisk_->setAxisTitle("ADC counts",1);
00251 }
00252 if(additInfo){
00253 mePixDigisDisk_ = theDMBE->book2D("hitmap_"+hid,twodtitle,260,0.,260.,160,0.,160.);
00254 mePixDigisDisk_->setAxisTitle("Columns",1);
00255 mePixDigisDisk_->setAxisTitle("Rows",2);
00256
00257 mePixRocsDisk_ = theDMBE->book2D("rocmap_"+hid,twodroctitle,26,0.,26.,24,1.,13.);
00258 mePixRocsDisk_ ->setAxisTitle("ROCs per Module (2 Panels)",1);
00259 mePixRocsDisk_ ->setAxisTitle("Blade Number",2);
00260 }
00261 }
00262 if(type==6 && endcap){
00263 uint32_t panel= PixelEndcapName(DetId(id_)).pannelName();
00264 uint32_t module= PixelEndcapName(DetId(id_)).plaquetteName();
00265 char slab[80]; sprintf(slab, "Panel_%i_Ring_%i",panel, module);
00266 hid = src.label() + "_" + slab;
00267
00268 meNDigisRing_ = theDMBE->book1D("ndigis_"+hid,"Number of Digis",25,0.,25.);
00269 meNDigisRing_->setAxisTitle("Number of digis",1);
00270
00271 meADCRing_ = theDMBE->book1D("adc_" + hid,"Digi charge",128,0.,256.);
00272 meADCRing_->setAxisTitle("ADC counts",1);
00273 if(!reducedSet)
00274 {
00275 if(twoD){
00276
00277 mePixDigisRing_ = theDMBE->book2D("hitmap_"+hid,twodtitle,nbinx,0.,float(ncols_),nbiny,0.,float(nrows_));
00278 mePixDigisRing_->setAxisTitle("Columns",1);
00279 mePixDigisRing_->setAxisTitle("Rows",2);
00280
00281 }
00282 else{
00283
00284 mePixDigisRing_px_ = theDMBE->book1D("hitmap_"+hid+"_px",pxtitle,nbinx,0.,float(ncols_));
00285 mePixDigisRing_py_ = theDMBE->book1D("hitmap_"+hid+"_py",pytitle,nbiny,0.,float(nrows_));
00286 mePixDigisRing_px_->setAxisTitle("Columns",1);
00287 mePixDigisRing_py_->setAxisTitle("Rows",1);
00288 }
00289 }
00290 }
00291 }
00292
00293
00294
00295
00296
00297 int SiPixelDigiModule::fill(const edm::DetSetVector<PixelDigi>& input, bool modon,
00298 bool ladon, bool layon, bool phion,
00299 bool bladeon, bool diskon, bool ringon,
00300 bool twoD, bool reducedSet, bool twoDimModOn, bool twoDimOnlyLayDisk,
00301 int &nDigisA, int &nDigisB) {
00302 bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00303 bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00304 bool isHalfModule = false;
00305 uint32_t DBladder = 0;
00306 if(barrel){
00307 isHalfModule = PixelBarrelName(DetId(id_)).isHalfModule();
00308 DBladder = PixelBarrelName(DetId(id_)).ladderName();
00309 }
00310
00311
00312 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00313
00314
00315 edm::DetSetVector<PixelDigi>::const_iterator isearch = input.find(id_);
00316
00317 unsigned int numberOfDigisMod = 0;
00318 int numberOfDigis[8]; for(int i=0; i!=8; i++) numberOfDigis[i]=0;
00319 nDigisA=0; nDigisB=0;
00320 if( isearch != input.end() ) {
00321
00322
00323 edm::DetSet<PixelDigi>::const_iterator di;
00324 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00325 int adc = di->adc();
00326 int col = di->column();
00327 int row = di->row();
00328 numberOfDigisMod++;
00329 PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(id_)).shell();
00330 int DBlayer = PixelBarrelName(DetId(id_)).layerName();
00331 int DBmodule = PixelBarrelName(DetId(id_)).moduleName();
00332 if(barrel){
00333 if(isHalfModule){
00334 if(DBshell==PixelBarrelName::pI||DBshell==PixelBarrelName::pO){
00335 numberOfDigis[0]++; nDigisA++;
00336 if(DBlayer==1) numberOfDigis[2]++;
00337 if(DBlayer==2) numberOfDigis[3]++;
00338 if(DBlayer==3) numberOfDigis[4]++;
00339 }
00340 if(DBshell==PixelBarrelName::mI||DBshell==PixelBarrelName::mO){
00341 numberOfDigis[1]++; nDigisB++;
00342 if(DBlayer==1) numberOfDigis[5]++;
00343 if(DBlayer==2) numberOfDigis[6]++;
00344 if(DBlayer==3) numberOfDigis[7]++;
00345 }
00346 }else{
00347 if(row<80){
00348 numberOfDigis[0]++; nDigisA++;
00349 if(DBlayer==1) numberOfDigis[2]++;
00350 if(DBlayer==2) numberOfDigis[3]++;
00351 if(DBlayer==3) numberOfDigis[4]++;
00352 }else{
00353 numberOfDigis[1]++; nDigisB++;
00354 if(DBlayer==1) numberOfDigis[5]++;
00355 if(DBlayer==2) numberOfDigis[6]++;
00356 if(DBlayer==3) numberOfDigis[7]++;
00357 }
00358 }
00359 }
00360 if(modon){
00361 if(!reducedSet){
00362 if(twoD) {
00363 if(twoDimModOn) (mePixDigis_)->Fill((float)col,(float)row);
00364
00365
00366 }
00367 else {
00368 (mePixDigis_px_)->Fill((float)col);
00369 (mePixDigis_py_)->Fill((float)row);
00370 }
00371 }
00372 (meADC_)->Fill((float)adc);
00373 }
00374 if(ladon && barrel){
00375 (meADCLad_)->Fill((float)adc);
00376 if(!reducedSet){
00377 if(twoD) (mePixDigisLad_)->Fill((float)col,(float)row);
00378 else {
00379 (mePixDigisLad_px_)->Fill((float)col);
00380 (mePixDigisLad_py_)->Fill((float)row);
00381 }
00382 }
00383 }
00384 if((layon || twoDimOnlyLayDisk) && barrel){
00385 if(!twoDimOnlyLayDisk) (meADCLay_)->Fill((float)adc);
00386 if(!reducedSet){
00387 if((layon && twoD) || twoDimOnlyLayDisk){
00388
00389 float rocx = (float)col/52. + 8.0*float(DBmodule-1);
00390 float rocy = (float)row/160.+float(DBladder);
00391
00392 if(DBladder==1) rocy = rocy + 0.5;
00393 mePixRocsLay_->Fill(rocx,rocy);
00394
00395
00396
00397
00398 if(isHalfModule && DBladder==1){
00399 (mePixDigisLay_)->Fill((float)col,(float)row+80);
00400 }
00401 else (mePixDigisLay_)->Fill((float)col,(float)row);
00402 }
00403 if((layon && !twoD) && !twoDimOnlyLayDisk){
00404 (mePixDigisLay_px_)->Fill((float)col);
00405 if(isHalfModule && DBladder==1) {
00406 (mePixDigisLay_py_)->Fill((float)row+80);
00407 }
00408 else (mePixDigisLay_py_)->Fill((float)row);
00409 }
00410 }
00411 }
00412 if(phion && barrel){
00413 (meADCPhi_)->Fill((float)adc);
00414 if(!reducedSet)
00415 {
00416 if(twoD){
00417 if(isHalfModule && DBladder==1){
00418 (mePixDigisPhi_)->Fill((float)col,(float)row+80);
00419 }
00420 else (mePixDigisPhi_)->Fill((float)col,(float)row);
00421 }
00422 else {
00423 (mePixDigisPhi_px_)->Fill((float)col);
00424 if(isHalfModule && DBladder==1) {
00425 (mePixDigisPhi_py_)->Fill((float)row+80);
00426 }
00427 else (mePixDigisPhi_py_)->Fill((float)row);
00428 }
00429 }
00430 }
00431 if(bladeon && endcap){
00432 (meADCBlade_)->Fill((float)adc);
00433 }
00434
00435 if((diskon || twoDimOnlyLayDisk) && endcap){
00436 if(!twoDimOnlyLayDisk) (meADCDisk_)->Fill((float)adc);
00437 if(twoDimOnlyLayDisk){
00438 (mePixDigisDisk_)->Fill((float)col,(float)row);
00439
00440 int DBpanel= PixelEndcapName(DetId(id_)).pannelName();
00441 int DBblade= PixelEndcapName(DetId(id_)).bladeName();
00442 float offx = 0.;
00443
00444 for (int i = DBpanel; i < DBmodule; ++i) {offx = offx + float(5+DBpanel-i);}
00445 float rocx = (float)col/52. + offx + 14.0*float(DBpanel-1);
00446 float rocy = (float)row/160.+float(DBblade);
00447 mePixRocsDisk_->Fill(rocx,rocy);
00448
00449
00450
00451
00452
00453 }
00454 }
00455 if(ringon && endcap){
00456 (meADCRing_)->Fill((float)adc);
00457 if(!reducedSet)
00458 {
00459 if(twoD) (mePixDigisRing_)->Fill((float)col,(float)row);
00460 else {
00461 (mePixDigisRing_px_)->Fill((float)col);
00462 (mePixDigisRing_py_)->Fill((float)row);
00463 }
00464 }
00465 }
00466 }
00467 if(modon) (meNDigis_)->Fill((float)numberOfDigisMod);
00468 if(ladon && barrel) (meNDigisLad_)->Fill((float)numberOfDigisMod);
00469 if(layon && barrel && !twoDimOnlyLayDisk) (meNDigisLay_)->Fill((float)numberOfDigisMod);
00470 if(phion && barrel) (meNDigisPhi_)->Fill((float)numberOfDigisMod);
00471 if(bladeon && endcap) (meNDigisBlade_)->Fill((float)numberOfDigisMod);
00472 if(diskon && endcap && !twoDimOnlyLayDisk) (meNDigisDisk_)->Fill((float)numberOfDigisMod);
00473 if(ringon && endcap) (meNDigisRing_)->Fill((float)numberOfDigisMod);
00474 if(barrel){
00475 MonitorElement* me=theDMBE->get("Pixel/Barrel/ALLMODS_ndigisCOMB_Barrel");
00476 if(me) me->Fill((float)numberOfDigisMod);
00477 me=theDMBE->get("Pixel/Barrel/ALLMODS_ndigisCHAN_Barrel");
00478 if(me){ if(numberOfDigis[0]>0) me->Fill((float)numberOfDigis[0]); if(numberOfDigis[1]>0) me->Fill((float)numberOfDigis[1]); }
00479 me=theDMBE->get("Pixel/Barrel/ALLMODS_ndigisCHAN_BarrelL1");
00480 if(me){ if(numberOfDigis[2]>0) me->Fill((float)numberOfDigis[2]); }
00481 me=theDMBE->get("Pixel/Barrel/ALLMODS_ndigisCHAN_BarrelL2");
00482 if(me){ if(numberOfDigis[3]>0) me->Fill((float)numberOfDigis[3]); }
00483 me=theDMBE->get("Pixel/Barrel/ALLMODS_ndigisCHAN_BarrelL3");
00484 if(me){ if(numberOfDigis[4]>0) me->Fill((float)numberOfDigis[4]); }
00485 }else if(endcap){
00486 MonitorElement* me=theDMBE->get("Pixel/Endcap/ALLMODS_ndigisCOMB_Endcap");
00487 if(me) me->Fill((float)numberOfDigisMod);
00488 }
00489 }
00490
00491
00492 return numberOfDigisMod;
00493 }