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