CMS 3D CMS Logo

SiStripLorentzAngleDQM.cc
Go to the documentation of this file.
4 #include "TCanvas.h"
5 
7  edm::RunNumber_t iRun,
8  edm::ParameterSet const &hPSet,
9  edm::ParameterSet const &fPSet,
10  const TrackerTopology *tTopo,
11  const TkDetMap *tkDetMap)
13  if (HistoMaps_On_) {
14  Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "LA_TkMap", 0.);
15  }
16 }
17 
19 
21  getConditionObject(eSetup);
22 
23  std::map<uint32_t, float>::const_iterator LAMapIter_;
24  std::map<uint32_t, float> LAMap_ = condObj_->getLorentzAngles();
25 
26  for (LAMapIter_ = LAMap_.begin(); LAMapIter_ != LAMap_.end(); LAMapIter_++) {
27  activeDetIds.push_back((*LAMapIter_).first);
28  }
29 }
30 
31 void SiStripLorentzAngleDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
32  // -----
33  // LA on layer-level : fill at once all detIds belonging to same layer when
34  // encountering first detID in the layer
35 
36  bool fillNext = true;
37  for (unsigned int i = 0; i < selectedDetIds.size(); i++) {
38  int subDetId_ = DetId(selectedDetIds[i]).subdetId();
39  if (subDetId_ < 3 || subDetId_ > 6) {
40  edm::LogError("SiStripLorentzAngle")
41  << "[SiStripLorentzAngle::fillSummaryMEs] WRONG INPUT : no such "
42  "subdetector type : "
43  << subDetId_ << " and detId " << selectedDetIds[i] << " therefore no filling!" << std::endl;
44  } else if (SummaryOnLayerLevel_On_) {
45  if (fillNext) {
46  fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i]);
47  }
48  if (getLayerNameAndId(selectedDetIds[i + 1]) == getLayerNameAndId(selectedDetIds[i])) {
49  fillNext = false;
50  } else {
51  fillNext = true;
52  }
53  } else if (SummaryOnStringLevel_On_) {
54  if (fillNext) {
55  fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i]);
56  }
57  if (getStringNameAndId(selectedDetIds[i + 1]) == getStringNameAndId(selectedDetIds[i])) {
58  fillNext = false;
59  } else {
60  fillNext = true;
61  }
62  }
63  }
64 
65  for (std::map<uint32_t, ModMEs>::iterator iter = SummaryMEsMap_.begin(); iter != SummaryMEsMap_.end(); iter++) {
66  ModMEs selME;
67  selME = iter->second;
68 
70  if (fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")) {
71  TCanvas c1("c1");
72  selME.SummaryOfProfileDistr->getTProfile()->Draw();
73  std::string name(selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
74  name += ".png";
75  c1.Print(name.c_str());
76  }
77 
78  if (fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")) {
79  TCanvas c2("c2");
80  selME.SummaryOfCumulDistr->getTH1()->Draw();
82  name2 += ".png";
83  c2.Print(name2.c_str());
84  }
85 
86  } else {
87  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") &&
88  fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")) {
89  TCanvas c1("c1");
90  selME.SummaryOfProfileDistr->getTProfile()->Draw();
91  std::string name(selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
92  name += ".png";
93  c1.Print(name.c_str());
94  }
95 
96  if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") &&
97  fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")) {
98  TCanvas c1("c1");
99  selME.SummaryOfCumulDistr->getTH1()->Draw();
101  name += ".png";
102  c1.Print(name.c_str());
103  }
104  }
105  }
106 }
107 
109  /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_) {
111 
112  std::string hSummaryOfProfile_description;
113  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
114 
115  std::string hSummary_name;
116 
117  int subDetId_ = DetId(selDetId_).subdetId();
118 
119  if (subDetId_ < 3 || subDetId_ > 6) {
120  edm::LogError("SiStripLorentzAngleDQM") << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such "
121  "subdetector type : "
122  << subDetId_ << " no folder set!" << std::endl;
123  return;
124  }
125 
126  std::vector<uint32_t> sameLayerDetIds_;
127  sameLayerDetIds_.clear();
128 
129  if (SummaryOnStringLevel_On_) { // FILLING FOR STRING LEVEL
130 
131  hSummary_name =
132  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getStringNameAndId(selDetId_).first, "");
133  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getStringNameAndId(selDetId_).second);
134 
135  ModMEs selME_;
136  if (selMEsMapIter_ != SummaryMEsMap_.end())
137  selME_ = selMEsMapIter_->second;
138 
139  getSummaryMEs(selME_, selDetId_);
140 
141  // -----
142  sameLayerDetIds_.clear();
143 
144  switch (DetId(selDetId_).subdetId()) {
146  if (tTopo_->tibIsInternalString(selDetId_)) {
148  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tibLayer(selDetId_), 0, 1, tTopo_->tibString(selDetId_));
149  }
150  if (tTopo_->tibIsExternalString(selDetId_)) {
152  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tibLayer(selDetId_), 0, 2, tTopo_->tibString(selDetId_));
153  }
154  break;
156  SiStripSubStructure::getTIDDetectors(activeDetIds, sameLayerDetIds_, tTopo_, 0, 0, 0, 0);
157  break;
160  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tobLayer(selDetId_), 0, tTopo_->tobRod(selDetId_));
161  break;
163  SiStripSubStructure::getTECDetectors(activeDetIds, sameLayerDetIds_, tTopo_, 0, 0, 0, 0, 0, 0);
164  break;
165  }
166 
167  // -----
168 
169  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
170  selME_.SummaryOfProfileDistr->Fill(i + 1, condObj_->getLorentzAngle(sameLayerDetIds_[i]));
171 
172  // Fill the Histo_TkMap+TkMap with the LA:
173  if (HistoMaps_On_)
174  Tk_HM_->fill(sameLayerDetIds_[i], condObj_->getLorentzAngle(sameLayerDetIds_[i]));
175 
176  std::cout << sameLayerDetIds_[i] << "\t" << condObj_->getLorentzAngle(sameLayerDetIds_[i]) << std::endl;
177 
178  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
179  fillTkMap(sameLayerDetIds_[i], condObj_->getLorentzAngle(sameLayerDetIds_[i]));
180  }
181  }
182 
183  std::string hSummaryOfCumul_description;
184  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
185 
186  std::string hSummaryOfCumul_name;
187 
188  if (subDetId_ < 3 || subDetId_ > 6) {
189  edm::LogError("SiStripLorentzAngleDQM") << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such "
190  "subdetector type : "
191  << subDetId_ << " no folder set!" << std::endl;
192  return;
193  }
194 
195  hSummaryOfCumul_name =
196  hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "");
197 
198  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
199  selME_.SummaryOfCumulDistr->Fill(condObj_->getLorentzAngle(sameLayerDetIds_[i]));
200  }
201  } // FILLING FOR STRING LEVEL
202 
203  else { // FILLING FOR LAYER LEVEL
204 
205  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
206 
207  ModMEs selME_;
208  if (selMEsMapIter_ != SummaryMEsMap_.end())
209  selME_ = selMEsMapIter_->second;
210 
211  getSummaryMEs(selME_, selDetId_);
212 
213  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
214  hSummary_name =
215  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
216 
217  // -----
218  sameLayerDetIds_.clear();
219 
220  sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
221 
222  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
223  selME_.SummaryOfProfileDistr->Fill(i + 1, condObj_->getLorentzAngle(sameLayerDetIds_[i]));
224 
225  // Fill the Histo_TkMap with LA:
226  if (HistoMaps_On_)
227  Tk_HM_->fill(sameLayerDetIds_[i], condObj_->getLorentzAngle(sameLayerDetIds_[i]));
228 
229  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
230  fillTkMap(sameLayerDetIds_[i], condObj_->getLorentzAngle(sameLayerDetIds_[i]));
231  }
232  }
233  } // if Fill ...
234 
235  if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")) {
236  std::string hSummaryOfCumul_description;
237  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
238 
239  std::string hSummaryOfCumul_name;
240 
241  if (subDetId_ < 3 || subDetId_ > 6) {
242  edm::LogError("SiStripLorentzAngleDQM") << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no "
243  "such subdetector type : "
244  << subDetId_ << " no folder set!" << std::endl;
245  return;
246  }
247 
248  hSummaryOfCumul_name =
249  hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(selDetId_).first, "");
250 
251  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
252  selME_.SummaryOfCumulDistr->Fill(condObj_->getLorentzAngle(sameLayerDetIds_[i]));
253  }
254  } // if Fill ...
255  } // FILLING FOR LAYER LEVEL
256 }
static constexpr auto TEC
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
unsigned int tobLayer(const DetId &id) const
void getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, const TrackerTopology *trackerTopology, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0)
virtual TProfile * getTProfile() const
const TrackerTopology * tTopo_
bool tibIsExternalString(const DetId &id) const
unsigned int tibString(const DetId &id) const
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, const TrackerTopology *trackerTopology, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0)
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, const TrackerTopology *trackerTopology, uint32_t side=0, uint32_t wheel=0, uint32_t petal_bkw_frw=0, uint32_t petal=0, uint32_t ring=0, uint32_t ster=0)
Log< level::Error, false > LogError
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_
void getActiveDetIds(const edm::EventSetup &eSetup) override
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
virtual std::string getTitle() const
get MonitorElement title
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds) override
Definition: DetId.h:17
float getLorentzAngle(const uint32_t &) const
static constexpr auto TIB
std::pair< std::string, uint32_t > getStringNameAndId(const uint32_t &detId_)
bool tibIsInternalString(const DetId &id) const
unsigned int tobRod(const DetId &id) const
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
virtual TH1 * getTH1() const
SiStripLorentzAngleDQM(edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > token, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet, const TrackerTopology *tTopo, const TkDetMap *tkDetMap)
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId)
std::vector< uint32_t > activeDetIds
unsigned int RunNumber_t
unsigned int tibLayer(const DetId &id) const
void getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, const TrackerTopology *trackerTopology, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0)
const std::map< unsigned int, float > & getLorentzAngles() 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_)
void fillMEsForLayer(uint32_t selDetId_) override
static constexpr auto TID
std::unique_ptr< TkHistoMap > Tk_HM_