CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/SiPixelMonitorRecHit/src/SiPixelRecHitModule.cc

Go to the documentation of this file.
00001 #include "DQM/SiPixelMonitorRecHit/interface/SiPixelRecHitModule.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 // STL
00007 #include <vector>
00008 #include <memory>
00009 #include <string>
00010 #include <iostream>
00011 #include <stdlib.h>
00012 
00013 // Data Formats
00014 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00015 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00016 #include "DataFormats/DetId/interface/DetId.h"
00017 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00018 //
00019 // Constructors
00020 //
00021 SiPixelRecHitModule::SiPixelRecHitModule() : id_(0) { }
00023 SiPixelRecHitModule::SiPixelRecHitModule(const uint32_t& id) : 
00024   id_(id)
00025 { 
00026 }
00027 
00028 //
00029 // Destructor
00030 //
00031 SiPixelRecHitModule::~SiPixelRecHitModule() {}
00032 //
00033 // Book histograms
00034 //
00035 void SiPixelRecHitModule::book(const edm::ParameterSet& iConfig, int type, 
00036                                bool twoD, bool reducedSet) {
00037 
00038   bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00039   bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00040   bool isHalfModule = false;
00041   if(barrel){
00042     isHalfModule = PixelBarrelName(DetId(id_)).isHalfModule(); 
00043   }
00044 
00045   std::string hid;
00046   // Get collection name and instantiate Histo Id builder
00047   edm::InputTag src = iConfig.getParameter<edm::InputTag>( "src" );
00048   // Get DQM interface
00049   DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00050 
00051 
00052   if(type==0){
00053     SiPixelHistogramId* theHistogramId = new SiPixelHistogramId( src.label() );
00054         if(!reducedSet)
00055         {
00056     if(twoD){
00057       // XYPosition
00058       hid = theHistogramId->setHistoId("xypos",id_);
00059       meXYPos_ = theDMBE->book2D(hid,"XY Position",100,-1.,1,100,-4,4);
00060       meXYPos_->setAxisTitle("X Position",1);
00061       meXYPos_->setAxisTitle("Y Position",2);
00062     }
00063     else{
00064       // projections of XYPosition
00065       hid = theHistogramId->setHistoId("xypos",id_);
00066       meXYPos_px_ = theDMBE->book1D(hid+"_px","X Position",100,-1.,1);
00067       meXYPos_px_->setAxisTitle("X Position",1);
00068       meXYPos_py_ = theDMBE->book1D(hid+"_py","Y Position",100,-4,4);
00069       meXYPos_py_->setAxisTitle("Y Position",1);
00070     }
00071         }
00072     hid = theHistogramId->setHistoId("ClustX",id_);
00073     meClustX_ = theDMBE->book1D(hid, "RecHit X size", 10, 0., 10.);
00074     meClustX_->setAxisTitle("RecHit size X dimension", 1);
00075     hid = theHistogramId->setHistoId("ClustY",id_);
00076     meClustY_ = theDMBE->book1D(hid, "RecHit Y size", 15, 0., 15.);
00077     meClustY_->setAxisTitle("RecHit size Y dimension", 1); 
00078 
00079     hid = theHistogramId->setHistoId("ErrorX",id_);
00080     meErrorX_ = theDMBE->book1D(hid, "RecHit error X", 100,0.,0.02);
00081     meErrorX_->setAxisTitle("RecHit error X", 1);
00082     hid = theHistogramId->setHistoId("ErrorY",id_);
00083     meErrorY_ = theDMBE->book1D(hid, "RecHit error Y", 100,0.,0.02);
00084     meErrorY_->setAxisTitle("RecHit error Y", 1);
00085 
00086     hid = theHistogramId->setHistoId("nRecHits",id_);
00087     menRecHits_ = theDMBE->book1D(hid, "# of rechits in this module", 8, 0, 8);
00088     menRecHits_->setAxisTitle("number of rechits",1);  
00089     delete theHistogramId;
00090   }
00091 
00092   if(type==1 && barrel){
00093     uint32_t DBladder = PixelBarrelName(DetId(id_)).ladderName();
00094     char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00095     hid = src.label() + "_" + sladder;
00096     if(isHalfModule) hid += "H";
00097     else hid += "F";
00098         if(!reducedSet)
00099         {
00100     if(twoD){
00101       meXYPosLad_ = theDMBE->book2D("xypos_" + hid,"XY Position",100,-1.,1,100,-4,4);
00102       meXYPosLad_->setAxisTitle("X Position",1);
00103       meXYPosLad_->setAxisTitle("Y Position",2);
00104     }
00105     else{
00106       // projections of XYPosition
00107       meXYPosLad_px_ = theDMBE->book1D("xypos_"+hid+"_px","X Position",100,-1.,1);
00108       meXYPosLad_px_->setAxisTitle("X Position",1);
00109       meXYPosLad_py_ = theDMBE->book1D("xypos_"+hid+"_py","Y Position",100,-4,4);
00110       meXYPosLad_py_->setAxisTitle("Y Position",1);
00111     }
00112         }
00113     meClustXLad_ = theDMBE->book1D("ClustX_" +hid, "RecHit X size", 10, 0., 10.);
00114     meClustXLad_->setAxisTitle("RecHit size X dimension", 1);
00115     meClustYLad_ = theDMBE->book1D("ClustY_" +hid,"RecHit Y size", 15, 0.,15.);
00116     meClustYLad_->setAxisTitle("RecHit size Y dimension", 1);
00117     meErrorXLad_ = theDMBE->book1D("ErrorX_"+hid, "RecHit error X", 100,0.,0.02);
00118     meErrorXLad_->setAxisTitle("RecHit error X", 1);
00119     meErrorYLad_ = theDMBE->book1D("ErrorY_"+hid, "RecHit error Y", 100,0.,0.02);
00120     meErrorYLad_->setAxisTitle("RecHit error Y", 1);
00121     menRecHitsLad_ = theDMBE->book1D("nRecHits_"+hid, "# of rechits in this module", 8, 0, 8);
00122     menRecHitsLad_->setAxisTitle("number of rechits",1);
00123 
00124   }
00125 
00126   if(type==2 && barrel){
00127     
00128     uint32_t DBlayer = PixelBarrelName(DetId(id_)).layerName();
00129     char slayer[80]; sprintf(slayer,"Layer_%i",DBlayer);
00130     hid = src.label() + "_" + slayer;
00131     
00132         if(!reducedSet)
00133         {
00134     if(twoD){
00135       meXYPosLay_ = theDMBE->book2D("xypos_" + hid,"XY Position",100,-1.,1,100,-4,4);
00136       meXYPosLay_->setAxisTitle("X Position",1);
00137       meXYPosLay_->setAxisTitle("Y Position",2);
00138     }
00139     else{
00140       // projections of XYPosition
00141       meXYPosLay_px_ = theDMBE->book1D("xypos_"+hid+"_px","X Position",100,-1.,1);
00142       meXYPosLay_px_->setAxisTitle("X Position",1);
00143       meXYPosLay_py_ = theDMBE->book1D("xypos_"+hid+"_py","Y Position",100,-4,4);
00144       meXYPosLay_py_->setAxisTitle("Y Position",1);
00145     }
00146         }
00147 
00148     meClustXLay_ = theDMBE->book1D("ClustX_" +hid, "RecHit X size", 10, 0., 10.);
00149     meClustXLay_->setAxisTitle("RecHit size X dimension", 1);
00150     meClustYLay_ = theDMBE->book1D("ClustY_" +hid,"RecHit Y size", 15, 0.,15.);
00151     meClustYLay_->setAxisTitle("RecHit size Y dimension", 1);
00152     meErrorXLay_ = theDMBE->book1D("ErrorX_"+hid, "RecHit error X", 100,0.,0.02);
00153     meErrorXLay_->setAxisTitle("RecHit error X", 1);
00154     meErrorYLay_ = theDMBE->book1D("ErrorY_"+hid, "RecHit error Y", 100,0.,0.02);
00155     meErrorYLay_->setAxisTitle("RecHit error Y", 1);
00156     menRecHitsLay_ = theDMBE->book1D("nRecHits_"+hid, "# of rechits in this module", 8, 0, 8);
00157     menRecHitsLay_->setAxisTitle("number of rechits",1);
00158 
00159   }
00160 
00161   if(type==3 && barrel){
00162     uint32_t DBmodule = PixelBarrelName(DetId(id_)).moduleName();
00163     char smodule[80]; sprintf(smodule,"Ring_%i",DBmodule);
00164     hid = src.label() + "_" + smodule;
00165     
00166         if(!reducedSet)
00167         {
00168     if(twoD){
00169       meXYPosPhi_ = theDMBE->book2D("xypos_" + hid,"XY Position",100,-1.,1,100,-4,4);
00170       meXYPosPhi_->setAxisTitle("X Position",1);
00171       meXYPosPhi_->setAxisTitle("Y Position",2);
00172     }
00173     else{
00174       // projections of XYPosition
00175       meXYPosPhi_px_ = theDMBE->book1D("xypos_"+hid+"_px","X Position",100,-1.,1);
00176       meXYPosPhi_px_->setAxisTitle("X Position",1);
00177       meXYPosPhi_py_ = theDMBE->book1D("xypos_"+hid+"_py","Y Position",100,-4,4);
00178       meXYPosPhi_py_->setAxisTitle("Y Position",1);
00179     }
00180         }
00181     meClustXPhi_ = theDMBE->book1D("ClustX_" +hid, "RecHit X size", 10, 0., 10.);
00182     meClustXPhi_->setAxisTitle("RecHit size X dimension", 1);
00183     meClustYPhi_ = theDMBE->book1D("ClustY_" +hid,"RecHit Y size", 15, 0.,15.);
00184     meClustYPhi_->setAxisTitle("RecHit size Y dimension", 1);
00185     meErrorXPhi_ = theDMBE->book1D("ErrorX_"+hid, "RecHit error X", 100,0.,0.02);
00186     meErrorXPhi_->setAxisTitle("RecHit error X", 1);
00187     meErrorYPhi_ = theDMBE->book1D("ErrorY_"+hid, "RecHit error Y", 100,0.,0.02);
00188     meErrorYPhi_->setAxisTitle("RecHit error Y", 1);
00189     menRecHitsPhi_ = theDMBE->book1D("nRecHits_"+hid, "# of rechits in this module", 8, 0, 8);
00190     menRecHitsPhi_->setAxisTitle("number of rechits",1);
00191 
00192   }
00193 
00194   if(type==4 && endcap){
00195     uint32_t blade= PixelEndcapName(DetId(id_)).bladeName();
00196     
00197     char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00198     hid = src.label() + "_" + sblade;
00199 //     meXYPosBlade_ = theDMBE->book2D("xypos_" + hid,"XY Position",100,-1.,1,100,-4,4);
00200 //     meXYPosBlade_->setAxisTitle("X Position",1);
00201 //     meXYPosBlade_->setAxisTitle("Y Position",2);
00202 
00203     meClustXBlade_ = theDMBE->book1D("ClustX_" +hid, "RecHit X size", 10, 0., 10.);
00204     meClustXBlade_->setAxisTitle("RecHit size X dimension", 1);
00205     meClustYBlade_ = theDMBE->book1D("ClustY_" +hid,"RecHit Y size", 15, 0.,15.);
00206     meClustYBlade_->setAxisTitle("RecHit size Y dimension", 1);
00207     meErrorXBlade_ = theDMBE->book1D("ErrorX_"+hid, "RecHit error X", 100,0.,0.02);
00208     meErrorXBlade_->setAxisTitle("RecHit error X", 1);
00209     meErrorYBlade_ = theDMBE->book1D("ErrorY_"+hid, "RecHit error Y", 100,0.,0.02);
00210     meErrorYBlade_->setAxisTitle("RecHit error Y", 1);
00211     menRecHitsBlade_ = theDMBE->book1D("nRecHits_"+hid, "# of rechits in this module", 8, 0, 8);
00212     menRecHitsBlade_->setAxisTitle("number of rechits",1);
00213 
00214   }
00215   if(type==5 && endcap){
00216     uint32_t disk = PixelEndcapName(DetId(id_)).diskName();
00217     
00218     char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00219     hid = src.label() + "_" + sdisk;
00220 //     meXYPosDisk_ = theDMBE->book2D("xypos_" + hid,"XY Position",100,-1.,1,100,-4,4);
00221 //     meXYPosDisk_->setAxisTitle("X Position",1);
00222 //     meXYPosDisk_->setAxisTitle("Y Position",2);
00223 
00224     meClustXDisk_ = theDMBE->book1D("ClustX_" +hid, "RecHit X size", 10, 0., 10.);
00225     meClustXDisk_->setAxisTitle("RecHit size X dimension", 1);
00226     meClustYDisk_ = theDMBE->book1D("ClustY_" +hid,"RecHit Y size", 15, 0.,15.);
00227     meClustYDisk_->setAxisTitle("RecHit size Y dimension", 1);
00228     meErrorXDisk_ = theDMBE->book1D("ErrorX_"+hid, "RecHit error X", 100,0.,0.02);
00229     meErrorXDisk_->setAxisTitle("RecHit error X", 1);
00230     meErrorYDisk_ = theDMBE->book1D("ErrorY_"+hid, "RecHit error Y", 100,0.,0.02);
00231     meErrorYDisk_->setAxisTitle("RecHit error Y", 1);
00232     menRecHitsDisk_ = theDMBE->book1D("nRecHits_"+hid, "# of rechits in this module", 8, 0, 8);
00233     menRecHitsDisk_->setAxisTitle("number of rechits",1);
00234 
00235   }
00236 
00237   if(type==6 && endcap){
00238     uint32_t panel= PixelEndcapName(DetId(id_)).pannelName();
00239     uint32_t module= PixelEndcapName(DetId(id_)).plaquetteName();
00240     char slab[80]; sprintf(slab, "Panel_%i_Ring_%i",panel, module);
00241     hid = src.label() + "_" + slab;
00242     
00243         if(!reducedSet)
00244         {
00245     if(twoD){
00246       meXYPosRing_ = theDMBE->book2D("xypos_" + hid,"XY Position",100,-1.,1,100,-4,4);
00247       meXYPosRing_->setAxisTitle("X Position",1);
00248       meXYPosRing_->setAxisTitle("Y Position",2);
00249     }
00250     else{
00251       // projections of XYPosition
00252       meXYPosRing_px_ = theDMBE->book1D("xypos_"+hid+"_px","X Position",100,-1.,1);
00253       meXYPosRing_px_->setAxisTitle("X Position",1);
00254       meXYPosRing_py_ = theDMBE->book1D("xypos_"+hid+"_py","Y Position",100,-4,4);
00255       meXYPosRing_py_->setAxisTitle("Y Position",1);
00256     }
00257         }
00258     meClustXRing_ = theDMBE->book1D("ClustX_" +hid, "RecHit X size", 10, 0., 10.);
00259     meClustXRing_->setAxisTitle("RecHit size X dimension", 1);
00260     meClustYRing_ = theDMBE->book1D("ClustY_" +hid,"RecHit Y size", 15, 0.,15.);
00261     meClustYRing_->setAxisTitle("RecHit size Y dimension", 1);
00262     meErrorXRing_ = theDMBE->book1D("ErrorX_"+hid, "RecHit error X", 100,0.,0.02);
00263     meErrorXRing_->setAxisTitle("RecHit error X", 1);
00264     meErrorYRing_ = theDMBE->book1D("ErrorY_"+hid, "RecHit error Y", 100,0.,0.02);
00265     meErrorYRing_->setAxisTitle("RecHit error Y", 1);
00266     menRecHitsRing_ = theDMBE->book1D("nRecHits_"+hid, "# of rechits in this module", 8, 0, 8);
00267     menRecHitsRing_->setAxisTitle("number of rechits",1);
00268 
00269   }
00270 
00271 }
00272 //
00273 // Fill histograms
00274 //
00275 void SiPixelRecHitModule::fill(const float& rechit_x, const float& rechit_y, 
00276                                const int& sizeX, const int& sizeY, 
00277                                const float& lerr_x, const float& lerr_y, 
00278                                bool modon, bool ladon, bool layon, bool phion, 
00279                                bool bladeon, bool diskon, bool ringon, 
00280                                bool twoD, bool reducedSet) {
00281 
00282   bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00283   bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00284 
00285   //std::cout << rechit_x << " " << rechit_y << " " << sizeX << " " << sizeY << std::endl;
00286   if(modon){
00287     meClustX_->Fill(sizeX);
00288     meClustY_->Fill(sizeY);
00289     meErrorX_->Fill(lerr_x);
00290     meErrorY_->Fill(lerr_y);  
00291         if(!reducedSet)
00292         {
00293     if(twoD) meXYPos_->Fill(rechit_x, rechit_y);
00294     else {
00295       meXYPos_px_->Fill(rechit_x); 
00296       meXYPos_py_->Fill(rechit_y);
00297     }
00298         }
00299   }
00300   //std::cout<<"number of detector units="<<numberOfDetUnits<<std::endl;
00301 
00302   if(ladon && barrel){
00303     meClustXLad_->Fill(sizeX);
00304     meClustYLad_->Fill(sizeY);
00305     meErrorXLad_->Fill(lerr_x);
00306     meErrorYLad_->Fill(lerr_y);  
00307         if(!reducedSet)
00308         {
00309     if(twoD) meXYPosLad_->Fill(rechit_x, rechit_y);
00310     else{
00311       meXYPosLad_px_->Fill(rechit_x); 
00312       meXYPosLad_py_->Fill(rechit_y);
00313     }
00314         }
00315   }
00316 
00317   if(layon && barrel){
00318     meClustXLay_->Fill(sizeX);
00319     meClustYLay_->Fill(sizeY);
00320     meErrorXLay_->Fill(lerr_x);
00321     meErrorYLay_->Fill(lerr_y); 
00322         if(!reducedSet)
00323         {
00324     if(twoD) meXYPosLay_->Fill(rechit_x, rechit_y);
00325     else{
00326       meXYPosLay_px_->Fill(rechit_x); 
00327       meXYPosLay_py_->Fill(rechit_y);
00328     }
00329         }
00330   }
00331 
00332   if(phion && barrel){
00333     meClustXPhi_->Fill(sizeX);
00334     meClustYPhi_->Fill(sizeY);
00335     meErrorXPhi_->Fill(lerr_x);
00336     meErrorYPhi_->Fill(lerr_y); 
00337     if(!reducedSet)
00338         {
00339     if(twoD) meXYPosPhi_->Fill(rechit_x, rechit_y);
00340     else{
00341       meXYPosPhi_px_->Fill(rechit_x); 
00342       meXYPosPhi_py_->Fill(rechit_y);
00343     }
00344         }       
00345   }
00346 
00347   if(bladeon && endcap){
00348     //meXYPosBlade_->Fill(rechit_x, rechit_y);
00349     meClustXBlade_->Fill(sizeX);
00350     meClustYBlade_->Fill(sizeY);
00351     meErrorXBlade_->Fill(lerr_x);
00352     meErrorYBlade_->Fill(lerr_y); 
00353   }
00354 
00355   if(diskon && endcap){
00356     //meXYPosDisk_->Fill(rechit_x, rechit_y);
00357     meClustXDisk_->Fill(sizeX);
00358     meClustYDisk_->Fill(sizeY);
00359     meErrorXDisk_->Fill(lerr_x);
00360     meErrorYDisk_->Fill(lerr_y); 
00361   }
00362 
00363   if(ringon && endcap){
00364     meClustXRing_->Fill(sizeX);
00365     meClustYRing_->Fill(sizeY);
00366     meErrorXRing_->Fill(lerr_x);
00367     meErrorYRing_->Fill(lerr_y); 
00368         if(!reducedSet)
00369         {
00370     if(twoD) meXYPosRing_->Fill(rechit_x, rechit_y);
00371     else{
00372       meXYPosRing_px_->Fill(rechit_x); 
00373       meXYPosRing_py_->Fill(rechit_y);
00374     }
00375         }       
00376   }
00377 }
00378 
00379 void SiPixelRecHitModule::nfill(const int& nrec, bool modon, bool ladon, bool layon, bool phion, bool bladeon, bool diskon, bool ringon) {
00380   
00381   bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00382   bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00383 
00384   if(modon) menRecHits_->Fill(nrec);
00385   //barrel
00386   if(ladon && barrel) menRecHitsLad_->Fill(nrec);
00387   if(layon && barrel) menRecHitsLay_->Fill(nrec);
00388   if(phion && barrel) menRecHitsPhi_->Fill(nrec);
00389   //endcap
00390   if(bladeon && endcap) menRecHitsBlade_->Fill(nrec);
00391   if(diskon && endcap) menRecHitsDisk_->Fill(nrec);
00392   if(ringon && endcap) menRecHitsRing_->Fill(nrec);
00393 }