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