CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripNoisesDQM.cc
Go to the documentation of this file.
2 
4  edm::RunNumber_t iRun,
5  edm::ParameterSet const &hPSet,
6  edm::ParameterSet const &fPSet,
7  const TrackerTopology *tTopo,
8  const TkDetMap *tkDetMap,
9  const SiStripApvGain *gainHandle)
10  : SiStripBaseCondObjDQMGet<SiStripNoises, SiStripNoisesRcd>{noiseToken, iRun, hPSet, fPSet, tTopo},
11  gainHandle_{gainHandle} {
12  // Build the Histo_TkMap:
13  if (HistoMaps_On_) {
14  Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "MeanNoise_TkMap", 0.);
15  }
16 }
17 
19 
21  getConditionObject(eSetup);
23 }
24 
25 void SiStripNoisesDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
26  ModMEs selModME_ = _selModME_;
27  std::vector<uint32_t> DetIds;
28  condObj_->getDetIds(DetIds);
29 
30  const auto noiseRange = condObj_->getRange(selDetId_);
31 
32  int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
33 
34  getModMEs(selModME_, selDetId_);
35 
36  float gainFactor;
37  float stripnoise;
38 
39  SiStripApvGain::Range gainRange;
40  if (gainHandle_) {
41  gainRange = gainHandle_->getRange(selDetId_);
42  }
43 
44  for (int istrip = 0; istrip < nStrip; ++istrip) {
45  if (gainHandle_)
46  gainFactor = gainHandle_->getStripGain(istrip, gainRange) ? gainHandle_->getStripGain(istrip, gainRange) : 1.;
47  else
48  gainFactor = 1;
49 
50  stripnoise = condObj_->getNoise(istrip, noiseRange) / gainFactor;
51  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
52  selModME_.ProfileDistr->Fill(istrip + 1, stripnoise);
53  }
54  if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
55  selModME_.CumulDistr->Fill(stripnoise);
56  }
57  } // istrip
58 }
59 
60 // -----
61 // FIXME too long. factorize this method.
62 // FIXME the number of lines of code in the derived classes should be reduced
63 // ONLY at what cannot be done in the base class because of the specific
64 // implementation
65 // FIXME of the derived class. Moreover, several loops on the same quantities
66 // should be avoided...
67 
69  /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_) {
70  // ----
71  int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
72 
73  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
74  edm::LogError("SiStripNoisesDQM") << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such "
75  "subdetector type : "
76  << subdetectorId_ << " no folder set!" << std::endl;
77  return;
78  }
79  // ----
80 
81  const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
82  ModMEs selME_;
83  if (selMEsMapIter_ != SummaryMEsMap_.end())
84  selME_ = selMEsMapIter_->second;
85  getSummaryMEs(selME_, selDetId_);
86 
87  const auto noiseRange = condObj_->getRange(selDetId_);
88  int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
89 
90  float stripnoise = -1.;
91  float meanNoise = 0;
92  int Nbadstrips = 0;
93 
94  SiStripApvGain::Range gainRange;
95  if (gainHandle_) {
96  gainRange = gainHandle_->getRange(selDetId_);
97  }
98  float gainFactor = 1;
99 
101 
102  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
103  // --> profile summary
104  std::string hSummaryOfProfile_description;
105  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
106 
107  std::string hSummaryOfProfile_name;
108  hSummaryOfProfile_name =
109  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
110  }
111  if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")) {
112  std::string hSummaryOfCumul_description;
113  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("Cumul_description");
114 
115  std::string hSummaryOfCumul_name;
116  hSummaryOfCumul_name =
117  hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "");
118  }
119  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
120  // --> cumul summary
121  std::string hSummary_description;
122  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
123 
124  std::string hSummary_name;
125  hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
126  }
127 
128  for (int istrip = 0; istrip < nStrip; ++istrip) {
129  if (gainHandle_) {
130  gainFactor = gainHandle_->getStripGain(istrip, gainRange) ? gainHandle_->getStripGain(istrip, gainRange) : 1.;
131  } else {
132  gainFactor = 1.;
133  }
134 
135  stripnoise = condObj_->getNoise(istrip, noiseRange) / gainFactor;
136  meanNoise += stripnoise;
137  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
138  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
139  selME_.SummaryOfProfileDistr->Fill(istrip + 1, stripnoise);
140  }
141  }
142 
143  if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")) {
144  if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
145  selME_.SummaryOfCumulDistr->Fill(stripnoise);
146  }
147  }
148 
149  // Fill the TkMap
150  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
151  fillTkMap(selDetId_, stripnoise);
152  }
153 
154  } // istrip
155 
156  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
157  meanNoise = meanNoise / (nStrip - Nbadstrips);
158  // get detIds belonging to same layer to fill X-axis with detId-number
159 
160  std::vector<uint32_t> sameLayerDetIds_;
161  sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
162 
163  std::vector<uint32_t>::const_iterator ibound =
164  lower_bound(sameLayerDetIds_.begin(), sameLayerDetIds_.end(), selDetId_);
165  if (ibound != sameLayerDetIds_.end() && *ibound == selDetId_)
166  selME_.SummaryDistr->Fill(ibound - sameLayerDetIds_.begin() + 1, meanNoise);
167 
168  // Fill the Histo_TkMap with the mean Noise:
169  if (HistoMaps_On_) {
170  Tk_HM_->fill(selDetId_, meanNoise);
171  }
172 
173  // Check the axis range for tkmap, and in case redefine;
174  int intNoise = int(meanNoise);
175  if (intNoise + 1 > (int)tkMapScaler.size()) {
176  tkMapScaler.resize(intNoise + 1, 0);
177  }
178  tkMapScaler[intNoise]++;
179  }
180 }
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
void fillMEsForLayer(uint32_t selDetId_) override
const SiStripApvGain * gainHandle_
std::vector< int > tkMapScaler
Log< level::Error, false > LogError
void fillTkMap(const uint32_t &detid, const float &value)
U second(std::pair< T, U > const &p)
std::map< uint32_t, ModMEs > SummaryMEsMap_
static float getNoise(uint16_t strip, const Range &range)
Definition: SiStripNoises.h:73
~SiStripNoisesDQM() override
std::pair< ContainerIterator, ContainerIterator > Range
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void getActiveDetIds(const edm::EventSetup &eSetup) override
SiStripNoisesDQM(edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet, const TrackerTopology *tTopo, const TkDetMap *tkDetMap, const SiStripApvGain *gainHandle)
void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_) override
std::pair< std::string, uint32_t > getStringNameAndId(const uint32_t &detId_)
void getDetIds(std::vector< uint32_t > &DetIds_) const
void getConditionObject(const edm::EventSetup &eSetup) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId)
static float getStripGain(uint16_t strip, const Range &range)
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
const Range getRange(const uint32_t detID) const
std::vector< uint32_t > activeDetIds
unsigned int RunNumber_t
const Range getRange(const uint32_t detID) const
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
std::unique_ptr< TkHistoMap > Tk_HM_