CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SiPixelLorentzAnglePCLWorker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiPixelLorentzAnglePCLWorker
4 // Class: SiPixelLorentzAnglePCLWorker
5 //
11 //
12 // Original Author: mmusich
13 // Created: Sat, 29 May 2021 14:46:19 GMT
14 //
15 //
16 
17 // system includes
18 #include <string>
19 #include <fmt/printf.h>
20 
21 // user include files
59 
60 // ROOT includes
61 #include <TTree.h>
62 #include <TFile.h>
63 #include <fstream>
64 
65 //
66 // class declaration
67 //
68 
69 static const int maxpix = 1000;
70 struct Pixinfo {
71  int npix;
72  float row[maxpix];
73  float col[maxpix];
74  float adc[maxpix];
75  float x[maxpix];
76  float y[maxpix];
77 };
78 
79 struct Hit {
80  float x;
81  float y;
82  double alpha;
83  double beta;
84  double gamma;
85 };
86 struct Clust {
87  float x;
88  float y;
89  float charge;
90  int size_x;
91  int size_y;
92  int maxPixelCol;
93  int maxPixelRow;
94  int minPixelCol;
95  int minPixelRow;
96 };
97 struct Rechit {
98  float x;
99  float y;
100 };
101 
103 
105 public:
107  ~SiPixelLorentzAnglePCLWorker() override = default;
108 
109  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
110 
111 private:
112  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
113 
114  void analyze(edm::Event const&, edm::EventSetup const&) override;
115 
116  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
117 
118  void dqmEndRun(edm::Run const&, edm::EventSetup const&);
119 
120  const Pixinfo fillPix(const SiPixelCluster& LocPix, const PixelTopology* topol) const;
121  const std::pair<LocalPoint, LocalPoint> surface_deformation(const PixelTopology* topol,
123  const SiPixelRecHit* recHitPix) const;
125  // ------------ member data ------------
127 
128  // template stuff
131  std::vector<SiPixelTemplateStore> thePixelTemp_;
132 
135  bool notInPCL_;
137  std::vector<std::string> newmodulelist_;
138 
139  // tree branches barrel
140  int run_;
141  long int event_;
143  int bx_;
144  int orbit_;
145  int module_;
146  int ladder_;
147  int layer_;
149  float pt_;
150  float eta_;
151  float phi_;
152  double chi2_;
153  double ndof_;
161  float qScale_;
162  float rQmQt_;
163 
164  // tree branches forward
165  int sideF_;
166  int diskF_;
167  int bladeF_;
168  int panelF_;
169  int moduleF_;
177  float qScaleF_;
178  float rQmQtF_;
179 
180  // parameters from config file
181  double ptmin_;
182  double normChi2Max_;
183  std::vector<int> clustSizeYMin_;
185  double residualMax_;
189 
190  std::unique_ptr<TFile> hFile_;
191  std::unique_ptr<TTree> SiPixelLorentzAngleTreeBarrel_;
192  std::unique_ptr<TTree> SiPixelLorentzAngleTreeForward_;
193 
194  // es consumes
201 
202  // event consumes
204 };
205 
206 //
207 // constructors and destructor
208 //
210  : analysisType_(convertStringToLorentzAngleAnalysisTypeEnum(iConfig.getParameter<std::string>("analysisType"))),
211  folder_(iConfig.getParameter<std::string>("folder")),
212  notInPCL_(iConfig.getParameter<bool>("notInPCL")),
213  filename_(iConfig.getParameter<std::string>("fileName")),
214  newmodulelist_(iConfig.getParameter<std::vector<std::string>>("newmodulelist")),
215  ptmin_(iConfig.getParameter<double>("ptMin")),
216  normChi2Max_(iConfig.getParameter<double>("normChi2Max")),
217  clustSizeYMin_(iConfig.getParameter<std::vector<int>>("clustSizeYMin")),
218  clustSizeXMax_(iConfig.getParameter<int>("clustSizeXMax")),
219  residualMax_(iConfig.getParameter<double>("residualMax")),
220  clustChargeMaxPerLength_(iConfig.getParameter<double>("clustChargeMaxPerLength")),
221  hist_depth_(iConfig.getParameter<int>("binsDepth")),
222  hist_drift_(iConfig.getParameter<int>("binsDrift")),
223  geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
224  topoEsToken_(esConsumes<edm::Transition::BeginRun>()),
225  siPixelTemplateEsToken_(esConsumes<edm::Transition::BeginRun>()),
226  topoPerEventEsToken_(esConsumes()),
227  geomPerEventEsToken_(esConsumes()),
228  magneticFieldToken_(esConsumes()) {
229  t_trajTrack = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("src"));
230 
231  // now do what ever initialization is needed
232  int bufsize = 64000;
233  // create tree structure
234  // Barrel pixel
235  if (notInPCL_) {
236  hFile_ = std::make_unique<TFile>(filename_.c_str(), "RECREATE");
238  std::make_unique<TTree>("SiPixelLorentzAngleTreeBarrel_", "SiPixel LorentzAngle tree barrel", bufsize);
239  SiPixelLorentzAngleTreeBarrel_->Branch("run", &run_, "run/I", bufsize);
240  SiPixelLorentzAngleTreeBarrel_->Branch("event", &event_, "event/l", bufsize);
241  SiPixelLorentzAngleTreeBarrel_->Branch("lumiblock", &lumiblock_, "lumiblock/I", bufsize);
242  SiPixelLorentzAngleTreeBarrel_->Branch("bx", &bx_, "bx/I", bufsize);
243  SiPixelLorentzAngleTreeBarrel_->Branch("orbit", &orbit_, "orbit/I", bufsize);
244  SiPixelLorentzAngleTreeBarrel_->Branch("module", &module_, "module/I", bufsize);
245  SiPixelLorentzAngleTreeBarrel_->Branch("ladder", &ladder_, "ladder/I", bufsize);
246  SiPixelLorentzAngleTreeBarrel_->Branch("layer", &layer_, "layer/I", bufsize);
247  SiPixelLorentzAngleTreeBarrel_->Branch("isflipped", &isflipped_, "isflipped/I", bufsize);
248  SiPixelLorentzAngleTreeBarrel_->Branch("pt", &pt_, "pt/F", bufsize);
249  SiPixelLorentzAngleTreeBarrel_->Branch("eta", &eta_, "eta/F", bufsize);
250  SiPixelLorentzAngleTreeBarrel_->Branch("phi", &phi_, "phi/F", bufsize);
251  SiPixelLorentzAngleTreeBarrel_->Branch("chi2", &chi2_, "chi2/D", bufsize);
252  SiPixelLorentzAngleTreeBarrel_->Branch("ndof", &ndof_, "ndof/D", bufsize);
253  SiPixelLorentzAngleTreeBarrel_->Branch("trackhit", &trackhit_, "x/F:y/F:alpha/D:beta/D:gamma_/D", bufsize);
254  SiPixelLorentzAngleTreeBarrel_->Branch("npix", &pixinfo_.npix, "npix/I", bufsize);
255  SiPixelLorentzAngleTreeBarrel_->Branch("rowpix", pixinfo_.row, "row[npix]/F", bufsize);
256  SiPixelLorentzAngleTreeBarrel_->Branch("colpix", pixinfo_.col, "col[npix]/F", bufsize);
257  SiPixelLorentzAngleTreeBarrel_->Branch("adc", pixinfo_.adc, "adc[npix]/F", bufsize);
258  SiPixelLorentzAngleTreeBarrel_->Branch("xpix", pixinfo_.x, "x[npix]/F", bufsize);
259  SiPixelLorentzAngleTreeBarrel_->Branch("ypix", pixinfo_.y, "y[npix]/F", bufsize);
260 
262  "clust",
263  &clust_,
264  "x/F:y/F:charge/F:size_x/I:size_y/I:maxPixelCol/I:maxPixelRow:minPixelCol/I:minPixelRow/I",
265  bufsize);
266  SiPixelLorentzAngleTreeBarrel_->Branch("rechit", &rechit_, "x/F:y/F", bufsize);
267  SiPixelLorentzAngleTreeBarrel_->Branch("rechit_corr", &rechitCorr_, "x/F:y/F", bufsize);
268  SiPixelLorentzAngleTreeBarrel_->Branch("trackhitcorr_x", &trackhitCorrX_, "trackhitcorr_x/F", bufsize);
269  SiPixelLorentzAngleTreeBarrel_->Branch("trackhitcorr_y", &trackhitCorrY_, "trackhitcorr_y/F", bufsize);
270  SiPixelLorentzAngleTreeBarrel_->Branch("qScale", &qScale_, "qScale/F", bufsize);
271  SiPixelLorentzAngleTreeBarrel_->Branch("rQmQt", &rQmQt_, "rQmQt/F", bufsize);
272  // Forward pixel
273 
275  std::make_unique<TTree>("SiPixelLorentzAngleTreeForward_", "SiPixel LorentzAngle tree forward", bufsize);
276  SiPixelLorentzAngleTreeForward_->Branch("run", &run_, "run/I", bufsize);
277  SiPixelLorentzAngleTreeForward_->Branch("event", &event_, "event/l", bufsize);
278  SiPixelLorentzAngleTreeForward_->Branch("lumiblock", &lumiblock_, "lumiblock/I", bufsize);
279  SiPixelLorentzAngleTreeForward_->Branch("bx", &bx_, "bx/I", bufsize);
280  SiPixelLorentzAngleTreeForward_->Branch("orbit", &orbit_, "orbit/I", bufsize);
281  SiPixelLorentzAngleTreeForward_->Branch("side", &sideF_, "side/I", bufsize);
282  SiPixelLorentzAngleTreeForward_->Branch("disk", &diskF_, "disk/I", bufsize);
283  SiPixelLorentzAngleTreeForward_->Branch("blade", &bladeF_, "blade/I", bufsize);
284  SiPixelLorentzAngleTreeForward_->Branch("panel", &panelF_, "panel/I", bufsize);
285  SiPixelLorentzAngleTreeForward_->Branch("module", &moduleF_, "module/I", bufsize);
286  SiPixelLorentzAngleTreeForward_->Branch("pt", &pt_, "pt/F", bufsize);
287  SiPixelLorentzAngleTreeForward_->Branch("eta", &eta_, "eta/F", bufsize);
288  SiPixelLorentzAngleTreeForward_->Branch("phi", &phi_, "phi/F", bufsize);
289  SiPixelLorentzAngleTreeForward_->Branch("chi2", &chi2_, "chi2/D", bufsize);
290  SiPixelLorentzAngleTreeForward_->Branch("ndof", &ndof_, "ndof/D", bufsize);
291  SiPixelLorentzAngleTreeForward_->Branch("trackhit", &trackhitF_, "x/F:y/F:alpha/D:beta/D:gamma_/D", bufsize);
292  SiPixelLorentzAngleTreeForward_->Branch("npix", &pixinfoF_.npix, "npix/I", bufsize);
293  SiPixelLorentzAngleTreeForward_->Branch("rowpix", pixinfoF_.row, "row[npix]/F", bufsize);
294  SiPixelLorentzAngleTreeForward_->Branch("colpix", pixinfoF_.col, "col[npix]/F", bufsize);
295  SiPixelLorentzAngleTreeForward_->Branch("adc", pixinfoF_.adc, "adc[npix]/F", bufsize);
296  SiPixelLorentzAngleTreeForward_->Branch("xpix", pixinfoF_.x, "x[npix]/F", bufsize);
297  SiPixelLorentzAngleTreeForward_->Branch("ypix", pixinfoF_.y, "y[npix]/F", bufsize);
298 
300  "clust",
301  &clustF_,
302  "x/F:y/F:charge/F:size_x/I:size_y/I:maxPixelCol/I:maxPixelRow:minPixelCol/I:minPixelRow/I",
303  bufsize);
304  SiPixelLorentzAngleTreeForward_->Branch("rechit", &rechitF_, "x/F:y/F", bufsize);
305  SiPixelLorentzAngleTreeForward_->Branch("rechit_corr", &rechitCorrF_, "x/F:y/F", bufsize);
306  SiPixelLorentzAngleTreeForward_->Branch("trackhitcorr_x", &trackhitCorrXF_, "trackhitcorr_x/F", bufsize);
307  SiPixelLorentzAngleTreeForward_->Branch("trackhitcorr_y", &trackhitCorrYF_, "trackhitcorr_y/F", bufsize);
308  SiPixelLorentzAngleTreeForward_->Branch("qScale", &qScaleF_, "qScale/F", bufsize);
309  SiPixelLorentzAngleTreeForward_->Branch("rQmQt", &rQmQtF_, "rQmQt/F", bufsize);
310  }
311 }
312 
313 //
314 // member functions
315 //
316 
317 // ------------ method called for each event ------------
318 
320  // Retrieve tracker topology from geometry
321  const TrackerTopology* const tTopo = &iSetup.getData(topoPerEventEsToken_);
322 
323  // Retrieve track geometry
325 
326  // Retrieve magnetic field
327  const MagneticField* magField = &iSetup.getData(magneticFieldToken_);
328 
329  // get the association map between tracks and trajectories
330  edm::Handle<TrajTrackAssociationCollection> trajTrackCollectionHandle;
331  iEvent.getByToken(t_trajTrack, trajTrackCollectionHandle);
332 
333  module_ = -1;
334  layer_ = -1;
335  ladder_ = -1;
336  isflipped_ = -1;
337  pt_ = -999;
338  eta_ = 999;
339  phi_ = 999;
340  pixinfo_.npix = 0;
341 
342  run_ = iEvent.id().run();
343  event_ = iEvent.id().event();
344  lumiblock_ = iEvent.luminosityBlock();
345  bx_ = iEvent.bunchCrossing();
346  orbit_ = iEvent.orbitNumber();
347 
348  if (!trajTrackCollectionHandle->empty()) {
349  for (TrajTrackAssociationCollection::const_iterator it = trajTrackCollectionHandle->begin();
350  it != trajTrackCollectionHandle->end();
351  ++it) {
352  const reco::Track& track = *it->val;
353  const Trajectory& traj = *it->key;
354 
355  // get the trajectory measurements
356  std::vector<TrajectoryMeasurement> tmColl = traj.measurements();
357  pt_ = track.pt();
358  eta_ = track.eta();
359  phi_ = track.phi();
360  chi2_ = traj.chiSquared();
361  ndof_ = traj.ndof();
362 
363  if (pt_ < ptmin_)
364  continue;
365 
370  iHists.h_tracks_->Fill(0);
371  bool pixeltrack = false;
372 
373  // iterate over trajectory measurements
374  for (const auto& itTraj : tmColl) {
375  if (!itTraj.updatedState().isValid())
376  continue;
377  const TransientTrackingRecHit::ConstRecHitPointer& recHit = itTraj.recHit();
378  if (!recHit->isValid() || recHit->geographicalId().det() != DetId::Tracker)
379  continue;
380  unsigned int subDetID = (recHit->geographicalId().subdetId());
381  if (subDetID == PixelSubdetector::PixelBarrel || subDetID == PixelSubdetector::PixelEndcap) {
382  if (!pixeltrack) {
383  iHists.h_tracks_->Fill(1);
384  }
385  pixeltrack = true;
386  }
387 
388  if (subDetID == PixelSubdetector::PixelBarrel) {
389  DetId detIdObj = recHit->geographicalId();
390  const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(tracker->idToDet(detIdObj));
391  if (!theGeomDet)
392  continue;
393 
394  const PixelTopology* topol = &(theGeomDet->specificTopology());
395 
396  float ypitch_ = topol->pitch().second;
397  float width_ = theGeomDet->surface().bounds().thickness();
398 
399  if (!topol)
400  continue;
401 
402  layer_ = tTopo->pxbLayer(detIdObj);
403  ladder_ = tTopo->pxbLadder(detIdObj);
404  module_ = tTopo->pxbModule(detIdObj);
405 
406  float tmp1 = theGeomDet->surface().toGlobal(Local3DPoint(0., 0., 0.)).perp();
407  float tmp2 = theGeomDet->surface().toGlobal(Local3DPoint(0., 0., 1.)).perp();
408 
409  isflipped_ = (tmp2 < tmp1) ? 1 : 0;
410 
411  const SiPixelRecHit* recHitPix = dynamic_cast<const SiPixelRecHit*>((*recHit).hit());
412  if (!recHitPix)
413  continue;
414  rechit_.x = recHitPix->localPosition().x();
415  rechit_.y = recHitPix->localPosition().y();
416  SiPixelRecHit::ClusterRef const& cluster = recHitPix->cluster();
417 
418  pixinfo_ = fillPix(*cluster, topol);
419 
420  // fill entries in clust_
421 
422  clust_.x = (cluster)->x();
423  clust_.y = (cluster)->y();
424  clust_.charge = (cluster->charge()) / 1000.; // clust_.charge: in the unit of 1000e
425  clust_.size_x = cluster->sizeX();
426  clust_.size_y = cluster->sizeY();
427  clust_.maxPixelCol = cluster->maxPixelCol();
428  clust_.maxPixelRow = cluster->maxPixelRow();
429  clust_.minPixelCol = cluster->minPixelCol();
430  clust_.minPixelRow = cluster->minPixelRow();
431 
432  // fill the trackhit info
433  TrajectoryStateOnSurface tsos = itTraj.updatedState();
434  if (!tsos.isValid()) {
435  edm::LogWarning("SiPixelLorentzAnglePCLWorker") << "tsos not valid";
436  continue;
437  }
438  LocalVector trackdirection = tsos.localDirection();
439  LocalPoint trackposition = tsos.localPosition();
440 
441  if (trackdirection.z() == 0)
442  continue;
443  // the local position and direction
444  trackhit_.alpha = atan2(trackdirection.z(), trackdirection.x());
445  trackhit_.beta = atan2(trackdirection.z(), trackdirection.y());
446  trackhit_.gamma = atan2(trackdirection.x(), trackdirection.y());
447  trackhit_.x = trackposition.x();
448  trackhit_.y = trackposition.y();
449 
450  // get qScale_ = templ.qscale() and templ.r_qMeas_qTrue();
451  float cotalpha = trackdirection.x() / trackdirection.z();
452  float cotbeta = trackdirection.y() / trackdirection.z();
453  float cotbeta_min = clustSizeYMin_[layer_ - 1] * ypitch_ / width_;
454  if (std::abs(cotbeta) <= cotbeta_min)
455  continue;
456  double drdz = sqrt(1. + cotalpha * cotalpha + cotbeta * cotbeta);
457  double clusterCharge_cut = clustChargeMaxPerLength_ * drdz;
458 
459  auto detId = detIdObj.rawId();
460  int DetId_index = -1;
461 
462  const auto& newModIt = (std::find(iHists.BPixnewDetIds_.begin(), iHists.BPixnewDetIds_.end(), detId));
463  bool isNewMod = (newModIt != iHists.BPixnewDetIds_.end());
464  if (isNewMod) {
465  DetId_index = std::distance(iHists.BPixnewDetIds_.begin(), newModIt);
466  }
467 
468  if (notInPCL_) {
469  // fill the template from the store (from dqmBeginRun)
470  SiPixelTemplate theTemplate(thePixelTemp_);
471 
472  float locBx = (cotbeta < 0.) ? -1 : 1.;
473  float locBz = (cotalpha < 0.) ? -locBx : locBx;
474 
475  int TemplID = templateDBobject_->getTemplateID(detId);
476  theTemplate.interpolate(TemplID, cotalpha, cotbeta, locBz, locBx);
477  qScale_ = theTemplate.qscale();
478  rQmQt_ = theTemplate.r_qMeas_qTrue();
479  }
480 
481  // Surface deformation
482  const auto& lp_pair = surface_deformation(topol, tsos, recHitPix);
483 
484  LocalPoint lp_track = lp_pair.first;
485  LocalPoint lp_rechit = lp_pair.second;
486 
487  rechitCorr_.x = lp_rechit.x();
488  rechitCorr_.y = lp_rechit.y();
489  trackhitCorrX_ = lp_track.x();
490  trackhitCorrY_ = lp_track.y();
491 
492  if (notInPCL_) {
494  }
495 
497  continue;
498  // is one pixel in cluster a large pixel ? (hit will be excluded)
499  bool large_pix = false;
500  for (int j = 0; j < pixinfo_.npix; j++) {
501  int colpos = static_cast<int>(pixinfo_.col[j]);
502  if (pixinfo_.row[j] == 0 || pixinfo_.row[j] == 79 || pixinfo_.row[j] == 80 || pixinfo_.row[j] == 159 ||
503  colpos % 52 == 0 || colpos % 52 == 51) {
504  large_pix = true;
505  }
506  }
507 
508  double residualsq = (trackhitCorrX_ - rechitCorr_.x) * (trackhitCorrX_ - rechitCorr_.x) +
510 
511  double xlim1 = trackhitCorrX_ - width_ * cotalpha / 2.;
512  double hypitch_ = ypitch_ / 2.;
513  double ylim1 = trackhitCorrY_ - width_ * cotbeta / 2.;
514  double ylim2 = trackhitCorrY_ + width_ * cotbeta / 2.;
515 
516  int clustSizeY_cut = clustSizeYMin_[layer_ - 1];
517 
518  if (!large_pix && (chi2_ / ndof_) < normChi2Max_ && cluster->sizeY() >= clustSizeY_cut &&
519  residualsq < residualMax_ * residualMax_ && cluster->charge() < clusterCharge_cut &&
520  cluster->sizeX() < clustSizeXMax_) {
521  // iterate over pixels in hit
522  for (int j = 0; j < pixinfo_.npix; j++) {
523  // use trackhits and include bowing correction
524  float ypixlow = pixinfo_.y[j] - hypitch_;
525  float ypixhigh = pixinfo_.y[j] + hypitch_;
526  if (cotbeta > 0.) {
527  if (ylim1 > ypixlow)
528  ypixlow = ylim1;
529  if (ylim2 < ypixhigh)
530  ypixhigh = ylim2;
531  } else {
532  if (ylim2 > ypixlow)
533  ypixlow = ylim2;
534  if (ylim1 < ypixhigh)
535  ypixhigh = ylim1;
536  }
537  float ypixavg = 0.5f * (ypixlow + ypixhigh);
538 
539  float dx = (pixinfo_.x[j] - xlim1) * siPixelLACalibration::cmToum; // dx: in the unit of micrometer
540  float dy = (ypixavg - ylim1) * siPixelLACalibration::cmToum; // dy: in the unit of micrometer
541  float depth = dy * tan(trackhit_.beta);
542  float drift = dx - dy * tan(trackhit_.gamma);
543 
544  if (isNewMod == false) {
545  int i_index = module_ + (layer_ - 1) * iHists.nModules_[layer_ - 1];
546  iHists.h_drift_depth_adc_[i_index]->Fill(drift, depth, pixinfo_.adc[j]);
548  iHists.h_drift_depth_noadc_[i_index]->Fill(drift, depth, 1.);
549  iHists.h_bySectOccupancy_->Fill(i_index - 1); // histogram starts at 0
550 
551  if (tracker->getDetectorType(subDetID) == TrackerGeometry::ModuleType::Ph1PXB) {
552  if ((module_ == 3 || module_ == 5) && (layer_ == 3 || layer_ == 4)) {
553  int i_index_merge = i_index + 1;
554  iHists.h_drift_depth_adc_[i_index_merge]->Fill(drift, depth, pixinfo_.adc[j]);
555  iHists.h_drift_depth_adc2_[i_index_merge]->Fill(drift, depth, pixinfo_.adc[j] * pixinfo_.adc[j]);
556  iHists.h_drift_depth_noadc_[i_index_merge]->Fill(drift, depth, 1.);
557  iHists.h_bySectOccupancy_->Fill(i_index_merge - 1);
558  }
559  if ((module_ == 4 || module_ == 6) && (layer_ == 3 || layer_ == 4)) {
560  int i_index_merge = i_index - 1;
561  iHists.h_drift_depth_adc_[i_index_merge]->Fill(drift, depth, pixinfo_.adc[j]);
562  iHists.h_drift_depth_adc2_[i_index_merge]->Fill(drift, depth, pixinfo_.adc[j] * pixinfo_.adc[j]);
563  iHists.h_drift_depth_noadc_[i_index_merge]->Fill(drift, depth, 1.);
564  iHists.h_bySectOccupancy_->Fill(i_index_merge - 1);
565  }
566  }
567 
568  } else {
569  int new_index = iHists.nModules_[iHists.nlay - 1] +
570  (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + DetId_index;
571 
572  iHists.h_drift_depth_adc_[new_index]->Fill(drift, depth, pixinfo_.adc[j]);
573  iHists.h_drift_depth_adc2_[new_index]->Fill(drift, depth, pixinfo_.adc[j] * pixinfo_.adc[j]);
574  iHists.h_drift_depth_noadc_[new_index]->Fill(drift, depth, 1.);
575  iHists.h_bySectOccupancy_->Fill(new_index - 1); // histogram starts at 0
576  }
577  }
578  }
579  } else if (subDetID == PixelSubdetector::PixelEndcap) {
580  DetId detIdObj = recHit->geographicalId();
581  const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(tracker->idToDet(detIdObj));
582  if (!theGeomDet)
583  continue;
584 
585  const PixelTopology* topol = &(theGeomDet->specificTopology());
586 
587  if (!topol)
588  continue;
589 
590  sideF_ = tTopo->pxfSide(detIdObj);
591  diskF_ = tTopo->pxfDisk(detIdObj);
592  bladeF_ = tTopo->pxfBlade(detIdObj);
593  panelF_ = tTopo->pxfPanel(detIdObj);
594  moduleF_ = tTopo->pxfModule(detIdObj);
595 
596  const SiPixelRecHit* recHitPix = dynamic_cast<const SiPixelRecHit*>((*recHit).hit());
597  if (!recHitPix)
598  continue;
599  rechitF_.x = recHitPix->localPosition().x();
600  rechitF_.y = recHitPix->localPosition().y();
601  SiPixelRecHit::ClusterRef const& cluster = recHitPix->cluster();
602 
603  pixinfoF_ = fillPix(*cluster, topol);
604 
605  // fill entries in clust_
606 
607  clustF_.x = (cluster)->x();
608  clustF_.y = (cluster)->y();
609  clustF_.charge = (cluster->charge()) / 1000.; // clustF_.charge: in the unit of 1000e
610  clustF_.size_x = cluster->sizeX();
611  clustF_.size_y = cluster->sizeY();
612  clustF_.maxPixelCol = cluster->maxPixelCol();
613  clustF_.maxPixelRow = cluster->maxPixelRow();
614  clustF_.minPixelCol = cluster->minPixelCol();
615  clustF_.minPixelRow = cluster->minPixelRow();
616 
617  // fill the trackhit info
618  TrajectoryStateOnSurface tsos = itTraj.updatedState();
619  if (!tsos.isValid()) {
620  edm::LogWarning("SiPixelLorentzAnglePCLWorker") << "tsos not valid";
621  continue;
622  }
623  LocalVector trackdirection = tsos.localDirection();
624  LocalPoint trackposition = tsos.localPosition();
625 
626  if (trackdirection.z() == 0)
627  continue;
628  // the local position and direction
629  trackhitF_.alpha = atan2(trackdirection.z(), trackdirection.x());
630  trackhitF_.beta = atan2(trackdirection.z(), trackdirection.y());
631  trackhitF_.gamma = atan2(trackdirection.x(), trackdirection.y());
632  trackhitF_.x = trackposition.x();
633  trackhitF_.y = trackposition.y();
634 
635  float cotalpha = trackdirection.x() / trackdirection.z();
636  float cotbeta = trackdirection.y() / trackdirection.z();
637 
638  auto detId = detIdObj.rawId();
639 
640  if (notInPCL_) {
641  // fill the template from the store (from dqmBeginRun)
642  SiPixelTemplate theTemplate(thePixelTemp_);
643 
644  float locBx = (cotbeta < 0.) ? -1 : 1.;
645  float locBz = (cotalpha < 0.) ? -locBx : locBx;
646 
647  int TemplID = templateDBobject_->getTemplateID(detId);
648  theTemplate.interpolate(TemplID, cotalpha, cotbeta, locBz, locBx);
649  qScaleF_ = theTemplate.qscale();
650  rQmQtF_ = theTemplate.r_qMeas_qTrue();
651  }
652 
653  // Surface deformation
654  const auto& lp_pair = surface_deformation(topol, tsos, recHitPix);
655 
656  LocalPoint lp_track = lp_pair.first;
657  LocalPoint lp_rechit = lp_pair.second;
658 
659  rechitCorrF_.x = lp_rechit.x();
660  rechitCorrF_.y = lp_rechit.y();
661  trackhitCorrXF_ = lp_track.x();
662  trackhitCorrYF_ = lp_track.y();
663  if (notInPCL_) {
665  }
666 
668  continue;
669 
670  int theMagField = magField->nominalValue();
671  if (theMagField < 37 || theMagField > 39)
672  continue;
673 
674  double chi2_ndof = chi2_ / ndof_;
675  if (chi2_ndof >= normChi2Max_)
676  continue;
677 
678  //--- large pixel cut
679  bool large_pix = false;
680  for (int j = 0; j < pixinfoF_.npix; j++) {
681  int colpos = static_cast<int>(pixinfoF_.col[j]);
682  if (pixinfoF_.row[j] == 0 || pixinfoF_.row[j] == 79 || pixinfoF_.row[j] == 80 || pixinfoF_.row[j] == 159 ||
683  colpos % 52 == 0 || colpos % 52 == 51) {
684  large_pix = true;
685  }
686  }
687 
688  if (large_pix)
689  continue;
690 
691  //--- residual cut
692  double residual = sqrt(pow(trackhitCorrXF_ - rechitCorrF_.x, 2) + pow(trackhitCorrYF_ - rechitCorrF_.y, 2));
693 
694  if (residual > residualMax_)
695  continue;
696 
697  int ringIdx = bladeF_ <= 22 ? 0 : 1;
698  int panelIdx = panelF_ - 1;
699  int sideIdx = sideF_ - 1;
700  int idx = iHists.nSides_ * iHists.nPanels_ * ringIdx + iHists.nSides_ * panelIdx + sideIdx;
701  int idxBeta = iHists.betaStartIdx_ + idx;
702 
703  double cotanAlpha = std::tan(M_PI / 2. - trackhitF_.alpha);
704  double cotanBeta = std::tan(M_PI / 2. - trackhitF_.beta);
705 
706  LocalVector Bfield = theGeomDet->surface().toLocal(magField->inTesla(theGeomDet->surface().position()));
707  iHists.h_fpixMagField_[0][idx]->Fill(Bfield.x());
708  iHists.h_fpixMagField_[1][idx]->Fill(Bfield.y());
709  iHists.h_fpixMagField_[2][idx]->Fill(Bfield.z());
710 
711  if (clustF_.size_y >= 2) {
712  iHists.h_fpixAngleSize_[idx]->Fill(cotanAlpha, clustF_.size_x);
713  }
714 
715  if (clust_.size_x >= 0) {
716  iHists.h_fpixAngleSize_[idxBeta]->Fill(cotanBeta, clustF_.size_y);
717  }
718  }
719  } //end iteration over trajectory measurements
720  } //end iteration over trajectories
721  }
722 }
723 
725  // geometry
726  const TrackerGeometry* geom = &iSetup.getData(geomEsToken_);
727  const TrackerTopology* tTopo = &iSetup.getData(topoEsToken_);
728 
729  if (notInPCL_) {
730  // Initialize 1D templates
731  if (watchSiPixelTemplateRcd_.check(iSetup)) {
734  edm::LogError("SiPixelLorentzAnglePCLWorker")
735  << "Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
736  << (*templateDBobject_).version();
737  }
738  }
739  }
740 
742  iHists.nlay = geom->numberOfLayers(PixelSubdetector::PixelBarrel);
743  iHists.nModules_.resize(iHists.nlay);
744  for (int i = 0; i < iHists.nlay; i++) {
745  iHists.nModules_[i] = map.getPXBModules(i + 1);
746  }
747 
748  // list of modules already filled, then return (we already entered here)
749  if (!iHists.BPixnewDetIds_.empty() || !iHists.FPixnewDetIds_.empty())
750  return;
751 
752  if (!newmodulelist_.empty()) {
753  for (auto const& modulename : newmodulelist_) {
754  if (modulename.find("BPix_") != std::string::npos) {
755  PixelBarrelName bn(modulename, true);
756  const auto& detId = bn.getDetId(tTopo);
757  iHists.BPixnewmodulename_.push_back(modulename);
758  iHists.BPixnewDetIds_.push_back(detId.rawId());
759  iHists.BPixnewModule_.push_back(bn.moduleName());
760  iHists.BPixnewLayer_.push_back(bn.layerName());
761  } else if (modulename.find("FPix_") != std::string::npos) {
762  PixelEndcapName en(modulename, true);
763  const auto& detId = en.getDetId(tTopo);
764  iHists.FPixnewmodulename_.push_back(modulename);
765  iHists.FPixnewDetIds_.push_back(detId.rawId());
766  iHists.FPixnewDisk_.push_back(en.diskName());
767  iHists.FPixnewBlade_.push_back(en.bladeName());
768  }
769  }
770  }
771 }
772 
774  edm::Run const& run,
775  edm::EventSetup const& iSetup) {
778  if (analysisType_ == eGrazingAngle) {
779  // book the by partition monitoring
780  const auto maxSect = iHists.nlay * iHists.nModules_[iHists.nlay - 1] + (int)iHists.BPixnewDetIds_.size();
781 
782  iBooker.setCurrentFolder(fmt::sprintf("%s/SectorMonitoring", folder_.data()));
783  iHists.h_bySectOccupancy_ = iBooker.book1D(
784  "h_bySectorOccupancy", "hit occupancy by sector;pixel sector;hits on track", maxSect, -0.5, maxSect - 0.5);
785 
786  iBooker.setCurrentFolder(folder_);
787  static constexpr double min_depth_ = -100.;
788  static constexpr double max_depth_ = 400.;
789  static constexpr double min_drift_ = -500.;
790  static constexpr double max_drift_ = 500.;
791 
792  // book the mean values projections and set the bin names of the by sector monitoring
793  for (int i_layer = 1; i_layer <= iHists.nlay; i_layer++) {
794  for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) {
795  unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1];
796  std::string binName = fmt::sprintf("BPix Lay%i Mod%i", i_layer, i_module);
797  LogDebug("SiPixelLorentzAnglePCLWorker") << " i_index: " << i_index << " bin name: " << binName
798  << " (i_layer: " << i_layer << " i_module:" << i_module << ")";
799 
800  iHists.h_bySectOccupancy_->setBinLabel(i_index, binName);
801 
802  name = fmt::sprintf("h_mean_layer%i_module%i", i_layer, i_module);
803  title = fmt::sprintf(
804  "average drift vs depth layer%i module%i; production depth [#mum]; #LTdrift#GT [#mum]", i_layer, i_module);
805  iHists.h_mean_[i_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_);
806  }
807  }
808  for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) {
809  name = fmt::sprintf("h_BPixnew_mean_%s", iHists.BPixnewmodulename_[i].c_str());
810  title = fmt::sprintf("average drift vs depth %s; production depth [#mum]; #LTdrift#GT [#mum]",
811  iHists.BPixnewmodulename_[i].c_str());
812  int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i;
813  iHists.h_mean_[new_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_);
814 
815  LogDebug("SiPixelLorentzAnglePCLWorker")
816  << "i_index" << new_index << " bin name: " << iHists.BPixnewmodulename_[i];
817 
819  }
820 
821  //book the 2D histograms
822  for (int i_layer = 1; i_layer <= iHists.nlay; i_layer++) {
823  iBooker.setCurrentFolder(fmt::sprintf("%s/BPix/BPixLayer%i", folder_.data(), i_layer));
824  for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) {
825  unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1];
826 
827  name = fmt::sprintf("h_drift_depth_adc_layer%i_module%i", i_layer, i_module);
828  title = fmt::sprintf(
829  "depth vs drift (ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
830  iHists.h_drift_depth_adc_[i_index] =
831  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
832 
833  name = fmt::sprintf("h_drift_depth_adc2_layer%i_module%i", i_layer, i_module);
834  title = fmt::sprintf(
835  "depth vs drift (ADC^{2}) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
836  iHists.h_drift_depth_adc2_[i_index] =
837  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
838 
839  name = fmt::sprintf("h_drift_depth_noadc_layer%i_module%i", i_layer, i_module);
840  title = fmt::sprintf(
841  "depth vs drift (no ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
842  iHists.h_drift_depth_noadc_[i_index] =
843  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
844 
845  name = fmt::sprintf("h_drift_depth_layer%i_module%i", i_layer, i_module);
846  title =
847  fmt::sprintf("depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
848  iHists.h_drift_depth_[i_index] =
849  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
850  }
851  }
852 
853  // book the "new" modules
854  iBooker.setCurrentFolder(fmt::sprintf("%s/BPix/NewModules", folder_.data()));
855  for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) {
856  int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i;
857 
858  name = fmt::sprintf("h_BPixnew_drift_depth_adc_%s", iHists.BPixnewmodulename_[i].c_str());
859  title = fmt::sprintf("depth vs drift (ADC) %s; drift [#mum]; production depth [#mum]",
860  iHists.BPixnewmodulename_[i].c_str());
861  iHists.h_drift_depth_adc_[new_index] =
862  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
863 
864  name = fmt::sprintf("h_BPixnew_drift_depth_adc2_%s", iHists.BPixnewmodulename_[i].c_str());
865  title = fmt::sprintf("depth vs drift (ADC^{2}) %s; drift [#mum]; production depth [#mum]",
866  iHists.BPixnewmodulename_[i].c_str());
867  iHists.h_drift_depth_adc2_[new_index] =
868  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
869 
870  name = fmt::sprintf("h_BPixnew_drift_depth_noadc_%s", iHists.BPixnewmodulename_[i].c_str());
871  title = fmt::sprintf("depth vs drift (no ADC)%s; drift [#mum]; production depth [#mum]",
872  iHists.BPixnewmodulename_[i].c_str());
873  iHists.h_drift_depth_noadc_[new_index] =
874  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
875 
876  name = fmt::sprintf("h_BPixnew_drift_depth_%s", iHists.BPixnewmodulename_[i].c_str());
877  title = fmt::sprintf("depth vs drift %s; drift [#mum]; production depth [#mum]",
878  iHists.BPixnewmodulename_[i].c_str());
879  iHists.h_drift_depth_[new_index] =
880  iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
881  }
882  } // end if GrazinAngleAnalysis
883  else {
884  iBooker.setCurrentFolder(folder_);
885  std::string baseName;
886  std::string baseTitle;
887 
888  for (int r = 0; r < iHists.nRings_; ++r) {
889  for (int p = 0; p < iHists.nPanels_; ++p) {
890  for (int s = 0; s < iHists.nSides_; ++s) {
891  baseName = fmt::sprintf("R%d_P%d_z%d", r + 1, p + 1, s + 1);
892  if (s == 0)
893  baseTitle = fmt::sprintf("Ring%d_Panel%d_z-", r + 1, p + 1);
894  else
895  baseTitle = fmt::sprintf("Ring%d_Panel%d_z+", r + 1, p + 1);
896 
897  int idx = iHists.nSides_ * iHists.nPanels_ * r + iHists.nSides_ * p + s;
898  int idxBeta = iHists.betaStartIdx_ + idx;
899 
900  name = fmt::sprintf("%s_alphaMean", baseName);
901  title = fmt::sprintf("%s_alphaMean;cot(#alpha); Average cluster size x (pixel)", baseTitle);
902  iHists.h_fpixMean_[idx] = iBooker.book1D(name, title, 60, -3., 3.);
903  name = fmt::sprintf("%s_betaMean", baseName);
904  title = fmt::sprintf("%s_betaMean;cot(#beta); Average cluster size y (pixel)", baseTitle);
905  iHists.h_fpixMean_[idxBeta] = iBooker.book1D(name, title, 60, -3., 3.);
906 
907  } // loop over sides
908  } // loop over panels
909  } // loop over rings
910  iBooker.setCurrentFolder(fmt::sprintf("%s/FPix", folder_.data()));
911  for (int r = 0; r < iHists.nRings_; ++r) {
912  for (int p = 0; p < iHists.nPanels_; ++p) {
913  for (int s = 0; s < iHists.nSides_; ++s) {
914  baseName = fmt::sprintf("R%d_P%d_z%d", r + 1, p + 1, s + 1);
915  if (s == 0)
916  baseTitle = fmt::sprintf("Ring%d_Panel%d_z-", r + 1, p + 1);
917  else
918  baseTitle = fmt::sprintf("Ring%d_Panel%d_z+", r + 1, p + 1);
919 
920  int idx = iHists.nSides_ * iHists.nPanels_ * r + iHists.nSides_ * p + s;
921  int idxBeta = iHists.betaStartIdx_ + idx;
922 
923  name = fmt::sprintf("%s_alpha", baseName);
924  title = fmt::sprintf("%s_alpha;cot(#alpha); Cluster size x (pixel)", baseTitle);
925  iHists.h_fpixAngleSize_[idx] = iBooker.book2D(name, title, 60, -3., 3., 10, 0.5, 10.5);
926  name = fmt::sprintf("%s_beta", baseName);
927  title = fmt::sprintf("%s_beta;cot(#beta); Cluster size y (pixel) ", baseTitle);
928  iHists.h_fpixAngleSize_[idxBeta] = iBooker.book2D(name, title, 60, -3., 3., 10, 0.5, 10.5);
929  for (int m = 0; m < 3; ++m) {
930  name = fmt::sprintf("%s_B%d", baseName, m);
931  char bComp = m == 0 ? 'x' : (m == 1 ? 'y' : 'z');
932  title = fmt::sprintf("%s_magField%d;B_{%c} [T];Entries", baseTitle, m, bComp);
933  iHists.h_fpixMagField_[m][idx] = iBooker.book1D(name, title, 10000, -5., 5.);
934  } // mag. field comps
935  } // loop over sides
936  } // loop over panels
937  } // loop over rings
938  } // if MinimalClusterSize
939 
940  // book the track monitoring plots
941  iBooker.setCurrentFolder(fmt::sprintf("%s/TrackMonitoring", folder_.data()));
942  iHists.h_tracks_ = iBooker.book1D("h_tracks", ";tracker volume;tracks", 2, -0.5, 1.5);
943  iHists.h_tracks_->setBinLabel(1, "all tracks", 1);
944  iHists.h_tracks_->setBinLabel(2, "has pixel hits", 1);
945  iHists.h_trackEta_ = iBooker.book1D("h_trackEta", ";track #eta; #tracks", 30, -3., 3.);
946  iHists.h_trackPhi_ = iBooker.book1D("h_trackPhi", ";track #phi; #tracks", 48, -M_PI, M_PI);
947  iHists.h_trackPt_ = iBooker.book1D("h_trackPt", ";track p_{T} [GeV]; #tracks", 100, 0., 100.);
948  iHists.h_trackChi2_ = iBooker.book1D("h_trackChi2ndof", ";track #chi^{2}/ndof; #tracks", 100, 0., 10.);
949 }
950 
952  if (notInPCL_) {
953  hFile_->cd();
954  hFile_->Write();
955  hFile_->Close();
956  }
957 }
958 
959 // method used to fill per pixel info
961  Pixinfo pixinfo;
962  const std::vector<SiPixelCluster::Pixel>& pixvector = LocPix.pixels();
963  pixinfo.npix = 0;
964  for (std::vector<SiPixelCluster::Pixel>::const_iterator itPix = pixvector.begin(); itPix != pixvector.end();
965  itPix++) {
966  pixinfo.row[pixinfo.npix] = itPix->x;
967  pixinfo.col[pixinfo.npix] = itPix->y;
968  pixinfo.adc[pixinfo.npix] = itPix->adc;
969  LocalPoint lp = topol->localPosition(MeasurementPoint(itPix->x + 0.5, itPix->y + 0.5));
970  pixinfo.x[pixinfo.npix] = lp.x();
971  pixinfo.y[pixinfo.npix] = lp.y();
972  pixinfo.npix++;
973  }
974  return pixinfo;
975 }
976 
977 // method used to correct for the surface deformation
978 const std::pair<LocalPoint, LocalPoint> SiPixelLorentzAnglePCLWorker::surface_deformation(
979  const PixelTopology* topol, TrajectoryStateOnSurface& tsos, const SiPixelRecHit* recHitPix) const {
980  LocalPoint trackposition = tsos.localPosition();
981  const LocalTrajectoryParameters& ltp = tsos.localParameters();
982  const Topology::LocalTrackAngles localTrackAngles(ltp.dxdz(), ltp.dydz());
983 
984  std::pair<float, float> pixels_track = topol->pixel(trackposition, localTrackAngles);
985  std::pair<float, float> pixels_rechit = topol->pixel(recHitPix->localPosition(), localTrackAngles);
986 
987  LocalPoint lp_track = topol->localPosition(MeasurementPoint(pixels_track.first, pixels_track.second));
988 
989  LocalPoint lp_rechit = topol->localPosition(MeasurementPoint(pixels_rechit.first, pixels_rechit.second));
990 
991  std::pair<LocalPoint, LocalPoint> lps = std::make_pair(lp_track, lp_rechit);
992  return lps;
993 }
994 
996  std::string type) {
997  return (type == "GrazingAngle") ? eGrazingAngle : eMinimumClusterSize;
998 }
999 
1000 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
1003  desc.setComment("Worker module of the SiPixel Lorentz Angle PCL monitoring workflow");
1004  desc.add<std::string>("analysisType", "GrazingAngle")
1005  ->setComment("analysis type - GrazingAngle (default) or MinimumClusterSize");
1006  desc.add<std::string>("folder", "AlCaReco/SiPixelLorentzAngle")->setComment("directory of PCL Worker output");
1007  desc.add<bool>("notInPCL", false)->setComment("create TTree (true) or not (false)");
1008  desc.add<std::string>("fileName", "testrun.root")->setComment("name of the TTree file if notInPCL = true");
1009  desc.add<std::vector<std::string>>("newmodulelist", {})->setComment("the list of DetIds for new sensors");
1010  desc.add<edm::InputTag>("src", edm::InputTag("TrackRefitter"))->setComment("input track collections");
1011  desc.add<double>("ptMin", 3.)->setComment("minimum pt on tracks");
1012  desc.add<double>("normChi2Max", 2.)->setComment("maximum reduced chi squared");
1013  desc.add<std::vector<int>>("clustSizeYMin", {4, 3, 3, 2})
1014  ->setComment("minimum cluster size on Y axis for all Barrel Layers");
1015  desc.add<int>("clustSizeXMax", 5)->setComment("maximum cluster size on X axis");
1016  desc.add<double>("residualMax", 0.005)->setComment("maximum residual");
1017  desc.add<double>("clustChargeMaxPerLength", 50000)
1018  ->setComment("maximum cluster charge per unit length of pixel depth (z)");
1019  desc.add<int>("binsDepth", 50)->setComment("# bins for electron production depth axis");
1020  desc.add<int>("binsDrift", 100)->setComment("# bins for electron drift axis");
1021  descriptions.addWithDefaultLabel(desc);
1022 }
1023 
1024 // define this as a plug-in
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
unsigned int pxbLayer(const DetId &id) const
T perp() const
Definition: PV3DBase.h:69
~SiPixelLorentzAnglePCLWorker() override=default
std::vector< SiPixelTemplateStore > thePixelTemp_
virtual std::pair< float, float > pixel(const LocalPoint &p) const =0
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
float x[maxpix]
std::string folder_
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
unsigned int pxfBlade(const DetId &id) const
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoPerEventEsToken_
int bladeName() const
blade id
int moduleName() const
module id (index in z)
float y[maxpix]
unsigned int pxfModule(const DetId &id) const
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:36
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomPerEventEsToken_
float chiSquared() const
Definition: Trajectory.h:241
const LocalTrajectoryParameters & localParameters() const
edm::ESWatcher< SiPixelTemplateDBObjectESProducerRcd > watchSiPixelTemplateRcd_
unsigned int pxbLadder(const DetId &id) const
bool empty() const
return true if empty
Log< level::Error, false > LogError
float r_qMeas_qTrue()
ratio of measured to true cluster charge
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
LocalPoint toLocal(const GlobalPoint &gp) const
const Pixinfo fillPix(const SiPixelCluster &LocPix, const PixelTopology *topol) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
DataContainer const & measurements() const
Definition: Trajectory.h:178
const_iterator end() const
last iterator over the map (read only)
const std::pair< LocalPoint, LocalPoint > surface_deformation(const PixelTopology *topol, TrajectoryStateOnSurface &tsos, const SiPixelRecHit *recHitPix) const
void Fill(long long x)
virtual float thickness() const =0
double beta
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
float qscale()
charge scaling factor
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
int iEvent
Definition: GenABIO.cc:224
int ndof(bool bon=true) const
Definition: Trajectory.cc:97
const SiPixelTemplateDBObject * templateDBobject_
int diskName() const
disk id
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const std::vector< Pixel > pixels() const
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsToken_
LocalVector localDirection() const
std::unique_ptr< TTree > SiPixelLorentzAngleTreeBarrel_
constexpr float Bfield
Definition: Config.h:96
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
unsigned int pxfDisk(const DetId &id) const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< std::string > newmodulelist_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
LorentzAngleAnalysisTypeEnum convertStringToLorentzAngleAnalysisTypeEnum(std::string type)
SiPixelLorentzAnglePCLWorker(const edm::ParameterSet &)
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
PXFDetId getDetId()
return DetId
#define M_PI
float adc[maxpix]
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
unsigned int pxfPanel(const DetId &id) const
Definition: DetId.h:17
unsigned int pxfSide(const DetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const PositionType & position() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
double alpha
int layerName() const
layer id
SiPixelLorentzAngleCalibrationHistograms iHists
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:212
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
short getTemplateID(const uint32_t &detid) const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
float col[maxpix]
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateEsToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const_iterator begin() const
first iterator over the map (read only)
Pixel cluster – collection of neighboring pixels above threshold.
HLT enums.
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
LocalPoint localPosition() const override
static const int maxpix
edm::EDGetTokenT< TrajTrackAssociationCollection > t_trajTrack
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:49
double gamma
virtual std::pair< float, float > pitch() const =0
unsigned int pxbModule(const DetId &id) const
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
LorentzAngleAnalysisTypeEnum analysisType_
PXBDetId getDetId()
return the DetId
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void dqmEndRun(edm::Run const &, edm::EventSetup const &)
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: Run.h:45
float row[maxpix]
Our base class.
Definition: SiPixelRecHit.h:23
#define LogDebug(id)
std::unique_ptr< TTree > SiPixelLorentzAngleTreeForward_
const Bounds & bounds() const
Definition: Surface.h:87
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9