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