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/PixelEndcapName.h"
00038
00039 #include <string>
00040 #include <stdlib.h>
00041
00042 using namespace std;
00043 using namespace edm;
00044
00045 SiPixelClusterSource::SiPixelClusterSource(const edm::ParameterSet& iConfig) :
00046 conf_(iConfig),
00047 src_( conf_.getParameter<edm::InputTag>( "src" ) ),
00048 saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
00049 isPIB( conf_.getUntrackedParameter<bool>("isPIB",false) ),
00050 slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
00051 modOn( conf_.getUntrackedParameter<bool>("modOn",true) ),
00052 twoDimOn( conf_.getUntrackedParameter<bool>("twoDimOn",true) ),
00053 reducedSet( conf_.getUntrackedParameter<bool>("reducedSet",false) ),
00054 ladOn( conf_.getUntrackedParameter<bool>("ladOn",false) ),
00055 layOn( conf_.getUntrackedParameter<bool>("layOn",false) ),
00056 phiOn( conf_.getUntrackedParameter<bool>("phiOn",false) ),
00057 ringOn( conf_.getUntrackedParameter<bool>("ringOn",false) ),
00058 bladeOn( conf_.getUntrackedParameter<bool>("bladeOn",false) ),
00059 diskOn( conf_.getUntrackedParameter<bool>("diskOn",false) )
00060 {
00061 theDMBE = edm::Service<DQMStore>().operator->();
00062 LogInfo ("PixelDQM") << "SiPixelClusterSource::SiPixelClusterSource: Got DQM BackEnd interface"<<endl;
00063 }
00064
00065
00066 SiPixelClusterSource::~SiPixelClusterSource()
00067 {
00068
00069
00070 LogInfo ("PixelDQM") << "SiPixelClusterSource::~SiPixelClusterSource: Destructor"<<endl;
00071 }
00072
00073
00074 void SiPixelClusterSource::beginJob(const edm::EventSetup& iSetup){
00075
00076 LogInfo ("PixelDQM") << " SiPixelClusterSource::beginJob - Initialisation ... " << std::endl;
00077 LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/"
00078 << layOn << "/" << phiOn << std::endl;
00079 LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/"
00080 << ringOn << std::endl;
00081 LogInfo ("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
00082
00083 eventNo = 0;
00084
00085 buildStructure(iSetup);
00086
00087 bookMEs();
00088
00089 }
00090
00091
00092 void SiPixelClusterSource::endJob(void){
00093 if(saveFile){
00094 LogInfo ("PixelDQM") << " SiPixelClusterSource::endJob - Saving Root File " << std::endl;
00095 std::string outputFile = conf_.getParameter<std::string>("outputFile");
00096 theDMBE->save( outputFile.c_str() );
00097 }
00098 }
00099
00100
00101
00102
00103 void
00104 SiPixelClusterSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00105 {
00106 eventNo++;
00107
00108
00109 edm::Handle< edmNew::DetSetVector<SiPixelCluster> > input;
00110 iEvent.getByLabel( src_, input );
00111
00112 std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
00113 for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++) {
00114
00115 (*struct_iter).second->fill(*input, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn, twoDimOn, reducedSet);
00116
00117 }
00118
00119
00120 if(slowDown) usleep(10000);
00121
00122 }
00123
00124
00125
00126
00127 void SiPixelClusterSource::buildStructure(const edm::EventSetup& iSetup){
00128
00129 LogInfo ("PixelDQM") <<" SiPixelClusterSource::buildStructure" ;
00130 edm::ESHandle<TrackerGeometry> pDD;
00131 iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
00132
00133 LogVerbatim ("PixelDQM") << " *** Geometry node for TrackerGeom is "<<&(*pDD)<<std::endl;
00134 LogVerbatim ("PixelDQM") << " *** I have " << pDD->dets().size() <<" detectors"<<std::endl;
00135 LogVerbatim ("PixelDQM") << " *** I have " << pDD->detTypes().size() <<" types"<<std::endl;
00136
00137 for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
00138
00139 if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
00140
00141 DetId detId = (*it)->geographicalId();
00142 const GeomDetUnit * geoUnit = pDD->idToDetUnit( detId );
00143 const PixelGeomDetUnit * pixDet = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
00144 int nrows = (pixDet->specificTopology()).nrows();
00145 int ncols = (pixDet->specificTopology()).ncolumns();
00146
00147 if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
00148 if(isPIB) continue;
00149 LogDebug ("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
00150 uint32_t id = detId();
00151 SiPixelClusterModule* theModule = new SiPixelClusterModule(id, ncols, nrows);
00152 thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
00153
00154 } else if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
00155 LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
00156 uint32_t id = detId();
00157 SiPixelClusterModule* theModule = new SiPixelClusterModule(id, ncols, nrows);
00158
00159 PixelEndcapName::HalfCylinder side = PixelEndcapName::PixelEndcapName(DetId::DetId(id)).halfCylinder();
00160 int disk = PixelEndcapName::PixelEndcapName(DetId::DetId(id)).diskName();
00161 int blade = PixelEndcapName::PixelEndcapName(DetId::DetId(id)).bladeName();
00162 int panel = PixelEndcapName::PixelEndcapName(DetId::DetId(id)).pannelName();
00163 int module = PixelEndcapName::PixelEndcapName(DetId::DetId(id)).plaquetteName();
00164
00165 char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
00166 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00167 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00168 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00169 char smodule[80];sprintf(smodule,"Module_%i",module);
00170 std::string side_str = sside;
00171 std::string disk_str = sdisk;
00172 bool mask = side_str.find("HalfCylinder_1")!=string::npos||
00173 side_str.find("HalfCylinder_2")!=string::npos||
00174 side_str.find("HalfCylinder_4")!=string::npos||
00175 disk_str.find("Disk_2")!=string::npos;
00176
00177 mask = false;
00178 if(isPIB && mask) continue;
00179
00180 thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
00181 }
00182
00183 }
00184 }
00185 LogInfo ("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
00186 }
00187
00188
00189
00190 void SiPixelClusterSource::bookMEs(){
00191
00192 std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
00193 theDMBE->setVerbose(0);
00194
00195 SiPixelFolderOrganizer theSiPixelFolder;
00196
00197 for(struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++){
00198
00200 if(modOn){
00201 if(theSiPixelFolder.setModuleFolder((*struct_iter).first)){
00202 (*struct_iter).second->book( conf_,0,twoDimOn,reducedSet);
00203 } else {
00204
00205 if(!isPIB) throw cms::Exception("LogicError")
00206 << "[SiPixelClusterSource::bookMEs] Creation of DQM folder failed";
00207 }
00208 }
00209 if(ladOn){
00210 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,1)){
00211 (*struct_iter).second->book( conf_,1,twoDimOn,reducedSet);
00212 } else {
00213 LogDebug ("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
00214 }
00215 }
00216 if(layOn){
00217 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,2)){
00218 (*struct_iter).second->book( conf_,2,twoDimOn,reducedSet);
00219 } else {
00220 LogDebug ("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
00221 }
00222 }
00223 if(phiOn){
00224 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,3)){
00225 (*struct_iter).second->book( conf_,3,twoDimOn,reducedSet);
00226 } else {
00227 LogDebug ("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
00228 }
00229 }
00230 if(bladeOn){
00231 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,4)){
00232 (*struct_iter).second->book( conf_,4,twoDimOn,reducedSet);
00233 } else {
00234 LogDebug ("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
00235 }
00236 }
00237 if(diskOn){
00238 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,5)){
00239 (*struct_iter).second->book( conf_,5,twoDimOn,reducedSet);
00240 } else {
00241 LogDebug ("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
00242 }
00243 }
00244 if(ringOn){
00245 if(theSiPixelFolder.setModuleFolder((*struct_iter).first,6)){
00246 (*struct_iter).second->book( conf_,6,twoDimOn,reducedSet);
00247 } else {
00248 LogDebug ("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
00249 }
00250 }
00251 }
00252
00253 }
00254
00255
00256 DEFINE_FWK_MODULE(SiPixelClusterSource);