CMS 3D CMS Logo

SiStripThresholdDQM.cc
Go to the documentation of this file.
4 
5 #include "TCanvas.h"
6 
7 // -----
9  edm::RunNumber_t iRun,
10  edm::ParameterSet const& hPSet,
11  edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, iRun, hPSet, fPSet){
12  WhichThreshold=hPSet.getParameter<std::string>("WhichThreshold");
13 
14  // Build the Histo_TkMap:
15  if(HistoMaps_On_ ){
16  edm::ESHandle<TkDetMap> tkDetMapHandle;
17  eSetup.get<TrackerTopologyRcd>().get(tkDetMapHandle);
18  const TkDetMap* tkDetMap = tkDetMapHandle.product();
19  if(WhichThreshold=="Low") Tk_HM_L = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map","LowThresh_TkMap",0.);
20  if(WhichThreshold=="High") Tk_HM_H = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map","HighThresh_TkMap",0.);
21  }
22 }
23 
24 // -----
25 
26 
27 
28 // -----
30 // -----
31 
32 
33 // -----
35 
36  getConditionObject(eSetup);
38 }
39 // -----
40 
41 //=====================================================================================
42 
43 
44 // -----
45 void SiStripThresholdDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds, const edm::EventSetup& es){
46 
47  //Retrieve tracker topology from geometry
49  es.get<TrackerTopologyRcd>().get(tTopoHandle);
50  const TrackerTopology* const tTopo = tTopoHandle.product();
51 
52  ModMEs CondObj_ME;
53 
54 
55  for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
56  detIter_!= selectedDetIds.end();detIter_++){
57 
58  fillMEsForDet(CondObj_ME,*detIter_,tTopo);
59 
60  }
61 }
62 // -----
63 
64 
65 
66 //======================================================================================
67 // -----
68 
69 
70 
71 void SiStripThresholdDQM::fillMEsForDet(const ModMEs& _selModME_, uint32_t selDetId_, const TrackerTopology* tTopo){
72  ModMEs selModME_ = _selModME_;
73  std::vector<uint32_t> DetIds;
74  thresholdHandle_->getDetIds(DetIds);
75 
76 
77  SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
78  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
79 
80 
81  getModMEs(selModME_,selDetId_,tTopo);
82 
83 
84 
85  for( int istrip=0;istrip<nStrip;++istrip){
86  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
87  if(WhichThreshold=="Low")
88  selModME_.ProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getLth());
89  if(WhichThreshold=="High")
90  selModME_.ProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getHth());
91  }
92  }// istrip
93 
94 
95 }
96 
97 
98 // -----
99 
100 
101 
102 //=======================================================================================
103 // -----
104 void SiStripThresholdDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds, const edm::EventSetup& es){
105 
106  //Retrieve tracker topology from geometry
107  edm::ESHandle<TrackerTopology> tTopoHandle;
108  es.get<TrackerTopologyRcd>().get(tTopoHandle);
109  const TrackerTopology* const tTopo = tTopoHandle.product();
110 
111  for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
112  detIter_!= selectedDetIds.end();detIter_++){
113  fillMEsForLayer(/*SummaryMEsMap_,*/ *detIter_,tTopo);
114 
115  }
116 
117 }
118 // -----
119 
120 
121 //=======================================================================================
122 // -----
123 void SiStripThresholdDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_, const TrackerTopology* tTopo){
124 
125  // ----
126  int subdetectorId_ = ((selDetId_>>25)&0x7);
127 
128  if( subdetectorId_<3 || subdetectorId_>6 ){
129  edm::LogError("SiStripThresholdDQM")
130  << "[SiStripThresholdDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
131  << subdetectorId_ << " no folder set!"
132  << std::endl;
133  return;
134  }
135  // ----
136 
137  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_,tTopo).second);
138  ModMEs selME_;
139  if ( selMEsMapIter_ != SummaryMEsMap_.end())
140  selME_ =selMEsMapIter_->second;
141 
142  getSummaryMEs(selME_,selDetId_,tTopo);
143 
144 
145  SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
146 
147  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
148 
150 
151 
152  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
153  // --> profile summary
154 
155  std::string hSummaryOfProfile_description;
156  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
157 
158  std::string hSummaryOfProfile_name;
159 
160  hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_,tTopo).first, "") ;
161 
162 
163 
164  for( int istrip=0;istrip<nStrip;++istrip){
165 
166  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
167  if(WhichThreshold=="Low"){
168  selME_.SummaryOfProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getLth());
169  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) fillTkMap(selDetId_, thresholdHandle_->getData(istrip,ThresholdRange).getLth());
170  }
171  if(WhichThreshold=="High"){
172  selME_.SummaryOfProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getHth());
173  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) fillTkMap(selDetId_, thresholdHandle_->getData(istrip,ThresholdRange).getHth());
174  }
175  }
176  }// istrip
177 
178 
179 
180  }//if Fill
181 
182 
183 
184  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
185 
186  // --> summary
187 
188  std::string hSummary_description;
189  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
190 
191  std::string hSummary_name;
192  hSummary_name = hidmanager.createHistoLayer(hSummary_description,
193  "layer",
194  getLayerNameAndId(selDetId_,tTopo).first,
195  "") ;
196 
197 
198  float meanLowThreshold=0;
199  float meanHighThreshold=0;
200 
201  for( int istrip=0;istrip<nStrip;++istrip){
202 
203  meanLowThreshold = meanLowThreshold + thresholdHandle_->getData(istrip,ThresholdRange).getLth();
204  meanHighThreshold = meanHighThreshold + thresholdHandle_->getData(istrip,ThresholdRange).getHth();
205  }//istrip
206 
207 
208  meanLowThreshold = meanLowThreshold/nStrip;
209  meanHighThreshold = meanHighThreshold/nStrip;
210 
211 
212  // -----
213  // get detIds belonging to same layer to fill X-axis with detId-number
214 
215  std::vector<uint32_t> sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_,tTopo);
216 
217  unsigned int iBin=0;
218  for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
219  if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
220  }
221 
222  if(WhichThreshold=="Low"){
223  selME_.SummaryDistr->Fill(iBin,meanLowThreshold);
224  if(HistoMaps_On_ ) Tk_HM_L->fill(selDetId_, meanLowThreshold);
225  }
226  if(WhichThreshold=="High"){
227  selME_.SummaryDistr->Fill(iBin,meanHighThreshold);
228  if(HistoMaps_On_ )Tk_HM_H->fill(selDetId_, meanHighThreshold);
229  }
230 
231  }//if Fill ...
232 
233 
234 
235 }
236 // -----
237 
std::unique_ptr< TkHistoMap > Tk_HM_L
T getParameter(std::string const &) const
void getConditionObject(const edm::EventSetup &eSetup) override
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::unique_ptr< TkHistoMap > Tk_HM_H
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
edm::ESHandle< SiStripThreshold > thresholdHandle_
void fillTkMap(const uint32_t &detid, const float &value)
void Fill(long long x)
U second(std::pair< T, U > const &p)
std::map< uint32_t, ModMEs > SummaryMEsMap_
SiStripDetInfoFileReader * reader
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es) override
void getActiveDetIds(const edm::EventSetup &eSetup) override
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId, const TrackerTopology *tTopo)
SiStripThreshold::Data getData(const uint16_t &strip, const Range &range) const
void fillModMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es) override
std::pair< ContainerIterator, ContainerIterator > Range
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_, const TrackerTopology *tTopo)
T get() const
Definition: EventSetup.h:63
std::vector< uint32_t > activeDetIds
void fillMEsForLayer(uint32_t selDetId_, const TrackerTopology *tTopo) override
unsigned int RunNumber_t
SiStripThresholdDQM(const edm::EventSetup &eSetup, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
const Range getRange(const uint32_t &detID) const
T const * product() const
Definition: ESHandle.h:86
void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_, const TrackerTopology *tTopo) override