00001 #include "DQM/SiStripMonitorSummary/interface/SiStripNoisesDQM.h"
00002
00003
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005
00006
00007 SiStripNoisesDQM::SiStripNoisesDQM(const edm::EventSetup & eSetup,
00008 edm::ParameterSet const& hPSet,
00009 edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
00010 gainRenormalisation_ = hPSet_.getParameter<bool>("GainRenormalisation");
00011 if( gainRenormalisation_){ eSetup.get<SiStripApvGainRcd>().get(gainHandle_);}
00012 }
00013
00014
00015
00016 SiStripNoisesDQM::~SiStripNoisesDQM(){}
00017
00018
00019
00020
00021 void SiStripNoisesDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00022
00023 getConditionObject(eSetup);
00024 noiseHandle_->getDetIds(activeDetIds);
00025 selectModules(activeDetIds);
00026
00027 }
00028
00029
00030
00031
00032 void SiStripNoisesDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds){
00033
00034 ModMEs CondObj_ME;
00035
00036 for(std::vector<uint32_t>::const_iterator detIter_=selectedDetIds.begin();
00037 detIter_!=selectedDetIds.end();++detIter_){
00038 fillMEsForDet(CondObj_ME,*detIter_);
00039 }
00040 }
00041
00042
00043
00044
00045 void SiStripNoisesDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
00046
00047 std::vector<uint32_t> DetIds;
00048 noiseHandle_->getDetIds(DetIds);
00049
00050 SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
00051
00052 int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00053
00054 getModMEs(selModME_,selDetId_);
00055
00056 float gainFactor;
00057
00058 for( int istrip=0;istrip<nStrip;++istrip){
00059 try{
00060 if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00061 if( gainRenormalisation_){
00062 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00063 gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00064 selModME_.ProfileDistr->Fill(istrip+1,noiseHandle_->getNoise(istrip,noiseRange)/gainFactor);
00065 }
00066 else{
00067 selModME_.ProfileDistr->Fill(istrip+1,noiseHandle_->getNoise(istrip,noiseRange));
00068 }
00069 }
00070 if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00071 if( gainRenormalisation_){
00072 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00073 gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00074 selModME_.CumulDistr->Fill(noiseHandle_->getNoise(istrip,noiseRange)/gainFactor);
00075 }
00076 else {
00077 selModME_.CumulDistr ->Fill(noiseHandle_->getNoise(istrip,noiseRange));
00078 }
00079 }
00080 }
00081 catch(cms::Exception& e){
00082 edm::LogError("SiStripNoisesDQM")
00083 << "[SiStripNoisesDQM::fillMEsForDet] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
00084 << istrip
00085 << " and detid "
00086 << selDetId_
00087 << " : "
00088 << e.what() ;
00089 }
00090 }
00091 }
00092
00093
00094 void SiStripNoisesDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
00095
00096 for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00097 detIter_!= selectedDetIds.end();detIter_++){
00098 fillMEsForLayer(SummaryMEsMap_, *detIter_);
00099
00100 }
00101 }
00102
00103
00104
00105
00106 void SiStripNoisesDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00107
00108
00109 int subdetectorId_ = ((selDetId_>>25)&0x7);
00110
00111 if( subdetectorId_<3 ||subdetectorId_>6 ){
00112 edm::LogError("SiStripNoisesDQM")
00113 << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00114 << subdetectorId_ << " no folder set!"
00115 << std::endl;
00116 return;
00117 }
00118
00119
00120 std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00121 ModMEs selME_;
00122 selME_ =selMEsMapIter_->second;
00123 getSummaryMEs(selME_,selDetId_);
00124
00125 SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
00126 int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00127
00128 SiStripHistoId hidmanager;
00129 float gainFactor=1;
00130
00131 if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00132
00133 std::string hSummaryOfProfile_description;
00134 hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00135
00136 std::string hSummaryOfProfile_name;
00137 hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description,
00138 "layer",
00139 getLayerNameAndId(selDetId_).first,
00140 "") ;
00141 for( int istrip=0;istrip<nStrip;++istrip){
00142
00143 try{
00144 if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00145 if(gainRenormalisation_ ){
00146 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00147 gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00148 selME_.SummaryOfProfileDistr->Fill(istrip+1,noiseHandle_->getNoise(istrip,noiseRange)/gainFactor);
00149 }
00150 else{
00151 selME_.SummaryOfProfileDistr->Fill(istrip+1,noiseHandle_->getNoise(istrip,noiseRange));
00152 }
00153 }
00154 }
00155 catch(cms::Exception& e){
00156 edm::LogError("SiStripNoisesDQM")
00157 << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
00158 << istrip
00159 << " and detid "
00160 << selDetId_
00161 << " : "
00162 << e.what() ;
00163 }
00164 }
00165 }
00166
00167 if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00168
00169 std::string hSummary_description;
00170 hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
00171
00172 std::string hSummary_name;
00173 hSummary_name = hidmanager.createHistoLayer(hSummary_description,
00174 "layer",
00175 getLayerNameAndId(selDetId_).first,
00176 "") ;
00177 gainFactor=1;
00178
00179 float meanNoise=0;
00180
00181 for( int istrip=0;istrip<nStrip;++istrip){
00182
00183 if( gainRenormalisation_){
00184 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00185 gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00186 try{
00187 meanNoise = meanNoise +noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
00188 }
00189 catch(cms::Exception& e){
00190 edm::LogError("SiStripNoisesDQM")
00191 << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
00192 << istrip
00193 << "and detid "
00194 << selDetId_
00195 << " : "
00196 << e.what() ;
00197 }
00198 }
00199 else {
00200 try{
00201 meanNoise = meanNoise +noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
00202 }
00203 catch(cms::Exception& e){
00204 edm::LogError("SiStripNoisesDQM")
00205 << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
00206 << istrip
00207 << "and detid "
00208 << selDetId_
00209 << " : "
00210 << e.what() ;
00211 }
00212 }
00213 }
00214 meanNoise = meanNoise/nStrip;
00215
00216
00217 std::vector<uint32_t> sameLayerDetIds_;
00218
00219 sameLayerDetIds_.clear();
00220
00221 sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00222
00223
00224 unsigned int iBin=0;
00225 for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
00226 if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
00227 }
00228 selME_.SummaryDistr->Fill(iBin,meanNoise);
00229
00230
00231 }
00232
00234 if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00235 std::string hSummaryOfCumul_description;
00236 hSummaryOfCumul_description = hPSet_.getParameter<std::string>("Cumul_description");
00237
00238 std::string hSummaryOfCumul_name;
00239 hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;
00240
00241 for( int istrip=0;istrip<nStrip;++istrip){
00242 try{
00243 if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00244 if(gainRenormalisation_){
00245 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00246 gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00247 selME_.SummaryOfCumulDistr->Fill(noiseHandle_->getNoise(istrip,noiseRange)/gainFactor);
00248 }
00249 else{
00250 selME_.SummaryOfCumulDistr->Fill(noiseHandle_->getNoise(istrip,noiseRange));
00251 }
00252 }
00253 }
00254 catch(cms::Exception& e){
00255 edm::LogError("SiStripNoisesDQM")
00256 << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
00257 << istrip
00258 << "and detid "
00259 << selDetId_
00260 << " : "
00261 << e.what() ;
00262 }
00263 }
00264 }
00265
00266 }
00267
00268
00269
00270