CMS 3D CMS Logo

SiStripApvGainsDQM.cc
Go to the documentation of this file.
2 
3 #include "TCanvas.h"
4 
6  edm::RunNumber_t iRun,
7  edm::ParameterSet const &hPSet,
8  edm::ParameterSet const &fPSet,
9  const TrackerTopology *tTopo,
10  const TkDetMap *tkDetMap)
11  : SiStripBaseCondObjDQMGet<SiStripApvGain, SiStripApvGainRcd>{token, iRun, hPSet, fPSet, tTopo} {
12  if (HistoMaps_On_) {
13  Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "MeanApvGain_TkMap", 0.);
14  }
15 }
16 
18 
20  getConditionObject(eSetup);
22 }
23 
24 void SiStripApvGainsDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
25  ModMEs CondObj_ME;
26  for (const auto detIter : selectedDetIds) {
27  fillMEsForDet(CondObj_ME, detIter);
28  }
29 }
30 
31 void SiStripApvGainsDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
32  ModMEs selModME_ = _selModME_;
33  std::vector<uint32_t> DetIds;
34  condObj_->getDetIds(DetIds);
35 
36  const auto gainRange = condObj_->getRange(selDetId_);
37 
38  int nApv = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first;
39 
40  getModMEs(selModME_, selDetId_);
41 
42  for (int iapv = 0; iapv < nApv; ++iapv) {
43  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
44  selModME_.ProfileDistr->Fill(iapv + 1, condObj_->getApvGain(iapv, gainRange));
45  }
46  if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
47  selModME_.CumulDistr->Fill(condObj_->getApvGain(iapv, gainRange));
48  }
49 
50  // Fill the TkMap
51  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
52  fillTkMap(selDetId_, condObj_->getApvGain(iapv, gainRange));
53  }
54  }
55 }
56 
57 void SiStripApvGainsDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
58  for (const auto det : selectedDetIds) {
59  fillMEsForLayer(/*SummaryMEsMap_,*/ det);
60  }
61 
62  for (const auto &itm : SummaryMEsMap_) {
63  ModMEs selME = itm.second;
64  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") &&
65  fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")) {
66  TCanvas c1("c1");
67  selME.SummaryOfProfileDistr->getTProfile()->Draw();
68  std::string name(selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
69  name += ".png";
70  c1.Print(name.c_str());
71  }
72  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") &&
73  fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
74  TCanvas c1("c1");
75  selME.SummaryDistr->getTH1()->Draw();
77  name += ".png";
78  c1.Print(name.c_str());
79  }
80  }
81 }
82 
84  /*std::map<uint32_t, ModMEs> selMEsMap_, */ uint32_t selDetId_) {
85  int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
86 
87  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
88  edm::LogError("SiStripApvGainsDQM") << "[SiStripApvGainsDQM::fillMEsForLayer] WRONG INPUT : no such "
89  "subdetector type : "
90  << subdetectorId_ << " no folder set!" << std::endl;
91  return;
92  }
93  // ----
94 
95  const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
96  ModMEs selME_;
97  if (selMEsMapIter_ != SummaryMEsMap_.end())
98  selME_ = selMEsMapIter_->second;
99  getSummaryMEs(selME_, selDetId_);
100 
101  const auto gainRange = condObj_->getRange(selDetId_);
102  int nApv = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first;
103 
104  float meanApvGain = 0;
105 
107 
108  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
109  // --> profile summary
110  std::string hSummaryOfProfile_description;
111  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
112 
113  std::string hSummaryOfProfile_name;
114  hSummaryOfProfile_name =
115  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
116 
117  for (int iapv = 0; iapv < nApv; ++iapv) {
118  meanApvGain = meanApvGain + condObj_->getApvGain(iapv, gainRange);
119  selME_.SummaryOfProfileDistr->Fill(iapv + 1, condObj_->getApvGain(iapv, gainRange));
120 
121  // Fill the TkMap
122  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
123  fillTkMap(selDetId_, condObj_->getApvGain(iapv, gainRange));
124  }
125 
126  } // iapv
127 
128  meanApvGain = meanApvGain / nApv;
129 
130  // Fill the TkHistoMap with meanApvgain:
131  if (HistoMaps_On_)
132  Tk_HM_->setBinContent(selDetId_, meanApvGain);
133 
134  } // if Fill ...
135 
136  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
137  // --> summary
138  std::string hSummary_description;
139  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
140 
141  std::string hSummary_name;
142  hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
143 
144  // get detIds belonging to same layer to fill X-axis with detId-number
145 
146  std::vector<uint32_t> sameLayerDetIds_;
147 
148  sameLayerDetIds_.clear();
149 
150  sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
151 
152  unsigned int iBin = 0;
153  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
154  if (sameLayerDetIds_[i] == selDetId_) {
155  iBin = i + 1;
156  }
157  }
158 
159  for (int iapv = 0; iapv < nApv; ++iapv) {
160  meanApvGain = meanApvGain + condObj_->getApvGain(iapv, gainRange);
161  selME_.SummaryDistr->Fill(iBin, condObj_->getApvGain(iapv, gainRange));
162  } // iapv
163  meanApvGain = meanApvGain / nApv;
164 
165  // Fill the TkHistoMap with meanApvgain:
166  // if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
167 
168  } // if Fill ...
169 }
SiStripHistoId::createHistoLayer
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
Definition: SiStripHistoId.cc:51
SiStripApvGainsDQM::fillMEsForLayer
void fillMEsForLayer(uint32_t selDetId_) override
Definition: SiStripApvGainsDQM.cc:83
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
SiStripBaseCondObjDQM::hidmanager
SiStripHistoId hidmanager
Definition: SiStripBaseCondObjDQM.h:141
mps_fire.i
i
Definition: mps_fire.py:428
SiStripBaseCondObjDQM::ModMEs::CumulDistr
MonitorElement * CumulDistr
Definition: SiStripBaseCondObjDQM.h:74
SiStripBaseCondObjDQM::ModMEs::ProfileDistr
MonitorElement * ProfileDistr
Definition: SiStripBaseCondObjDQM.h:73
SiStripApvGainsDQM::~SiStripApvGainsDQM
~SiStripApvGainsDQM() override
Definition: SiStripApvGainsDQM.cc:17
SiStripApvGainsDQM::fillSummaryMEs
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds) override
Definition: SiStripApvGainsDQM.cc:57
TrackerTopology
Definition: TrackerTopology.h:16
SiStripBaseCondObjDQM::activeDetIds
std::vector< uint32_t > activeDetIds
Definition: SiStripBaseCondObjDQM.h:114
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
SiStripBaseCondObjDQM::ModMEs::SummaryOfProfileDistr
MonitorElement * SummaryOfProfileDistr
Definition: SiStripBaseCondObjDQM.h:75
SiStripBaseCondObjDQM::HistoMaps_On_
bool HistoMaps_On_
Definition: SiStripBaseCondObjDQM.h:100
SiStripApvGain::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripApvGain.cc:30
SiStripBaseCondObjDQM::SummaryMEsMap_
std::map< uint32_t, ModMEs > SummaryMEsMap_
Definition: SiStripBaseCondObjDQM.h:113
SiStripApvGainsDQM::SiStripApvGainsDQM
SiStripApvGainsDQM(edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > token, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet, const TrackerTopology *tTopo, const TkDetMap *tkDetMap)
Definition: SiStripApvGainsDQM.cc:5
SiStripApvGainsDQM::fillModMEs
void fillModMEs(const std::vector< uint32_t > &selectedDetIds) override
Definition: SiStripApvGainsDQM.cc:24
SiStripBaseCondObjDQM::ModMEs::SummaryDistr
MonitorElement * SummaryDistr
Definition: SiStripBaseCondObjDQM.h:77
SiStripBaseCondObjDQM::fillTkMap
void fillTkMap(const uint32_t &detid, const float &value)
Definition: SiStripBaseCondObjDQM.cc:1050
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
SiStripBaseCondObjDQM::getLayerNameAndId
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
Definition: SiStripBaseCondObjDQM.cc:828
SiStripBaseCondObjDQM::Tk_HM_
std::unique_ptr< TkHistoMap > Tk_HM_
Definition: SiStripBaseCondObjDQM.h:117
SiStripDetInfo::getNumberOfApvsAndStripLength
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
Definition: SiStripDetInfo.cc:19
SiStripBaseCondObjDQM::getModMEs
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
Definition: SiStripBaseCondObjDQM.cc:301
TkDetMap
Definition: TkDetMap.h:175
dqm::legacy::MonitorElement::getTProfile
virtual TProfile * getTProfile() const
Definition: MonitorElement.h:507
SiStripApvGainsDQM::getActiveDetIds
void getActiveDetIds(const edm::EventSetup &eSetup) override
Definition: SiStripApvGainsDQM.cc:19
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:475
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
SiStripBaseCondObjDQMGet
Definition: SiStripBaseCondObjDQM.h:148
SiStripBaseCondObjDQM::CondObj_fillId_
std::string CondObj_fillId_
Definition: SiStripBaseCondObjDQM.h:109
edm::ParameterSet
Definition: ParameterSet.h:47
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
SiStripApvGainsDQM::fillMEsForDet
void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_) override
Definition: SiStripApvGainsDQM.cc:31
edm::EventSetup
Definition: EventSetup.h:58
dqm::impl::MonitorElement::getTitle
virtual std::string getTitle() const
get MonitorElement title
Definition: MonitorElement.cc:683
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd >
SiStripBaseCondObjDQM::GetSameLayerDetId
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId)
Definition: SiStripBaseCondObjDQM.cc:1023
SiStripBaseCondObjDQM::detInfo_
SiStripDetInfo detInfo_
Definition: SiStripBaseCondObjDQM.h:94
SiStripApvGainRcd
Definition: SiStripCondDataRecords.h:8
SiStripBaseCondObjDQM::ModMEs
Definition: SiStripBaseCondObjDQM.h:64
SiStripHistoId
Definition: SiStripHistoId.h:25
SiStripBaseCondObjDQM::getSummaryMEs
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
Definition: SiStripBaseCondObjDQM.cc:334
SiStripApvGainsDQM.h
SiStripBaseCondObjDQM::fPSet_
edm::ParameterSet fPSet_
Definition: SiStripBaseCondObjDQM.h:97
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripBaseCondObjDQM::hPSet_
edm::ParameterSet hPSet_
Definition: SiStripBaseCondObjDQM.h:96
SiStripApvGain::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripApvGain.cc:53
SiStripBaseCondObjDQMGet< SiStripApvGain, SiStripApvGainRcd >::getConditionObject
void getConditionObject(const edm::EventSetup &eSetup) override
Definition: SiStripBaseCondObjDQM.h:159
SiStripBaseCondObjDQMGet< SiStripApvGain, SiStripApvGainRcd >::condObj_
const SiStripApvGain * condObj_
Definition: SiStripBaseCondObjDQM.h:163
SiStripApvGain
Definition: SiStripApvGain.h:25
SiStripApvGain::getApvGain
static float getApvGain(uint16_t apv, const Range &range)
Definition: SiStripApvGain.h:82
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316