00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "DQM/SiPixelMonitorCluster/interface/SiPixelClusterSource.h"
00022
00023 #include "FWCore/ServiceRegistry/interface/Service.h"
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025
00026 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028
00029 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00030 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00031 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00032 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00033
00034 #include "DataFormats/DetId/interface/DetId.h"
00035 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00036 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00037 #include "DataFormats/SiPixelDetId/interface/PixelBarrelNameUpgrade.h"
00038 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00039 #include "DataFormats/SiPixelDetId/interface/PixelEndcapNameUpgrade.h"
00040
00041 #include <string>
00042 #include <stdlib.h>
00043
00044 using namespace std;
00045 using namespace edm;
00046
00047 SiPixelClusterSource::SiPixelClusterSource(const edm::ParameterSet& iConfig) :
00048 conf_(iConfig),
00049 src_( conf_.getParameter<edm::InputTag>( "src" ) ),
00050 saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
00051 isPIB( conf_.getUntrackedParameter<bool>("isPIB",false) ),
00052 slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
00053 modOn( conf_.getUntrackedParameter<bool>("modOn",true) ),
00054 twoDimOn( conf_.getUntrackedParameter<bool>("twoDimOn",true) ),
00055 reducedSet( conf_.getUntrackedParameter<bool>("reducedSet",false) ),
00056 ladOn( conf_.getUntrackedParameter<bool>("ladOn",false) ),
00057 layOn( conf_.getUntrackedParameter<bool>("layOn",false) ),
00058 phiOn( conf_.getUntrackedParameter<bool>("phiOn",false) ),
00059 ringOn( conf_.getUntrackedParameter<bool>("ringOn",false) ),
00060 bladeOn( conf_.getUntrackedParameter<bool>("bladeOn",false) ),
00061 diskOn( conf_.getUntrackedParameter<bool>("diskOn",false) ),
00062 smileyOn(conf_.getUntrackedParameter<bool>("smileyOn",false) ),
00063 bigEventSize( conf_.getUntrackedParameter<int>("bigEventSize",100) ),
00064 isUpgrade( conf_.getUntrackedParameter<bool>("isUpgrade",false) )
00065 {
00066 theDMBE = edm::Service<DQMStore>().operator->();
00067 LogInfo ("PixelDQM") << "SiPixelClusterSource::SiPixelClusterSource: Got DQM BackEnd interface"<<endl;
00068 }
00069
00070
00071 SiPixelClusterSource::~SiPixelClusterSource()
00072 {
00073
00074
00075 LogInfo ("PixelDQM") << "SiPixelClusterSource::~SiPixelClusterSource: Destructor"<<endl;
00076
00077 std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
00078 for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++){
00079 delete struct_iter->second;
00080 struct_iter->second = 0;
00081 }
00082 }
00083
00084
00085 void SiPixelClusterSource::beginJob(){
00086 firstRun = true;
00087 }
00088
00089 void SiPixelClusterSource::beginRun(const edm::Run& r, const edm::EventSetup& iSetup){
00090
00091 LogInfo ("PixelDQM") << " SiPixelClusterSource::beginJob - Initialisation ... " << std::endl;
00092 LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/"
00093 << layOn << "/" << phiOn << std::endl;
00094 LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/"
00095 << ringOn << std::endl;
00096 LogInfo ("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
00097 LogInfo ("PixelDQM") << "Smiley (Cluster sizeY vs. Cluster eta) is " << smileyOn << "\n";
00098
00099 if(firstRun){
00100 eventNo = 0;
00101 lumSec = 0;
00102 nLumiSecs = 0;
00103 nBigEvents = 0;
00104
00105 buildStructure(iSetup);
00106
00107 bookMEs();
00108
00109 theDMBE->setCurrentFolder("Pixel/Clusters/OffTrack");
00110
00111 meClPosLayer1 = theDMBE->book2D("position_siPixelClusters_Layer_1","Clusters Layer1;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
00112 meClPosLayer2 = theDMBE->book2D("position_siPixelClusters_Layer_2","Clusters Layer2;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
00113 meClPosLayer3 = theDMBE->book2D("position_siPixelClusters_Layer_3","Clusters Layer3;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
00114 if (isUpgrade) {
00115 meClPosLayer4 = theDMBE->book2D("position_siPixelClusters_Layer_4","Clusters Layer4;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
00116 }
00117
00118 meClPosDisk1pz = theDMBE->book2D("position_siPixelClusters_pz_Disk_1","Clusters +Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
00119 meClPosDisk2pz = theDMBE->book2D("position_siPixelClusters_pz_Disk_2","Clusters +Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
00120 meClPosDisk1mz = theDMBE->book2D("position_siPixelClusters_mz_Disk_1","Clusters -Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
00121 meClPosDisk2mz = theDMBE->book2D("position_siPixelClusters_mz_Disk_2","Clusters -Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
00122 if (isUpgrade) {
00123 meClPosDisk3pz = theDMBE->book2D("position_siPixelClusters_pz_Disk_3","Clusters +Z Disk3;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
00124 meClPosDisk3mz = theDMBE->book2D("position_siPixelClusters_mz_Disk_3","Clusters -Z Disk3;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
00125 }
00126
00127 firstRun = false;
00128 }
00129 }
00130
00131
00132 void SiPixelClusterSource::endJob(void){
00133 if(saveFile){
00134 LogInfo ("PixelDQM") << " SiPixelClusterSource::endJob - Saving Root File " << std::endl;
00135 std::string outputFile = conf_.getParameter<std::string>("outputFile");
00136 theDMBE->save( outputFile.c_str() );
00137 }
00138 }
00139
00140
00141
00142
00143 void SiPixelClusterSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00144 {
00145 eventNo++;
00146
00147 if(modOn && !isUpgrade){
00148 MonitorElement* meReset = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_1");
00149 MonitorElement* meReset1 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_2");
00150 MonitorElement* meReset2 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_3");
00151 MonitorElement* meReset3 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_1");
00152 MonitorElement* meReset4 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_2");
00153 MonitorElement* meReset5 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_1");
00154 MonitorElement* meReset6 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_2");
00155 if(meReset && meReset->getEntries()>150000){
00156 meReset->Reset();
00157 meReset1->Reset();
00158 meReset2->Reset();
00159 meReset3->Reset();
00160 meReset4->Reset();
00161 meReset5->Reset();
00162 meReset6->Reset();
00163 }
00164 }else if(modOn && isUpgrade){
00165 MonitorElement* meReset = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_1");
00166 MonitorElement* meReset1 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_2");
00167 MonitorElement* meReset2 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_3");
00168 MonitorElement* meReset3 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_4");
00169 MonitorElement* meReset4 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_1");
00170 MonitorElement* meReset5 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_2");
00171 MonitorElement* meReset6 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_3");
00172 MonitorElement* meReset7 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_1");
00173 MonitorElement* meReset8 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_2");
00174 MonitorElement* meReset9 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_3");
00175 if(meReset && meReset->getEntries()>150000){
00176 meReset->Reset();
00177 meReset1->Reset();
00178 meReset2->Reset();
00179 meReset3->Reset();
00180 meReset4->Reset();
00181 meReset5->Reset();
00182 meReset6->Reset();
00183 meReset7->Reset();
00184 meReset8->Reset();
00185 meReset9->Reset();
00186 }
00187 }
00188
00189
00190 edm::Handle< edmNew::DetSetVector<SiPixelCluster> > input;
00191 iEvent.getByLabel( src_, input );
00192
00193 edm::ESHandle<TrackerGeometry> pDD;
00194 iSetup.get<TrackerDigiGeometryRecord> ().get (pDD);
00195 const TrackerGeometry* tracker = &(* pDD);
00196
00197
00198
00199
00200
00201 int lumiSection = (int)iEvent.luminosityBlock();
00202 int nEventFpixClusters = 0;
00203
00204
00205 std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
00206 for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++) {
00207
00208 int numberOfFpixClusters = (*struct_iter).second->fill(*input, tracker, modOn,
00209 ladOn, layOn, phiOn,
00210 bladeOn, diskOn, ringOn,
00211 twoDimOn, reducedSet, smileyOn, isUpgrade);
00212 nEventFpixClusters = nEventFpixClusters + numberOfFpixClusters;
00213
00214 }
00215
00216
00217
00218
00219
00220 if(nEventFpixClusters>bigEventSize){
00221 MonitorElement* me = theDMBE->get("Pixel/bigFpixClusterEventRate");
00222 if(me){
00223 me->Fill(lumiSection,1./23.);
00224 }
00225 }
00226
00227
00228
00229 if(slowDown) usleep(10000);
00230
00231 }
00232
00233
00234
00235
00236 void SiPixelClusterSource::buildStructure(const edm::EventSetup& iSetup){
00237
00238 LogInfo ("PixelDQM") <<" SiPixelClusterSource::buildStructure" ;
00239 edm::ESHandle<TrackerGeometry> pDD;
00240 iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
00241
00242 LogVerbatim ("PixelDQM") << " *** Geometry node for TrackerGeom is "<<&(*pDD)<<std::endl;
00243 LogVerbatim ("PixelDQM") << " *** I have " << pDD->dets().size() <<" detectors"<<std::endl;
00244 LogVerbatim ("PixelDQM") << " *** I have " << pDD->detTypes().size() <<" types"<<std::endl;
00245
00246 for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
00247
00248 if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
00249
00250 DetId detId = (*it)->geographicalId();
00251 const GeomDetUnit * geoUnit = pDD->idToDetUnit( detId );
00252 const PixelGeomDetUnit * pixDet = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
00253 int nrows = (pixDet->specificTopology()).nrows();
00254 int ncols = (pixDet->specificTopology()).ncolumns();
00255
00256
00257 if((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
00258 (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))){
00259 uint32_t id = detId();
00260 SiPixelClusterModule* theModule = new SiPixelClusterModule(id, ncols, nrows);
00261 if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
00262 if(isPIB) continue;
00263 LogDebug ("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
00264 thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
00265 }else if ( (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade) ) {
00266 LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
00267 PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(id)).halfCylinder();
00268 int disk = PixelEndcapName(DetId(id)).diskName();
00269 int blade = PixelEndcapName(DetId(id)).bladeName();
00270 int panel = PixelEndcapName(DetId(id)).pannelName();
00271 int module = PixelEndcapName(DetId(id)).plaquetteName();
00272 char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
00273 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00274 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00275 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00276 char smodule[80];sprintf(smodule,"Module_%i",module);
00277 std::string side_str = sside;
00278 std::string disk_str = sdisk;
00279 bool mask = side_str.find("HalfCylinder_1")!=string::npos||
00280 side_str.find("HalfCylinder_2")!=string::npos||
00281 side_str.find("HalfCylinder_4")!=string::npos||
00282 disk_str.find("Disk_2")!=string::npos;
00283
00284 mask = false;
00285 if(isPIB && mask) continue;
00286 thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
00287 } else if ( (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade) ) {
00288 LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
00289 PixelEndcapNameUpgrade::HalfCylinder side = PixelEndcapNameUpgrade(DetId(id)).halfCylinder();
00290 int disk = PixelEndcapNameUpgrade(DetId(id)).diskName();
00291 int blade = PixelEndcapNameUpgrade(DetId(id)).bladeName();
00292 int panel = PixelEndcapNameUpgrade(DetId(id)).pannelName();
00293 int module = PixelEndcapNameUpgrade(DetId(id)).plaquetteName();
00294 char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
00295 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00296 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00297 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00298 char smodule[80];sprintf(smodule,"Module_%i",module);
00299 std::string side_str = sside;
00300 std::string disk_str = sdisk;
00301 bool mask = side_str.find("HalfCylinder_1")!=string::npos||
00302 side_str.find("HalfCylinder_2")!=string::npos||
00303 side_str.find("HalfCylinder_4")!=string::npos||
00304 disk_str.find("Disk_2")!=string::npos;
00305
00306 mask = false;
00307 if(isPIB && mask) continue;
00308 thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
00309 }
00310 }
00311 }
00312 }
00313 LogInfo ("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
00314 }
00315
00316
00317
00318 void SiPixelClusterSource::bookMEs(){
00319
00320
00321 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00322 theDMBE->setCurrentFolder("Pixel");
00323 char title[256]; snprintf(title, 256, "Rate of events with >%i FPIX clusters;LumiSection;Rate of large FPIX events per LS [Hz]",bigEventSize);
00324 bigFpixClusterEventRate = theDMBE->book1D("bigFpixClusterEventRate",title,5000,0.,5000.);
00325
00326
00327 std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
00328
00329 SiPixelFolderOrganizer theSiPixelFolder;
00330
00331 for(struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++){
00332
00334 if(modOn){
00335 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,0,isUpgrade)){
00336 (*struct_iter).second->book( conf_,0,twoDimOn,reducedSet,isUpgrade);
00337 } else {
00338
00339 if(!isPIB) throw cms::Exception("LogicError")
00340 << "[SiPixelClusterSource::bookMEs] Creation of DQM folder failed";
00341 }
00342 }
00343 if(ladOn){
00344 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,1,isUpgrade)){
00345 (*struct_iter).second->book( conf_,1,twoDimOn,reducedSet,isUpgrade);
00346 } else {
00347 LogDebug ("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
00348 }
00349 }
00350 if(layOn){
00351 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,2,isUpgrade)){
00352 (*struct_iter).second->book( conf_,2,twoDimOn,reducedSet,isUpgrade);
00353 } else {
00354 LogDebug ("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
00355 }
00356 }
00357 if(phiOn){
00358 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,3,isUpgrade)){
00359 (*struct_iter).second->book( conf_,3,twoDimOn,reducedSet,isUpgrade);
00360 } else {
00361 LogDebug ("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
00362 }
00363 }
00364 if(bladeOn){
00365 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,4,isUpgrade)){
00366 (*struct_iter).second->book( conf_,4,twoDimOn,reducedSet,isUpgrade);
00367 } else {
00368 LogDebug ("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
00369 }
00370 }
00371 if(diskOn){
00372 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,5,isUpgrade)){
00373 (*struct_iter).second->book( conf_,5,twoDimOn,reducedSet,isUpgrade);
00374 } else {
00375 LogDebug ("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
00376 }
00377 }
00378 if(ringOn){
00379 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,6,isUpgrade)){
00380 (*struct_iter).second->book( conf_,6,twoDimOn,reducedSet,isUpgrade);
00381 } else {
00382 LogDebug ("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
00383 }
00384 }
00385 if(smileyOn){
00386 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,7,isUpgrade)){
00387 (*struct_iter).second->book( conf_,7,twoDimOn,reducedSet,isUpgrade);
00388 } else {
00389 LogDebug ("PixelDQM") << "PROBLEM WITH BARREL-FOLDER\n";
00390 }
00391 }
00392
00393 }
00394
00395 }
00396
00397
00398 DEFINE_FWK_MODULE(SiPixelClusterSource);