CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/RPCMonitorDigi/src/RPCBookDetUnitME.cc

Go to the documentation of this file.
00001 #include <DQM/RPCMonitorDigi/interface/RPCMonitorDigi.h>
00002 #include <DQM/RPCMonitorDigi/interface/RPCBookFolderStructure.h>
00003 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00004 #include <Geometry/RPCGeometry/interface/RPCGeomServ.h>
00005 #include <Geometry/RPCGeometry/interface/RPCGeometry.h>
00006 #include <DQM/RPCMonitorDigi/interface/utils.h>
00007 #include <iomanip>
00008 
00009 void RPCMonitorDigi::bookRollME(RPCDetId & detId, const edm::EventSetup & iSetup, const std::string & recHitType, std::map<std::string, MonitorElement*>  & meMap) {
00010   //std::map<std::string, MonitorElement*> RPCMonitorDigi::bookRollME(RPCDetId & detId, const edm::EventSetup & iSetup, std::string recHitType) {
00011   //std::map<std::string, MonitorElement*> meMap;  
00012 
00013   RPCBookFolderStructure *  folderStr = new RPCBookFolderStructure();
00014   std::string folder = subsystemFolder_+ "/"+ recHitType +"/"+folderStr->folderStructure(detId);
00015 
00016   dbe->setCurrentFolder(folder);
00017   
00018   //get number of strips in current roll
00019   int nstrips = this->stripsInRoll(detId, iSetup);
00020   if (nstrips == 0 ) nstrips = 1;
00021 
00023   RPCGeomServ RPCname(detId);
00024   std::string nameRoll = "";
00025  
00026   if (RPCMonitorDigi::useRollInfo_) {
00027     nameRoll = RPCname.name();
00028   }else{
00029     nameRoll = RPCname.chambername();
00030   }
00031 
00032     if(detId.region() != 0 || //Endcaps
00033        (abs(detId.ring()) == 2 && detId.station()== 2 && detId.layer() != 1) ||  //Wheel -/+2 RB2out
00034        (abs(detId.ring()) != 2 && detId.station()== 2 && detId.layer() == 1)){nstrips *= 3;} //Wheel -1,0,+1 RB2in
00035     else {
00036       nstrips *= 2;
00037     }
00038 
00039 
00040   std::stringstream os;
00041   os.str("");
00042   os<<"Occupancy_"<<nameRoll;
00043   meMap[os.str()] = dbe->book1D(os.str(), os.str(), nstrips, 0.5, nstrips+0.5);
00044   dbe->tag( meMap[os.str()],  rpcdqm::OCCUPANCY);
00045 
00046   os.str("");
00047   os<<"BXDistribution_"<<nameRoll;
00048   meMap[os.str()] = dbe->book1D(os.str(), os.str(), 7, -3.5, 3.5);
00049    
00050 
00051   if(detId.region() == 0){
00052     os.str("");
00053     os<<"ClusterSize_"<<nameRoll;
00054     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 15, 0.5, 15.5);
00055     dbe->tag( meMap[os.str()],  rpcdqm::CLUSTERSIZE);
00056     
00057     os.str("");
00058     os<<"Multiplicity_"<<nameRoll;
00059     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 30, 0.5, 30.5);
00060     dbe->tag( meMap[os.str()],  rpcdqm::MULTIPLICITY);
00061 
00062   }else{
00063     os.str("");
00064     os<<"ClusterSize_"<<nameRoll;
00065     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 10, 0.5, 10.5);
00066     dbe->tag( meMap[os.str()],  rpcdqm::CLUSTERSIZE);
00067     
00068     os.str("");
00069     os<<"Multiplicity_"<<nameRoll;
00070     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 15, 0.5, 15.5);
00071     dbe->tag( meMap[os.str()],  rpcdqm::MULTIPLICITY);
00072   }
00073 
00074 
00075 //   os.str("");
00076 //   os<<"BXWithData_"<<nameRoll;
00077 //   meMap[os.str()] = dbe->book1D(os.str(), os.str(), 10, 0.5, 10.5);
00078   
00079   os.str("");
00080   os<<"NumberOfClusters_"<<nameRoll;
00081   meMap[os.str()] = dbe->book1D(os.str(), os.str(),10,0.5,10.5);
00082   
00083 
00084   delete folderStr;
00085   //  return meMap;
00086 }
00087 
00088 
00089 void RPCMonitorDigi::bookSectorRingME(const std::string &recHitType, std::map<std::string, MonitorElement*> & meMap) {  
00090   //std::map<std::string, MonitorElement*> RPCMonitorDigi::bookSectorRingME(std::string recHitType) {  
00091 
00092   //  std::map<std::string, MonitorElement*> meMap;  
00093   std::stringstream os;
00094  
00095   for(int wheel = -2 ; wheel <= 2; wheel++){
00096       os.str("");     
00097       os<< subsystemFolder_<< "/"<<recHitType<<"/Barrel/Wheel_"<<wheel<<"/SummaryBySectors";
00098       dbe->setCurrentFolder(os.str());
00099       
00100       for (int sector = 1 ; sector <= 12 ; sector++){
00101         
00102         os.str("");
00103         os<<"Occupancy_Wheel_"<<wheel<<"_Sector_"<<sector;
00104     
00105         if (sector==9 || sector==11)
00106           meMap[os.str()] = dbe->book2D(os.str(), os.str(),  90, 0.5,  90.5, 15, 0.5, 15.5);
00107         else  if (sector==4) 
00108           meMap[os.str()] = dbe->book2D(os.str(), os.str(),  90, 0.5,  90.5, 21, 0.5, 21.5);
00109         else
00110           meMap[os.str()] = dbe->book2D(os.str(), os.str(),  90, 0.5,  90.5, 17, 0.5, 17.5);
00111         
00112         meMap[os.str()]->setAxisTitle("strip", 1);
00113         rpcdqm::utils rpcUtils;
00114         rpcUtils.labelYAxisRoll( meMap[os.str()], 0, wheel, true);
00115         
00116 //      os.str("");
00117 //      os<<"BxDistribution_Wheel_"<<wheel<<"_Sector_"<<sector;
00118 //      meMap[os.str()] = dbe->book1D(os.str(), os.str(), 11, -5.5, 5.5);
00119 
00120       }
00121   }
00122 
00123 
00124   for (int region = -1 ; region <= 1; region++){
00125     if( region == 0 ) continue;
00126 
00127     std::string regionName = "Endcap-";
00128     if(region == 1) regionName = "Endcap+";
00129 
00130     for (int disk = 1; disk <=  RPCMonitorDigi::numberOfDisks_; disk++) {
00131       os.str("");
00132       os<< subsystemFolder_<< "/"<<recHitType<<"/"<<regionName<<"/Disk_"<<(region * disk)<<"/SummaryByRings/";
00133      
00134       dbe->setCurrentFolder(os.str());
00135 
00136       for (int ring = RPCMonitorDigi::numberOfInnerRings_  ; ring <= 3; ring ++) {
00137 
00138         os.str("");
00139         os<<"Occupancy_Disk_"<<(region * disk)<<"_Ring_"<<ring<<"_CH01-CH18";
00140 
00141         meMap[os.str()] = dbe->book2D(os.str(), os.str(), 96, 0.5, 96.5, 18 , 0.5,  18.5);
00142         meMap[os.str()]->setAxisTitle("strip", 1);
00143 
00144         std::stringstream yLabel;
00145         for (int i = 1 ; i<=18; i++) {
00146           yLabel.str("");
00147           yLabel<<"R"<<ring<<"_CH"<<std::setw(2)<<std::setfill('0')<<i;
00148           meMap[os.str()]->setBinLabel(i, yLabel.str(), 2);
00149         }
00150       
00151       
00152         for(int i = 1; i <= 96 ; i++) {
00153           if (i ==1) meMap[os.str()]->setBinLabel(i, "1", 1);
00154           else if (i==16) meMap[os.str()]->setBinLabel(i, "RollA", 1);
00155           else if (i==32) meMap[os.str()]->setBinLabel(i, "32", 1);
00156           else if (i==33) meMap[os.str()]->setBinLabel(i, "1", 1);
00157           else if (i==48) meMap[os.str()]->setBinLabel(i, "RollB", 1);
00158           else if (i==64) meMap[os.str()]->setBinLabel(i, "32", 1);
00159           else if (i==65) meMap[os.str()]->setBinLabel(i, "1", 1);
00160           else if (i==80) meMap[os.str()]->setBinLabel(i, "RollC", 1);
00161           else if (i==96) meMap[os.str()]->setBinLabel(i, "32", 1);
00162           else  meMap[os.str()]->setBinLabel(i, "", 1);
00163         }
00164   
00165 
00166         os.str("");
00167         os<<"Occupancy_Disk_"<<(region * disk)<<"_Ring_"<<ring<<"_CH19-CH36";
00168 
00169         meMap[os.str()] = dbe->book2D(os.str(), os.str(), 96, 0.5, 96.5, 18 , 18.5,  36.5);
00170         meMap[os.str()]->setAxisTitle("strip", 1);
00171         
00172         for (int i = 1 ; i<= 18; i++) {
00173           yLabel.str("");
00174           yLabel<<"R"<<ring<<"_CH"<<i+18;
00175           meMap[os.str()]->setBinLabel(i, yLabel.str(), 2);
00176         }
00177         
00178         
00179         for(int i = 1; i <= 96 ; i++) {
00180           if (i ==1) meMap[os.str()]->setBinLabel(i, "1", 1);
00181           else if (i==16) meMap[os.str()]->setBinLabel(i, "RollA", 1);
00182           else if (i==32) meMap[os.str()]->setBinLabel(i, "32", 1);
00183           else if (i==33) meMap[os.str()]->setBinLabel(i, "1", 1);
00184           else if (i==48) meMap[os.str()]->setBinLabel(i, "RollB", 1);
00185           else if (i==64) meMap[os.str()]->setBinLabel(i, "32", 1);
00186           else if (i==65) meMap[os.str()]->setBinLabel(i, "1", 1);
00187           else if (i==80) meMap[os.str()]->setBinLabel(i, "RollC", 1);
00188           else if (i==96) meMap[os.str()]->setBinLabel(i, "32", 1);
00189           else  meMap[os.str()]->setBinLabel(i, "", 1);
00190         }
00191    
00192         
00193 //      os.str("");
00194 //      os<<"BxDistribution_Disk_"<<(region * disk)<<"_Ring_"<<ring;
00195 //      meMap[os.str()] = dbe->book1D(os.str(), os.str(), 11, -5.5, 5.5);
00196         
00197       }  //loop ring
00198     } //loop disk
00199   } //loop region
00200 
00201   // return meMap;
00202 } 
00203 
00204 
00205 void RPCMonitorDigi::bookWheelDiskME(const std::string &recHitType, std::map<std::string, MonitorElement*> &meMap) {  
00206   //std::map<std::string, MonitorElement*> RPCMonitorDigi::bookWheelDiskME(std::string recHitType) {  
00207 
00208   //  std::map<std::string, MonitorElement*> meMap;  
00209   dbe->setCurrentFolder(subsystemFolder_ +"/"+recHitType+"/"+ globalFolder_);
00210 
00211   std::stringstream os, label, name, title ;
00212   rpcdqm::utils rpcUtils;
00213 
00214   for (int wheel = -2 ; wheel<= 2; wheel++ ) {//Loop on wheel
00215 
00216     //    os<<"OccupancyXY_"<<ringType<<"_"<<ring;
00217     //    meMap[os.str()] = dbe->book2D(os.str(), os.str(),63, -800, 800, 63, -800, 800);
00218     //    meMap[os.str()] = dbe->book2D(os.str(), os.str(),1000, -800, 800, 1000, -800, 800);
00219     
00220     
00221     os.str("");
00222     os<<"1DOccupancy_Wheel_"<<wheel;
00223     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 12, 0.5, 12.5);
00224     for(int i=1; i<12; i++) {
00225       label.str("");
00226       label<<"Sec"<<i;
00227       meMap[os.str()] ->setBinLabel(i, label.str(), 1); 
00228     }
00229     
00230     os.str("");
00231     os<<"Occupancy_Roll_vs_Sector_Wheel_"<<wheel;                                   
00232     meMap[os.str()] = dbe->book2D(os.str(), os.str(), 12, 0.5,12.5, 21, 0.5, 21.5);
00233     rpcUtils.labelXAxisSector(meMap[os.str()]);
00234     rpcUtils.labelYAxisRoll( meMap[os.str()], 0, wheel, true);
00235 
00236     os.str("");
00237     os<<"BxDistribution_Wheel_"<<wheel;
00238     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 9, -4.5, 4.5);
00239     
00240 
00241     for(int layer = 1 ; layer <= 6 ; layer ++){
00242       name.str("");
00243       title.str("");
00244       name<<"ClusterSize_Wheel_"<<wheel<<"_Layer"<< layer;
00245       title<< "ClusterSize - Wheel "<<wheel<<" Layer"<<layer;
00246       meMap[name.str()] = dbe->book1D(name.str(), title.str(),  16, 0.5, 16.5);
00247     }
00248 
00249 
00250     
00251   }//end loop on wheel 
00252 
00253 
00254   for (int disk = - RPCMonitorDigi::numberOfDisks_; disk <=  RPCMonitorDigi::numberOfDisks_; disk++){
00255     
00256     if(disk == 0) continue;
00257   
00258 
00259     os.str("");
00260     os<<"Occupancy_Ring_vs_Segment_Disk_"<<disk;                                  
00261     meMap[os.str()] = dbe->book2D(os.str(), os.str(), 36, 0.5,36.5, 6, 0.5, 6.5);
00262     
00263     rpcUtils.labelXAxisSegment(meMap[os.str()]);
00264     rpcUtils.labelYAxisRing(meMap[os.str()], 2, true);
00265 
00266     os.str("");
00267     os<<"BxDistribution_Disk_"<<disk;
00268     meMap[os.str()] = dbe->book1D(os.str(), os.str(), 9, -4.5, 4.5);
00269 
00270 
00271     for(int ring = RPCMonitorDigi::numberOfInnerRings_  ; ring <= 3 ; ring ++){
00272     
00273       name.str("");
00274       title.str("");
00275       name<<"ClusterSize_Disk_"<<disk<<"_Ring"<< ring;
00276       title<< "ClusterSize - Disk"<<disk<<" Ring"<<ring;
00277       meMap[name.str()] = dbe->book1D(name.str(), title.str(),  16, 0.5, 16.5);
00278       
00279     }
00280     
00281   }
00282 
00283    for(int ring = RPCMonitorDigi::numberOfInnerRings_  ; ring <= 3 ; ring ++){
00284      os.str("");
00285      os<<"1DOccupancy_Ring_"<<ring;
00286      meMap[os.str()] = dbe->book1D(os.str(), os.str(), 6 , 0.5, 6.5);
00287      for(int xbin= 1 ; xbin<= 6 ; xbin++) {
00288        label.str("");
00289        if (xbin < 4) label<<"Disk "<< (xbin - 4);
00290        else label<<"Disk "<< (xbin - 3);
00291        meMap[os.str()] ->setBinLabel(xbin, label.str(), 1); 
00292      }
00293    }
00294 
00295 
00296 
00297       
00298   //  return meMap; 
00299 }
00300 
00301 
00302 
00303 //returns the number of strips in each roll
00304 int  RPCMonitorDigi::stripsInRoll(RPCDetId & id, const edm::EventSetup & iSetup) {
00305   edm::ESHandle<RPCGeometry> rpcgeo;
00306   iSetup.get<MuonGeometryRecord>().get(rpcgeo);
00307 
00308   const RPCRoll * rpcRoll = rpcgeo->roll(id);
00309 
00310   if (!rpcRoll) return 1;
00311 
00312   return  rpcRoll->nstrips();
00313 
00314   
00315 
00316 }
00317 
00318 
00319 void RPCMonitorDigi::bookRegionME(const std::string & recHitType, std::map<std::string, MonitorElement*>  & meMap) {
00320   //std::map<std::string, MonitorElement*>   RPCMonitorDigi::bookRegionME(std::string recHitType) {
00321 
00322   //  std::map<std::string, MonitorElement*> meMap;  
00323 
00324   std::string currentFolder = subsystemFolder_ +"/"+recHitType+"/"+ globalFolder_;
00325   dbe->setCurrentFolder(currentFolder);  
00326   
00327   MonitorElement * me = NULL;
00328   std::stringstream name;
00329   std::stringstream title;
00330   for(int r = 0; r < 3; r++){ //RPC regions are E-, B, and E+
00331     
00332     std::string regionName = RPCMonitorDigi::regionNames_[r];
00333     //Cluster size
00334     name.str("");
00335     title.str("");
00336     name<<"ClusterSize_"<< regionName;
00337     title<< "ClusterSize - "<<regionName;
00338     me = dbe->get(currentFolder+ "/" + name.str());
00339     if (me) dbe->removeElement(me->getName());
00340      meMap[name.str()] = dbe->book1D(name.str(), title.str(),  16, 0.5, 16.5);
00341     
00342  
00343   }
00344  
00345 
00346   //Number of Cluster
00347   name.str("");
00348   title.str("");
00349   name<<"NumberOfClusters_Barrel";
00350   title<< "Number of Clusters per Event - Barrel";
00351   me = dbe->get(currentFolder+ "/" + name.str());
00352   if (me) dbe->removeElement(me->getName());
00353   meMap[name.str()]  = dbe->book1D(name.str(), title.str(),  30, 0.5, 30.5);
00354 
00355   name.str("");
00356   title.str("");
00357   name<<"NumberOfClusters_Endcap+";
00358   title<< "Number of Clusters per Event - Endcap+";
00359   me = dbe->get(currentFolder+ "/" + name.str());
00360   if (me) dbe->removeElement(me->getName());
00361   meMap[name.str()]  = dbe->book1D(name.str(), title.str(),  15, 0.5, 15.5);
00362  
00363   name.str("");
00364   title.str("");
00365   name<<"NumberOfClusters_Endcap-";
00366   title<< "Number of Clusters per Event - Endcap-";
00367   me = dbe->get(currentFolder+ "/" + name.str());
00368   if (me) dbe->removeElement(me->getName());
00369   meMap[name.str()]  = dbe->book1D(name.str(), title.str(),  15, 0.5, 15.5);
00370 
00371   //Number of Digis
00372   name.str("");
00373   title.str("");
00374   name<<"Multiplicity_Barrel";
00375   title<< "Multiplicity per Event per Roll - Barrel";
00376   me = dbe->get(currentFolder+ "/" + name.str());
00377   if (me) dbe->removeElement(me->getName());
00378   meMap[name.str()] = dbe->book1D(name.str(), title.str(), 50, 0.5, 50.5);   
00379   
00380   
00381   name.str("");
00382   title.str("");
00383   name<<"Multiplicity_Endcap+";
00384   title<< "Multiplicity per Event per Roll - Endcap+";
00385   me = dbe->get(currentFolder+ "/" + name.str());
00386   if (me) dbe->removeElement(me->getName());
00387   meMap[name.str()] = dbe->book1D(name.str(), title.str(), 32, 0.5, 32.5);  
00388   
00389   name.str("");
00390   title.str("");
00391   name<<"Multiplicity_Endcap-";
00392   title<< "Multiplicity per Event per Roll - Endcap-";
00393   me = dbe->get(currentFolder+ "/" + name.str());
00394   if (me) dbe->removeElement(me->getName());
00395   meMap[name.str()] = dbe->book1D(name.str(), title.str(), 32, 0.5, 32.5);  
00396 
00397   
00398   for(int layer = 1 ; layer <= 6 ; layer ++){
00399     
00400     name.str("");
00401     title.str("");
00402     name<<"ClusterSize_Layer"<< layer;
00403     title<< "ClusterSize - Layer"<<layer;
00404     me = dbe->get(currentFolder+ "/" + name.str());
00405     if (me) dbe->removeElement(me->getName());
00406     meMap[name.str()] = dbe->book1D(name.str(), title.str(),  16, 0.5, 16.5);
00407   }
00408 
00409   for(int ring = RPCMonitorDigi::numberOfInnerRings_  ; ring <= 3 ; ring ++){
00410     
00411     name.str("");
00412     title.str("");
00413     name<<"ClusterSize_Ring"<< ring;
00414     title<< "ClusterSize - Ring"<<ring;
00415     me = dbe->get(currentFolder+ "/" + name.str());
00416     if (me) dbe->removeElement(me->getName());
00417     meMap[name.str()] = dbe->book1D(name.str(), title.str(),  16, 0.5, 16.5);
00418   
00419   }
00420 
00421 
00422   me = dbe->get(currentFolder+ "/Occupancy_for_Endcap");
00423   if (me) dbe->removeElement(me->getName());
00424   meMap["Occupancy_for_Endcap"] = dbe -> book2D("Occupancy_for_Endcap", "Occupancy Endcap", 6, 0.5, 6.5, 2, 1.5, 3.5);
00425   meMap["Occupancy_for_Endcap"] ->setAxisTitle("Disk", 1);
00426   meMap["Occupancy_for_Endcap"] ->setAxisTitle("Ring", 2);
00427 
00428   std::stringstream binlabel;
00429   for (int bin = 1 ; bin <= 6 ; bin++){
00430     binlabel.str("");
00431     if(bin<4) {//negative endcap
00432       binlabel<<(bin-4); 
00433     }else{//positive endcaps
00434       binlabel<<(bin-3); 
00435     }
00436     meMap["Occupancy_for_Endcap"]->setBinLabel( bin , binlabel.str(), 1);
00437   }
00438 
00439   meMap["Occupancy_for_Endcap"]->setBinLabel( 1 , "2", 2);
00440   meMap["Occupancy_for_Endcap"]->setBinLabel( 2 , "3", 2);
00441 
00442 
00443   me = dbe->get(currentFolder+ "/Occupancy_for_Barrel");
00444   if (me) dbe->removeElement(me->getName());
00445   meMap["Occupancy_for_Barrel"]  = dbe -> book2D("Occupancy_for_Barrel", "Occupancy Barrel", 12, 0.5 , 12.5, 5, -2.5, 2.5 );
00446   meMap["Occupancy_for_Barrel"] ->setAxisTitle("Sec", 1);
00447   meMap["Occupancy_for_Barrel"] ->setAxisTitle("Wheel", 2);
00448   
00449   for (int bin = 1 ; bin <= 12 ; bin++){
00450     binlabel.str("");
00451     binlabel<<bin;
00452     meMap["Occupancy_for_Barrel"]->setBinLabel( bin , binlabel.str(), 1);
00453     if(bin <= 5 ){
00454       binlabel.str("");
00455       binlabel<< (bin - 3);
00456      meMap["Occupancy_for_Barrel"]->setBinLabel( bin , binlabel.str(), 2);
00457     }
00458   }
00459   //  return meMap; 
00460 
00461 }