CMS 3D CMS Logo

TrackerRemapper.cc
Go to the documentation of this file.
1 //
2 // Original Author: Pawel Jurgielewicz
3 // Created: Tue, 21 Nov 2017 13:38:45 GMT
4 //
5 // Modified by: Marco Musich
6 //
7 
8 // system include files
9 #include <memory>
10 #include <fstream>
11 #include <utility>
12 #include <iostream>
13 #include <vector>
14 #include <map>
15 #include <string>
16 
17 // user include files
42 
43 // root include files
44 #include "TGraph.h"
45 #include "TObjString.h"
46 #include "TObjArray.h"
47 #include "TH2Poly.h"
48 #include "TProfile2D.h"
49 #include "TColor.h"
50 
51 using namespace edm;
52 
53 class TrackerRemapper : public edm::one::EDAnalyzer<edm::one::SharedResources> {
54 public:
55  explicit TrackerRemapper(const edm::ParameterSet&);
56  ~TrackerRemapper() override;
57 
58  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
59 
61  INVALID = 0,
62 
67 
69  PXF_R2
70  };
71 
72  enum AnalyzeData {
73  RECHITS = 1,
76  };
77 
78  enum OpMode { MODE_ANALYZE = 0, MODE_REMAP = 1 };
79 
80 private:
81  void beginJob() override;
82  void analyze(const edm::Event&, const edm::EventSetup&) override;
83  void endJob() override;
84 
85  void readVertices(double& minx, double& maxx, double& miny, double& maxy);
86 
87  void prepareStripNames();
88  void preparePixelNames();
89 
90  void bookBins();
91 
92  template <class T>
93  void analyzeGeneric(const edm::Event& iEvent, const edm::EDGetTokenT<T>& src);
94  void analyzeRechits(const edm::Event& iEvent, const edm::EDGetTokenT<reco::TrackCollection>& src);
95 
96  void fillStripRemap();
97  void fillPixelRemap(const TrackerGeometry* theTrackerGeometry, const TrackerTopology* tt);
98  void fillBarrelRemap(TFile* rootFileHandle, const TrackerGeometry* theTrackerGeometry, const TrackerTopology* tt);
99  void fillEndcapRemap(TFile* rootFileHandle, const TrackerGeometry* theTrackerGeometry, const TrackerTopology* tt);
100 
104 
107 
108  int m_opMode;
110 
111  std::map<long, TGraph*> m_bins;
112  std::vector<unsigned> m_detIdVector;
113 
115 
116  std::map<unsigned, std::string> m_stripHistnameMap;
117  std::map<unsigned, std::string> m_pixelHistnameMap;
118  std::map<unsigned, std::string> m_analyzeModeNameMap;
119 
122 
124  std::string m_pixelBaseDir, m_pixelDesiredHistogramBarrel, m_pixelDesiredHistogramDisk;
125 
127 
128  TH2Poly* trackerMap{nullptr};
129 
133 };
134 
135 template <class T>
136 //***************************************************************//
138 //***************************************************************//
139 {
141  iEvent.getByToken(src, input);
142 
143  if (!input.isValid()) {
144  edm::LogError("TrackerRemapper") << "<GENERIC> not found... Aborting...\n";
145  return;
146  }
147 
148  typename T::const_iterator it;
149  for (it = input->begin(); it != input->end(); ++it) {
150  auto id = DetId(it->detId());
151  trackerMap->Fill(TString::Format("%ld", (long)id.rawId()), it->size());
152  }
153 }
154 
155 template <>
156 //***************************************************************//
158 //***************************************************************//
159 {
160  analyzeRechits(iEvent, t);
161 }
162 
163 //***************************************************************//
165  : geomToken_(esConsumes()),
166  topoToken_(esConsumes()),
167  tkDetMapToken_(esConsumes()),
168  iConfig(iConfig),
169  m_opMode(iConfig.getParameter<int>("opMode")),
170  m_analyzeMode(iConfig.getParameter<int>("analyzeMode")) {
171  usesResource("TFileService");
172 
173  if (m_opMode == MODE_REMAP) {
174  m_stripRemapFile = iConfig.getParameter<std::string>("stripRemapFile");
176  runString = iConfig.getParameter<std::string>("runString");
177 
178  m_pixelRemapFile = std::string("DQM_V0001_PixelPhase1_R000305516.root");
179 
180  m_stripBaseDir = std::string("DQMData/Run " + runString + "/SiStrip/Run summary/MechanicalView/");
181  m_pixelBaseDir = std::string("DQMData/Run " + runString + "/PixelPhase1/Run summary/Phase1_MechanicalView/");
182 
183  m_pixelDesiredHistogramBarrel = std::string("adc_per_SignedModule_per_SignedLadder");
184  m_pixelDesiredHistogramDisk = std::string("adc_per_PXDisk_per_SignedBladePanel");
185 
188  } else if (m_opMode == MODE_ANALYZE) {
189  m_analyzeModeNameMap[RECHITS] = "# Rechits";
190  m_analyzeModeNameMap[DIGIS] = "# Digis";
191  m_analyzeModeNameMap[CLUSTERS] = "# Clusters";
192 
193  switch (m_analyzeMode) {
194  case RECHITS:
195  rechitSrcToken = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"));
196  break;
197  case DIGIS:
198  digiSrcToken = consumes<edmNew::DetSetVector<SiStripDigi>>(iConfig.getParameter<edm::InputTag>("src"));
199  break;
200  case CLUSTERS:
201  clusterSrcToken = consumes<edmNew::DetSetVector<SiStripCluster>>(iConfig.getParameter<edm::InputTag>("src"));
202  break;
203  default:
204  edm::LogError("LogicError") << "Unrecognized analyze mode!" << std::endl;
205  }
206  } else {
207  throw cms::Exception("TrackerRemapper") << "Unrecognized operations mode!" << std::endl;
208  }
209 
210  // TColor::SetPalette(1);
211 }
212 
213 //***************************************************************//
215 //***************************************************************//
216 {
217  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIB_L1] =
218  m_stripBaseDir + "TIB/layer_1/" + m_stripDesiredHistogram + "_TIB_L1;1";
219  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIB_L2] =
220  m_stripBaseDir + "TIB/layer_2/" + m_stripDesiredHistogram + "_TIB_L2;1";
221  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIB_L3] =
222  m_stripBaseDir + "TIB/layer_3/" + m_stripDesiredHistogram + "_TIB_L3;1";
223  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIB_L4] =
224  m_stripBaseDir + "TIB/layer_4/" + m_stripDesiredHistogram + "_TIB_L4;1";
225 
226  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIDM_D1] =
227  m_stripBaseDir + "TID/MINUS/wheel_1/" + m_stripDesiredHistogram + "_TIDM_D1;1";
228  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIDM_D2] =
229  m_stripBaseDir + "TID/MINUS/wheel_2/" + m_stripDesiredHistogram + "_TIDM_D2;1";
230  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIDM_D3] =
231  m_stripBaseDir + "TID/MINUS/wheel_3/" + m_stripDesiredHistogram + "_TIDM_D3;1";
232  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIDP_D1] =
233  m_stripBaseDir + "TID/PLUS/wheel_1/" + m_stripDesiredHistogram + "_TIDP_D1;1";
234  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIDP_D2] =
235  m_stripBaseDir + "TID/PLUS/wheel_2/" + m_stripDesiredHistogram + "_TIDP_D2;1";
236  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TIDP_D3] =
237  m_stripBaseDir + "TID/PLUS/wheel_3/" + m_stripDesiredHistogram + "_TIDP_D3;1";
238 
239  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TOB_L1] =
240  m_stripBaseDir + "TOB/layer_1/" + m_stripDesiredHistogram + "_TOB_L1;1";
241  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TOB_L2] =
242  m_stripBaseDir + "TOB/layer_2/" + m_stripDesiredHistogram + "_TOB_L2;1";
243  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TOB_L3] =
244  m_stripBaseDir + "TOB/layer_3/" + m_stripDesiredHistogram + "_TOB_L3;1";
245  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TOB_L4] =
246  m_stripBaseDir + "TOB/layer_4/" + m_stripDesiredHistogram + "_TOB_L4;1";
247  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TOB_L5] =
248  m_stripBaseDir + "TOB/layer_5/" + m_stripDesiredHistogram + "_TOB_L5;1";
249  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TOB_L6] =
250  m_stripBaseDir + "TOB/layer_6/" + m_stripDesiredHistogram + "_TOB_L6;1";
251 
252  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W1] =
253  m_stripBaseDir + "TEC/MINUS/wheel_1/" + m_stripDesiredHistogram + "_TECM_W1;1";
254  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W2] =
255  m_stripBaseDir + "TEC/MINUS/wheel_2/" + m_stripDesiredHistogram + "_TECM_W2;1";
256  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W3] =
257  m_stripBaseDir + "TEC/MINUS/wheel_3/" + m_stripDesiredHistogram + "_TECM_W3;1";
258  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W4] =
259  m_stripBaseDir + "TEC/MINUS/wheel_4/" + m_stripDesiredHistogram + "_TECM_W4;1";
260  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W5] =
261  m_stripBaseDir + "TEC/MINUS/wheel_5/" + m_stripDesiredHistogram + "_TECM_W5;1";
262  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W6] =
263  m_stripBaseDir + "TEC/MINUS/wheel_6/" + m_stripDesiredHistogram + "_TECM_W6;1";
264  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W7] =
265  m_stripBaseDir + "TEC/MINUS/wheel_7/" + m_stripDesiredHistogram + "_TECM_W7;1";
266  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W8] =
267  m_stripBaseDir + "TEC/MINUS/wheel_8/" + m_stripDesiredHistogram + "_TECM_W8;1";
268  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECM_W9] =
269  m_stripBaseDir + "TEC/MINUS/wheel_9/" + m_stripDesiredHistogram + "_TECM_W9;1";
270 
271  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W1] =
272  m_stripBaseDir + "TEC/PLUS/wheel_1/" + m_stripDesiredHistogram + "_TECP_W1;1";
273  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W2] =
274  m_stripBaseDir + "TEC/PLUS/wheel_2/" + m_stripDesiredHistogram + "_TECP_W2;1";
275  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W3] =
276  m_stripBaseDir + "TEC/PLUS/wheel_3/" + m_stripDesiredHistogram + "_TECP_W3;1";
277  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W4] =
278  m_stripBaseDir + "TEC/PLUS/wheel_4/" + m_stripDesiredHistogram + "_TECP_W4;1";
279  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W5] =
280  m_stripBaseDir + "TEC/PLUS/wheel_5/" + m_stripDesiredHistogram + "_TECP_W5;1";
281  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W6] =
282  m_stripBaseDir + "TEC/PLUS/wheel_6/" + m_stripDesiredHistogram + "_TECP_W6;1";
283  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W7] =
284  m_stripBaseDir + "TEC/PLUS/wheel_7/" + m_stripDesiredHistogram + "_TECP_W7;1";
285  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W8] =
286  m_stripBaseDir + "TEC/PLUS/wheel_8/" + m_stripDesiredHistogram + "_TECP_W8;1";
287  m_stripHistnameMap[TkLayerMap::TkLayerEnum::TECP_W9] =
288  m_stripBaseDir + "TEC/PLUS/wheel_9/" + m_stripDesiredHistogram + "_TECP_W9;1";
289 }
290 
291 //***************************************************************//
293 //***************************************************************//
294 {
295  m_pixelHistnameMap[PixelLayerEnum::PXB_L1] =
296  m_pixelBaseDir + "PXBarrel/" + m_pixelDesiredHistogramBarrel + "_PXLayer_1;1";
297  m_pixelHistnameMap[PixelLayerEnum::PXB_L2] =
298  m_pixelBaseDir + "PXBarrel/" + m_pixelDesiredHistogramBarrel + "_PXLayer_2;1";
299  m_pixelHistnameMap[PixelLayerEnum::PXB_L3] =
300  m_pixelBaseDir + "PXBarrel/" + m_pixelDesiredHistogramBarrel + "_PXLayer_3;1";
301  m_pixelHistnameMap[PixelLayerEnum::PXB_L4] =
302  m_pixelBaseDir + "PXBarrel/" + m_pixelDesiredHistogramBarrel + "_PXLayer_4;1";
303 
304  m_pixelHistnameMap[PixelLayerEnum::PXF_R1] =
305  m_pixelBaseDir + "PXForward/" + m_pixelDesiredHistogramDisk + "_PXRing_1;1";
306  m_pixelHistnameMap[PixelLayerEnum::PXF_R2] =
307  m_pixelBaseDir + "PXForward/" + m_pixelDesiredHistogramDisk + "_PXRing_2;1";
308 }
309 
311 
312 //***************************************************************//
314 //***************************************************************//
315 {
316  // get the ES products
317 
318  const TrackerGeometry* theTrackerGeometry = &iSetup.getData(geomToken_);
319  const TrackerTopology* tt = &iSetup.getData(topoToken_);
320  m_tkdetmap = &iSetup.getData(tkDetMapToken_);
321 
322  if (!trackerMap)
323  bookBins();
324 
325  if (m_opMode == MODE_ANALYZE) {
326  switch (m_analyzeMode) {
327  case AnalyzeData::RECHITS:
329  break;
330  case AnalyzeData::DIGIS:
332  break;
333  case AnalyzeData::CLUSTERS:
335  break;
336  default:
337  edm::LogError("LogicError") << "Unrecognized Analyze mode!" << std::endl;
338  return;
339  }
340  } else if (m_opMode == MODE_REMAP) {
341  fillStripRemap();
342  fillPixelRemap(theTrackerGeometry, tt);
343  }
344 }
345 
346 //***************************************************************//
348 //***************************************************************//
349 {
351  iEvent.getByToken(src, tracks);
352  if (!tracks.isValid()) {
353  LogInfo("Analyzer") << "reco::TrackCollection not found... Aborting...\n";
354  return;
355  }
356 
357  for (auto const& track : *tracks) {
358  auto recHitsBegin = track.recHitsBegin();
359  for (unsigned i = 0; i < track.recHitsSize(); ++i) {
360  auto recHit = *(recHitsBegin + i);
361  if (!recHit->isValid())
362  continue;
363 
364  DetId id = recHit->geographicalId();
365  unsigned subdetId = id.subdetId();
366 
367  //reject Pixel
368  if (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap)
369  continue;
370 
371  // NRECHITS
372  trackerMap->Fill(TString::Format("%ld", (long)id.rawId()), 1);
373  }
374  }
375 }
376 
377 //***************************************************************//
379 //***************************************************************//
380 {
381  // Read vertices from file
382  double minx = 0xFFFFFF, maxx = -0xFFFFFF, miny = 0xFFFFFF, maxy = -0xFFFFFFF;
383  readVertices(minx, maxx, miny, maxy);
384 
385  TObject* ghostObj = fs->make<TH2Poly>("ghost", "ghost", -1, 1, -1, 1);
386 
387  TDirectory* topDir = fs->getBareDirectory();
388  topDir->cd();
389 
390  int margin = 50;
391  std::string mapTitle;
392  switch (m_opMode) {
393  case MODE_ANALYZE:
395  break;
396  case MODE_REMAP:
397  mapTitle = std::string(m_stripDesiredHistogram + " - " + runString);
398  break;
399  }
400 
401  trackerMap = new TH2Poly("Tracker Map", mapTitle.c_str(), minx - margin, maxx + margin, miny - margin, maxy + margin);
402  trackerMap->SetFloat();
403  trackerMap->SetOption("COLZ");
404  trackerMap->SetStats(false);
405 
406  for (auto pair : m_bins) {
407  trackerMap->AddBin(pair.second->Clone());
408  }
409 
410  topDir->Add(trackerMap);
411 
412  ghostObj->Delete(); //not needed any more
413 }
414 
415 //***************************************************************//
416 void TrackerRemapper::readVertices(double& minx, double& maxx, double& miny, double& maxy)
417 //***************************************************************//
418 {
419  std::ifstream in;
420 
421  // TPolyline vertices stored at https://github.com/cms-data/DQM-SiStripMonitorClient
422  in.open(edm::FileInPath("DQM/SiStripMonitorClient/data/Geometry/tracker_map_bare").fullPath().c_str());
423 
424  unsigned count = 0;
425 
426  if (!in.good()) {
427  throw cms::Exception("TrackerRemapper") << "Error Reading File" << std::endl;
428  }
429  while (in.good()) {
430  long detid = 0;
431  double x[5], y[5];
432 
434  std::getline(in, line);
435  ++count;
436 
437  TString string(line);
438  TObjArray* array = string.Tokenize(" ");
439  int ix{0}, iy{0};
440  bool isPixel{false};
441  for (int i = 0; i < array->GetEntries(); ++i) {
442  if (i == 0) {
443  detid = static_cast<TObjString*>(array->At(i))->String().Atoll();
444 
445  // Drop Pixel Data
446  DetId detId(detid);
448  isPixel = true;
449  break;
450  }
451  } else {
452  if (i % 2 == 0) {
453  x[ix] = static_cast<TObjString*>(array->At(i))->String().Atof();
454 
455  if (x[ix] < minx)
456  minx = x[ix];
457  if (x[ix] > maxx)
458  maxx = x[ix];
459 
460  ++ix;
461  } else {
462  y[iy] = static_cast<TObjString*>(array->At(i))->String().Atof();
463 
464  if (y[iy] < miny)
465  miny = y[iy];
466  if (y[iy] > maxy)
467  maxy = y[iy];
468 
469  ++iy;
470  }
471  }
472  }
473 
474  if (isPixel)
475  continue;
476 
477  m_detIdVector.push_back(detid);
478  m_bins[detid] = new TGraph(ix, x, y);
479  m_bins[detid]->SetName(TString::Format("%ld", detid));
480  m_bins[detid]->SetTitle(TString::Format("Module ID=%ld", detid));
481  }
482 }
483 
484 //***************************************************************//
486 //***************************************************************//
487 {
488  int nchX;
489  int nchY;
490  double lowX, highX;
491  double lowY, highY;
492 
493  TFile* rootFileHandle = new TFile(m_stripRemapFile.c_str());
494 
495  for (int layer = TkLayerMap::TkLayerEnum::TIB_L1; layer <= TkLayerMap::TkLayerEnum::TECP_W9; ++layer) {
496  m_tkdetmap->getComponents(layer, nchX, lowX, highX, nchY, lowY, highY);
497 
498  const TProfile2D* histHandle = (TProfile2D*)rootFileHandle->Get(m_stripHistnameMap[layer].c_str());
499 
500  if (!histHandle) {
501  edm::LogError("TrackerRemapper") << "Could not find histogram:\n\t" << m_stripHistnameMap[layer] << std::endl;
502  return;
503  }
504 
505  for (unsigned binx = 1; binx <= (unsigned)nchX; ++binx) {
506  for (unsigned biny = 1; biny <= (unsigned)nchY; ++biny) {
507  long rawid = m_tkdetmap->getDetFromBin(layer, binx, biny);
508 
509  if (rawid) //bin represents real module -> go to file
510  {
511  double val = histHandle->GetBinContent(binx, biny);
512 
513  // edm::LogInfo("TrackerRemapper") << rawid << " " << val << "\n";
514 
515  trackerMap->Fill(TString::Format("%ld", rawid), val);
516  }
517  }
518  }
519  }
520 
521  rootFileHandle->Close();
522 }
523 
524 //***************************************************************//
525 void TrackerRemapper::fillPixelRemap(const TrackerGeometry* theTrackerGeometry, const TrackerTopology* tt)
526 //***************************************************************//
527 {
528  TFile* rootFileHandle = new TFile(m_pixelRemapFile.c_str());
529 
530  if (!rootFileHandle) {
531  edm::LogError("TrackerRemapper") << "Could not find file:\n\t" << m_pixelRemapFile << std::endl;
532  return;
533  }
534  fillBarrelRemap(rootFileHandle, theTrackerGeometry, tt);
535  fillEndcapRemap(rootFileHandle, theTrackerGeometry, tt);
536 
537  rootFileHandle->Close();
538 }
539 
540 //***************************************************************//
541 void TrackerRemapper::fillBarrelRemap(TFile* rootFileHandle,
542  const TrackerGeometry* theTrackerGeometry,
543  const TrackerTopology* tt)
544 //***************************************************************//
545 {
546  TrackingGeometry::DetContainer pxb = theTrackerGeometry->detsPXB();
547 
548  for (auto& i : pxb) {
549  const GeomDet* det = i;
550 
551  PXBDetId id = det->geographicalId();
552  long rawid = id.rawId();
553 
554  int module = tt->pxbModule(id);
555  int layer = tt->pxbLayer(id);
556 
557  int signedOnlineModule = module - 4;
558  if (signedOnlineModule <= 0)
559  --signedOnlineModule;
560 
561  PixelBarrelName pixelBarrelName = PixelBarrelName(id, tt, true);
562  int onlineShell = pixelBarrelName.shell();
563 
564  int signedOnlineLadder = ((onlineShell & 1) ? -pixelBarrelName.ladderName() : pixelBarrelName.ladderName());
565 
566  const TProfile2D* histHandle = (TProfile2D*)rootFileHandle->Get(m_pixelHistnameMap[layer].c_str());
567 
568  unsigned nx = histHandle->GetNbinsX();
569  unsigned ny = histHandle->GetNbinsY();
570 
571  unsigned binX = signedOnlineModule + ((nx + 1) >> 1);
572  unsigned binY = (signedOnlineLadder) + ((ny + 1) >> 1);
573 
574  double val = histHandle->GetBinContent(binX, binY);
575 
576  trackerMap->Fill(TString::Format("%ld", rawid), val);
577  }
578 }
579 
580 //***************************************************************//
581 void TrackerRemapper::fillEndcapRemap(TFile* rootFileHandle,
582  const TrackerGeometry* theTrackerGeometry,
583  const TrackerTopology* tt)
584 //***************************************************************//
585 {
586  TrackingGeometry::DetContainer pxf = theTrackerGeometry->detsPXF();
587 
588  for (auto& i : pxf) {
589  const GeomDet* det = i;
590 
591  PXFDetId id = det->geographicalId();
592 
593  int side = tt->side(id);
594  int disk = tt->layer(id);
595 
596  long rawid = id.rawId();
597 
598  PixelEndcapName pixelEndcapName = PixelEndcapName(PXFDetId(rawid), tt, true);
599 
600  unsigned layer = pixelEndcapName.ringName() - 1 + PixelLayerEnum::PXF_R1;
601  const TProfile2D* histHandle = (TProfile2D*)rootFileHandle->Get(m_pixelHistnameMap[layer].c_str());
602 
603  // ---- REMAP (Online -> Offline)
604  unsigned nx = histHandle->GetNbinsX();
605  unsigned ny = histHandle->GetNbinsY();
606 
607  int onlineBlade = pixelEndcapName.bladeName();
608  bool isInnerOnlineBlade = !(pixelEndcapName.halfCylinder() & 1); // inner -> blade > 0 (?)
609 
610  int signedOnlineBlade = (isInnerOnlineBlade) ? onlineBlade : -onlineBlade;
611  int signedDisk = (side == 2) ? disk : -disk;
612  int pannel = pixelEndcapName.pannelName() - 1;
613 
614  unsigned binX = signedDisk + ((nx + 1) >> 1);
615  unsigned binY = (signedOnlineBlade * 2) + (ny >> 1);
616 
617  double val = histHandle->GetBinContent(binX, binY + pannel);
618 
619  trackerMap->Fill(TString::Format("%ld", rawid), val);
620  }
621 }
622 
624 
626 
627 //***************************************************************//
629 //***************************************************************//
630 {
632  desc.setComment(
633  "Creates TH2Poly Strip Tracker maps by either analyzing the event or remapping exising DQM historams");
634  desc.add<edm::InputTag>("src", edm::InputTag("generalTracks"));
635  desc.ifValue(edm::ParameterDescription<int>("opMode", 0, true),
637  1 >> (edm::ParameterDescription<std::string>("stripRemapFile", "", true) and
638  edm::ParameterDescription<std::string>("stripHistogram", "", true) and
639  edm::ParameterDescription<std::string>("runString", "", true)))
640  ->setComment("0 for Analyze, 1 for Remap");
641 
642  desc.ifValue(edm::ParameterDescription<int>("analyzeMode", 1, true), edm::allowedValues<int>(1, 2, 3))
643  ->setComment("1=Rechits, 2=Digis, 3=Clusters");
644 
645  //desc.add<unsigned int>("analyzeMode", 1)->setComment("1=Rechits, 2=Digis, 3=Clusters");
646  //desc.add<unsigned int>("opMode", 0)->setComment("0 for Analyze, 1 for Remap");
647  //desc.addOptional<std::string>("stripRemapFile","" )->setComment("file name to analyze, will come from the config file");
648  //desc.addOptional<std::string>("stripHistogram","TkHMap_NumberValidHits" )->setComment("histogram to use to remap");
649  //desc.addOptional<std::string>("runString", "")->setComment("run number, will come form config file");
650  descriptions.addWithDefaultLabel(desc);
651 }
652 
653 //define this as a plug-in
TrackerRemapper::DIGIS
Definition: TrackerRemapper.cc:74
allowedValues.h
DDAxes::y
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
TrackerRemapper::m_stripDesiredHistogram
std::string m_stripDesiredHistogram
Definition: TrackerRemapper.cc:123
TrackerRemapper::iConfig
const edm::ParameterSet & iConfig
Definition: TrackerRemapper.cc:106
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
input
static const std::string input
Definition: EdmProvDump.cc:48
PixelBarrelName.h
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
ESHandle.h
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
TrackerRemapper::m_analyzeMode
int m_analyzeMode
Definition: TrackerRemapper.cc:109
edm::EDGetTokenT
Definition: EDGetToken.h:33
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TrackerRemapper::PXB_L2
Definition: TrackerRemapper.cc:64
PixelBarrelName
Definition: PixelBarrelName.h:16
TrackerRemapper::OpMode
OpMode
Definition: TrackerRemapper.cc:78
TrackerRemapper::m_pixelBaseDir
std::string m_pixelBaseDir
Definition: TrackerRemapper.cc:124
MODE_ANALYZE
Definition: SiPixelPhase1Analyzer.h:68
TrackerRemapper::analyzeGeneric
void analyzeGeneric(const edm::Event &iEvent, const edm::EDGetTokenT< T > &src)
Definition: TrackerRemapper.cc:137
TrackerRemapper::beginJob
void beginJob() override
Definition: TrackerRemapper.cc:623
mps_check.array
array
Definition: mps_check.py:216
EmptyGroupDescription.h
PixelEndcapName::halfCylinder
HalfCylinder halfCylinder() const
Definition: PixelEndcapName.h:42
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
TrackerRemapper::rechitSrcToken
edm::EDGetTokenT< reco::TrackCollection > rechitSrcToken
Definition: TrackerRemapper.cc:130
TrackerRemapper::m_detIdVector
std::vector< unsigned > m_detIdVector
Definition: TrackerRemapper.cc:112
TrackerRemapper::m_pixelRemapFile
std::string m_pixelRemapFile
Definition: TrackerRemapper.cc:121
TrackerRemapper::geomToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
Definition: TrackerRemapper.cc:101
PixelEndcapName::pannelName
int pannelName() const
pannel id
Definition: PixelEndcapName.h:51
TrackerRemapper::digiSrcToken
edm::EDGetTokenT< edmNew::DetSetVector< SiStripDigi > > digiSrcToken
Definition: TrackerRemapper.cc:131
edm::Handle
Definition: AssociativeIterator.h:50
PixelEndcapName::bladeName
int bladeName() const
blade id
Definition: PixelEndcapName.h:48
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
TrackerRemapper::RECHITS
Definition: TrackerRemapper.cc:73
TrackerRemapper::~TrackerRemapper
~TrackerRemapper() override
Definition: TrackerRemapper.cc:310
TrackerRemapper::analyzeRechits
void analyzeRechits(const edm::Event &iEvent, const edm::EDGetTokenT< reco::TrackCollection > &src)
Definition: TrackerRemapper.cc:347
TrackerRemapper::endJob
void endJob() override
Definition: TrackerRemapper.cc:625
TrackerRemapper::m_pixelDesiredHistogramDisk
std::string m_pixelDesiredHistogramDisk
Definition: TrackerRemapper.cc:124
TrackerRemapper::fillPixelRemap
void fillPixelRemap(const TrackerGeometry *theTrackerGeometry, const TrackerTopology *tt)
Definition: TrackerRemapper.cc:525
TrackerGeometry::detsPXB
const DetContainer & detsPXB() const
Definition: TrackerGeometry.cc:171
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:61
MakerMacros.h
TrackerTopology.h
TrackerRemapper::m_stripHistnameMap
std::map< unsigned, std::string > m_stripHistnameMap
Definition: TrackerRemapper.cc:116
Track.h
PixelEndcapName
Definition: PixelEndcapName.h:16
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackerRemapper::fillBarrelRemap
void fillBarrelRemap(TFile *rootFileHandle, const TrackerGeometry *theTrackerGeometry, const TrackerTopology *tt)
Definition: TrackerRemapper.cc:541
Service.h
SiStripDigi.h
TrackerRemapper::prepareStripNames
void prepareStripNames()
Definition: TrackerRemapper.cc:214
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
cond::time::INVALID
static constexpr TimeType INVALID
Definition: Time.h:33
TkDetMap::getDetFromBin
DetId getDetFromBin(int layer, int ix, int iy) const
Definition: TkDetMap.h:191
TrackerRemapper::PXB_L3
Definition: TrackerRemapper.cc:65
TrackerGeometry::detsPXF
const DetContainer & detsPXF() const
Definition: TrackerGeometry.cc:173
TkDetMap
Definition: TkDetMap.h:175
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
TrackerRemapper::m_stripRemapFile
std::string m_stripRemapFile
Definition: TrackerRemapper.cc:120
TrackerRemapper::AnalyzeData
AnalyzeData
Definition: TrackerRemapper.cc:72
PXFDetId
Definition: PXFDetId.h:15
PixelBarrelName::ladderName
int ladderName() const
ladder id (index in phi)
Definition: PixelBarrelName.h:49
TrackerRemapper::tkDetMapToken_
const edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
Definition: TrackerRemapper.cc:103
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
TFileService.h
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
TrackerDigiGeometryRecord.h
TrackerRemapper::topoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: TrackerRemapper.cc:102
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripCluster.h
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
TrackerRemapper::PixelLayerEnum
PixelLayerEnum
Definition: TrackerRemapper.cc:60
TrackerRemapper::PXB_L1
Definition: TrackerRemapper.cc:63
TrackerRemapper::TrackerRemapper
TrackerRemapper(const edm::ParameterSet &)
Definition: TrackerRemapper.cc:164
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
fastTrackerRecHitType::isPixel
bool isPixel(HitType hitType)
Definition: FastTrackerRecHit.h:37
TrackerRemapper::MODE_REMAP
Definition: TrackerRemapper.cc:78
PixelBarrelName::shell
Shell shell() const
Definition: PixelBarrelName.h:40
TrackerRemapper::fillEndcapRemap
void fillEndcapRemap(TFile *rootFileHandle, const TrackerGeometry *theTrackerGeometry, const TrackerTopology *tt)
Definition: TrackerRemapper.cc:581
TrackingGeometry::DetContainer
std::vector< const GeomDet * > DetContainer
Definition: TrackingGeometry.h:29
recoMuon::in
Definition: RecoMuonEnumerators.h:6
TrackerRemapper::runString
std::string runString
Definition: TrackerRemapper.cc:126
TrackerRemapper::m_tkdetmap
const TkDetMap * m_tkdetmap
Definition: TrackerRemapper.cc:114
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
TrackerRemapper::fillStripRemap
void fillStripRemap()
Definition: TrackerRemapper.cc:485
TrackerRemapper::m_opMode
int m_opMode
Definition: TrackerRemapper.cc:108
TrackerRemapper::CLUSTERS
Definition: TrackerRemapper.cc:75
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:58
TrackerRemapper::preparePixelNames
void preparePixelNames()
Definition: TrackerRemapper.cc:292
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TrackerRemapper::m_pixelDesiredHistogramBarrel
std::string m_pixelDesiredHistogramBarrel
Definition: TrackerRemapper.cc:124
TrackerRemapper::PXB_L4
Definition: TrackerRemapper.cc:66
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
TrackerRemapper::m_bins
std::map< long, TGraph * > m_bins
Definition: TrackerRemapper.cc:111
TrackerRemapper::m_pixelHistnameMap
std::map< unsigned, std::string > m_pixelHistnameMap
Definition: TrackerRemapper.cc:117
callgraph.module
module
Definition: callgraph.py:61
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
heppy_batch.val
val
Definition: heppy_batch.py:351
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TFileService::getBareDirectory
TDirectory * getBareDirectory(const std::string &subdir="") const
Definition: TFileService.h:52
Frameworkfwd.h
TrackerRemapper::trackerMap
TH2Poly * trackerMap
Definition: TrackerRemapper.cc:128
Exception
Definition: hltDiff.cc:245
TrackerRemapper::m_analyzeModeNameMap
std::map< unsigned, std::string > m_analyzeModeNameMap
Definition: TrackerRemapper.cc:118
TkDetMap::getComponents
void getComponents(int layer, int &nchX, double &lowX, double &highX, int &nchY, double &lowY, double &highY) const
Definition: TkDetMap.cc:589
TrackerRemapper::m_stripBaseDir
std::string m_stripBaseDir
Definition: TrackerRemapper.cc:123
TrackerRemapper::PXF_R1
Definition: TrackerRemapper.cc:68
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrackerRemapper::MODE_ANALYZE
Definition: TrackerRemapper.cc:78
TkDetMap.h
TrackerRemapper::clusterSrcToken
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusterSrcToken
Definition: TrackerRemapper.cc:132
TrackerRemapper::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TrackerRemapper.cc:628
PXBDetId
Definition: PXBDetId.h:16
TrackerRemapper
Definition: TrackerRemapper.cc:53
ParameterSet.h
PXBDetId.h
PXFDetId.h
TrackerRemapper::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TrackerRemapper.cc:313
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
mps_splice.line
line
Definition: mps_splice.py:76
TrackerRemapper::bookBins
void bookBins()
Definition: TrackerRemapper.cc:378
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MODE_REMAP
Definition: SiPixelPhase1Analyzer.h:68
edm::EmptyGroupDescription
Definition: EmptyGroupDescription.h:15
edm::ParameterDescription
Definition: ParameterDescription.h:110
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15
PixelEndcapName::ringName
int ringName() const
ring Id
Definition: PixelEndcapName.h:57
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
TrackerRemapper::fs
edm::Service< TFileService > fs
Definition: TrackerRemapper.cc:105
TrackerRemapper::readVertices
void readVertices(double &minx, double &maxx, double &miny, double &maxy)
Definition: TrackerRemapper.cc:416
margin
Double_t margin
Definition: trackSplitPlot.h:45
PixelEndcapName.h
TrackerGeometry
Definition: TrackerGeometry.h:14