00001
00002
00003
00006
00007
00008
00009 #include <vector>
00010 #include <numeric>
00011 #include <fstream>
00012 #include <math.h>
00013 #include "TNamed.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016
00017 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00018 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00019 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
00020 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00021 #include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
00022 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00023 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
00024 #include "DataFormats/Common/interface/DetSetVector.h"
00025 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00026 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00027 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00028 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
00029 #include "DQM/SiStripMonitorCluster/interface/SiStripMonitorCluster.h"
00030 #include "DQMServices/Core/interface/DQMStore.h"
00031 #include "DQMServices/Core/interface/MonitorElement.h"
00032 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00033 #include "DataFormats/SiStripDetId/interface/SiStripSubStructure.h"
00034 #include "CalibTracker/SiStripCommon/interface/SiStripDCSStatus.h"
00035 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00036
00037 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
00038 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
00039
00040 #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
00041
00042 #include "TMath.h"
00043 #include <iostream>
00044
00045
00046 SiStripMonitorCluster::SiStripMonitorCluster(const edm::ParameterSet& iConfig)
00047 : dqmStore_(edm::Service<DQMStore>().operator->()), conf_(iConfig), show_mechanical_structure_view(true), show_readout_view(false), show_control_view(false), select_all_detectors(false), reset_each_run(false), m_cacheID_(0)
00048
00049 {
00050
00051
00052 passBPTXfilter_ = true;
00053
00054
00055
00056 genTriggerEventFlagBPTXfilter_ = new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("BPTXfilter") );
00057 genTriggerEventFlagPixelDCSfilter_ = new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("PixelDCSfilter") );
00058 genTriggerEventFlagStripDCSfilter_ = new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("StripDCSfilter") );
00059
00060 firstEvent = -1;
00061 eventNb = 0;
00062
00063
00064 SubDetPhasePartMap["TIB"] = "TI";
00065 SubDetPhasePartMap["TID__side__1"] = "TI";
00066 SubDetPhasePartMap["TID__side__2"] = "TI";
00067 SubDetPhasePartMap["TOB"] = "TO";
00068 SubDetPhasePartMap["TEC__side__1"] = "TM";
00069 SubDetPhasePartMap["TEC__side__2"] = "TP";
00070
00071
00072 edm::ParameterSet ParametersnClusters = conf_.getParameter<edm::ParameterSet>("TH1nClusters");
00073 layerswitchncluson = ParametersnClusters.getParameter<bool>("layerswitchon");
00074 moduleswitchncluson = ParametersnClusters.getParameter<bool>("moduleswitchon");
00075
00076 edm::ParameterSet ParametersClusterCharge = conf_.getParameter<edm::ParameterSet>("TH1ClusterCharge");
00077 layerswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("layerswitchon");
00078 moduleswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("moduleswitchon");
00079
00080 edm::ParameterSet ParametersClusterStoN = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoN");
00081 layerswitchclusstonon = ParametersClusterStoN.getParameter<bool>("layerswitchon");
00082 moduleswitchclusstonon = ParametersClusterStoN.getParameter<bool>("moduleswitchon");
00083
00084 edm::ParameterSet ParametersClusterStoNVsPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
00085 layerswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("layerswitchon");
00086 moduleswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("moduleswitchon");
00087
00088 edm::ParameterSet ParametersClusterPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterPos");
00089 layerswitchclusposon = ParametersClusterPos.getParameter<bool>("layerswitchon");
00090 moduleswitchclusposon = ParametersClusterPos.getParameter<bool>("moduleswitchon");
00091
00092 edm::ParameterSet ParametersClusterDigiPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterDigiPos");
00093 layerswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("layerswitchon");
00094 moduleswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("moduleswitchon");
00095
00096 edm::ParameterSet ParametersClusterNoise = conf_.getParameter<edm::ParameterSet>("TH1ClusterNoise");
00097 layerswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("layerswitchon");
00098 moduleswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("moduleswitchon");
00099
00100 edm::ParameterSet ParametersClusterWidth = conf_.getParameter<edm::ParameterSet>("TH1ClusterWidth");
00101 layerswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("layerswitchon");
00102 moduleswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("moduleswitchon");
00103
00104 edm::ParameterSet ParametersModuleLocalOccupancy = conf_.getParameter<edm::ParameterSet>("TH1ModuleLocalOccupancy");
00105 layerswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("layerswitchon");
00106 moduleswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("moduleswitchon");
00107
00108 edm::ParameterSet ParametersNrOfClusterizedStrips = conf_.getParameter<edm::ParameterSet>("TH1NrOfClusterizedStrips");
00109 layerswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("layerswitchon");
00110 moduleswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("moduleswitchon");
00111
00112 edm::ParameterSet ParametersClusterProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfCluster");
00113 layerswitchnumclusterprofon = ParametersClusterProf.getParameter<bool>("layerswitchon");
00114
00115 edm::ParameterSet ParametersClusterWidthProf = conf_.getParameter<edm::ParameterSet>("TProfClusterWidth");
00116 layerswitchclusterwidthprofon = ParametersClusterWidthProf.getParameter<bool>("layerswitchon");
00117
00118 edm::ParameterSet ParametersTotClusterProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
00119 subdetswitchtotclusprofon = ParametersTotClusterProf.getParameter<bool>("subdetswitchon");
00120
00121 edm::ParameterSet ParametersTotClusterTH1 = conf_.getParameter<edm::ParameterSet>("TH1TotalNumberOfClusters");
00122 subdetswitchtotclusth1on = ParametersTotClusterTH1.getParameter<bool>("subdetswitchon");
00123
00124 edm::ParameterSet ParametersClusterApvProf = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
00125 subdetswitchapvcycleprofon = ParametersClusterApvProf.getParameter<bool>("subdetswitchon");
00126
00127 edm::ParameterSet ParametersClustersApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
00128 subdetswitchapvcycleth2on = ParametersClustersApvTH2.getParameter<bool>("subdetswitchon");
00129
00130 edm::ParameterSet ParametersApvCycleDBxProf2 = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
00131 subdetswitchapvcycledbxprof2on = ParametersApvCycleDBxProf2.getParameter<bool>("subdetswitchon");
00132
00133 edm::ParameterSet ParametersDBxCycleProf = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
00134 subdetswitchdbxcycleprofon = ParametersDBxCycleProf.getParameter<bool>("subdetswitchon");
00135
00136 edm::ParameterSet ParametersCStripVsCPix = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
00137 globalswitchcstripvscpix = ParametersCStripVsCPix.getParameter<bool>("globalswitchon");
00138
00139 edm::ParameterSet ParametersMultiplicityRegionsTH1 = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
00140 globalswitchMultiRegions = ParametersMultiplicityRegionsTH1.getParameter<bool>("globalswitchon");
00141
00142 edm::ParameterSet ParametersApvCycleVsDBxGlobalTH2 = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
00143 globalswitchapvcycledbxth2on = ParametersApvCycleVsDBxGlobalTH2.getParameter<bool>("globalswitchon");
00144
00145 edm::ParameterSet ParametersNoiseStrip2ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
00146 globalswitchstripnoise2apvcycle = ParametersNoiseStrip2ApvCycle.getParameter<bool>("globalswitchon");
00147
00148 edm::ParameterSet ParametersNoiseStrip3ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
00149 globalswitchstripnoise3apvcycle = ParametersNoiseStrip3ApvCycle.getParameter<bool>("globalswitchon");
00150
00151 edm::ParameterSet ParametersMainDiagonalPosition = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
00152 globalswitchmaindiagonalposition= ParametersMainDiagonalPosition.getParameter<bool>("globalswitchon");
00153
00154 edm::ParameterSet ClusterMultiplicityRegions = conf_.getParameter<edm::ParameterSet>("MultiplicityRegions");
00155 k0 = ClusterMultiplicityRegions.getParameter<double>("k0");
00156 q0 = ClusterMultiplicityRegions.getParameter<double>("q0");
00157 dk0 = ClusterMultiplicityRegions.getParameter<double>("dk0");
00158 maxClus = ClusterMultiplicityRegions.getParameter<double>("MaxClus");
00159 minPix = ClusterMultiplicityRegions.getParameter<double>("MinPix");
00160
00161 clustertkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
00162 createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
00163 Mod_On_ = conf_.getParameter<bool>("Mod_On");
00164 ClusterHisto_ = conf_.getParameter<bool>("ClusterHisto");
00165
00166 topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
00167
00168
00169
00170 clusterProducerStrip_ = conf_.getParameter<edm::InputTag>("ClusterProducerStrip");
00171 clusterProducerPix_ = conf_.getParameter<edm::InputTag>("ClusterProducerPix");
00172
00173 qualityLabel_ = conf_.getParameter<std::string>("StripQualityLabel");
00174
00175 edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
00176 applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
00177 sToNLowerLimit_ = cluster_condition.getParameter<double>("minStoN");
00178 sToNUpperLimit_ = cluster_condition.getParameter<double>("maxStoN");
00179 widthLowerLimit_ = cluster_condition.getParameter<double>("minWidth");
00180 widthUpperLimit_ = cluster_condition.getParameter<double>("maxWidth");
00181
00182
00183 historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
00184
00185 apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
00186
00187
00188 bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
00189 if (checkDCS) dcsStatus_ = new SiStripDCSStatus();
00190 else dcsStatus_ = 0;
00191
00192 }
00193
00194 SiStripMonitorCluster::~SiStripMonitorCluster() {
00195 if (dcsStatus_) delete dcsStatus_;
00196 if (genTriggerEventFlagBPTXfilter_ ) delete genTriggerEventFlagBPTXfilter_;
00197 if (genTriggerEventFlagPixelDCSfilter_) delete genTriggerEventFlagPixelDCSfilter_;
00198 if (genTriggerEventFlagStripDCSfilter_) delete genTriggerEventFlagStripDCSfilter_;
00199 }
00200
00201
00202 void SiStripMonitorCluster::beginRun(const edm::Run& run, const edm::EventSetup& es){
00203
00204
00205 if ( genTriggerEventFlagBPTXfilter_->on() )
00206 genTriggerEventFlagBPTXfilter_->initRun( run, es );
00207 if ( genTriggerEventFlagPixelDCSfilter_->on() )
00208 genTriggerEventFlagPixelDCSfilter_->initRun( run, es );
00209 if ( genTriggerEventFlagStripDCSfilter_->on() )
00210 genTriggerEventFlagStripDCSfilter_->initRun( run, es );
00211
00212 if (show_mechanical_structure_view) {
00213 unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
00214 if (m_cacheID_ != cacheID) {
00215 m_cacheID_ = cacheID;
00216 edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::beginRun: "
00217 << " Creating MEs for new Cabling ";
00218
00219 createMEs(es);
00220 }
00221 } else if (reset_each_run) {
00222 edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::beginRun: "
00223 << " Resetting MEs ";
00224 for (std::map<uint32_t, ModMEs >::const_iterator idet = ModuleMEsMap.begin() ; idet!=ModuleMEsMap.end() ; idet++) {
00225 ResetModuleMEs(idet->first);
00226 }
00227 }
00228 }
00229
00230
00231 void SiStripMonitorCluster::createMEs(const edm::EventSetup& es){
00232
00233 if ( show_mechanical_structure_view ){
00234
00235
00236 edm::ESHandle<TrackerTopology> tTopoHandle;
00237 es.get<IdealGeometryRecord>().get(tTopoHandle);
00238 const TrackerTopology* const tTopo = tTopoHandle.product();
00239
00240
00241 es.get<SiStripDetCablingRcd>().get(SiStripDetCabling_);
00242
00243
00244 std::vector<uint32_t> activeDets;
00245 SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
00246
00247 SiStripSubStructure substructure;
00248
00249 SiStripFolderOrganizer folder_organizer;
00250 folder_organizer.setSiStripFolderName(topFolderName_);
00251 folder_organizer.setSiStripFolder();
00252
00253
00254
00255 if (clustertkhistomapon) {
00256 if (topFolderName_ == "SiStrip") tkmapcluster = new TkHistoMap("SiStrip/TkHistoMap","TkHMap_NumberOfCluster",0.,1);
00257 else tkmapcluster = new TkHistoMap(topFolderName_+"/TkHistoMap","TkHMap_NumberOfCluster",0.,0);
00258 }
00259
00260
00261 edm::LogInfo("SiStripTkDQM|SiStripMonitorCluster")<<"nr. of activeDets: "<<activeDets.size();
00262 for(std::vector<uint32_t>::iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
00263 uint32_t detid = (*detid_iterator);
00264
00265 if(detid == 0) {
00266 activeDets.erase(detid_iterator);
00267 continue;
00268 }
00269
00270 if (Mod_On_) {
00271 ModMEs mod_single;
00272
00273 folder_organizer.setDetectorFolder(detid, tTopo);
00274 if (reset_each_run) ResetModuleMEs(detid);
00275 createModuleMEs(mod_single, detid);
00276
00277 ModuleMEsMap.insert( std::make_pair(detid, mod_single));
00278 }
00279
00280
00281 std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
00282 SiStripHistoId hidmanager;
00283 std::string label = hidmanager.getSubdetid(detid,tTopo,false);
00284
00285 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
00286 if(iLayerME==LayerMEsMap.end()) {
00287
00288
00289 int32_t lnumber = det_layer_pair.second;
00290 std::vector<uint32_t> layerDetIds;
00291 if (det_layer_pair.first == "TIB") {
00292 substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
00293 } else if (det_layer_pair.first == "TOB") {
00294 substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
00295 } else if (det_layer_pair.first == "TID" && lnumber > 0) {
00296 substructure.getTIDDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0);
00297 } else if (det_layer_pair.first == "TID" && lnumber < 0) {
00298 substructure.getTIDDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0);
00299 } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
00300 substructure.getTECDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0,0,0);
00301 } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
00302 substructure.getTECDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0,0,0);
00303 }
00304 LayerDetMap[label] = layerDetIds;
00305
00306
00307 folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second);
00308 createLayerMEs(label, layerDetIds.size());
00309 }
00310
00311 std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
00312 if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
00313 dqmStore_->setCurrentFolder(sdet_pair.first);
00314 createSubDetMEs(sdet_pair.second);
00315 }
00316 }
00317
00318
00319 if (globalswitchapvcycledbxth2on) {
00320 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00321 edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
00322 std::string HistoName = "DeltaBx_vs_ApvCycle";
00323 GlobalApvCycleDBxTH2 = dqmStore_->book2D(HistoName,HistoName,
00324 GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
00325 GlobalTH2Parameters.getParameter<double>("xmin"),
00326 GlobalTH2Parameters.getParameter<double>("xmax"),
00327 GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
00328 GlobalTH2Parameters.getParameter<double>("ymin"),
00329 GlobalTH2Parameters.getParameter<double>("ymax"));
00330 GlobalApvCycleDBxTH2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
00331 GlobalApvCycleDBxTH2->setAxisTitle("Delta Bunch Crossing Cycle",2);
00332 }
00333
00334 if (globalswitchcstripvscpix) {
00335 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00336 edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
00337 std::string HistoName = "StripClusVsPixClus";
00338 GlobalCStripVsCpix = dqmStore_->book2D(HistoName,HistoName,
00339 GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
00340 GlobalTH2Parameters.getParameter<double>("xmin"),
00341 GlobalTH2Parameters.getParameter<double>("xmax"),
00342 GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
00343 GlobalTH2Parameters.getParameter<double>("ymin"),
00344 GlobalTH2Parameters.getParameter<double>("ymax"));
00345 GlobalCStripVsCpix->setAxisTitle("Strip Clusters",1);
00346 GlobalCStripVsCpix->setAxisTitle("Pix Clusters",2);
00347 }
00348
00349 if (globalswitchMultiRegions){
00350 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00351 edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
00352 std::string HistoName = "ClusterMultiplicityRegions";
00353 PixVsStripMultiplicityRegions = dqmStore_->book1D(HistoName,HistoName,
00354 GlobalTH2Parameters.getParameter<int32_t>("Nbinx"),
00355 GlobalTH2Parameters.getParameter<double>("xmin"),
00356 GlobalTH2Parameters.getParameter<double>("xmax"));
00357 PixVsStripMultiplicityRegions->setAxisTitle("");
00358 PixVsStripMultiplicityRegions->setBinLabel(1,"Main Diagonal");
00359 PixVsStripMultiplicityRegions->setBinLabel(2,"Strip Noise");
00360 PixVsStripMultiplicityRegions->setBinLabel(3,"High Strip Noise");
00361 PixVsStripMultiplicityRegions->setBinLabel(4,"Beam Background");
00362 PixVsStripMultiplicityRegions->setBinLabel(5,"No Strip Clusters");
00363 }
00364
00365 if (globalswitchmaindiagonalposition){
00366 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00367 edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
00368 std::string HistoName = "MainDiagonal Position";
00369 GlobalMainDiagonalPosition = dqmStore_->book1D(HistoName,HistoName,
00370 GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
00371 GlobalTH1Parameters.getParameter<double>("xmin"),
00372 GlobalTH1Parameters.getParameter<double>("xmax"));
00373 GlobalMainDiagonalPosition->setAxisTitle("atan(NPix/(k*NStrip))");
00374 }
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 if (globalswitchstripnoise2apvcycle){
00389 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00390 edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
00391 std::string HistoName = "StripNoise_ApvCycle";
00392 StripNoise2Cycle = dqmStore_->book1D(HistoName,HistoName,
00393 GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
00394 GlobalTH1Parameters.getParameter<double>("xmin"),
00395 GlobalTH1Parameters.getParameter<double>("xmax"));
00396 StripNoise2Cycle->setAxisTitle("APV Cycle");
00397 }
00398
00399 if (globalswitchstripnoise3apvcycle){
00400 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00401 edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
00402 std::string HistoName = "HighStripNoise_ApvCycle";
00403 StripNoise3Cycle = dqmStore_->book1D(HistoName,HistoName,
00404 GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
00405 GlobalTH1Parameters.getParameter<double>("xmin"),
00406 GlobalTH1Parameters.getParameter<double>("xmax"));
00407 StripNoise3Cycle->setAxisTitle("APV Cycle");
00408 }
00409
00410 if (ClusterHisto_){
00411 dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00412 edm::ParameterSet PixelCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusPx");
00413 std::string HistoName = "NumberOfClustersInPixel";
00414 NumberOfPixelClus = dqmStore_->book1D(HistoName, HistoName,
00415 PixelCluster.getParameter<int32_t>("Nbinsx"),
00416 PixelCluster.getParameter<double>("xmin"),
00417 PixelCluster.getParameter<double>("xmax"));
00418 NumberOfPixelClus->setAxisTitle("# of Clusters in Pixel", 1);
00419 NumberOfPixelClus->setAxisTitle("Number of Events", 2);
00420
00421 edm::ParameterSet StripCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusStrip");
00422 HistoName = "NumberOfClustersInStrip";
00423 NumberOfStripClus = dqmStore_->book1D(HistoName, HistoName,
00424 StripCluster.getParameter<int32_t>("Nbinsx"),
00425 StripCluster.getParameter<double>("xmin"),
00426 StripCluster.getParameter<double>("xmax"));
00427 NumberOfStripClus->setAxisTitle("# of Clusters in Strip", 1);
00428 NumberOfStripClus->setAxisTitle("Number of Events", 2);
00429 }
00430
00431
00432 }
00433 }
00434
00435
00436 void SiStripMonitorCluster::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00437 {
00438
00439 edm::ESHandle<TrackerTopology> tTopoHandle;
00440 iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00441 const TrackerTopology* const tTopo = tTopoHandle.product();
00442
00443
00444 passBPTXfilter_ = ( iEvent.isRealData() and genTriggerEventFlagBPTXfilter_->on() ) ? genTriggerEventFlagBPTXfilter_->accept( iEvent, iSetup) : true;
00445 passPixelDCSfilter_ = ( iEvent.isRealData() and genTriggerEventFlagPixelDCSfilter_->on() ) ? genTriggerEventFlagPixelDCSfilter_->accept( iEvent, iSetup) : true;
00446 passStripDCSfilter_ = ( iEvent.isRealData() and genTriggerEventFlagStripDCSfilter_->on() ) ? genTriggerEventFlagStripDCSfilter_->accept( iEvent, iSetup) : true;
00447
00448
00449
00450 if (dcsStatus_ && !dcsStatus_->getStatus(iEvent,iSetup)) return;
00451
00452 runNb = iEvent.id().run();
00453 eventNb++;
00454 float iOrbitSec = iEvent.orbitNumber()/11223.0;
00455
00456 int NPixClusters=0, NStripClusters=0, MultiplicityRegion=0;
00457 bool isPixValid=false;
00458
00459 edm::ESHandle<SiStripNoises> noiseHandle;
00460 iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
00461
00462 edm::ESHandle<SiStripGain> gainHandle;
00463 iSetup.get<SiStripGainRcd>().get(gainHandle);
00464
00465 edm::ESHandle<SiStripQuality> qualityHandle;
00466 iSetup.get<SiStripQualityRcd>().get(qualityLabel_,qualityHandle);
00467
00468 iSetup.get<SiStripDetCablingRcd>().get(SiStripDetCabling_);
00469
00470
00471 edm::Handle< edmNew::DetSetVector<SiStripCluster> > cluster_detsetvektor;
00472 iEvent.getByLabel(clusterProducerStrip_, cluster_detsetvektor);
00473
00474
00475 edm::Handle< edmNew::DetSetVector<SiPixelCluster> > cluster_detsetvektor_pix;
00476 iEvent.getByLabel(clusterProducerPix_, cluster_detsetvektor_pix);
00477
00478 if (!cluster_detsetvektor.isValid()) return;
00479
00480 const edmNew::DetSetVector<SiStripCluster> * StrC= cluster_detsetvektor.product();
00481 NStripClusters= StrC->data().size();
00482
00483 if (cluster_detsetvektor_pix.isValid()){
00484 const edmNew::DetSetVector<SiPixelCluster> * PixC= cluster_detsetvektor_pix.product();
00485 NPixClusters= PixC->data().size();
00486 isPixValid=true;
00487 MultiplicityRegion=FindRegion(NStripClusters,NPixClusters);
00488
00489 if ( passBPTXfilter_ and passPixelDCSfilter_ and passStripDCSfilter_ ) {
00490 if (globalswitchcstripvscpix) GlobalCStripVsCpix->Fill(NStripClusters,NPixClusters);
00491 if (globalswitchmaindiagonalposition && NStripClusters > 0) GlobalMainDiagonalPosition->Fill(atan(NPixClusters/(k0*NStripClusters)));
00492 if (globalswitchMultiRegions) PixVsStripMultiplicityRegions->Fill(MultiplicityRegion);
00493 }
00494
00495 if (ClusterHisto_){
00496 if ( passBPTXfilter_ and passPixelDCSfilter_ )
00497 NumberOfPixelClus->Fill(NPixClusters);
00498 if ( passBPTXfilter_ and passStripDCSfilter_ )
00499 NumberOfStripClus->Fill(NStripClusters);
00500 }
00501 }
00502
00503 for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin();
00504 iSubdet != SubDetMEsMap.end(); iSubdet++) {
00505 iSubdet->second.totNClusters = 0;
00506 }
00507
00508 SiStripFolderOrganizer folder_organizer;
00509 bool found_layer_me = false;
00510 for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
00511 iterLayer != LayerDetMap.end(); iterLayer++) {
00512
00513 std::string layer_label = iterLayer->first;
00514
00515 int ncluster_layer = 0;
00516 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
00517
00518
00519 LayerMEs layer_single;
00520 if(iLayerME != LayerMEsMap.end()) {
00521 layer_single = iLayerME->second;
00522 found_layer_me = true;
00523 }
00524
00525 bool found_module_me = false;
00526 uint16_t iDet = 0;
00527 std::string subdet_label = "";
00528
00529 for (std::vector< uint32_t >::const_iterator iterDets = iterLayer->second.begin() ;
00530 iterDets != iterLayer->second.end() ; iterDets++) {
00531 iDet++;
00532
00533 uint32_t detid = (*iterDets);
00534
00535
00536 if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid, tTopo).second;
00537
00538
00539 ModMEs mod_single;
00540 if (Mod_On_) {
00541 std::map<uint32_t, ModMEs >::iterator imodME = ModuleMEsMap.find(detid);
00542 if (imodME != ModuleMEsMap.end()) {
00543 mod_single = imodME->second;
00544 found_module_me = true;
00545 }
00546 } else found_module_me = false;
00547
00548 edmNew::DetSetVector<SiStripCluster>::const_iterator isearch = cluster_detsetvektor->find(detid);
00549
00550 if(isearch==cluster_detsetvektor->end()){
00551 if(found_module_me && moduleswitchncluson && (mod_single.NumberOfClusters)){
00552 (mod_single.NumberOfClusters)->Fill(0.);
00553 }
00554 if(clustertkhistomapon) tkmapcluster->fill(detid,0.);
00555 if (found_layer_me && layerswitchnumclusterprofon) layer_single.LayerNumberOfClusterProfile->Fill(iDet, 0.0);
00556 continue;
00557 }
00558
00559
00560 edmNew::DetSet<SiStripCluster> cluster_detset = (*cluster_detsetvektor)[detid];
00561
00562
00563 if(clustertkhistomapon) {
00564 tkmapcluster->fill(detid,static_cast<float>(cluster_detset.size()));
00565 }
00566
00567 if(moduleswitchncluson && found_module_me && (mod_single.NumberOfClusters != NULL)){
00568 (mod_single.NumberOfClusters)->Fill(static_cast<float>(cluster_detset.size()));
00569 }
00570
00571 if (found_layer_me && layerswitchnumclusterprofon)
00572 layer_single.LayerNumberOfClusterProfile->Fill(iDet, static_cast<float>(cluster_detset.size()));
00573 ncluster_layer += cluster_detset.size();
00574
00575 short total_clusterized_strips = 0;
00576
00577 SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detid);
00578 SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
00579 SiStripQuality::Range qualityRange = qualityHandle->getRange(detid);
00580
00581 for(edmNew::DetSet<SiStripCluster>::const_iterator clusterIter = cluster_detset.begin(); clusterIter!= cluster_detset.end(); clusterIter++){
00582
00583 const std::vector<uint8_t>& ampls = clusterIter->amplitudes();
00584
00585 float cluster_position = clusterIter->barycenter();
00586
00587 short cluster_start = clusterIter->firstStrip();
00588
00589 short cluster_width = ampls.size();
00590
00591 total_clusterized_strips = total_clusterized_strips + cluster_width;
00592
00593
00594 float cluster_signal = 0.0;
00595 float cluster_noise = 0.0;
00596 int nrnonzeroamplitudes = 0;
00597 float noise2 = 0.0;
00598 float noise = 0.0;
00599 for(uint iamp=0; iamp<ampls.size(); iamp++){
00600 if(ampls[iamp]>0){
00601 cluster_signal += ampls[iamp];
00602 if(!qualityHandle->IsStripBad(qualityRange, clusterIter->firstStrip()+iamp)){
00603 noise = noiseHandle->getNoise(clusterIter->firstStrip()+iamp,detNoiseRange)/gainHandle->getStripGain(clusterIter->firstStrip()+iamp, detGainRange);
00604 }
00605 noise2 += noise*noise;
00606 nrnonzeroamplitudes++;
00607 }
00608 }
00609
00610 if (nrnonzeroamplitudes > 0) cluster_noise = sqrt(noise2/nrnonzeroamplitudes);
00611
00612 if( applyClusterQuality_ &&
00613 (cluster_signal/cluster_noise < sToNLowerLimit_ ||
00614 cluster_signal/cluster_noise > sToNUpperLimit_ ||
00615 cluster_width < widthLowerLimit_ ||
00616 cluster_width > widthUpperLimit_) ) continue;
00617
00618 ClusterProperties cluster_properties;
00619 cluster_properties.charge = cluster_signal;
00620 cluster_properties.position = cluster_position;
00621 cluster_properties.start = cluster_start;
00622 cluster_properties.width = cluster_width;
00623 cluster_properties.noise = cluster_noise;
00624
00625
00626 if (found_module_me) fillModuleMEs(mod_single, cluster_properties);
00627
00628
00629 if (found_layer_me) {
00630 fillLayerMEs(layer_single, cluster_properties, iOrbitSec);
00631 if (layerswitchclusterwidthprofon)
00632 layer_single.LayerClusterWidthProfile->Fill(iDet, cluster_width);
00633 }
00634 }
00635
00636 short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00637 float local_occupancy = static_cast<float>(total_clusterized_strips)/static_cast<float>(total_nr_strips);
00638 if (found_module_me) {
00639 if(moduleswitchnrclusterizedstrip && mod_single.NrOfClusterizedStrips ){
00640 mod_single.NrOfClusterizedStrips->Fill(static_cast<float>(total_clusterized_strips));
00641 }
00642
00643 if(moduleswitchlocaloccupancy && mod_single.ModuleLocalOccupancy ){
00644 mod_single.ModuleLocalOccupancy->Fill(local_occupancy);
00645 }
00646 }
00647 if (layerswitchlocaloccupancy && found_layer_me && layer_single.LayerLocalOccupancy) {
00648 fillME(layer_single.LayerLocalOccupancy,local_occupancy);
00649 if (createTrendMEs) fillME(layer_single.LayerLocalOccupancyTrend,iOrbitSec,local_occupancy);
00650 }
00651 }
00652 std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
00653 if(iSubdet != SubDetMEsMap.end()) iSubdet->second.totNClusters += ncluster_layer;
00654 }
00655
00656
00657 edm::Handle<EventWithHistory> event_history;
00658 iEvent.getByLabel(historyProducer_,event_history);
00659
00660
00661 edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
00662 iEvent.getByLabel(apvPhaseProducer_,apv_phase_collection);
00663
00664 if (event_history.isValid()
00665 && !event_history.failedToGet()
00666 && apv_phase_collection.isValid()
00667 && !apv_phase_collection.failedToGet()) {
00668
00669
00670 long long dbx = event_history->deltaBX();
00671 long long tbx = event_history->absoluteBX();
00672
00673 bool global_histo_filled = false;
00674 bool MultiplicityRegion_Vs_APVcycle_filled=false;
00675
00676 for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
00677 it != SubDetMEsMap.end(); it++) {
00678 std::string sdet = it->first;
00679
00680 SubDetMEs sdetmes = it->second;
00681
00682 int the_phase = APVCyclePhaseCollection::invalid;
00683 long long tbx_corr = tbx;
00684
00685 if (SubDetPhasePartMap.find(sdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[sdet]);
00686 if(the_phase==APVCyclePhaseCollection::nopartition ||
00687 the_phase==APVCyclePhaseCollection::multiphase ||
00688 the_phase==APVCyclePhaseCollection::invalid) {
00689 the_phase=30;
00690
00691 }
00692 tbx_corr -= the_phase;
00693 long long dbxincycle = event_history->deltaBXinCycle(the_phase);
00694 if (globalswitchapvcycledbxth2on && !global_histo_filled) {
00695 GlobalApvCycleDBxTH2->Fill(tbx_corr%70,dbx);
00696 global_histo_filled = true;
00697 }
00698
00699 if (isPixValid && !MultiplicityRegion_Vs_APVcycle_filled){
00700 if (globalswitchstripnoise2apvcycle && MultiplicityRegion==2) {StripNoise2Cycle->Fill(tbx_corr%70);}
00701 if (globalswitchstripnoise3apvcycle && MultiplicityRegion==3) {StripNoise3Cycle->Fill(tbx_corr%70);}
00702 MultiplicityRegion_Vs_APVcycle_filled=true;
00703 }
00704
00705 if (subdetswitchtotclusth1on)
00706 sdetmes.SubDetTotClusterTH1->Fill(sdetmes.totNClusters);
00707 if (subdetswitchtotclusprofon)
00708 sdetmes.SubDetTotClusterProf->Fill(iOrbitSec,sdetmes.totNClusters);
00709 if (subdetswitchapvcycleprofon)
00710 sdetmes.SubDetClusterApvProf->Fill(tbx_corr%70,sdetmes.totNClusters);
00711 if (subdetswitchapvcycleth2on)
00712 sdetmes.SubDetClusterApvTH2->Fill(tbx_corr%70,sdetmes.totNClusters);
00713 if (subdetswitchdbxcycleprofon)
00714 sdetmes.SubDetClusterDBxCycleProf->Fill(dbxincycle,sdetmes.totNClusters);
00715 if (subdetswitchapvcycledbxprof2on)
00716 sdetmes.SubDetApvDBxProf2->Fill(tbx_corr%70,dbx,sdetmes.totNClusters);
00717 }
00718 }
00719 }
00720
00721
00722
00723 void SiStripMonitorCluster::endJob(void){
00724 bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00725 std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00726
00727
00728 if(outputMEsInRootFile) dqmStore_->save(outputFileName);
00729 }
00730
00731
00732
00733 void SiStripMonitorCluster::ResetModuleMEs(uint32_t idet){
00734 std::map<uint32_t, ModMEs >::iterator pos = ModuleMEsMap.find(idet);
00735 ModMEs mod_me = pos->second;
00736
00737 if (moduleswitchncluson) mod_me.NumberOfClusters->Reset();
00738 if (moduleswitchclusposon) mod_me.ClusterPosition->Reset();
00739 if (moduleswitchclusdigiposon) mod_me.ClusterDigiPosition->Reset();
00740 if (moduleswitchclusstonVsposon) mod_me.ClusterSignalOverNoiseVsPos->Reset();
00741 if (moduleswitchcluswidthon) mod_me.ClusterWidth->Reset();
00742 if (moduleswitchcluschargeon) mod_me.ClusterCharge->Reset();
00743 if (moduleswitchclusnoiseon) mod_me.ClusterNoise->Reset();
00744 if (moduleswitchclusstonon) mod_me.ClusterSignalOverNoise->Reset();
00745 if (moduleswitchlocaloccupancy) mod_me.ModuleLocalOccupancy->Reset();
00746 if (moduleswitchnrclusterizedstrip) mod_me.NrOfClusterizedStrips->Reset();
00747 }
00748
00749
00750
00751 void SiStripMonitorCluster::createModuleMEs(ModMEs& mod_single, uint32_t detid) {
00752
00753
00754 SiStripHistoId hidmanager;
00755 std::string hid;
00756
00757
00758 if(moduleswitchncluson) {
00759 hid = hidmanager.createHistoId("NumberOfClusters","det",detid);
00760 mod_single.NumberOfClusters = bookME1D("TH1nClusters", hid.c_str());
00761 dqmStore_->tag(mod_single.NumberOfClusters, detid);
00762 mod_single.NumberOfClusters->setAxisTitle("number of clusters in one detector module");
00763 mod_single.NumberOfClusters->getTH1()->StatOverflows(kTRUE);
00764 }
00765
00766
00767 if(moduleswitchclusposon) {
00768 short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00769 hid = hidmanager.createHistoId("ClusterPosition","det",detid);
00770 mod_single.ClusterPosition = dqmStore_->book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
00771 dqmStore_->tag(mod_single.ClusterPosition, detid);
00772 mod_single.ClusterPosition->setAxisTitle("cluster position [strip number +0.5]");
00773 }
00774
00775
00776 if(moduleswitchclusdigiposon) {
00777 short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00778 hid = hidmanager.createHistoId("ClusterDigiPosition","det",detid);
00779 mod_single.ClusterDigiPosition = dqmStore_->book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
00780 dqmStore_->tag(mod_single.ClusterDigiPosition, detid);
00781 mod_single.ClusterDigiPosition->setAxisTitle("digi in cluster position [strip number +0.5]");
00782 }
00783
00784
00785 if(moduleswitchcluswidthon) {
00786 hid = hidmanager.createHistoId("ClusterWidth","det",detid);
00787 mod_single.ClusterWidth = bookME1D("TH1ClusterWidth", hid.c_str());
00788 dqmStore_->tag(mod_single.ClusterWidth, detid);
00789 mod_single.ClusterWidth->setAxisTitle("cluster width [nr strips]");
00790 }
00791
00792
00793 if(moduleswitchcluschargeon) {
00794 hid = hidmanager.createHistoId("ClusterCharge","det",detid);
00795 mod_single.ClusterCharge = bookME1D("TH1ClusterCharge", hid.c_str());
00796 dqmStore_->tag(mod_single.ClusterCharge, detid);
00797 mod_single.ClusterCharge->setAxisTitle("cluster charge [ADC]");
00798 }
00799
00800
00801 if(moduleswitchclusnoiseon) {
00802 hid = hidmanager.createHistoId("ClusterNoise","det",detid);
00803 mod_single.ClusterNoise = bookME1D("TH1ClusterNoise", hid.c_str());
00804 dqmStore_->tag(mod_single.ClusterNoise, detid);
00805 mod_single.ClusterNoise->setAxisTitle("cluster noise");
00806 }
00807
00808
00809 if(moduleswitchclusstonon) {
00810 hid = hidmanager.createHistoId("ClusterSignalOverNoise","det",detid);
00811 mod_single.ClusterSignalOverNoise = bookME1D("TH1ClusterStoN", hid.c_str());
00812 dqmStore_->tag(mod_single.ClusterSignalOverNoise, detid);
00813 mod_single.ClusterSignalOverNoise->setAxisTitle("ratio of signal to noise for each cluster");
00814 }
00815
00816
00817 if(moduleswitchclusstonVsposon) {
00818 hid = hidmanager.createHistoId("ClusterSignalOverNoiseVsPos","det",detid);
00819 Parameters = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
00820 mod_single.ClusterSignalOverNoiseVsPos= dqmStore_->bookProfile(hid.c_str(),hid.c_str(),
00821 Parameters.getParameter<int32_t>("Nbinx"),
00822 Parameters.getParameter<double>("xmin"),
00823 Parameters.getParameter<double>("xmax"),
00824 Parameters.getParameter<int32_t>("Nbiny"),
00825 Parameters.getParameter<double>("ymin"),
00826 Parameters.getParameter<double>("ymax")
00827 );
00828 dqmStore_->tag(mod_single.ClusterSignalOverNoiseVsPos, detid);
00829 mod_single.ClusterSignalOverNoiseVsPos->setAxisTitle("pos");
00830 }
00831
00832
00833 if (moduleswitchlocaloccupancy) {
00834 hid = hidmanager.createHistoId("ClusterLocalOccupancy","det",detid);
00835 mod_single.ModuleLocalOccupancy = bookME1D("TH1ModuleLocalOccupancy", hid.c_str());
00836 dqmStore_->tag(mod_single.ModuleLocalOccupancy, detid);
00837 mod_single.ModuleLocalOccupancy->setAxisTitle("module local occupancy [% of clusterized strips]");
00838 }
00839
00840
00841 if (moduleswitchnrclusterizedstrip) {
00842 hid = hidmanager.createHistoId("NrOfClusterizedStrips","det",detid);
00843 mod_single.NrOfClusterizedStrips = bookME1D("TH1NrOfClusterizedStrips", hid.c_str());
00844 dqmStore_->tag(mod_single.NrOfClusterizedStrips, detid);
00845 mod_single.NrOfClusterizedStrips->setAxisTitle("number of clusterized strips");
00846 }
00847 }
00848
00849
00850
00851 void SiStripMonitorCluster::createLayerMEs(std::string label, int ndets) {
00852
00853 SiStripHistoId hidmanager;
00854
00855 LayerMEs layerMEs;
00856 layerMEs.LayerClusterStoN = 0;
00857 layerMEs.LayerClusterStoNTrend = 0;
00858 layerMEs.LayerClusterCharge = 0;
00859 layerMEs.LayerClusterChargeTrend = 0;
00860 layerMEs.LayerClusterNoise = 0;
00861 layerMEs.LayerClusterNoiseTrend = 0;
00862 layerMEs.LayerClusterWidth = 0;
00863 layerMEs.LayerClusterWidthTrend = 0;
00864 layerMEs.LayerLocalOccupancy = 0;
00865 layerMEs.LayerLocalOccupancyTrend = 0;
00866 layerMEs.LayerNumberOfClusterProfile = 0;
00867 layerMEs.LayerClusterWidthProfile = 0;
00868
00869
00870 if(layerswitchcluswidthon) {
00871 layerMEs.LayerClusterWidth=bookME1D("TH1ClusterWidth", hidmanager.createHistoLayer("Summary_ClusterWidth","layer",label,"").c_str());
00872 if (createTrendMEs) layerMEs.LayerClusterWidthTrend=bookMETrend("TH1ClusterWidth", hidmanager.createHistoLayer("Trend_ClusterWidth","layer",label,"").c_str());
00873 }
00874
00875
00876 if(layerswitchclusnoiseon) {
00877 layerMEs.LayerClusterNoise=bookME1D("TH1ClusterNoise", hidmanager.createHistoLayer("Summary_ClusterNoise","layer",label,"").c_str());
00878 if (createTrendMEs) layerMEs.LayerClusterNoiseTrend=bookMETrend("TH1ClusterNoise", hidmanager.createHistoLayer("Trend_ClusterNoise","layer",label,"").c_str());
00879 }
00880
00881
00882 if(layerswitchcluschargeon) {
00883 layerMEs.LayerClusterCharge=bookME1D("TH1ClusterCharge", hidmanager.createHistoLayer("Summary_ClusterCharge","layer",label,"").c_str());
00884 if (createTrendMEs) layerMEs.LayerClusterChargeTrend=bookMETrend("TH1ClusterCharge", hidmanager.createHistoLayer("Trend_ClusterCharge","layer",label,"").c_str());
00885 }
00886
00887
00888 if(layerswitchclusstonon) {
00889 layerMEs.LayerClusterStoN=bookME1D("TH1ClusterStoN", hidmanager.createHistoLayer("Summary_ClusterSignalOverNoise","layer",label,"").c_str());
00890 if (createTrendMEs) layerMEs.LayerClusterStoNTrend=bookMETrend("TH1ClusterStoN", hidmanager.createHistoLayer("Trend_ClusterSignalOverNoise","layer",label,"").c_str());
00891 }
00892
00893
00894 if(layerswitchlocaloccupancy) {
00895 layerMEs.LayerLocalOccupancy=bookME1D("TH1ModuleLocalOccupancy", hidmanager.createHistoLayer("Summary_ClusterLocalOccupancy","layer",label,"").c_str());
00896 if (createTrendMEs) layerMEs.LayerLocalOccupancyTrend=bookMETrend("TH1ModuleLocalOccupancy", hidmanager.createHistoLayer("Trend_ClusterLocalOccupancy","layer",label,"").c_str());
00897
00898 }
00899
00900
00901 if(layerswitchnumclusterprofon) {
00902 std::string hid = hidmanager.createHistoLayer("NumberOfClusterProfile","layer",label,"");
00903 layerMEs.LayerNumberOfClusterProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 20.5);
00904 }
00905
00906
00907 if(layerswitchclusterwidthprofon) {
00908 std::string hid = hidmanager.createHistoLayer("ClusterWidthProfile","layer",label,"");
00909 layerMEs.LayerClusterWidthProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 20, -0.5, 19.5);
00910 }
00911
00912 LayerMEsMap[label]=layerMEs;
00913 }
00914
00915
00916
00917 void SiStripMonitorCluster::createSubDetMEs(std::string label) {
00918
00919 SubDetMEs subdetMEs;
00920 subdetMEs.totNClusters = 0;
00921 subdetMEs.SubDetTotClusterTH1 = 0;
00922 subdetMEs.SubDetTotClusterProf = 0;
00923 subdetMEs.SubDetClusterApvProf = 0;
00924 subdetMEs.SubDetClusterApvTH2 = 0;
00925 subdetMEs.SubDetClusterDBxCycleProf = 0;
00926 subdetMEs.SubDetApvDBxProf2 = 0;
00927
00928 std::string HistoName;
00929
00930 if (subdetswitchtotclusth1on){
00931 HistoName = "TotalNumberOfCluster__" + label;
00932 subdetMEs.SubDetTotClusterTH1 = bookME1D("TH1TotalNumberOfClusters",HistoName.c_str());
00933 subdetMEs.SubDetTotClusterTH1->setAxisTitle("Total number of clusters in subdetector");
00934 subdetMEs.SubDetTotClusterTH1->getTH1()->StatOverflows(kTRUE);
00935 }
00936
00937 if (subdetswitchtotclusprofon){
00938 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
00939 HistoName = "TotalNumberOfClusterProfile__" + label;
00940 subdetMEs.SubDetTotClusterProf = dqmStore_->bookProfile(HistoName,HistoName,
00941 Parameters.getParameter<int32_t>("Nbins"),
00942 Parameters.getParameter<double>("xmin"),
00943 Parameters.getParameter<double>("xmax"),
00944 100,
00945 Parameters.getParameter<double>("ymin"),
00946 Parameters.getParameter<double>("ymax"),
00947 "" );
00948 subdetMEs.SubDetTotClusterProf->setAxisTitle("Event Time (Seconds)",1);
00949 if (subdetMEs.SubDetTotClusterProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotClusterProf->getTH1()->SetBit(TH1::kCanRebin);
00950 }
00951
00952 if(subdetswitchapvcycleprofon){
00953 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
00954 HistoName = "Cluster_vs_ApvCycle__" + label;
00955 subdetMEs.SubDetClusterApvProf=dqmStore_->bookProfile(HistoName,HistoName,
00956 Parameters.getParameter<int32_t>("Nbins"),
00957 Parameters.getParameter<double>("xmin"),
00958 Parameters.getParameter<double>("xmax"),
00959 200,
00960 Parameters.getParameter<double>("ymin"),
00961 Parameters.getParameter<double>("ymax"),
00962 "" );
00963 subdetMEs.SubDetClusterApvProf->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70)",1);
00964 }
00965
00966
00967 if(subdetswitchapvcycleth2on){
00968 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
00969 HistoName = "Cluster_vs_ApvCycle_2D__" + label;
00970
00971 double h2ymax = 9999.0;
00972 double yfact = Parameters.getParameter<double>("yfactor");
00973 if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
00974 else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
00975 else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
00976 else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
00977
00978 subdetMEs.SubDetClusterApvTH2=dqmStore_->book2D(HistoName,HistoName,
00979 Parameters.getParameter<int32_t>("Nbinsx"),
00980 Parameters.getParameter<double>("xmin"),
00981 Parameters.getParameter<double>("xmax"),
00982 Parameters.getParameter<int32_t>("Nbinsy"),
00983 Parameters.getParameter<double>("ymin"),
00984 h2ymax);
00985 subdetMEs.SubDetClusterApvTH2->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70))",1);
00986 subdetMEs.SubDetClusterApvTH2->setAxisTitle("Total # of Clusters",2);
00987
00988 }
00989
00990 if(subdetswitchdbxcycleprofon){
00991 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
00992 HistoName = "Cluster_vs_DeltaBxCycle__" + label;
00993 subdetMEs.SubDetClusterDBxCycleProf = dqmStore_->bookProfile(HistoName,HistoName,
00994 Parameters.getParameter<int32_t>("Nbins"),
00995 Parameters.getParameter<double>("xmin"),
00996 Parameters.getParameter<double>("xmax"),
00997 200,
00998 Parameters.getParameter<double>("ymin"),
00999 Parameters.getParameter<double>("ymax"),
01000 "" );
01001 subdetMEs.SubDetClusterDBxCycleProf->setAxisTitle("Delta Bunch Crossing Cycle",1);
01002 }
01003
01004 if(subdetswitchapvcycledbxprof2on){
01005 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
01006 HistoName = "DeltaBx_vs_ApvCycle__" + label;
01007 subdetMEs.SubDetApvDBxProf2 = dqmStore_->bookProfile2D(HistoName,HistoName,
01008 Parameters.getParameter<int32_t>("Nbinsx"),
01009 Parameters.getParameter<double>("xmin"),
01010 Parameters.getParameter<double>("xmax"),
01011 Parameters.getParameter<int32_t>("Nbinsy"),
01012 Parameters.getParameter<double>("ymin"),
01013 Parameters.getParameter<double>("ymax"),
01014 Parameters.getParameter<double>("zmin"),
01015 Parameters.getParameter<double>("zmax"),
01016 "" );
01017 subdetMEs.SubDetApvDBxProf2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
01018 subdetMEs.SubDetApvDBxProf2->setAxisTitle("Delta Bunch Crossing Cycle",2);
01019 }
01020 SubDetMEsMap[label]=subdetMEs;
01021 }
01022
01023
01024
01025
01026 void SiStripMonitorCluster::fillModuleMEs(ModMEs& mod_mes, ClusterProperties& cluster) {
01027
01028 if(moduleswitchclusposon && (mod_mes.ClusterPosition))
01029 (mod_mes.ClusterPosition)->Fill(cluster.position);
01030
01031
01032 if(moduleswitchclusdigiposon && (mod_mes.ClusterDigiPosition)) {
01033 for(int ipos=cluster.start+1; ipos<=cluster.start+cluster.width; ipos++){
01034 (mod_mes.ClusterDigiPosition)->Fill(ipos);
01035 }
01036 }
01037
01038 if(moduleswitchcluswidthon && (mod_mes.ClusterWidth))
01039 (mod_mes.ClusterWidth)->Fill(static_cast<float>(cluster.width));
01040
01041 if(moduleswitchclusstonon && (mod_mes.ClusterSignalOverNoise)) {
01042 if (cluster.noise > 0)
01043 (mod_mes.ClusterSignalOverNoise)->Fill(cluster.charge/cluster.noise);
01044 }
01045
01046 if(moduleswitchclusstonVsposon && (mod_mes.ClusterSignalOverNoiseVsPos)) {
01047 if (cluster.noise > 0)
01048 (mod_mes.ClusterSignalOverNoiseVsPos)->Fill(cluster.position,cluster.charge/cluster.noise);
01049 }
01050
01051 if(moduleswitchclusnoiseon && (mod_mes.ClusterNoise))
01052 (mod_mes.ClusterNoise)->Fill(cluster.noise);
01053
01054 if(moduleswitchcluschargeon && (mod_mes.ClusterCharge))
01055 (mod_mes.ClusterCharge)->Fill(cluster.charge);
01056
01057 }
01058
01059
01060
01061 void SiStripMonitorCluster::fillLayerMEs(LayerMEs& layerMEs, ClusterProperties& cluster, float timeinorbit) {
01062 if(layerswitchclusstonon) {
01063 fillME(layerMEs.LayerClusterStoN ,cluster.charge/cluster.noise);
01064 if (createTrendMEs) fillME(layerMEs.LayerClusterStoNTrend,timeinorbit,cluster.charge/cluster.noise);
01065 }
01066
01067 if(layerswitchcluschargeon) {
01068 fillME(layerMEs.LayerClusterCharge,cluster.charge);
01069 if (createTrendMEs) fillME(layerMEs.LayerClusterChargeTrend,timeinorbit,cluster.charge);
01070 }
01071
01072 if(layerswitchclusnoiseon) {
01073 fillME(layerMEs.LayerClusterNoise ,cluster.noise);
01074 if (createTrendMEs) fillME(layerMEs.LayerClusterNoiseTrend,timeinorbit,cluster.noise);
01075 }
01076
01077 if(layerswitchcluswidthon) {
01078 fillME(layerMEs.LayerClusterWidth ,cluster.width);
01079 if (createTrendMEs) fillME(layerMEs.LayerClusterWidthTrend,timeinorbit,cluster.width);
01080 }
01081
01082 }
01083
01084 MonitorElement* SiStripMonitorCluster::bookMETrend(const char* ParameterSetLabel, const char* HistoName)
01085 {
01086 Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
01087 edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
01088 MonitorElement* me = dqmStore_->bookProfile(HistoName,HistoName,
01089 ParametersTrend.getParameter<int32_t>("Nbins"),
01090
01091 ParametersTrend.getParameter<double>("xmin"),
01092 ParametersTrend.getParameter<double>("xmax"),
01093
01094 100,
01095 ParametersTrend.getParameter<double>("ymin"),
01096 ParametersTrend.getParameter<double>("ymax"),
01097 "" );
01098 if(!me) return me;
01099 me->setAxisTitle("Event Time in Seconds",1);
01100 if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
01101 return me;
01102 }
01103
01104
01105 MonitorElement* SiStripMonitorCluster::bookME1D(const char* ParameterSetLabel, const char* HistoName)
01106 {
01107 Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
01108 return dqmStore_->book1D(HistoName,HistoName,
01109 Parameters.getParameter<int32_t>("Nbinx"),
01110 Parameters.getParameter<double>("xmin"),
01111 Parameters.getParameter<double>("xmax")
01112 );
01113 }
01114
01115 int SiStripMonitorCluster::FindRegion(int nstrip,int npix){
01116
01117 double kplus= k0*(1+dk0/100);
01118 double kminus=k0*(1-dk0/100);
01119 int region=0;
01120
01121 if (nstrip!=0 && npix >= (nstrip*kminus-q0) && npix <=(nstrip*kplus+q0)) region=1;
01122 else if (nstrip!=0 && npix < (nstrip*kminus-q0) && nstrip <= maxClus) region=2;
01123 else if (nstrip!=0 && npix < (nstrip*kminus-q0) && nstrip > maxClus) region=3;
01124 else if (nstrip!=0 && npix > (nstrip*kplus+q0)) region=4;
01125 else if (npix > minPix && nstrip==0) region=5;
01126 return region;
01127
01128 }
01129
01130
01131