CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/SiStripMonitorCluster/src/SiStripMonitorCluster.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Package:    SiStripMonitorCluster
00003 // Class:      SiStripMonitorCluster
00006 // Original Author:  Dorian Kcira
00007 //         Created:  Wed Feb  1 16:42:34 CET 2006
00008 // $Id: SiStripMonitorCluster.cc,v 1.75 2011/03/15 10:44:19 borrell Exp $
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 
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 
00040 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
00041 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
00042 
00043 
00044 #include "TMath.h"
00045 #include <iostream>
00046 
00047 //--------------------------------------------------------------------------------------------
00048 SiStripMonitorCluster::SiStripMonitorCluster(const edm::ParameterSet& iConfig) : 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)
00049 {
00050 
00051   firstEvent = -1;
00052   eventNb = 0;
00053 
00054   // Detector Partitions
00055   SubDetPhasePartMap["TIB"]        = "TI";
00056   SubDetPhasePartMap["TID__side__1"] = "TI";
00057   SubDetPhasePartMap["TID__side__2"] = "TI";
00058   SubDetPhasePartMap["TOB"]        = "TO";
00059   SubDetPhasePartMap["TEC__side__1"] = "TM";
00060   SubDetPhasePartMap["TEC__side__2"] = "TP";
00061 
00062   //get on/off option for every cluster from cfi
00063   edm::ParameterSet ParametersnClusters =  conf_.getParameter<edm::ParameterSet>("TH1nClusters");
00064   layerswitchncluson = ParametersnClusters.getParameter<bool>("layerswitchon");
00065   moduleswitchncluson = ParametersnClusters.getParameter<bool>("moduleswitchon");
00066   
00067   edm::ParameterSet ParametersClusterCharge =  conf_.getParameter<edm::ParameterSet>("TH1ClusterCharge");
00068   layerswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("layerswitchon");
00069   moduleswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("moduleswitchon");
00070   
00071   edm::ParameterSet ParametersClusterStoN =  conf_.getParameter<edm::ParameterSet>("TH1ClusterStoN");
00072   layerswitchclusstonon = ParametersClusterStoN.getParameter<bool>("layerswitchon");
00073   moduleswitchclusstonon = ParametersClusterStoN.getParameter<bool>("moduleswitchon");
00074 
00075   edm::ParameterSet ParametersClusterStoNVsPos =  conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
00076   layerswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("layerswitchon");
00077   moduleswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("moduleswitchon");
00078   
00079   edm::ParameterSet ParametersClusterPos =  conf_.getParameter<edm::ParameterSet>("TH1ClusterPos");
00080   layerswitchclusposon = ParametersClusterPos.getParameter<bool>("layerswitchon");
00081   moduleswitchclusposon = ParametersClusterPos.getParameter<bool>("moduleswitchon");
00082 
00083   edm::ParameterSet ParametersClusterDigiPos =  conf_.getParameter<edm::ParameterSet>("TH1ClusterDigiPos");
00084   layerswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("layerswitchon");
00085   moduleswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("moduleswitchon");
00086   
00087   edm::ParameterSet ParametersClusterNoise =  conf_.getParameter<edm::ParameterSet>("TH1ClusterNoise");
00088   layerswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("layerswitchon");
00089   moduleswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("moduleswitchon");
00090   
00091   edm::ParameterSet ParametersClusterWidth =  conf_.getParameter<edm::ParameterSet>("TH1ClusterWidth");
00092   layerswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("layerswitchon");
00093   moduleswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("moduleswitchon");
00094   
00095   edm::ParameterSet ParametersModuleLocalOccupancy =  conf_.getParameter<edm::ParameterSet>("TH1ModuleLocalOccupancy");
00096   layerswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("layerswitchon");
00097   moduleswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("moduleswitchon");
00098 
00099   edm::ParameterSet ParametersNrOfClusterizedStrips =  conf_.getParameter<edm::ParameterSet>("TH1NrOfClusterizedStrips");
00100   layerswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("layerswitchon");
00101   moduleswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("moduleswitchon");
00102 
00103   edm::ParameterSet ParametersClusterProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfCluster");
00104   layerswitchnumclusterprofon = ParametersClusterProf.getParameter<bool>("layerswitchon");
00105 
00106   edm::ParameterSet ParametersClusterWidthProf = conf_.getParameter<edm::ParameterSet>("TProfClusterWidth");
00107   layerswitchclusterwidthprofon = ParametersClusterWidthProf.getParameter<bool>("layerswitchon");
00108 
00109   edm::ParameterSet ParametersTotClusterProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
00110   subdetswitchtotclusprofon = ParametersTotClusterProf.getParameter<bool>("subdetswitchon");
00111 
00112   edm::ParameterSet ParametersTotClusterTH1 = conf_.getParameter<edm::ParameterSet>("TH1TotalNumberOfClusters");
00113   subdetswitchtotclusth1on = ParametersTotClusterTH1.getParameter<bool>("subdetswitchon");
00114 
00115   edm::ParameterSet ParametersClusterApvProf = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
00116   subdetswitchapvcycleprofon = ParametersClusterApvProf.getParameter<bool>("subdetswitchon");
00117 
00118   edm::ParameterSet ParametersClustersApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
00119   subdetswitchapvcycleth2on = ParametersClustersApvTH2.getParameter<bool>("subdetswitchon");
00120 
00121   edm::ParameterSet ParametersApvCycleDBxProf2 = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
00122   subdetswitchapvcycledbxprof2on = ParametersApvCycleDBxProf2.getParameter<bool>("subdetswitchon");
00123 
00124   edm::ParameterSet ParametersDBxCycleProf = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
00125   subdetswitchdbxcycleprofon = ParametersDBxCycleProf.getParameter<bool>("subdetswitchon");
00126 
00127   edm::ParameterSet ParametersApvCycleVsDBxGlobalTH2 = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
00128   globalswitchapvcycledbxth2on = ParametersApvCycleVsDBxGlobalTH2.getParameter<bool>("globalswitchon");
00129 
00130   clustertkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
00131   createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
00132   Mod_On_ = conf_.getParameter<bool>("Mod_On");
00133 
00134   topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
00135 
00136 
00137   // Poducer name of input StripClusterCollection
00138   clusterProducer_ = conf_.getParameter<edm::InputTag>("ClusterProducer");
00139   // SiStrip Quality Label
00140   qualityLabel_  = conf_.getParameter<std::string>("StripQualityLabel");
00141   // cluster quality conditions 
00142   edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
00143   applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
00144   sToNLowerLimit_      = cluster_condition.getParameter<double>("minStoN");
00145   sToNUpperLimit_      = cluster_condition.getParameter<double>("maxStoN");
00146   widthLowerLimit_     = cluster_condition.getParameter<double>("minWidth"); 
00147   widthUpperLimit_     = cluster_condition.getParameter<double>("maxWidth"); 
00148 
00149   // Event History Producer
00150   historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
00151   // Apv Phase Producer
00152   apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
00153 
00154   // Create DCS Status
00155   bool checkDCS    = conf_.getParameter<bool>("UseDCSFiltering");
00156   if (checkDCS) dcsStatus_ = new SiStripDCSStatus();
00157   else dcsStatus_ = 0; 
00158 
00159 } 
00160 
00161 SiStripMonitorCluster::~SiStripMonitorCluster() { 
00162   if (dcsStatus_) delete dcsStatus_;
00163 }
00164 
00165 //--------------------------------------------------------------------------------------------
00166 void SiStripMonitorCluster::beginRun(const edm::Run& run, const edm::EventSetup& es){
00167 
00168   if (show_mechanical_structure_view) {
00169     unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
00170     if (m_cacheID_ != cacheID) {
00171       m_cacheID_ = cacheID;       
00172      edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::beginRun: " 
00173                                             << " Creating MEs for new Cabling ";     
00174 
00175       createMEs(es);
00176     } 
00177   } else if (reset_each_run) {
00178     edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::beginRun: " 
00179                                           << " Resetting MEs ";        
00180     for (std::map<uint32_t, ModMEs >::const_iterator idet = ModuleMEsMap.begin() ; idet!=ModuleMEsMap.end() ; idet++) {
00181       ResetModuleMEs(idet->first);
00182     }
00183   }
00184 }
00185 
00186 //--------------------------------------------------------------------------------------------
00187 void SiStripMonitorCluster::createMEs(const edm::EventSetup& es){
00188 
00189   if ( show_mechanical_structure_view ){
00190     // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on
00191     es.get<SiStripDetCablingRcd>().get(SiStripDetCabling_);
00192     
00193     // get list of active detectors from SiStripDetCabling 
00194     std::vector<uint32_t> activeDets;
00195     SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
00196     
00197     SiStripSubStructure substructure;
00198 
00199     SiStripFolderOrganizer folder_organizer;
00200     folder_organizer.setSiStripFolderName(topFolderName_);
00201     folder_organizer.setSiStripFolder();
00202 
00203 
00204     // Create TkHistoMap for Cluster
00205     if (clustertkhistomapon) {
00206       if (topFolderName_ == "SiStrip") tkmapcluster = new TkHistoMap("SiStrip/TkHistoMap","TkHMap_NumberOfCluster",0.,1);
00207       else tkmapcluster = new TkHistoMap(topFolderName_+"/TkHistoMap","TkHMap_NumberOfCluster",0.,0);
00208     }    
00209 
00210     // loop over detectors and book MEs
00211     edm::LogInfo("SiStripTkDQM|SiStripMonitorCluster")<<"nr. of activeDets:  "<<activeDets.size();
00212     for(std::vector<uint32_t>::iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
00213       uint32_t detid = (*detid_iterator);
00214       // remove any eventual zero elements - there should be none, but just in case
00215       if(detid == 0) {
00216         activeDets.erase(detid_iterator);
00217         continue;
00218       }
00219       
00220       if (Mod_On_) {
00221         ModMEs mod_single;
00222         mod_single.NumberOfClusters = 0;
00223         mod_single.ClusterPosition = 0;
00224         mod_single.ClusterDigiPosition = 0;
00225         mod_single.ClusterWidth = 0;
00226         mod_single.ClusterCharge = 0;
00227         mod_single.ClusterNoise = 0;
00228         mod_single.ClusterSignalOverNoise = 0;
00229         mod_single.ClusterSignalOverNoiseVsPos = 0;
00230         mod_single.ModuleLocalOccupancy = 0;
00231         mod_single.NrOfClusterizedStrips = 0; 
00232         
00233         // set appropriate folder using SiStripFolderOrganizer
00234         folder_organizer.setDetectorFolder(detid); // pass the detid to this method
00235         if (reset_each_run) ResetModuleMEs(detid);
00236         createModuleMEs(mod_single, detid);
00237         // append to ModuleMEsMap
00238         ModuleMEsMap.insert( std::make_pair(detid, mod_single));
00239       }
00240       
00241       // Create Layer Level MEs if they are not created already
00242       std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid);
00243       SiStripHistoId hidmanager;
00244       std::string label = hidmanager.getSubdetid(detid,false);
00245       
00246       std::map<std::string, LayerMEs>::iterator iLayerME  = LayerMEsMap.find(label);
00247       if(iLayerME==LayerMEsMap.end()) {
00248         
00249         // get detids for the layer
00250         int32_t lnumber = det_layer_pair.second;
00251         std::vector<uint32_t> layerDetIds;        
00252         if (det_layer_pair.first == "TIB") {
00253           substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
00254         } else if (det_layer_pair.first == "TOB") {
00255           substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
00256         } else if (det_layer_pair.first == "TID" && lnumber > 0) {
00257           substructure.getTIDDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0);
00258         } else if (det_layer_pair.first == "TID" && lnumber < 0) {
00259           substructure.getTIDDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0);
00260         } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
00261           substructure.getTECDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0,0,0);
00262         } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
00263           substructure.getTECDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0,0,0);
00264         }
00265         LayerDetMap[label] = layerDetIds;
00266 
00267         // book Layer MEs 
00268         folder_organizer.setLayerFolder(detid,det_layer_pair.second);
00269         createLayerMEs(label, layerDetIds.size());
00270       }
00271       // book sub-detector plots
00272       std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid);
00273       if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
00274         dqmStore_->setCurrentFolder(sdet_pair.first);
00275         createSubDetMEs(sdet_pair.second);        
00276       }
00277     }//end of loop over detectors
00278 
00279     // Create Global Histogram
00280     if (globalswitchapvcycledbxth2on) {
00281       dqmStore_->setCurrentFolder(topFolderName_+"/MechanicalView/");
00282       edm::ParameterSet GlobalTH2Parameters =  conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
00283       std::string HistoName = "DeltaBx_vs_ApvCycle";
00284       GlobalApvCycleDBxTH2 = dqmStore_->book2D(HistoName,HistoName,
00285                                                GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
00286                                                GlobalTH2Parameters.getParameter<double>("xmin"),
00287                                                GlobalTH2Parameters.getParameter<double>("xmax"),
00288                                                GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
00289                                                GlobalTH2Parameters.getParameter<double>("ymin"),
00290                                                GlobalTH2Parameters.getParameter<double>("ymax"));
00291       GlobalApvCycleDBxTH2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
00292       GlobalApvCycleDBxTH2->setAxisTitle("Delta Bunch Crossing Cycle",2);
00293     }
00294   }//end of if
00295 }//end of method
00296 
00297 //--------------------------------------------------------------------------------------------
00298 void SiStripMonitorCluster::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00299 {
00300 
00301   // Filter out events if DCS Event if requested
00302   if (dcsStatus_ && !dcsStatus_->getStatus(iEvent,iSetup)) return;
00303 
00304   runNb   = iEvent.id().run();
00305   eventNb++;
00306   float iOrbitSec      = iEvent.orbitNumber()/11223.0;
00307 
00308   edm::ESHandle<SiStripNoises> noiseHandle;
00309   iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
00310 
00311   edm::ESHandle<SiStripGain> gainHandle;
00312   iSetup.get<SiStripGainRcd>().get(gainHandle);
00313 
00314 
00315   edm::ESHandle<SiStripQuality> qualityHandle;
00316   iSetup.get<SiStripQualityRcd>().get(qualityLabel_,qualityHandle);
00317 
00318   iSetup.get<SiStripDetCablingRcd>().get(SiStripDetCabling_);
00319 
00320   // get collection of DetSetVector of clusters from Event
00321   edm::Handle< edmNew::DetSetVector<SiStripCluster> > cluster_detsetvektor;
00322   iEvent.getByLabel(clusterProducer_, cluster_detsetvektor);
00323 
00324   if (!cluster_detsetvektor.isValid()) return;
00325  
00326   // initialise # of clusters to zero
00327   for (std::map<std::string, SubDetMEs>::iterator iSubdet  = SubDetMEsMap.begin();
00328        iSubdet != SubDetMEsMap.end(); iSubdet++) {
00329     iSubdet->second.totNClusters = 0;
00330   }
00331 
00332   SiStripFolderOrganizer folder_organizer;
00333   bool found_layer_me = false;
00334   for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
00335        iterLayer != LayerDetMap.end(); iterLayer++) {
00336     
00337     std::string layer_label = iterLayer->first;
00338     
00339     int ncluster_layer = 0;
00340     std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
00341     
00342     //get Layer MEs 
00343     LayerMEs layer_single;
00344     if(iLayerME != LayerMEsMap.end()) {
00345        layer_single = iLayerME->second; 
00346        found_layer_me = true;
00347      } 
00348 
00349     bool found_module_me = false;
00350     uint16_t iDet = 0;
00351     std::string subdet_label = ""; 
00352     // loop over all modules in the layer
00353     for (std::vector< uint32_t >::const_iterator iterDets = iterLayer->second.begin() ; 
00354          iterDets != iterLayer->second.end() ; iterDets++) {
00355       iDet++;
00356       // detid and type of ME
00357       uint32_t detid = (*iterDets);
00358 
00359       // Get SubDet label once
00360       if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid).second;
00361 
00362       // DetId and corresponding set of MEs
00363       ModMEs mod_single;
00364       if (Mod_On_) {
00365         std::map<uint32_t, ModMEs >::iterator imodME = ModuleMEsMap.find(detid);
00366         if (imodME != ModuleMEsMap.end()) {
00367           mod_single = imodME->second;
00368           found_module_me = true;
00369         } 
00370       } else found_module_me = false;
00371 
00372       edmNew::DetSetVector<SiStripCluster>::const_iterator isearch = cluster_detsetvektor->find(detid); // search  clusters of detid
00373     
00374       if(isearch==cluster_detsetvektor->end()){
00375         if(found_module_me && moduleswitchncluson && (mod_single.NumberOfClusters)){
00376           (mod_single.NumberOfClusters)->Fill(0.); // no clusters for this detector module,fill histogram with 0
00377         }
00378         if(clustertkhistomapon) tkmapcluster->fill(detid,0.);
00379         if (found_layer_me && layerswitchnumclusterprofon) layer_single.LayerNumberOfClusterProfile->Fill(iDet, 0.0);
00380         continue; // no clusters for this detid => jump to next step of loop
00381       }
00382       
00383       //cluster_detset is a structure, cluster_detset.data is a std::vector<SiStripCluster>, cluster_detset.id is uint32_t
00384       edmNew::DetSet<SiStripCluster> cluster_detset = (*cluster_detsetvektor)[detid]; // the statement above makes sure there exists an element with 'detid'
00385       
00386       // Filling TkHistoMap with number of clusters for each module 
00387       if(clustertkhistomapon) {
00388         tkmapcluster->fill(detid,static_cast<float>(cluster_detset.size()));
00389       }
00390 
00391       if(moduleswitchncluson && found_module_me && (mod_single.NumberOfClusters != NULL)){ // nr. of clusters per module
00392         (mod_single.NumberOfClusters)->Fill(static_cast<float>(cluster_detset.size()));
00393       }
00394       if (found_layer_me && layerswitchnumclusterprofon) 
00395         layer_single.LayerNumberOfClusterProfile->Fill(iDet, static_cast<float>(cluster_detset.size()));
00396       ncluster_layer +=  cluster_detset.size();
00397       
00398       short total_clusterized_strips = 0;
00399       
00400       SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detid);
00401       SiStripApvGain::Range detGainRange = gainHandle->getRange(detid); 
00402       SiStripQuality::Range qualityRange = qualityHandle->getRange(detid);
00403       
00404       for(edmNew::DetSet<SiStripCluster>::const_iterator clusterIter = cluster_detset.begin(); clusterIter!= cluster_detset.end(); clusterIter++){
00405 
00406         const std::vector<uint8_t>& ampls = clusterIter->amplitudes();
00407         // cluster position
00408         float cluster_position = clusterIter->barycenter();
00409         // start defined as nr. of first strip beloning to the cluster
00410         short cluster_start    = clusterIter->firstStrip();
00411         // width defined as nr. of strips that belong to cluster
00412         short cluster_width    = ampls.size(); 
00413         // add nr of strips of this cluster to total nr. of clusterized strips
00414         total_clusterized_strips = total_clusterized_strips + cluster_width; 
00415         
00416         // cluster signal and noise from the amplitudes
00417         float cluster_signal = 0.0;
00418         float cluster_noise  = 0.0;
00419         int nrnonzeroamplitudes = 0;
00420         float noise2 = 0.0;
00421         float noise  = 0.0;
00422         for(uint iamp=0; iamp<ampls.size(); iamp++){
00423           if(ampls[iamp]>0){ // nonzero amplitude
00424             cluster_signal += ampls[iamp];
00425             if(!qualityHandle->IsStripBad(qualityRange, clusterIter->firstStrip()+iamp)){
00426               noise = noiseHandle->getNoise(clusterIter->firstStrip()+iamp,detNoiseRange)/gainHandle->getStripGain(clusterIter->firstStrip()+iamp, detGainRange);
00427             }
00428             noise2 += noise*noise;
00429             nrnonzeroamplitudes++;
00430           }
00431         } // End loop over cluster amplitude
00432         
00433         if (nrnonzeroamplitudes > 0) cluster_noise = sqrt(noise2/nrnonzeroamplitudes);
00434         
00435         if( applyClusterQuality_ &&
00436             (cluster_signal/cluster_noise < sToNLowerLimit_ ||
00437              cluster_signal/cluster_noise > sToNUpperLimit_ ||
00438              cluster_width < widthLowerLimit_ ||
00439              cluster_width > widthUpperLimit_) ) continue;  
00440         
00441         ClusterProperties cluster_properties;
00442         cluster_properties.charge    = cluster_signal;
00443         cluster_properties.position  = cluster_position;
00444         cluster_properties.start     = cluster_start;
00445         cluster_properties.width     = cluster_width;
00446         cluster_properties.noise     = cluster_noise;
00447         
00448         // Fill Module Level MEs
00449         if (found_module_me) fillModuleMEs(mod_single, cluster_properties);
00450         
00451         // Fill Layer Level MEs
00452         if (found_layer_me) {
00453           fillLayerMEs(layer_single, cluster_properties, iOrbitSec);
00454           if (layerswitchclusterwidthprofon) 
00455             layer_single.LayerClusterWidthProfile->Fill(iDet, cluster_width);
00456         }
00457       } // end loop over clusters
00458       
00459       short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
00460       float local_occupancy = static_cast<float>(total_clusterized_strips)/static_cast<float>(total_nr_strips);
00461       if (found_module_me) {
00462         if(moduleswitchnrclusterizedstrip && mod_single.NrOfClusterizedStrips ){ // nr of clusterized strips
00463           mod_single.NrOfClusterizedStrips->Fill(static_cast<float>(total_clusterized_strips));
00464         }
00465         
00466         if(moduleswitchlocaloccupancy && mod_single.ModuleLocalOccupancy ){ // Occupancy
00467           mod_single.ModuleLocalOccupancy->Fill(local_occupancy);
00468         }
00469       }
00470       if (layerswitchlocaloccupancy && found_layer_me && layer_single.LayerLocalOccupancy) {
00471         fillME(layer_single.LayerLocalOccupancy,local_occupancy);
00472         if (createTrendMEs) fillME(layer_single.LayerLocalOccupancyTrend,iOrbitSec,local_occupancy);
00473       }
00474     }
00475     std::map<std::string, SubDetMEs>::iterator iSubdet  = SubDetMEsMap.find(subdet_label);
00476     if(iSubdet != SubDetMEsMap.end()) iSubdet->second.totNClusters += ncluster_layer; 
00477   }
00478   
00479   //  EventHistory 
00480   edm::Handle<EventWithHistory> event_history;
00481   iEvent.getByLabel(historyProducer_,event_history);
00482   
00483   // Phase of APV
00484   edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
00485   iEvent.getByLabel(apvPhaseProducer_,apv_phase_collection);
00486 
00487   if (event_history.isValid() 
00488         && !event_history.failedToGet()
00489         && apv_phase_collection.isValid() 
00490         && !apv_phase_collection.failedToGet()) {
00491 
00492 
00493     long long dbx        = event_history->deltaBX();
00494     long long tbx        = event_history->absoluteBX();    
00495 
00496     bool global_histo_filled = false;
00497     for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
00498        it != SubDetMEsMap.end(); it++) {
00499       std::string sdet = it->first;
00500       //      std::string sdet = sdet_tag.substr(0,sdet_tag.find_first_of("_"));
00501       SubDetMEs sdetmes = it->second;
00502 
00503       int the_phase = APVCyclePhaseCollection::invalid;
00504       long long tbx_corr = tbx;
00505 
00506       if (SubDetPhasePartMap.find(sdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[sdet]);
00507       if(the_phase==APVCyclePhaseCollection::nopartition ||
00508          the_phase==APVCyclePhaseCollection::multiphase ||
00509          the_phase==APVCyclePhaseCollection::invalid) the_phase=30;
00510       tbx_corr  -= the_phase;
00511       long long dbxincycle = event_history->deltaBXinCycle(the_phase);
00512       if (globalswitchapvcycledbxth2on && !global_histo_filled) { 
00513         GlobalApvCycleDBxTH2->Fill(tbx_corr%70,dbx);
00514         global_histo_filled = true;
00515       }
00516       if (subdetswitchtotclusth1on) sdetmes.SubDetTotClusterTH1->Fill(sdetmes.totNClusters);
00517       if (subdetswitchtotclusprofon) sdetmes.SubDetTotClusterProf->Fill(iOrbitSec,sdetmes.totNClusters);
00518       if (subdetswitchapvcycleprofon) sdetmes.SubDetClusterApvProf->Fill(tbx_corr%70,sdetmes.totNClusters);
00519       if (subdetswitchapvcycleth2on) sdetmes.SubDetClusterApvTH2->Fill(tbx_corr%70,sdetmes.totNClusters);
00520       if (subdetswitchdbxcycleprofon) sdetmes.SubDetClusterDBxCycleProf->Fill(dbxincycle,sdetmes.totNClusters);
00521       if (subdetswitchapvcycledbxprof2on) sdetmes.SubDetApvDBxProf2->Fill(tbx_corr%70,dbx,sdetmes.totNClusters);
00522     }
00523   }
00524 }
00525 //
00526 // -- EndJob
00527 //
00528 void SiStripMonitorCluster::endJob(void){
00529   bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00530   std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00531  
00532   // save histos in a file
00533   if(outputMEsInRootFile) dqmStore_->save(outputFileName);
00534 }
00535 //
00536 // -- Reset MEs
00537 //------------------------------------------------------------------------------
00538 void SiStripMonitorCluster::ResetModuleMEs(uint32_t idet){
00539   std::map<uint32_t, ModMEs >::iterator pos = ModuleMEsMap.find(idet);
00540   ModMEs mod_me = pos->second;
00541 
00542   if (moduleswitchncluson)            mod_me.NumberOfClusters->Reset();
00543   if (moduleswitchclusposon)          mod_me.ClusterPosition->Reset();
00544   if (moduleswitchclusdigiposon)            mod_me.ClusterDigiPosition->Reset();
00545   if (moduleswitchclusstonVsposon)    mod_me.ClusterSignalOverNoiseVsPos->Reset();
00546   if (moduleswitchcluswidthon)        mod_me.ClusterWidth->Reset();
00547   if (moduleswitchcluschargeon)       mod_me.ClusterCharge->Reset();
00548   if (moduleswitchclusnoiseon)        mod_me.ClusterNoise->Reset();
00549   if (moduleswitchclusstonon)         mod_me.ClusterSignalOverNoise->Reset();
00550   if (moduleswitchlocaloccupancy)     mod_me.ModuleLocalOccupancy->Reset();
00551   if (moduleswitchnrclusterizedstrip) mod_me.NrOfClusterizedStrips->Reset(); 
00552 }
00553 //
00554 // -- Create Module Level MEs
00555 //
00556 void SiStripMonitorCluster::createModuleMEs(ModMEs& mod_single, uint32_t detid) {
00557 
00558   // use SistripHistoId for producing histogram id (and title)
00559   SiStripHistoId hidmanager;
00560   std::string hid;
00561   
00562   //nr. of clusters per module
00563   if(moduleswitchncluson) {
00564     hid = hidmanager.createHistoId("NumberOfClusters","det",detid);
00565     mod_single.NumberOfClusters = bookME1D("TH1nClusters", hid.c_str());
00566     dqmStore_->tag(mod_single.NumberOfClusters, detid);
00567     mod_single.NumberOfClusters->setAxisTitle("number of clusters in one detector module");
00568     mod_single.NumberOfClusters->getTH1()->StatOverflows(kTRUE);  // over/underflows in Mean calculation
00569   }
00570   
00571   //ClusterPosition
00572   if(moduleswitchclusposon) {
00573     short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs    
00574     hid = hidmanager.createHistoId("ClusterPosition","det",detid);
00575     mod_single.ClusterPosition = dqmStore_->book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
00576     dqmStore_->tag(mod_single.ClusterPosition, detid);
00577     mod_single.ClusterPosition->setAxisTitle("cluster position [strip number +0.5]");
00578   }
00579 
00580   //ClusterDigiPosition
00581   if(moduleswitchclusdigiposon) {
00582     short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs    
00583     hid = hidmanager.createHistoId("ClusterDigiPosition","det",detid);
00584     mod_single.ClusterDigiPosition = dqmStore_->book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
00585     dqmStore_->tag(mod_single.ClusterDigiPosition, detid);
00586     mod_single.ClusterDigiPosition->setAxisTitle("digi in cluster position [strip number +0.5]");
00587   }
00588   
00589   //ClusterWidth
00590   if(moduleswitchcluswidthon) {
00591     hid = hidmanager.createHistoId("ClusterWidth","det",detid);
00592     mod_single.ClusterWidth = bookME1D("TH1ClusterWidth", hid.c_str());
00593     dqmStore_->tag(mod_single.ClusterWidth, detid);
00594     mod_single.ClusterWidth->setAxisTitle("cluster width [nr strips]");
00595   }
00596   
00597   //ClusterCharge
00598   if(moduleswitchcluschargeon) {
00599     hid = hidmanager.createHistoId("ClusterCharge","det",detid);
00600     mod_single.ClusterCharge = bookME1D("TH1ClusterCharge", hid.c_str());
00601     dqmStore_->tag(mod_single.ClusterCharge, detid);
00602     mod_single.ClusterCharge->setAxisTitle("cluster charge [ADC]");
00603   }
00604   
00605   //ClusterNoise
00606   if(moduleswitchclusnoiseon) {
00607     hid = hidmanager.createHistoId("ClusterNoise","det",detid);
00608     mod_single.ClusterNoise = bookME1D("TH1ClusterNoise", hid.c_str());
00609     dqmStore_->tag(mod_single.ClusterNoise, detid);
00610     mod_single.ClusterNoise->setAxisTitle("cluster noise");
00611   }
00612   
00613   //ClusterSignalOverNoise
00614   if(moduleswitchclusstonon) {
00615     hid = hidmanager.createHistoId("ClusterSignalOverNoise","det",detid);
00616     mod_single.ClusterSignalOverNoise = bookME1D("TH1ClusterStoN", hid.c_str());
00617     dqmStore_->tag(mod_single.ClusterSignalOverNoise, detid);
00618     mod_single.ClusterSignalOverNoise->setAxisTitle("ratio of signal to noise for each cluster");
00619   }
00620 
00621   //ClusterSignalOverNoiseVsPos
00622   if(moduleswitchclusstonVsposon) {
00623     hid = hidmanager.createHistoId("ClusterSignalOverNoiseVsPos","det",detid);
00624     Parameters =  conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
00625     mod_single.ClusterSignalOverNoiseVsPos= dqmStore_->bookProfile(hid.c_str(),hid.c_str(),
00626                                                                    Parameters.getParameter<int32_t>("Nbinx"),
00627                                                                    Parameters.getParameter<double>("xmin"),
00628                                                                    Parameters.getParameter<double>("xmax"),
00629                                                                    Parameters.getParameter<int32_t>("Nbiny"),
00630                                                                    Parameters.getParameter<double>("ymin"),
00631                                                                    Parameters.getParameter<double>("ymax")
00632                                                                    );
00633     dqmStore_->tag(mod_single.ClusterSignalOverNoiseVsPos, detid);
00634     mod_single.ClusterSignalOverNoiseVsPos->setAxisTitle("pos");
00635   }
00636   
00637   //ModuleLocalOccupancy
00638   if (moduleswitchlocaloccupancy) {
00639     hid = hidmanager.createHistoId("ClusterLocalOccupancy","det",detid);
00640     mod_single.ModuleLocalOccupancy = bookME1D("TH1ModuleLocalOccupancy", hid.c_str());
00641     dqmStore_->tag(mod_single.ModuleLocalOccupancy, detid);
00642     mod_single.ModuleLocalOccupancy->setAxisTitle("module local occupancy [% of clusterized strips]");
00643   }
00644   
00645   //NrOfClusterizedStrips
00646   if (moduleswitchnrclusterizedstrip) {
00647     hid = hidmanager.createHistoId("NrOfClusterizedStrips","det",detid);
00648     mod_single.NrOfClusterizedStrips = bookME1D("TH1NrOfClusterizedStrips", hid.c_str());
00649     dqmStore_->tag(mod_single.NrOfClusterizedStrips, detid);
00650     mod_single.NrOfClusterizedStrips->setAxisTitle("number of clusterized strips");
00651   }
00652 }  
00653 //
00654 // -- Create Module Level MEs
00655 //  
00656 void SiStripMonitorCluster::createLayerMEs(std::string label, int ndets) {
00657 
00658   SiStripHistoId hidmanager;
00659   
00660   LayerMEs layerMEs; 
00661   layerMEs.LayerClusterStoN = 0;
00662   layerMEs.LayerClusterStoNTrend = 0;
00663   layerMEs.LayerClusterCharge = 0;
00664   layerMEs.LayerClusterChargeTrend = 0;
00665   layerMEs.LayerClusterNoise = 0;
00666   layerMEs.LayerClusterNoiseTrend = 0;
00667   layerMEs.LayerClusterWidth = 0;
00668   layerMEs.LayerClusterWidthTrend = 0;
00669   layerMEs.LayerLocalOccupancy = 0;
00670   layerMEs.LayerLocalOccupancyTrend = 0;
00671   layerMEs.LayerNumberOfClusterProfile = 0;
00672   layerMEs.LayerClusterWidthProfile = 0;
00673   
00674   //Cluster Width
00675   if(layerswitchcluswidthon) {
00676     layerMEs.LayerClusterWidth=bookME1D("TH1ClusterWidth", hidmanager.createHistoLayer("Summary_ClusterWidth","layer",label,"").c_str()); 
00677     if (createTrendMEs) layerMEs.LayerClusterWidthTrend=bookMETrend("TH1ClusterWidth", hidmanager.createHistoLayer("Trend_ClusterWidth","layer",label,"").c_str()); 
00678   }
00679   
00680   //Cluster Noise
00681   if(layerswitchclusnoiseon) {
00682     layerMEs.LayerClusterNoise=bookME1D("TH1ClusterNoise", hidmanager.createHistoLayer("Summary_ClusterNoise","layer",label,"").c_str()); 
00683     if (createTrendMEs) layerMEs.LayerClusterNoiseTrend=bookMETrend("TH1ClusterNoise", hidmanager.createHistoLayer("Trend_ClusterNoise","layer",label,"").c_str()); 
00684   }
00685   
00686   //Cluster Charge
00687   if(layerswitchcluschargeon) {
00688     layerMEs.LayerClusterCharge=bookME1D("TH1ClusterCharge", hidmanager.createHistoLayer("Summary_ClusterCharge","layer",label,"").c_str());
00689     if (createTrendMEs) layerMEs.LayerClusterChargeTrend=bookMETrend("TH1ClusterCharge", hidmanager.createHistoLayer("Trend_ClusterCharge","layer",label,"").c_str());
00690   }
00691   
00692   //Cluster StoN
00693   if(layerswitchclusstonon) {
00694     layerMEs.LayerClusterStoN=bookME1D("TH1ClusterStoN", hidmanager.createHistoLayer("Summary_ClusterSignalOverNoise","layer",label,"").c_str());
00695     if (createTrendMEs) layerMEs.LayerClusterStoNTrend=bookMETrend("TH1ClusterStoN", hidmanager.createHistoLayer("Trend_ClusterSignalOverNoise","layer",label,"").c_str());
00696   }
00697   
00698   //Cluster Occupancy
00699   if(layerswitchlocaloccupancy) {
00700     layerMEs.LayerLocalOccupancy=bookME1D("TH1ModuleLocalOccupancy", hidmanager.createHistoLayer("Summary_ClusterLocalOccupancy","layer",label,"").c_str());  
00701     if (createTrendMEs) layerMEs.LayerLocalOccupancyTrend=bookMETrend("TH1ModuleLocalOccupancy", hidmanager.createHistoLayer("Trend_ClusterLocalOccupancy","layer",label,"").c_str());  
00702     
00703   }
00704   
00705   // # of Cluster Profile 
00706   if(layerswitchnumclusterprofon) {
00707     std::string hid = hidmanager.createHistoLayer("NumberOfClusterProfile","layer",label,"");
00708     layerMEs.LayerNumberOfClusterProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 20.5);      
00709   }
00710   
00711   // Cluster Width Profile 
00712   if(layerswitchclusterwidthprofon) {
00713     std::string hid = hidmanager.createHistoLayer("ClusterWidthProfile","layer",label,"");      
00714     layerMEs.LayerClusterWidthProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 20, -0.5, 19.5);      
00715   }
00716 
00717   LayerMEsMap[label]=layerMEs;
00718 }
00719 //
00720 // -- Create SubDetector MEs
00721 //
00722 void SiStripMonitorCluster::createSubDetMEs(std::string label) {
00723 
00724   SubDetMEs subdetMEs;
00725   subdetMEs.totNClusters              = 0;
00726   subdetMEs.SubDetTotClusterTH1       = 0;
00727   subdetMEs.SubDetTotClusterProf      = 0;
00728   subdetMEs.SubDetClusterApvProf      = 0;
00729   subdetMEs.SubDetClusterApvTH2       = 0;
00730   subdetMEs.SubDetClusterDBxCycleProf = 0;
00731   subdetMEs.SubDetApvDBxProf2         = 0;
00732   
00733   std::string HistoName;
00734   // Total Number of Cluster - 1D 
00735   if (subdetswitchtotclusth1on){
00736     HistoName = "TotalNumberOfCluster__" + label;
00737     subdetMEs.SubDetTotClusterTH1 = bookME1D("TH1TotalNumberOfClusters",HistoName.c_str());
00738     subdetMEs.SubDetTotClusterTH1->setAxisTitle("Total number of clusters in subdetector");
00739     subdetMEs.SubDetTotClusterTH1->getTH1()->StatOverflows(kTRUE);  // over/underflows in Mean calculation
00740   }
00741   // Total Number of Cluster vs Time - Profile
00742   if (subdetswitchtotclusprofon){
00743     edm::ParameterSet Parameters =  conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
00744     HistoName = "TotalNumberOfClusterProfile__" + label;
00745     subdetMEs.SubDetTotClusterProf = dqmStore_->bookProfile(HistoName,HistoName,
00746                                                             Parameters.getParameter<int32_t>("Nbins"),
00747                                                             Parameters.getParameter<double>("xmin"),
00748                                                             Parameters.getParameter<double>("xmax"),
00749                                                             100, //that parameter should not be there !?
00750                                                             Parameters.getParameter<double>("ymin"),
00751                                                             Parameters.getParameter<double>("ymax"),
00752                                                             "" );
00753     subdetMEs.SubDetTotClusterProf->setAxisTitle("Event Time (Seconds)",1);
00754     if (subdetMEs.SubDetTotClusterProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotClusterProf->getTH1()->SetBit(TH1::kCanRebin);
00755   }
00756   // Total Number of Cluster vs APV cycle - Profile
00757   if(subdetswitchapvcycleprofon){
00758     edm::ParameterSet Parameters =  conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
00759     HistoName = "Cluster_vs_ApvCycle__" + label;
00760     subdetMEs.SubDetClusterApvProf=dqmStore_->bookProfile(HistoName,HistoName,
00761                                                           Parameters.getParameter<int32_t>("Nbins"),
00762                                                           Parameters.getParameter<double>("xmin"),
00763                                                           Parameters.getParameter<double>("xmax"),
00764                                                           200, //that parameter should not be there !?
00765                                                           Parameters.getParameter<double>("ymin"),
00766                                                           Parameters.getParameter<double>("ymax"),
00767                                                           "" );
00768     subdetMEs.SubDetClusterApvProf->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70)",1);
00769   }
00770   
00771   // Total Number of Clusters vs ApvCycle - 2D 
00772   if(subdetswitchapvcycleth2on){
00773     edm::ParameterSet Parameters =  conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
00774     HistoName = "Cluster_vs_ApvCycle_2D__" + label;
00775     // Adjusting the scale for 2D histogram
00776     double h2ymax = 9999.0;     
00777     double yfact = Parameters.getParameter<double>("yfactor");
00778     if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
00779     else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
00780     else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
00781     else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
00782     
00783     subdetMEs.SubDetClusterApvTH2=dqmStore_->book2D(HistoName,HistoName,
00784                                                     Parameters.getParameter<int32_t>("Nbinsx"),
00785                                                     Parameters.getParameter<double>("xmin"),
00786                                                     Parameters.getParameter<double>("xmax"),
00787                                                     Parameters.getParameter<int32_t>("Nbinsy"),
00788                                                     Parameters.getParameter<double>("ymin"),
00789                                                     h2ymax);
00790     subdetMEs.SubDetClusterApvTH2->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70))",1);
00791     subdetMEs.SubDetClusterApvTH2->setAxisTitle("Total # of Clusters",2);
00792     
00793   }
00794   // Total Number of Cluster vs DeltaBxCycle - Profile
00795   if(subdetswitchdbxcycleprofon){
00796     edm::ParameterSet Parameters =  conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
00797     HistoName = "Cluster_vs_DeltaBxCycle__" + label;
00798     subdetMEs.SubDetClusterDBxCycleProf = dqmStore_->bookProfile(HistoName,HistoName,
00799                                                                  Parameters.getParameter<int32_t>("Nbins"),
00800                                                                  Parameters.getParameter<double>("xmin"),
00801                                                                  Parameters.getParameter<double>("xmax"),
00802                                                                  200, //that parameter should not be there !?
00803                                                                  Parameters.getParameter<double>("ymin"),
00804                                                                  Parameters.getParameter<double>("ymax"),
00805                                                                  "" );
00806     subdetMEs.SubDetClusterDBxCycleProf->setAxisTitle("Delta Bunch Crossing Cycle",1);
00807   }
00808   // DeltaBx vs ApvCycle - 2DProfile
00809   if(subdetswitchapvcycledbxprof2on){
00810     edm::ParameterSet Parameters =  conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
00811     HistoName = "DeltaBx_vs_ApvCycle__" + label;
00812     subdetMEs.SubDetApvDBxProf2 = dqmStore_->bookProfile2D(HistoName,HistoName,
00813                                                            Parameters.getParameter<int32_t>("Nbinsx"),
00814                                                            Parameters.getParameter<double>("xmin"),
00815                                                            Parameters.getParameter<double>("xmax"),
00816                                                            Parameters.getParameter<int32_t>("Nbinsy"),
00817                                                            Parameters.getParameter<double>("ymin"),
00818                                                            Parameters.getParameter<double>("ymax"),
00819                                                            Parameters.getParameter<double>("zmin"),
00820                                                            Parameters.getParameter<double>("zmax"),
00821                                                            "" );
00822     subdetMEs.SubDetApvDBxProf2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
00823     subdetMEs.SubDetApvDBxProf2->setAxisTitle("Delta Bunch Crossing Cycle",2);
00824   }
00825   SubDetMEsMap[label]=subdetMEs;
00826 }
00827 
00828 //
00829 // -- Fill Module Level Histograms
00830 //
00831 void SiStripMonitorCluster::fillModuleMEs(ModMEs& mod_mes, ClusterProperties& cluster) {
00832   
00833   if(moduleswitchclusposon && (mod_mes.ClusterPosition)) // position of cluster
00834     (mod_mes.ClusterPosition)->Fill(cluster.position);
00835   
00836   // position of digis in cluster
00837   if(moduleswitchclusdigiposon && (mod_mes.ClusterDigiPosition)) {
00838     for(int ipos=cluster.start+1; ipos<=cluster.start+cluster.width; ipos++){
00839       (mod_mes.ClusterDigiPosition)->Fill(ipos);
00840     }
00841   }
00842 
00843   if(moduleswitchcluswidthon && (mod_mes.ClusterWidth)) // width of cluster
00844     (mod_mes.ClusterWidth)->Fill(static_cast<float>(cluster.width));
00845  
00846   if(moduleswitchclusstonon && (mod_mes.ClusterSignalOverNoise)) {// SignalToNoise
00847     if (cluster.noise > 0) 
00848       (mod_mes.ClusterSignalOverNoise)->Fill(cluster.charge/cluster.noise);
00849   }
00850 
00851   if(moduleswitchclusstonVsposon && (mod_mes.ClusterSignalOverNoiseVsPos)) {// SignalToNoise
00852     if (cluster.noise > 0) 
00853       (mod_mes.ClusterSignalOverNoiseVsPos)->Fill(cluster.position,cluster.charge/cluster.noise);
00854   }
00855 
00856   if(moduleswitchclusnoiseon && (mod_mes.ClusterNoise))  // Noise
00857     (mod_mes.ClusterNoise)->Fill(cluster.noise);
00858 
00859   if(moduleswitchcluschargeon && (mod_mes.ClusterCharge)) // charge of cluster
00860     (mod_mes.ClusterCharge)->Fill(cluster.charge);
00861   
00862 } 
00863 //
00864 // -- Fill Layer Level MEs
00865 //
00866 void SiStripMonitorCluster::fillLayerMEs(LayerMEs& layerMEs, ClusterProperties& cluster, float timeinorbit) { 
00867   if(layerswitchclusstonon) {
00868     fillME(layerMEs.LayerClusterStoN  ,cluster.charge/cluster.noise);
00869     if (createTrendMEs) fillME(layerMEs.LayerClusterStoNTrend,timeinorbit,cluster.charge/cluster.noise);
00870   }
00871   
00872   if(layerswitchcluschargeon) {
00873     fillME(layerMEs.LayerClusterCharge,cluster.charge);
00874     if (createTrendMEs) fillME(layerMEs.LayerClusterChargeTrend,timeinorbit,cluster.charge);
00875   }
00876   
00877   if(layerswitchclusnoiseon) {
00878     fillME(layerMEs.LayerClusterNoise ,cluster.noise);
00879     if (createTrendMEs) fillME(layerMEs.LayerClusterNoiseTrend,timeinorbit,cluster.noise);
00880   }
00881   
00882   if(layerswitchcluswidthon) {
00883     fillME(layerMEs.LayerClusterWidth ,cluster.width);
00884     if (createTrendMEs) fillME(layerMEs.LayerClusterWidthTrend,timeinorbit,cluster.width);
00885   }
00886   
00887 }
00888 //------------------------------------------------------------------------------------------
00889 MonitorElement* SiStripMonitorCluster::bookMETrend(const char* ParameterSetLabel, const char* HistoName)
00890 {
00891   Parameters =  conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
00892   edm::ParameterSet ParametersTrend =  conf_.getParameter<edm::ParameterSet>("Trending");
00893   MonitorElement* me = dqmStore_->bookProfile(HistoName,HistoName,
00894                                               ParametersTrend.getParameter<int32_t>("Nbins"),
00895                                               //                                              0,
00896                                               ParametersTrend.getParameter<double>("xmin"),
00897                                               ParametersTrend.getParameter<double>("xmax"),
00898                                               //                                              ParametersTrend.getParameter<int32_t>("Nbins"),
00899                                               100, //that parameter should not be there !?
00900                                               ParametersTrend.getParameter<double>("ymin"),
00901                                               ParametersTrend.getParameter<double>("ymax"),
00902                                               "" );
00903   if(!me) return me;
00904   me->setAxisTitle("Event Time in Seconds",1);
00905   if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
00906   return me;
00907 }
00908 
00909 //------------------------------------------------------------------------------------------
00910 MonitorElement* SiStripMonitorCluster::bookME1D(const char* ParameterSetLabel, const char* HistoName)
00911 {
00912   Parameters =  conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
00913   return dqmStore_->book1D(HistoName,HistoName,
00914                            Parameters.getParameter<int32_t>("Nbinx"),
00915                            Parameters.getParameter<double>("xmin"),
00916                            Parameters.getParameter<double>("xmax")
00917                            );
00918 }
00919 
00920 
00921