CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPixelPhase1Analyzer Class Reference

#include <EJTerm/SiPixelPhase1Analyzer/plugins/SiPixelPhase1Analyzer.cc>

Inheritance diagram for SiPixelPhase1Analyzer:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  complementaryElements
 

Public Member Functions

 SiPixelPhase1Analyzer (const edm::ParameterSet &)
 
 ~SiPixelPhase1Analyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void BookBarrelBins (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
 
void BookBarrelHistograms (TDirectory *currentDir, const std::string &currentHistoName)
 
void BookBins (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
 
void BookForwardBins (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
 
void BookForwardHistograms (TDirectory *currentDir, const std::string &currentHistoName)
 
void BookHistograms ()
 
void FillBarrelBinsAnalyze (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt, unsigned rawId, const GlobalPoint &globalPoint)
 
void FillBarrelBinsRemap (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
 
void FillBins (edm::Handle< reco::TrackCollection > *tracks, const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
 
void FillForwardBinsAnalyze (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt, unsigned rawId, const GlobalPoint &globalPoint)
 
void FillForwardBinsRemap (const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
 
void SaveDetectorData (bool isBarrel, unsigned rawId, int shell_hc, int layer_disk, int ladder_blade)
 
void SaveDetectorVertices (const TrackerTopology *tt)
 

Private Attributes

std::vector< std::string > analazedRootFileName
 
std::vector< std::string > baseHistogramName
 
std::map< uint32_t, TGraph * > bins
 
std::map< uint32_t, TGraph * > binsSummary
 
std::ofstream debugFile
 
std::string debugFileName
 
bool firstEvent
 
edm::Service< TFileServicefs
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordgeomToken_
 
std::vector< unsigned > isBarrelSource
 
std::map< unsigned short, complementaryElementsmapOfComplementaryElements
 
OperationMode opMode
 
mat4 orthoProjectionMatrix
 
std::vector< std::string > pathToHistograms
 
std::map< std::string, std::vector< TH2Poly * > > pxfTh2PolyForward
 
std::map< std::string, TH2Poly * > pxfTh2PolyForwardSummary
 
TFile * rootFileHandle
 
std::map< std::string, std::vector< TH2Poly * > > th2PolyBarrel
 
std::map< std::string, TH2Poly * > th2PolyBarrelSummary
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtopoToken_
 
edm::EDGetTokenT< reco::TrackCollectiontracksToken
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 70 of file SiPixelPhase1Analyzer.h.

Constructor & Destructor Documentation

◆ SiPixelPhase1Analyzer()

SiPixelPhase1Analyzer::SiPixelPhase1Analyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 12 of file SiPixelPhase1Analyzer.cc.

References analazedRootFileName, baseHistogramName, mat4::BuildOrthographicMatrix(), debugFile, debugFileName, f, edm::ParameterSet::getParameter(), MODE_ANALYZE, MODE_REMAP, opMode, orthoProjectionMatrix, MillePedeFileConverter_cfg::out, pathToHistograms, and tracksToken.

15  opMode(static_cast<OperationMode>(iConfig.getUntrackedParameter<unsigned int>("opMode"))),
16  debugFileName(iConfig.getUntrackedParameter<string>("debugFileName")),
17  firstEvent(true),
18  rootFileHandle(nullptr),
19  isBarrelSource(iConfig.getUntrackedParameter<vector<unsigned>>("isBarrelSource")),
20  analazedRootFileName(iConfig.getUntrackedParameter<vector<string>>("remapRootFileName")),
21  pathToHistograms(iConfig.getUntrackedParameter<vector<string>>("pathToHistograms")),
22  baseHistogramName(iConfig.getUntrackedParameter<vector<string>>("baseHistogramName")) {
23 #ifdef DEBUG_MODE
24  debugFile = std::ofstream(debugFileName.c_str(), std::ofstream::out);
25 #endif
26  usesResource("TFileService");
27 
28  orthoProjectionMatrix.BuildOrthographicMatrix(1.0f, -1.0f, 1.0f, -1.0f, -10.0f, 10.0f);
29 
30  switch (opMode) {
31  case MODE_ANALYZE:
32 
33  tracksToken = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"));
34 
35  analazedRootFileName.clear();
36 
37  pathToHistograms.clear();
38  pathToHistograms.push_back("RecHits/");
39 
40  baseHistogramName.clear();
41  baseHistogramName.push_back("RecHits");
42 
43  break;
44  case MODE_REMAP:
45  break;
46  default:
47  break;
48  }
49 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::string > pathToHistograms
std::vector< unsigned > isBarrelSource
void BuildOrthographicMatrix(float left, float right, float top, float bottom, float near, float far)
Definition: mat4.h:86
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::TrackCollection > tracksToken
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
double f[11][100]
std::vector< std::string > analazedRootFileName
std::vector< std::string > baseHistogramName

◆ ~SiPixelPhase1Analyzer()

SiPixelPhase1Analyzer::~SiPixelPhase1Analyzer ( )
override

Definition at line 51 of file SiPixelPhase1Analyzer.cc.

References bins, binsSummary, debugFile, and mps_fire::i.

51  {
52  for (auto& i : bins) {
53  delete i.second;
54  }
55 
56  for (auto& i : binsSummary) {
57  delete i.second;
58  }
59 
60 #ifdef DEBUG_MODE
61  debugFile.close();
62 #endif
63 }
std::map< uint32_t, TGraph * > binsSummary
std::map< uint32_t, TGraph * > bins

Member Function Documentation

◆ analyze()

void SiPixelPhase1Analyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 66 of file SiPixelPhase1Analyzer.cc.

References BookBins(), BookHistograms(), FillBins(), firstEvent, geomToken_, edm::EventSetup::getData(), iEvent, MODE_ANALYZE, MODE_REMAP, opMode, topoToken_, tracks, and tracksToken.

66  {
67  const auto& theTrackerGeometry = iSetup.getData(geomToken_);
68  const auto& tt = &iSetup.getData(topoToken_);
69 
70  if (firstEvent) {
74  BookBins(theTrackerGeometry, tt);
76  if (opMode == MODE_REMAP) {
77  FillBins(nullptr, theTrackerGeometry, tt);
78  }
80  firstEvent = false;
81  }
82  if (opMode == MODE_ANALYZE) {
84  iEvent.getByToken(tracksToken, tracks);
85  if (!tracks.isValid()) {
86  LogInfo("Analyzer") << "reco::TrackCollection not found... Aborting...\n";
87  return;
88  }
89  FillBins(&tracks, theTrackerGeometry, tt);
90  }
91  // debugFile << "SiPixelPhase1Analyzer::analyze() - Event " << iEvent.run() << "/" << iEvent.id().event() << endl;
92 }
void FillBins(edm::Handle< reco::TrackCollection > *tracks, const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
edm::EDGetTokenT< reco::TrackCollection > tracksToken
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
Log< level::Info, false > LogInfo
auto const & tracks
cannot be loose
void BookBins(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)

◆ BookBarrelBins()

void SiPixelPhase1Analyzer::BookBarrelBins ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt 
)
private

Definition at line 268 of file SiPixelPhase1Analyzer.cc.

References b, baseHistogramName, bins, binsSummary, Surface::bounds(), debugFile, TrackerGeometry::detsPXB(), f, dqmMemoryStats::float, GeomDet::geographicalId(), mps_fire::i, isBarrelSource, dqmdumpme::k, PVValHelper::ladder, PixelBarrelName::ladderName(), phase1PixelTopology::layer, PixelBarrelName::layerName(), MODE_ANALYZE, callgraph::module, opMode, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, SaveDetectorData(), PixelBarrelName::shell(), mathSSE::sqrt(), GeomDet::surface(), th2PolyBarrel, th2PolyBarrelSummary, and Surface::toGlobal().

Referenced by BookBins().

268  {
269  TrackingGeometry::DetContainer pxb = theTrackerGeometry.detsPXB();
270 #ifdef DEBUG_MODE
271  debugFile << "There are " << pxb.size() << " detector elements in the PXB." << endl;
272 #endif
273  for (auto& i : pxb) {
274  const GeomDet* det = i;
275 
276  PXBDetId id = det->geographicalId();
277 
278  Local2DPoint origin;
279  GlobalPoint p = det->surface().toGlobal(origin);
280 
281  int layer = tt->pxbLayer(id);
282  int ladder = tt->pxbLadder(id);
283 
284 #ifdef DEBUG_MODE
285  int module = tt->pxbModule(id);
286  PixelBarrelName pixelBarrelName(id, tt, true);
288  true, id.rawId(), pixelBarrelName.shell(), pixelBarrelName.layerName(), pixelBarrelName.ladderName());
289 #endif
290 
291 #ifdef DEBUG_MODE
292  float r = sqrt(p.x() * p.x() + p.y() * p.y());
293 
294  debugFile << "Layer: " << layer << "\tLadder: " << ladder << "\tModule: " << module << "\t(x, y, z, r2): (" << p.x()
295  << ", " << p.y() << ", " << p.z() << ", " << r << ")" << endl;
296 #endif
297 
298  const Bounds& b = (det->surface().bounds());
299  float bl = b.length();
300 
301 #ifdef DEBUG_MODE
302  float bw = b.width();
303  float bt = b.thickness();
304 
305  debugFile << "Length: " << bl << "\tWidth: " << bw << "\tThickness: " << bt << endl;
306 #endif
307 
308  float vertX[] = {p.z() - bl * 0.5f, p.z() + bl * 0.5f, p.z() + bl * 0.5f, p.z() - bl * 0.5f, p.z() - bl * 0.5f};
309  float vertY[] = {(ladder - 1.0f), (ladder - 1.0f), (float)ladder, (float)ladder, (ladder - 1.0f)};
310 
311  bins[id.rawId()] = new TGraph(5, vertX, vertY);
312  bins[id.rawId()]->SetName(TString::Format("%u", id.rawId()));
313 
314  // Summary plot
315  for (unsigned k = 0; k < 5; ++k) {
316  vertX[k] += ((layer == 2 || layer == 3) ? 0.0f : -60.0f);
317  vertY[k] += ((layer > 2) ? 30.0f : 0.0f);
318  }
319 
320  binsSummary[id.rawId()] = new TGraph(5, vertX, vertY);
321  binsSummary[id.rawId()]->SetName(TString::Format("%u", id.rawId()));
322 
323  for (unsigned nameNum = 0; nameNum < baseHistogramName.size(); ++nameNum) {
324  if (isBarrelSource[nameNum] || opMode == MODE_ANALYZE) {
325  const string& strName = baseHistogramName[nameNum];
326  th2PolyBarrel[strName][layer - 1]->AddBin(bins[id.rawId()]->Clone());
327  th2PolyBarrelSummary[strName]->AddBin(binsSummary[id.rawId()]->Clone());
328  }
329  }
330  }
331 }
std::map< std::string, std::vector< TH2Poly * > > th2PolyBarrel
const DetContainer & detsPXB() const
std::map< uint32_t, TGraph * > binsSummary
std::vector< unsigned > isBarrelSource
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< const GeomDet * > DetContainer
Definition: TTTypes.h:54
T sqrt(T t)
Definition: SSEVec.h:19
double f[11][100]
void SaveDetectorData(bool isBarrel, unsigned rawId, int shell_hc, int layer_disk, int ladder_blade)
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
std::map< uint32_t, TGraph * > bins
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
double b
Definition: hdecay.h:118
std::vector< std::string > baseHistogramName
Definition: Bounds.h:18
std::map< std::string, TH2Poly * > th2PolyBarrelSummary
const Bounds & bounds() const
Definition: Surface.h:87

◆ BookBarrelHistograms()

void SiPixelPhase1Analyzer::BookBarrelHistograms ( TDirectory *  currentDir,
const std::string &  currentHistoName 
)
private

Definition at line 128 of file SiPixelPhase1Analyzer.cc.

References runEdmFileComparison::currentDir, f, mps_fire::i, MODE_ANALYZE, opMode, th2PolyBarrel, th2PolyBarrelSummary, and cond::impl::to_string().

Referenced by BookHistograms().

128  {
129  string histName;
130  TH2Poly* th2p;
131 
132 #ifdef DEBUG_MODE
133  TH2* th2;
134 #endif
135 
136  for (unsigned i = 0; i < 4; ++i) {
137  histName = "barrel_layer_";
138 
139  th2p = new TH2Poly((histName + std::to_string(i + 1)).c_str(), "PXBMap", -15.0, 15.0, 0.0, 5.0);
140 
141  th2p->SetFloat();
142 
143  th2p->GetXaxis()->SetTitle("z [cm]");
144  th2p->GetYaxis()->SetTitle("ladder");
145 
146 #ifdef DEBUG_MODE
147  th2p->SetOption("COLZ 0 TEXT");
148 #else
149  th2p->SetOption("COLZ L");
150 #endif
151 
152  currentDir->Add(th2p);
153  th2PolyBarrel[currentHistoName].push_back(th2p);
154 
155 #ifdef DEBUG_MODE
156  if (opMode == MODE_ANALYZE) {
157  th2 = new TH2I((histName + std::to_string(i + 1) + "_DEBUG").c_str(),
158  "position",
159  3000,
160  -30.0f,
161  30.0f,
162  1000,
163  -4.5f * (i + 1),
164  4.5f * (i + 1));
165 
166  th2->GetXaxis()->SetTitle("z [cm]");
167  th2->GetYaxis()->SetTitle("-x [?]");
168 
169  th2->SetOption("COLZ 0 TEXT");
170 
171  currentDir->Add(th2);
172  th2PolyBarrelDebug[currentHistoName].push_back(th2);
173  }
174 #endif
175  }
176 
177  th2p = new TH2Poly("barrel_summary", "PXBMap", -5.0, 5.0, 0.0, 5.0);
178  th2p->SetFloat();
179 
180  th2p->GetXaxis()->SetTitle("");
181  th2p->GetYaxis()->SetTitle("~ladder");
182 
183  th2p->SetOption("COLZ L");
184 
185  currentDir->Add(th2p);
186  th2PolyBarrelSummary[currentHistoName] = th2p;
187 }
std::map< std::string, std::vector< TH2Poly * > > th2PolyBarrel
std::string to_string(const V &value)
Definition: OMSAccess.h:71
double f[11][100]
std::map< std::string, TH2Poly * > th2PolyBarrelSummary

◆ BookBins()

void SiPixelPhase1Analyzer::BookBins ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt 
)
private

Definition at line 259 of file SiPixelPhase1Analyzer.cc.

References BookBarrelBins(), BookForwardBins(), and SaveDetectorVertices().

Referenced by analyze().

259  {
260  BookBarrelBins(theTrackerGeometry, tt);
261  BookForwardBins(theTrackerGeometry, tt);
262 
263 #ifdef DEBUG_MODE
265 #endif
266 }
void BookForwardBins(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
void BookBarrelBins(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
Definition: TTTypes.h:54
void SaveDetectorVertices(const TrackerTopology *tt)

◆ BookForwardBins()

void SiPixelPhase1Analyzer::BookForwardBins ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt 
)
private

Definition at line 333 of file SiPixelPhase1Analyzer.cc.

References b, baseHistogramName, bins, binsSummary, PixelEndcapName::bladeName(), Surface::bounds(), CODE_FORWARD, debugFile, TrackerGeometry::detsPXF(), PixelEndcapName::diskName(), f, dqmMemoryStats::float, GeomDet::geographicalId(), PixelEndcapName::halfCylinder(), mps_fire::i, isBarrelSource, dqmiolumiharvest::j, dqmdumpme::k, mapOfComplementaryElements, MODE_ANALYZE, callgraph::module, mat4::MulVec(), opMode, orthoProjectionMatrix, AlCaHLTBitMon_ParallelJobs::p, pxfTh2PolyForward, pxfTh2PolyForwardSummary, alignCSCRings::r, makeMuonMisalignmentScenario::rot, GeomDet::rotation(), SaveDetectorData(), mathSSE::sqrt(), GeomDet::surface(), std::swap(), and Surface::toGlobal().

Referenced by BookBins().

333  {
334  TrackingGeometry::DetContainer pxf = theTrackerGeometry.detsPXF();
335 #ifdef DEBUG_MODE
336  debugFile << "There are " << pxf.size() << " detector elements in the PXF." << endl;
337 #endif
338  bool firstForwardElem = true;
339 
340  float elemWidth = 1.0f;
341  float elemLength = 1.0f;
342 
343  // FIRST PASS -> MAKE MAP OF CORRESPONDING ELEMENTS (BLADES ON BOTH PANELS)
344  for (auto& i : pxf) {
345  const GeomDet* det = i;
346 
347  PXFDetId id = det->geographicalId();
348 
349  Local2DPoint origin;
350  GlobalPoint p = det->surface().toGlobal(origin);
351 
352  int panel = tt->pxfPanel(id);
353  int side = tt->side(id); //tt->pxfSide(id);
354  int disk = tt->layer(id); //tt->pxfDisk(id);
355  int blade = tt->pxfBlade(id);
356 
357 #ifdef DEBUG_MODE
358  int module = tt->module(id); //tt->pxfModule(id);
359  PixelEndcapName pixelEndcapName(id, tt, true);
361  false, id.rawId(), pixelEndcapName.halfCylinder(), pixelEndcapName.diskName(), pixelEndcapName.bladeName());
362 #endif
363 
364 #ifdef DEBUG_MODE
365  float r = sqrt(p.x() * p.x() + p.y() * p.y());
366 
367  debugFile << "Panel: " << panel << "\tSide: " << side << "\tDisk: " << disk << "\tBlade: " << blade
368  << "\tModule: " << module << "\t(x, y, z, r): (" << p.x() << ", " << p.y() << ", " << p.z() << ", " << r
369  << ")" << endl;
370 #endif
371  if (firstForwardElem) {
372  const Bounds& b = det->surface().bounds(); //const RectangularPlaneBounds& b
373 
374  elemLength = b.length();
375  elemWidth = b.width();
376 
377  firstForwardElem = false;
378  }
379 
380  const auto& rot = det->rotation();
381 
382  mat4 transMat(
383  rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz(), p.x(), p.y(), p.z());
384 
385  mapOfComplementaryElements[CODE_FORWARD(side, disk, blade)].mat[panel - 1] = transMat;
386  mapOfComplementaryElements[CODE_FORWARD(side, disk, blade)].rawId[panel - 1] = id.rawId();
387  }
388 
389  // SECOND PASS -> USE INFORMATION FROM MAP TO MAKE GEOMETRIC OBJECTS (BINS)
390  for (auto& i : mapOfComplementaryElements) {
391  // decode side&disk from the map key
392  unsigned side = i.first & 0xF;
393  unsigned disk = (i.first & 0xF0) >> 4;
394  // unsigned blade = (i.first & 0xFF00) >> 8;
395 
396  unsigned mapIdx = disk + (side - 1) * 3 - 1;
397 
398  // normal vectors of elements point to the (almost) opposite direction, so correction is needed before interploation (probably not 100% correct but fast)
399  i.second.mat[1].data[0] = -i.second.mat[1].data[0];
400  i.second.mat[1].data[1] = -i.second.mat[1].data[1];
401  i.second.mat[1].data[2] = -i.second.mat[1].data[2];
402 
403  i.second.mat[1].data[6] = -i.second.mat[1].data[6];
404  i.second.mat[1].data[7] = -i.second.mat[1].data[7];
405  i.second.mat[1].data[8] = -i.second.mat[1].data[8];
406 
407  mat4 meanTransform = (i.second.mat[0] + i.second.mat[1]) * 0.5f;
408  // mat4 meanTransform = i.second.mat[0];
409 
410  static const float baseVertX[4] = {-elemWidth * 0.8f, -elemWidth * 0.5f, elemWidth * 0.8f, elemWidth * 0.5f};
411  static const float baseVertY[4] = {
412  elemLength * 0.38f, -elemLength * 0.38f, elemLength * 0.38f, -elemLength * 0.38f};
413 
414  float vertXPanel[2][4], vertYPanel[2][4];
415  float vertIn[3], vertOut[3];
416 
417  /*
418  (1) __________________ (3)
419  \ /
420  \ /
421  \ /
422  \ /
423  (2)\_________/(4)
424 
425  - division line: (2) - (3)
426 
427  - panel 1: triangle of lower area (2, 3, 4)
428  - panel 2: triangle of bigger area (1, 2, 3)
429  */
430 
431  // obtain transformed vertices
432  for (unsigned j = 0; j < 4; ++j) {
433  vertIn[0] = baseVertX[j];
434  vertIn[1] = baseVertY[j];
435  vertIn[2] = 0.0f;
436 
437  meanTransform.MulVec(vertIn, vertOut);
438  std::swap(vertIn, vertOut);
439  orthoProjectionMatrix.MulVec(vertIn, vertOut);
440 
441  // vertical flip
442  vertOut[0] = -vertOut[0]; // so that inner elements have positive x-coordinate
443 
444  if (j > 0) {
445  vertXPanel[0][j - 1] = vertOut[0];
446  vertYPanel[0][j - 1] = vertOut[1]; // for panel 2
447  }
448  if (j < 3) {
449  vertXPanel[1][j] = vertOut[0];
450  vertYPanel[1][j] = vertOut[1]; // for panel 1
451  }
452  }
453 
454  for (unsigned j = 0; j < 2; ++j) {
455  vertXPanel[j][3] = vertXPanel[j][0];
456  vertYPanel[j][3] = vertYPanel[j][0];
457 
458  bins[i.second.rawId[j]] = new TGraph(4, vertXPanel[j], vertYPanel[j]);
459  bins[i.second.rawId[j]]->SetName(TString::Format("%u", i.second.rawId[j]));
460 
461  // for (auto strName: baseHistogramName)
462  // {
463  // pxfTh2PolyForward[strName][mapIdx]->AddBin(bins[i.second.rawId[j]]->Clone());
464  // }
465 
466  // Summary plot
467  for (unsigned k = 0; k < 4; ++k) {
468  vertXPanel[j][k] += (float(side) - 1.5f) * 40.0f;
469  vertYPanel[j][k] += (disk - 1) * 35.0f;
470  }
471 
472  binsSummary[i.second.rawId[j]] = new TGraph(4, vertXPanel[j], vertYPanel[j]);
473  binsSummary[i.second.rawId[j]]->SetName(TString::Format("%u", i.second.rawId[j]));
474 
475  for (unsigned nameNum = 0; nameNum < baseHistogramName.size(); ++nameNum) {
476  if (!isBarrelSource[nameNum] || opMode == MODE_ANALYZE) {
477  const string& strName = baseHistogramName[nameNum];
478  pxfTh2PolyForward[strName][mapIdx]->AddBin(bins[i.second.rawId[j]]->Clone());
479  pxfTh2PolyForwardSummary[strName]->AddBin(binsSummary[i.second.rawId[j]]->Clone());
480  }
481  }
482  }
483  }
484 }
Definition: mat4.h:9
std::map< uint32_t, TGraph * > binsSummary
std::vector< unsigned > isBarrelSource
const DetContainer & detsPXF() const
std::map< std::string, std::vector< TH2Poly * > > pxfTh2PolyForward
std::map< unsigned short, complementaryElements > mapOfComplementaryElements
const Surface::RotationType & rotation() const
The rotation defining the local R.F.
Definition: GeomDet.h:46
std::vector< const GeomDet * > DetContainer
Definition: TTTypes.h:54
std::map< std::string, TH2Poly * > pxfTh2PolyForwardSummary
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
#define CODE_FORWARD(s, d, b)
double f[11][100]
void SaveDetectorData(bool isBarrel, unsigned rawId, int shell_hc, int layer_disk, int ladder_blade)
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
void MulVec(const float *vecIn, float *vecOut)
Definition: mat4.h:77
std::map< uint32_t, TGraph * > bins
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
double b
Definition: hdecay.h:118
std::vector< std::string > baseHistogramName
Definition: Bounds.h:18
const Bounds & bounds() const
Definition: Surface.h:87

◆ BookForwardHistograms()

void SiPixelPhase1Analyzer::BookForwardHistograms ( TDirectory *  currentDir,
const std::string &  currentHistoName 
)
private

Definition at line 189 of file SiPixelPhase1Analyzer.cc.

References runEdmFileComparison::currentDir, f, MODE_ANALYZE, opMode, pxfTh2PolyForward, pxfTh2PolyForwardSummary, and cond::impl::to_string().

Referenced by BookHistograms().

189  {
190  string histName;
191  TH2Poly* th2p;
192 #ifdef DEBUG_MODE
193  TH2* th2;
194 #endif
195 
196  for (unsigned side = 1; side <= 2; ++side) {
197  for (unsigned disk = 1; disk <= 3; ++disk) {
198  histName = "forward_disk_";
199 
200  th2p = new TH2Poly((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(),
201  "PXFMap",
202  -15.0,
203  15.0,
204  -15.0,
205  15.0);
206 
207  th2p->SetFloat();
208 
209  th2p->GetXaxis()->SetTitle("x [cm]");
210  th2p->GetYaxis()->SetTitle("y [cm]");
211 
212 #ifdef DEBUG_MODE
213  th2p->SetOption("COLZ 0 TEXT");
214 #else
215  th2p->SetOption("COLZ L");
216 #endif
217  currentDir->Add(th2p);
218  pxfTh2PolyForward[currentHistoName].push_back(th2p);
219 
220 #ifdef DEBUG_MODE
221  if (opMode == MODE_ANALYZE) {
222  th2 = new TH2I((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk)) + "_DEBUG").c_str(),
223  "position",
224  1000,
225  -15.0f,
226  15.0f,
227  1000,
228  -15.0f,
229  15.0f);
230 
231  th2->GetXaxis()->SetTitle("x [cm]");
232  th2->GetYaxis()->SetTitle("y [cm]");
233 
234  th2->SetOption("COLZ 0 TEXT");
235 
236  currentDir->Add(th2);
237  pxfTh2PolyForwardDebug[currentHistoName].push_back(th2);
238  }
239 #endif
240  }
241  }
242 
243  th2p = new TH2Poly("forward_summary", "PXFMap", -40.0, 50.0, -20.0, 90.0);
244  th2p->SetFloat();
245 
246  th2p->GetXaxis()->SetTitle("");
247  th2p->GetYaxis()->SetTitle("");
248 
249 #ifdef DEBUG_MODE
250  th2p->SetOption("COLZ 0 TEXT");
251 #else
252  th2p->SetOption("COLZ L");
253 #endif
254 
255  currentDir->Add(th2p);
256  pxfTh2PolyForwardSummary[currentHistoName] = th2p;
257 }
std::string to_string(const V &value)
Definition: OMSAccess.h:71
std::map< std::string, std::vector< TH2Poly * > > pxfTh2PolyForward
std::map< std::string, TH2Poly * > pxfTh2PolyForwardSummary
double f[11][100]

◆ BookHistograms()

void SiPixelPhase1Analyzer::BookHistograms ( )
private

Definition at line 94 of file SiPixelPhase1Analyzer.cc.

References baseHistogramName, BookBarrelHistograms(), BookForwardHistograms(), runEdmFileComparison::currentDir, debugFile, fs, TFileService::fullPath(), TFileService::getBareDirectory(), isBarrelSource, dqmiolumiharvest::j, TFileService::make(), MODE_REMAP, and opMode.

Referenced by analyze().

94  {
95  // ghost object <initializes> FileService (without it, it crashes and creation of directories would not be possible)
96  TObject* ghostObj = fs->make<TH2Poly>("ghost", "ghost", -1, 1, -1, 1);
97 
98  TDirectory* topDir = fs->getBareDirectory();
99  topDir->cd();
100 
101 #ifdef DEBUG_MODE
102  debugFile << "Full path: " << fs->fullPath() << endl << endl;
103 #endif
104  string histName;
105  for (unsigned j = 0; j < baseHistogramName.size(); ++j) {
106  string currentHistoName = baseHistogramName[j];
107 
108  TDirectory* currentDir = topDir->mkdir(currentHistoName.c_str());
109  currentDir->cd();
110 
111  if (opMode == MODE_REMAP) {
112  if (isBarrelSource[j]) {
113  BookBarrelHistograms(currentDir, currentHistoName);
114  } else {
115  BookForwardHistograms(currentDir, currentHistoName);
116  }
117  } else {
118  BookBarrelHistograms(currentDir, currentHistoName);
119  BookForwardHistograms(currentDir, currentHistoName);
120  }
121 
122  topDir->cd();
123  }
124 
125  ghostObj->Delete(); //not needed any more
126 }
std::vector< unsigned > isBarrelSource
TDirectory * getBareDirectory(const std::string &subdir="") const
Definition: TFileService.h:52
void BookBarrelHistograms(TDirectory *currentDir, const std::string &currentHistoName)
edm::Service< TFileService > fs
std::string fullPath() const
return the full path of the stored histograms
Definition: TFileService.h:74
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< std::string > baseHistogramName
void BookForwardHistograms(TDirectory *currentDir, const std::string &currentHistoName)

◆ FillBarrelBinsAnalyze()

void SiPixelPhase1Analyzer::FillBarrelBinsAnalyze ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt,
unsigned  rawId,
const GlobalPoint globalPoint 
)
private

Definition at line 595 of file SiPixelPhase1Analyzer.cc.

References baseHistogramName, l1ctLayer2EG_cff::id, phase1PixelTopology::layer, th2PolyBarrel, th2PolyBarrelSummary, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by FillBins().

598  {
599  for (unsigned nameNum = 0; nameNum < baseHistogramName.size(); ++nameNum) {
600  string strName = baseHistogramName[nameNum];
601 
602  PXBDetId id(rawId);
603 
604  int layer = tt->pxbLayer(id);
605 
606  th2PolyBarrel[strName][layer - 1]->Fill(TString::Format("%u", rawId), 1);
607  th2PolyBarrelSummary[strName]->Fill(TString::Format("%u", rawId), 1);
608 #ifdef DEBUG_MODE
609  th2PolyBarrelDebug[strName][layer - 1]->Fill((globalPoint.y() < 0 ? globalPoint.z() + 0.5f : globalPoint.z()),
610  -globalPoint.x(),
611  (globalPoint.y() < 0 ? -1 : 1));
612 #endif
613  }
614 }
std::map< std::string, std::vector< TH2Poly * > > th2PolyBarrel
T z() const
Definition: PV3DBase.h:61
constexpr std::array< uint8_t, layerIndexSize > layer
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Definition: TTTypes.h:54
std::vector< std::string > baseHistogramName
std::map< std::string, TH2Poly * > th2PolyBarrelSummary

◆ FillBarrelBinsRemap()

void SiPixelPhase1Analyzer::FillBarrelBinsRemap ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt 
)
private

Definition at line 639 of file SiPixelPhase1Analyzer.cc.

References analazedRootFileName, baseHistogramName, debugFile, TrackerGeometry::detsPXB(), fs, GeomDet::geographicalId(), TFileService::getBareDirectory(), h, mps_fire::i, isBarrelSource, PixelBarrelName::ladderName(), phase1PixelTopology::layer, callgraph::module, pathToHistograms, DetId::rawId(), rootFileHandle, PixelBarrelName::shell(), th2PolyBarrel, th2PolyBarrelSummary, cond::impl::to_string(), and heppy_batch::val.

Referenced by FillBins().

639  {
640  rootFileHandle = new TFile(analazedRootFileName[0].c_str());
641 
642  if (!rootFileHandle) {
643  LogInfo("Analyzer") << "Could not open file: " << analazedRootFileName[0] << "..." << endl;
644  return;
645  }
646 
647 #ifdef DEBUG_MODE
648  rootFileHandle->ls();
649  LogInfo("Analyzer") << "\n\n";
650  rootFileHandle->pwd();
651  LogInfo("Analyzer") << "\n\n";
652 #endif
653 
654  for (unsigned nameNum = 0; nameNum < baseHistogramName.size(); ++nameNum) {
655  if (!isBarrelSource[nameNum])
656  continue;
657 
658  // if (pathToHistograms[nameNum][pathToHistograms.size() - 1] != '/') pathToHistograms[nameNum] += "/";
659  string baseHistogramNameWithPath = pathToHistograms[nameNum] + baseHistogramName[nameNum] + "_";
660 
661  const TProfile2D* handles[4];
662 #ifndef DEBUG_MODE
663  const TProfile2D* h;
664 #endif
665  bool problemWithHandles = false;
666 
667  for (unsigned i = 0; i < 4; ++i) {
668  string fullFileName = (baseHistogramNameWithPath + std::to_string(i + 1) + ";1 ");
669  handles[i] = (TProfile2D*)rootFileHandle->Get(fullFileName.c_str());
670  if (!handles[i]) {
671  problemWithHandles = true;
672  LogInfo("Analyzer") << "Histogram: " << fullFileName << " does not exist!\n";
673 
674  break;
675  }
676  }
677 
678  if (!problemWithHandles) {
679  LogInfo("Analyzer") << "\nInput histograms: " << baseHistogramNameWithPath << " opened successfully\n";
680 
681  //Add original histograms to this file
682 
683  TDirectory* currDir = fs->getBareDirectory()->GetDirectory(baseHistogramName[nameNum].c_str());
684  currDir->cd();
685 
686  for (unsigned i = 0; i < 4; ++i) {
687  currDir->Add(handles[i]->Clone());
688  }
689 
690  TrackingGeometry::DetContainer pxb = theTrackerGeometry.detsPXB();
691 #ifdef DEBUG_MODE
692  debugFile << "There are " << pxb.size() << " detector elements in the PXB." << endl;
693 #endif
694  for (auto& i : pxb) {
695  const GeomDet* det = i;
696 
697  PXBDetId id = det->geographicalId();
698  unsigned rawId = id.rawId();
699 
700  int module = tt->pxbModule(id);
701  //int ladder = tt->pxbLadder(id);
702  int layer = tt->pxbLayer(id);
703 
704  int signedOnlineModule = module - 4;
705  if (signedOnlineModule <= 0)
706  --signedOnlineModule;
707 
708  PixelBarrelName pixelBarrelName = PixelBarrelName(id, tt, true);
709  int onlineShell = pixelBarrelName.shell();
710 
711  int signedOnlineLadder = ((onlineShell & 1) ? -pixelBarrelName.ladderName() : pixelBarrelName.ladderName());
712  string strName = baseHistogramName[nameNum];
713 
714 #ifdef DEBUG_MODE
715  th2PolyBarrel[strName][layer - 1]->Fill(TString::Format("%u", rawId), signedOnlineLadder);
716  th2PolyBarrelSummary[strName]->Fill(TString::Format("%u", rawId), signedOnlineLadder);
717 #else
718  h = handles[layer - 1];
719  unsigned nx = h->GetNbinsX();
720  unsigned ny = h->GetNbinsY();
721  unsigned binX = signedOnlineModule + ((nx + 1) >> 1);
722  unsigned binY = (signedOnlineLadder) + ((ny + 1) >> 1);
723  double val = h->GetBinContent(binX, binY);
724  th2PolyBarrel[strName][layer - 1]->Fill(TString::Format("%u", rawId), val);
725  th2PolyBarrelSummary[strName]->Fill(TString::Format("%u", rawId), val);
726 #endif
727  }
728  }
729  }
730 
731  rootFileHandle->Close();
732  delete rootFileHandle;
733 }
std::vector< std::string > pathToHistograms
std::map< std::string, std::vector< TH2Poly * > > th2PolyBarrel
const DetContainer & detsPXB() const
std::vector< unsigned > isBarrelSource
std::string to_string(const V &value)
Definition: OMSAccess.h:71
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< const GeomDet * > DetContainer
Definition: TTTypes.h:54
std::vector< BaseVolumeHandle * > handles
TDirectory * getBareDirectory(const std::string &subdir="") const
Definition: TFileService.h:52
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
std::vector< std::string > analazedRootFileName
Shell shell() const
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::Service< TFileService > fs
int ladderName() const
ladder id (index in phi)
std::vector< std::string > baseHistogramName
std::map< std::string, TH2Poly * > th2PolyBarrelSummary
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ FillBins()

void SiPixelPhase1Analyzer::FillBins ( edm::Handle< reco::TrackCollection > *  tracks,
const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt 
)
private

Definition at line 554 of file SiPixelPhase1Analyzer.cc.

References FillBarrelBinsAnalyze(), FillBarrelBinsRemap(), FillForwardBinsAnalyze(), FillForwardBinsRemap(), mps_fire::i, TrackerGeometry::idToDet(), MODE_ANALYZE, MODE_REMAP, opMode, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, rpcPointValidation_cfi::recHit, GeomDet::surface(), Surface::toGlobal(), HLT_2022v15_cff::track, and tracks.

Referenced by analyze().

556  {
557  switch (opMode) {
558  case MODE_ANALYZE:
559  for (auto const& track : *(*tracks)) {
560  auto recHitsBegin = track.recHitsBegin();
561  for (unsigned i = 0; i < track.recHitsSize(); ++i) {
562  auto recHit = *(recHitsBegin + i);
563  if (!recHit->isValid())
564  continue;
565 
566  DetId id = recHit->geographicalId();
567  unsigned subdetId = id.subdetId();
568 
569  if (subdetId != PixelSubdetector::PixelBarrel && subdetId != PixelSubdetector::PixelEndcap)
570  continue;
571 
572  const PixelGeomDetUnit* geomdetunit =
573  dynamic_cast<const PixelGeomDetUnit*>(theTrackerGeometry.idToDet(id)); // theTrackerGeometry ?????
574  //const PixelTopology& topol = geomdetunit->specificTopology();
575 
576  LocalPoint localPoint = recHit->localPosition();
577  GlobalPoint globalPoint = geomdetunit->surface().toGlobal(localPoint);
578 
579  if (subdetId == PixelSubdetector::PixelBarrel)
580  FillBarrelBinsAnalyze(theTrackerGeometry, tt, id.rawId(), globalPoint);
581  else
582  FillForwardBinsAnalyze(theTrackerGeometry, tt, id.rawId(), globalPoint);
583  }
584  }
585  break;
586  case MODE_REMAP:
587  FillBarrelBinsRemap(theTrackerGeometry, tt);
588  FillForwardBinsRemap(theTrackerGeometry, tt);
589  break;
590  default:
591  break;
592  }
593 }
Definition: TTTypes.h:54
void FillBarrelBinsAnalyze(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt, unsigned rawId, const GlobalPoint &globalPoint)
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
auto const & tracks
cannot be loose
void FillForwardBinsRemap(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
void FillForwardBinsAnalyze(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt, unsigned rawId, const GlobalPoint &globalPoint)
void FillBarrelBinsRemap(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)

◆ fillDescriptions()

void SiPixelPhase1Analyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 823 of file SiPixelPhase1Analyzer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

823  {
824  //The following says we do not know what parameters are allowed so do no validation
825  // Please change this to state exactly what you do use, even if it is no parameters
827  desc.setComment(
828  "Creates TH2Poly Pixel Tracker maps by either analyzing the event or remapping exising DQM historams");
829  desc.add<edm::InputTag>("src", edm::InputTag("generalTracks"));
830  desc.addUntracked<unsigned int>("opMode", 1);
831  desc.addUntracked<std::string>("debugFileName", "debug.txt");
832  desc.addUntracked<std::vector<unsigned int>>("isBarrelSource", {0, 0, 1});
833  desc.addUntracked<std::vector<std::string>>("remapRootFileName", {"dqmFile.root"});
834  desc.addUntracked<std::vector<std::string>>(
835  "pathToHistograms",
836  {"DQMData/Run 1/PixelPhase1/Run summary/Phase1_MechanicalView/PXForward/",
837  "DQMData/Run 1/PixelPhase1/Run summary/Phase1_MechanicalView/PXForward/",
838  "DQMData/Run 1/PixelPhase1/Run summary/Phase1_MechanicalView/PXBarrel/"});
839  desc.addUntracked<std::vector<std::string>>("baseHistogramName",
840  {"num_clusters_per_PXDisk_per_SignedBladePanel_PXRing",
841  "num_digis_per_PXDisk_per_SignedBladePanel_PXRing",
842  "num_digis_per_SignedModule_per_SignedLadder_PXLayer"});
843  descriptions.addWithDefaultLabel(desc);
844 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ FillForwardBinsAnalyze()

void SiPixelPhase1Analyzer::FillForwardBinsAnalyze ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt,
unsigned  rawId,
const GlobalPoint globalPoint 
)
private

Definition at line 616 of file SiPixelPhase1Analyzer.cc.

References baseHistogramName, l1ctLayer2EG_cff::id, pxfTh2PolyForward, pxfTh2PolyForwardSummary, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by FillBins().

619  {
620  for (unsigned nameNum = 0; nameNum < baseHistogramName.size(); ++nameNum) {
621  string strName = baseHistogramName[nameNum];
622 
623  PXFDetId id(rawId);
624 
625  int side = tt->side(id); //tt->pxfSide(id);
626  int disk = tt->layer(id); //tt->pxfDisk(id);
627  // int blade = tt->pxfBlade(id);
628  unsigned mapIdx = disk + (side - 1) * 3 - 1;
629 
630  pxfTh2PolyForward[strName][mapIdx]->Fill(TString::Format("%u", rawId), 1);
631  pxfTh2PolyForwardSummary[strName]->Fill(TString::Format("%u", rawId), 1);
632 
633 #ifdef DEBUG_MODE
634  pxfTh2PolyForwardDebug[strName][mapIdx]->Fill(globalPoint.x(), globalPoint.y(), 1);
635 #endif
636  }
637 }
std::map< std::string, std::vector< TH2Poly * > > pxfTh2PolyForward
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Definition: TTTypes.h:54
std::map< std::string, TH2Poly * > pxfTh2PolyForwardSummary
std::vector< std::string > baseHistogramName

◆ FillForwardBinsRemap()

void SiPixelPhase1Analyzer::FillForwardBinsRemap ( const TrackerGeometry theTrackerGeometry,
const TrackerTopology tt 
)
private

Definition at line 735 of file SiPixelPhase1Analyzer.cc.

References analazedRootFileName, baseHistogramName, PixelEndcapName::bladeName(), TrackerGeometry::detsPXF(), fs, GeomDet::geographicalId(), TFileService::getBareDirectory(), h, PixelEndcapName::halfCylinder(), mps_fire::i, isBarrelSource, PixelEndcapName::pannelName(), pathToHistograms, pxfTh2PolyForward, pxfTh2PolyForwardSummary, PixelEndcapName::ringName(), rootFileHandle, and heppy_batch::val.

Referenced by FillBins().

735  {
736  rootFileHandle = new TFile(analazedRootFileName[0].c_str());
737 
738  if (!rootFileHandle) {
739  return;
740  }
741 
742  TrackingGeometry::DetContainer pxf = theTrackerGeometry.detsPXF();
743 
744 #ifdef DEBUG_MODE
745  rootFileHandle->ls();
746  LogInfo("Analyzer") << "\n\n";
747  rootFileHandle->pwd();
748  LogInfo("Analyzer") << "\n\n";
749 #endif
750 
751  for (unsigned nameNum = 0; nameNum < baseHistogramName.size(); ++nameNum) {
752  if (isBarrelSource[nameNum])
753  continue;
754 
755  string baseHistogramNameWithPath = pathToHistograms[nameNum] + baseHistogramName[nameNum] + "_";
756 
757  const TProfile2D* h_1 = (TProfile2D*)rootFileHandle->Get((baseHistogramNameWithPath + "1;1 ").c_str());
758  const TProfile2D* h_2 = (TProfile2D*)rootFileHandle->Get((baseHistogramNameWithPath + "2;1 ").c_str());
759 #ifndef DEBUG_MODE
760  const TProfile2D* h;
761 #endif
762  if (h_2 && h_1) {
763  LogInfo("Analyzer") << "\nInput histograms: " << baseHistogramNameWithPath << " opened successfully\n";
764 
765  //Add original histograms to this file
766  TDirectory* currDir = fs->getBareDirectory()->GetDirectory(baseHistogramName[nameNum].c_str());
767  currDir->cd();
768  currDir->Add(h_1->Clone());
769  currDir->Add(h_2->Clone());
770 
771  for (auto& i : pxf) {
772  const GeomDet* det = i;
773 
774  PXFDetId id = det->geographicalId();
775 
776  int side = tt->side(id); //tt->pxfSide(id);
777  int disk = tt->layer(id); //tt->pxfDisk(id);
778 
779  unsigned rawId = id.rawId();
780  PixelEndcapName pixelEndcapName = PixelEndcapName(PXFDetId(rawId), tt, true);
781 
782 #ifdef DEBUG_MODE
783  int blade = tt->pxfBlade(id);
784 #else
785  int onlineBlade = pixelEndcapName.bladeName();
786  bool isInnerOnlineBlade = !(pixelEndcapName.halfCylinder() & 1); // inner -> blade > 0 (?)
787 
788  int signedOnlineBlade = (isInnerOnlineBlade) ? onlineBlade : -onlineBlade;
789  int signedDisk = (side == 2) ? disk : -disk;
790 
791  int pannel = pixelEndcapName.pannelName() - 1;
792 
793 #endif
794  unsigned mapIdx = disk + (side - 1) * 3 - 1;
795  string strName = baseHistogramName[nameNum];
796 
797 #ifdef DEBUG_MODE
798  pxfTh2PolyForward[strName][mapIdx]->Fill(TString::Format("%u", rawId), blade);
799  pxfTh2PolyForwardSummary[strName]->Fill(TString::Format("%u", rawId), blade);
800 #else
801  if (pixelEndcapName.ringName() == 1)
802  h = h_1;
803  else
804  h = h_2;
805  // ---- REMAP (Online -> Offline)
806  unsigned nx = h->GetNbinsX();
807  unsigned ny = h->GetNbinsY();
808  unsigned binX = signedDisk + ((nx + 1) >> 1);
809  unsigned binY = (signedOnlineBlade * 2) + (ny >> 1);
810  double val = h->GetBinContent(binX, binY + pannel);
811  pxfTh2PolyForward[strName][mapIdx]->Fill(TString::Format("%u", rawId), val);
812  pxfTh2PolyForwardSummary[strName]->Fill(TString::Format("%u", rawId), val);
813 #endif
814  }
815  }
816  }
817 
818  rootFileHandle->Close();
819  delete rootFileHandle;
820 }
std::vector< std::string > pathToHistograms
int ringName() const
ring Id
int bladeName() const
blade id
std::vector< unsigned > isBarrelSource
const DetContainer & detsPXF() const
std::map< std::string, std::vector< TH2Poly * > > pxfTh2PolyForward
std::vector< const GeomDet * > DetContainer
Definition: TTTypes.h:54
std::map< std::string, TH2Poly * > pxfTh2PolyForwardSummary
HalfCylinder halfCylinder() const
TDirectory * getBareDirectory(const std::string &subdir="") const
Definition: TFileService.h:52
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
std::vector< std::string > analazedRootFileName
Log< level::Info, false > LogInfo
edm::Service< TFileService > fs
std::vector< std::string > baseHistogramName
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
int pannelName() const
pannel id

◆ SaveDetectorData()

void SiPixelPhase1Analyzer::SaveDetectorData ( bool  isBarrel,
unsigned  rawId,
int  shell_hc,
int  layer_disk,
int  ladder_blade 
)
inlineprivate

Definition at line 157 of file SiPixelPhase1Analyzer.h.

References geometryDiff::file, PixelPluginsPhase0_cfi::isBarrel, and MillePedeFileConverter_cfg::out.

Referenced by BookBarrelBins(), and BookForwardBins().

157  {
158  std::ofstream file("det.data", std::ofstream::out);
159 
160  file << isBarrel << "\t" << rawId << "\t" << shell_hc << "\t" << layer_disk << "\t" << ladder_blade << std::endl;
161  }

◆ SaveDetectorVertices()

void SiPixelPhase1Analyzer::SaveDetectorVertices ( const TrackerTopology tt)
private

Definition at line 486 of file SiPixelPhase1Analyzer.cc.

References newFWLiteAna::bin, bins, f, mps_fire::i, l1ctLayer2EG_cff::id, dqmiolumiharvest::j, phase1PixelTopology::layer, PixelBarrelName::name(), PixelEndcapName::name(), MillePedeFileConverter_cfg::out, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, and cond::impl::to_string().

Referenced by BookBins().

486  {
487  vector<std::ofstream*> verticesFiles[2];
488  for (unsigned i = 0; i < 4; ++i) {
489  std::ofstream* f = new std::ofstream(("vertices_barrel_" + std::to_string(i + 1)).c_str(), std::ofstream::out);
490 
491  verticesFiles[0].push_back(f);
492  }
493 
494  for (unsigned side = 1; side <= 2; ++side) {
495  for (unsigned disk = 1; disk <= 3; ++disk) {
496  std::ofstream* f = new std::ofstream(
497  ("vertices_forward_" + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), std::ofstream::out);
498 
499  verticesFiles[1].push_back(f);
500  }
501  }
502 
503  for (auto& bin : bins) {
504  unsigned rawId = bin.first;
505  DetId id(rawId);
506  unsigned subdetId = id.subdetId();
507 
508  if (subdetId != PixelSubdetector::PixelBarrel && subdetId != PixelSubdetector::PixelEndcap)
509  continue;
510 
511  double* vertX = bin.second->GetX();
512  double* vertY = bin.second->GetY();
513 
514  if (subdetId == PixelSubdetector::PixelBarrel) {
515  PXBDetId pxbId(rawId);
516  unsigned layer = tt->pxbLayer(pxbId);
517  string onlineName = PixelBarrelName(pxbId, tt, true).name();
518 
519  *(verticesFiles[0][layer - 1]) << rawId << " " << onlineName << " \"";
520  for (unsigned i = 0; i < 4; ++i) {
521  *(verticesFiles[0][layer - 1]) << vertX[i] << "," << vertY[i];
522  if (i == 3)
523  *(verticesFiles[0][layer - 1]) << "\"\n";
524  else
525  *(verticesFiles[0][layer - 1]) << " ";
526  }
527  } else {
528  PXFDetId pxfId(rawId);
529  unsigned side = tt->pxfSide(pxfId);
530  unsigned disk = tt->pxfDisk(pxfId);
531  string onlineName = PixelEndcapName(pxfId, tt, true).name();
532  unsigned mapIdx = disk + (side - 1) * 3 - 1;
533 
534  *(verticesFiles[1][mapIdx]) << rawId << " " << onlineName << " \"";
535  for (unsigned i = 0; i < 3; ++i) {
536  *(verticesFiles[1][mapIdx]) << vertX[i] << "," << vertY[i];
537 
538  if (i == 2)
539  *(verticesFiles[1][mapIdx]) << "\"\n";
540  else
541  *(verticesFiles[1][mapIdx]) << " ";
542  }
543  }
544  }
545 
546  for (unsigned i = 0; i < 2; ++i) {
547  for (auto& j : verticesFiles[i]) {
548  j->close();
549  delete j;
550  }
551  }
552 }
std::string to_string(const V &value)
Definition: OMSAccess.h:71
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: TTTypes.h:54
std::string name() const override
from base class
double f[11][100]
std::map< uint32_t, TGraph * > bins
Definition: DetId.h:17
std::string name() const override
from base class

Member Data Documentation

◆ analazedRootFileName

std::vector<std::string> SiPixelPhase1Analyzer::analazedRootFileName
private

◆ baseHistogramName

std::vector<std::string> SiPixelPhase1Analyzer::baseHistogramName
private

◆ bins

std::map<uint32_t, TGraph*> SiPixelPhase1Analyzer::bins
private

◆ binsSummary

std::map<uint32_t, TGraph*> SiPixelPhase1Analyzer::binsSummary
private

◆ debugFile

std::ofstream SiPixelPhase1Analyzer::debugFile
private

◆ debugFileName

std::string SiPixelPhase1Analyzer::debugFileName
private

Definition at line 114 of file SiPixelPhase1Analyzer.h.

Referenced by SiPixelPhase1Analyzer().

◆ firstEvent

bool SiPixelPhase1Analyzer::firstEvent
private

Definition at line 119 of file SiPixelPhase1Analyzer.h.

Referenced by analyze(), looper.Looper::loop(), and Printer.Printer::process().

◆ fs

edm::Service<TFileService> SiPixelPhase1Analyzer::fs
private

◆ geomToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelPhase1Analyzer::geomToken_
private

Definition at line 107 of file SiPixelPhase1Analyzer.h.

Referenced by analyze().

◆ isBarrelSource

std::vector<unsigned> SiPixelPhase1Analyzer::isBarrelSource
private

◆ mapOfComplementaryElements

std::map<unsigned short, complementaryElements> SiPixelPhase1Analyzer::mapOfComplementaryElements
private

Definition at line 145 of file SiPixelPhase1Analyzer.h.

Referenced by BookForwardBins().

◆ opMode

OperationMode SiPixelPhase1Analyzer::opMode
private

◆ orthoProjectionMatrix

mat4 SiPixelPhase1Analyzer::orthoProjectionMatrix
private

Definition at line 137 of file SiPixelPhase1Analyzer.h.

Referenced by BookForwardBins(), and SiPixelPhase1Analyzer().

◆ pathToHistograms

std::vector<std::string> SiPixelPhase1Analyzer::pathToHistograms
private

◆ pxfTh2PolyForward

std::map<std::string, std::vector<TH2Poly*> > SiPixelPhase1Analyzer::pxfTh2PolyForward
private

◆ pxfTh2PolyForwardSummary

std::map<std::string, TH2Poly*> SiPixelPhase1Analyzer::pxfTh2PolyForwardSummary
private

◆ rootFileHandle

TFile* SiPixelPhase1Analyzer::rootFileHandle
private

Definition at line 148 of file SiPixelPhase1Analyzer.h.

Referenced by FillBarrelBinsRemap(), and FillForwardBinsRemap().

◆ th2PolyBarrel

std::map<std::string, std::vector<TH2Poly*> > SiPixelPhase1Analyzer::th2PolyBarrel
private

◆ th2PolyBarrelSummary

std::map<std::string, TH2Poly*> SiPixelPhase1Analyzer::th2PolyBarrelSummary
private

◆ topoToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPixelPhase1Analyzer::topoToken_
private

Definition at line 108 of file SiPixelPhase1Analyzer.h.

Referenced by analyze().

◆ tracksToken

edm::EDGetTokenT<reco::TrackCollection> SiPixelPhase1Analyzer::tracksToken
private

Definition at line 112 of file SiPixelPhase1Analyzer.h.

Referenced by analyze(), and SiPixelPhase1Analyzer().