CMS 3D CMS Logo

MillePedeDQMModule.cc
Go to the documentation of this file.
1 
9 /*** header-file ***/
11 
12 /*** ROOT objects ***/
13 #include "TH1F.h"
14 
15 /*** Core framework functionality ***/
19 
20 /*** Geometry ***/
24 
25 /*** Alignment ***/
29 
30 /*** Thresholds from DB ***/
32 
33 /*** Necessary Framework infrastructure ***/
36 
38  : mpReaderConfig_(config.getParameter<edm::ParameterSet>("MillePedeFileReader")) {
39  consumes<AlignmentToken, edm::InProcess>(config.getParameter<edm::InputTag>("alignmentTokenSrc"));
40 }
41 
43 
44 //=============================================================================
45 //=== INTERFACE IMPLEMENTATION ===
46 //=============================================================================
47 
49  edm::LogInfo("MillePedeDQMModule") << "Booking histograms";
50 
51  booker.cd();
52  booker.setCurrentFolder("AlCaReco/SiPixelAli/");
53 
54  h_xPos = booker.book1D("Xpos", "Alignment fit #DeltaX;;#mum", 36, 0., 36.);
55  h_xRot = booker.book1D("Xrot", "Alignment fit #Delta#theta_{X};;#murad", 36, 0., 36.);
56  h_yPos = booker.book1D("Ypos", "Alignment fit #DeltaY;;#mum", 36, 0., 36.);
57  h_yRot = booker.book1D("Yrot", "Alignment fit #Delta#theta_{Y};;#murad", 36, 0., 36.);
58  h_zPos = booker.book1D("Zpos", "Alignment fit #DeltaZ;;#mum", 36, 0., 36.);
59  h_zRot = booker.book1D("Zrot", "Alignment fit #Delta#theta_{Z};;#murad", 36, 0., 36.);
60 
61  statusResults = booker.book2D("statusResults", "Status of SiPixelAli PCL workflow;;", 6, 0., 6., 1, 0., 1.);
62  binariesAvalaible = booker.bookInt("BinariesFound");
63  exitCode = booker.bookString("PedeExitCode", "");
64 
65  booker.cd();
66 }
67 
69  bookHistograms(booker);
70  if (mpReader_) {
71  mpReader_->read();
72  } else {
73  throw cms::Exception("LogicError") << "@SUB=MillePedeDQMModule::dqmEndJob\n"
74  << "Try to read MillePede results before initializing MillePedeFileReader";
75  }
78  binariesAvalaible->Fill(mpReader_->binariesAmount());
79  auto theResults = mpReader_->getResults();
80  std::string exitCodeStr = theResults.getExitMessage();
81  exitCode->Fill(exitCodeStr);
82 }
83 
84 //=============================================================================
85 //=== PRIVATE METHOD IMPLEMENTATION ===
86 //=============================================================================
87 
89  if (!setupChanged(setup))
90  return;
91 
93  setup.get<TrackerTopologyRcd>().get(tTopo);
94  edm::ESHandle<GeometricDet> geometricDet;
95  setup.get<IdealGeometryRecord>().get(geometricDet);
97  setup.get<PTrackerParametersRcd>().get(ptp);
98 
99  // take the thresholds from DB
100  edm::ESHandle<AlignPCLThresholds> thresholdHandle;
101  setup.get<AlignPCLThresholdsRcd>().get(thresholdHandle);
102  auto thresholds_ = thresholdHandle.product();
103 
104  auto myThresholds = std::make_shared<AlignPCLThresholds>();
105  myThresholds->setAlignPCLThresholds(thresholds_->getNrecords(), thresholds_->getThreshold_Map());
106 
108 
109  const auto trackerGeometry = builder.build(&(*geometricDet), *ptp, &(*tTopo));
110  tracker_ = std::make_unique<AlignableTracker>(trackerGeometry, &(*tTopo));
111 
112  const std::string labelerPlugin{"PedeLabeler"};
113  edm::ParameterSet labelerConfig{};
114  labelerConfig.addUntrackedParameter("plugin", labelerPlugin);
115  labelerConfig.addUntrackedParameter("RunRangeSelection", edm::VParameterSet{});
116 
117  std::shared_ptr<PedeLabelerBase> pedeLabeler{PedeLabelerPluginFactory::get()->create(
118  labelerPlugin, PedeLabelerBase::TopLevelAlignables(tracker_.get(), nullptr, nullptr), labelerConfig)};
119 
120  mpReader_ = std::make_unique<MillePedeFileReader>(
121  mpReaderConfig_, pedeLabeler, std::shared_ptr<const AlignPCLThresholds>(myThresholds));
122 }
123 
125  TH2F* histo_status = statusHisto->getTH2F();
126  auto theResults = mpReader_->getResults();
127  theResults.print();
128  histo_status->SetBinContent(1, 1, theResults.getDBUpdated());
129  histo_status->GetXaxis()->SetBinLabel(1, "DB updated");
130  histo_status->SetBinContent(2, 1, theResults.exceedsCutoffs());
131  histo_status->GetXaxis()->SetBinLabel(2, "significant movement");
132  histo_status->SetBinContent(3, 1, theResults.getDBVetoed());
133  histo_status->GetXaxis()->SetBinLabel(3, "DB update vetoed");
134  histo_status->SetBinContent(4, 1, !theResults.exceedsThresholds());
135  histo_status->GetXaxis()->SetBinLabel(4, "within max movement");
136  histo_status->SetBinContent(5, 1, !theResults.exceedsMaxError());
137  histo_status->GetXaxis()->SetBinLabel(5, "within max error");
138  histo_status->SetBinContent(6, 1, !theResults.belowSignificance());
139  histo_status->GetXaxis()->SetBinLabel(6, "above significance");
140 }
141 
143  std::array<double, 6> Xcut_, sigXcut_, maxMoveXcut_, maxErrorXcut_;
144  std::array<double, 6> tXcut_, sigtXcut_, maxMovetXcut_, maxErrortXcut_;
145 
146  std::array<double, 6> Ycut_, sigYcut_, maxMoveYcut_, maxErrorYcut_;
147  std::array<double, 6> tYcut_, sigtYcut_, maxMovetYcut_, maxErrortYcut_;
148 
149  std::array<double, 6> Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_;
150  std::array<double, 6> tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_;
151 
152  auto myMap = mpReader_->getThresholdMap();
153 
154  std::vector<std::string> alignablesList;
155  for (auto it = myMap.begin(); it != myMap.end(); ++it) {
156  alignablesList.push_back(it->first);
157  }
158 
159  for (auto& alignable : alignablesList) {
160  int detIndex = getIndexFromString(alignable);
161 
162  Xcut_[detIndex] = myMap[alignable].getXcut();
163  sigXcut_[detIndex] = myMap[alignable].getSigXcut();
164  maxMoveXcut_[detIndex] = myMap[alignable].getMaxMoveXcut();
165  maxErrorXcut_[detIndex] = myMap[alignable].getErrorXcut();
166 
167  Ycut_[detIndex] = myMap[alignable].getYcut();
168  sigYcut_[detIndex] = myMap[alignable].getSigYcut();
169  maxMoveYcut_[detIndex] = myMap[alignable].getMaxMoveYcut();
170  maxErrorYcut_[detIndex] = myMap[alignable].getErrorYcut();
171 
172  Zcut_[detIndex] = myMap[alignable].getZcut();
173  sigZcut_[detIndex] = myMap[alignable].getSigZcut();
174  maxMoveZcut_[detIndex] = myMap[alignable].getMaxMoveZcut();
175  maxErrorZcut_[detIndex] = myMap[alignable].getErrorZcut();
176 
177  tXcut_[detIndex] = myMap[alignable].getThetaXcut();
178  sigtXcut_[detIndex] = myMap[alignable].getSigThetaXcut();
179  maxMovetXcut_[detIndex] = myMap[alignable].getMaxMoveThetaXcut();
180  maxErrortXcut_[detIndex] = myMap[alignable].getErrorThetaXcut();
181 
182  tYcut_[detIndex] = myMap[alignable].getThetaYcut();
183  sigtYcut_[detIndex] = myMap[alignable].getSigThetaYcut();
184  maxMovetYcut_[detIndex] = myMap[alignable].getMaxMoveThetaYcut();
185  maxErrortYcut_[detIndex] = myMap[alignable].getErrorThetaYcut();
186 
187  tZcut_[detIndex] = myMap[alignable].getThetaZcut();
188  sigtZcut_[detIndex] = myMap[alignable].getSigThetaZcut();
189  maxMovetZcut_[detIndex] = myMap[alignable].getMaxMoveThetaZcut();
190  maxErrortZcut_[detIndex] = myMap[alignable].getErrorThetaZcut();
191  }
192 
193  fillExpertHisto(h_xPos, Xcut_, sigXcut_, maxMoveXcut_, maxErrorXcut_, mpReader_->getXobs(), mpReader_->getXobsErr());
195  h_xRot, tXcut_, sigtXcut_, maxMovetXcut_, maxErrortXcut_, mpReader_->getTXobs(), mpReader_->getTXobsErr());
196 
197  fillExpertHisto(h_yPos, Ycut_, sigYcut_, maxMoveYcut_, maxErrorYcut_, mpReader_->getYobs(), mpReader_->getYobsErr());
199  h_yRot, tYcut_, sigtYcut_, maxMovetYcut_, maxErrortYcut_, mpReader_->getTYobs(), mpReader_->getTYobsErr());
200 
201  fillExpertHisto(h_zPos, Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_, mpReader_->getZobs(), mpReader_->getZobsErr());
203  h_zRot, tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_, mpReader_->getTZobs(), mpReader_->getTZobsErr());
204 }
205 
207  const std::array<double, 6>& cut,
208  const std::array<double, 6>& sigCut,
209  const std::array<double, 6>& maxMoveCut,
210  const std::array<double, 6>& maxErrorCut,
211  const std::array<double, 6>& obs,
212  const std::array<double, 6>& obsErr) {
213  TH1F* histo_0 = histo->getTH1F();
214 
215  double max_ = *std::max_element(maxMoveCut.begin(), maxMoveCut.end());
216 
217  histo_0->SetMinimum(-(max_));
218  histo_0->SetMaximum(max_);
219 
220  // Schematics of the bin contents
221  //
222  // XX XX XX XX XX XX OO OO OO OO II II II II
223  // |--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|
224  // | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17| ...
225  //
226  // |-----------------| |-----------| |-----------|
227  // |observed movement| |thresholds1| |thresholds2|
228 
229  for (size_t i = 0; i < obs.size(); ++i) {
230  // fist obs.size() bins for observed movements
231  histo_0->SetBinContent(i + 1, obs[i]);
232  histo_0->SetBinError(i + 1, obsErr[i]);
233 
234  // then at bin 8,8+5,8+10,... for cutoffs
235  // 5 bins is the space allocated for the 4 other thresholds + 1 empty separation bin
236  histo_0->SetBinContent(8 + i * 5, cut[i]);
237 
238  // then at bin 9,9+5,9+10,... for significances
239  histo_0->SetBinContent(9 + i * 5, sigCut[i]);
240 
241  // then at bin 10,10+5,10+10,... for maximum movements
242  histo_0->SetBinContent(10 + i * 5, maxMoveCut[i]);
243 
244  // then at bin 11,11+5,11+10,... for maximum errors
245  histo_0->SetBinContent(11 + i * 5, maxErrorCut[i]);
246  }
247 }
248 
250  bool changed{false};
251 
253  changed = true;
255  changed = true;
257  changed = true;
258 
259  return changed;
260 }
261 
263  if (alignableId == "TPBHalfBarrelXminus") {
264  return 3;
265  } else if (alignableId == "TPBHalfBarrelXplus") {
266  return 2;
267  } else if (alignableId == "TPEHalfCylinderXminusZminus") {
268  return 1;
269  } else if (alignableId == "TPEHalfCylinderXplusZminus") {
270  return 0;
271  } else if (alignableId == "TPEHalfCylinderXminusZplus") {
272  return 5;
273  } else if (alignableId == "TPEHalfCylinderXplusZplus") {
274  return 4;
275  } else {
276  throw cms::Exception("LogicError") << "@SUB=MillePedeDQMModule::getIndexFromString\n"
277  << "Retrieving conversion for not supported Alignable partition" << alignableId;
278  }
279 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
MillePedeDQMModule::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: MillePedeDQMModule.cc:68
PedeLabelerPluginFactory.h
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
MillePedeDQMModule::binariesAvalaible
MonitorElement * binariesAvalaible
Definition: MillePedeDQMModule.h:88
ESHandle.h
MillePedeDQMModule::tracker_
std::unique_ptr< AlignableTracker > tracker_
Definition: MillePedeDQMModule.h:72
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
MillePedeDQMModule::mpReader_
std::unique_ptr< MillePedeFileReader > mpReader_
Definition: MillePedeDQMModule.h:73
ProcessBlock.h
MillePedeDQMModule::h_xPos
MonitorElement * h_xPos
Definition: MillePedeDQMModule.h:80
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:43
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
AlignPCLThresholdsRcd
Definition: AlignPCLThresholdsRcd.h:23
PTrackerParameters.h
MillePedeDQMModule::bookHistograms
void bookHistograms(DQMStore::IBooker &)
Definition: MillePedeDQMModule.cc:48
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MillePedeDQMModule::fillStatusHisto
void fillStatusHisto(MonitorElement *statusHisto)
Definition: MillePedeDQMModule.cc:124
edm::ParameterSet::addUntrackedParameter
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:192
PedeLabelerBase.h
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
PTrackerParametersRcd
Definition: PTrackerParametersRcd.h:9
config
Definition: config.py:1
TrackerTopology.h
AlignmentToken.h
AlignPCLThresholdsRcd.h
MillePedeDQMModule::fillExpertHistos
void fillExpertHistos()
Definition: MillePedeDQMModule.cc:142
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
MillePedeDQMModule::watchPTrackerParametersRcd_
edm::ESWatcher< PTrackerParametersRcd > watchPTrackerParametersRcd_
Definition: MillePedeDQMModule.h:77
edm::ESHandle< TrackerTopology >
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
MillePedeDQMModule::h_yPos
MonitorElement * h_yPos
Definition: MillePedeDQMModule.h:82
PedeLabelerBase::TopLevelAlignables
Definition: PedeLabelerBase.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MillePedeDQMModule::h_zPos
MonitorElement * h_zPos
Definition: MillePedeDQMModule.h:84
edm::ParameterSet
Definition: ParameterSet.h:47
MillePedeAlignmentAlgorithm_cfi.pedeLabeler
pedeLabeler
Definition: MillePedeAlignmentAlgorithm_cfi.py:38
dqm::implementation::IBooker::bookString
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
Definition: DQMStore.h:87
ParameterSet
Definition: Functions.h:16
MillePedeDQMModule::mpReaderConfig_
const edm::ParameterSet mpReaderConfig_
Definition: MillePedeDQMModule.h:71
MillePedeDQMModule::watchIdealGeometryRcd_
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
Definition: MillePedeDQMModule.h:76
dqm::implementation::IBooker::bookInt
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
HLT_FULL_cff.sigCut
sigCut
Definition: HLT_FULL_cff.py:51965
MillePedeDQMModule::~MillePedeDQMModule
~MillePedeDQMModule() override
Definition: MillePedeDQMModule.cc:42
edm::EventSetup
Definition: EventSetup.h:57
MillePedeDQMModule::MillePedeDQMModule
MillePedeDQMModule(const edm::ParameterSet &)
Definition: MillePedeDQMModule.cc:37
MillePedeDQMModule::fillExpertHisto
void fillExpertHisto(MonitorElement *histo, const std::array< double, 6 > &cut, const std::array< double, 6 > &sigCut, const std::array< double, 6 > &maxMoveCut, const std::array< double, 6 > &maxErrorCut, const std::array< double, 6 > &obs, const std::array< double, 6 > &obsErr)
Definition: MillePedeDQMModule.cc:206
get
#define get
MillePedeDQMModule::h_yRot
MonitorElement * h_yRot
Definition: MillePedeDQMModule.h:83
MillePedeDQMModule::setupChanged
bool setupChanged(const edm::EventSetup &)
Definition: MillePedeDQMModule.cc:249
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
Exception
Definition: hltDiff.cc:246
MillePedeDQMModule::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: MillePedeDQMModule.cc:88
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
TrackerGeomBuilderFromGeometricDet.h
TrackerGeomBuilderFromGeometricDet
Definition: TrackerGeomBuilderFromGeometricDet.h:17
MillePedeDQMModule::h_zRot
MonitorElement * h_zRot
Definition: MillePedeDQMModule.h:85
AlignableTracker.h
MillePedeDQMModule::exitCode
MonitorElement * exitCode
Definition: MillePedeDQMModule.h:89
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
MillePedeDQMModule::getIndexFromString
int getIndexFromString(const std::string &alignableId)
Definition: MillePedeDQMModule.cc:262
MillePedeDQMModule::watchTrackerTopologyRcd_
edm::ESWatcher< TrackerTopologyRcd > watchTrackerTopologyRcd_
Definition: MillePedeDQMModule.h:75
MillePedeDQMModule.h
DQM Plotter for PCL-Alignment.
MillePedeDQMModule::h_xRot
MonitorElement * h_xRot
Definition: MillePedeDQMModule.h:81
edm::InputTag
Definition: InputTag.h:15
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
MillePedeDQMModule::statusResults
MonitorElement * statusResults
Definition: MillePedeDQMModule.h:87
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:490