15 opMode(static_cast<
OperationMode>(iConfig.getUntrackedParameter<unsigned
int>(
"opMode"))),
16 debugFileName(iConfig.getUntrackedParameter<
string>(
"debugFileName")),
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")) {
26 usesResource(
"TFileService");
52 for (
auto&
i :
bins) {
86 LogInfo(
"Analyzer") <<
"reco::TrackCollection not found... Aborting...\n";
96 TObject* ghostObj =
fs->
make<TH2Poly>(
"ghost",
"ghost", -1, 1, -1, 1);
108 TDirectory*
currentDir = topDir->mkdir(currentHistoName.c_str());
136 for (
unsigned i = 0;
i < 4; ++
i) {
137 histName =
"barrel_layer_";
139 th2p =
new TH2Poly((histName +
std::to_string(
i + 1)).c_str(),
"PXBMap", -15.0, 15.0, 0.0, 5.0);
143 th2p->GetXaxis()->SetTitle(
"z [cm]");
144 th2p->GetYaxis()->SetTitle(
"ladder");
147 th2p->SetOption(
"COLZ 0 TEXT");
149 th2p->SetOption(
"COLZ L");
166 th2->GetXaxis()->SetTitle(
"z [cm]");
167 th2->GetYaxis()->SetTitle(
"-x [?]");
169 th2->SetOption(
"COLZ 0 TEXT");
172 th2PolyBarrelDebug[currentHistoName].push_back(th2);
177 th2p =
new TH2Poly(
"barrel_summary",
"PXBMap", -5.0, 5.0, 0.0, 5.0);
180 th2p->GetXaxis()->SetTitle(
"");
181 th2p->GetYaxis()->SetTitle(
"~ladder");
183 th2p->SetOption(
"COLZ L");
196 for (
unsigned side = 1; side <= 2; ++side) {
197 for (
unsigned disk = 1; disk <= 3; ++disk) {
198 histName =
"forward_disk_";
200 th2p =
new TH2Poly((histName +
std::to_string((side == 1 ? -(
int(disk)) : (
int)disk))).c_str(),
209 th2p->GetXaxis()->SetTitle(
"x [cm]");
210 th2p->GetYaxis()->SetTitle(
"y [cm]");
213 th2p->SetOption(
"COLZ 0 TEXT");
215 th2p->SetOption(
"COLZ L");
222 th2 =
new TH2I((histName +
std::to_string((side == 1 ? -(
int(disk)) : (
int)disk)) +
"_DEBUG").c_str(),
231 th2->GetXaxis()->SetTitle(
"x [cm]");
232 th2->GetYaxis()->SetTitle(
"y [cm]");
234 th2->SetOption(
"COLZ 0 TEXT");
237 pxfTh2PolyForwardDebug[currentHistoName].push_back(th2);
243 th2p =
new TH2Poly(
"forward_summary",
"PXFMap", -40.0, 50.0, -20.0, 90.0);
246 th2p->GetXaxis()->SetTitle(
"");
247 th2p->GetYaxis()->SetTitle(
"");
250 th2p->SetOption(
"COLZ 0 TEXT");
252 th2p->SetOption(
"COLZ L");
271 debugFile <<
"There are " << pxb.size() <<
" detector elements in the PXB." << endl;
273 for (
auto&
i : pxb) {
292 float r =
sqrt(
p.x() *
p.x() +
p.y() *
p.y());
295 <<
", " <<
p.y() <<
", " <<
p.z() <<
", " <<
r <<
")" << endl;
299 float bl =
b.length();
302 float bw =
b.width();
303 float bt =
b.thickness();
305 debugFile <<
"Length: " << bl <<
"\tWidth: " << bw <<
"\tThickness: " << bt << endl;
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};
311 bins[
id.rawId()] =
new TGraph(5, vertX, vertY);
312 bins[
id.rawId()]->SetName(TString::Format(
"%u",
id.
rawId()));
315 for (
unsigned k = 0;
k < 5; ++
k) {
317 vertY[
k] += ((
layer > 2) ? 30.0
f : 0.0
f);
320 binsSummary[
id.rawId()] =
new TGraph(5, vertX, vertY);
336 debugFile <<
"There are " << pxf.size() <<
" detector elements in the PXF." << endl;
338 bool firstForwardElem =
true;
340 float elemWidth = 1.0f;
341 float elemLength = 1.0f;
344 for (
auto&
i : pxf) {
352 int panel =
tt->pxfPanel(
id);
353 int side =
tt->side(
id);
354 int disk =
tt->layer(
id);
355 int blade =
tt->pxfBlade(
id);
365 float r =
sqrt(
p.x() *
p.x() +
p.y() *
p.y());
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 371 if (firstForwardElem) {
374 elemLength =
b.length();
375 elemWidth =
b.width();
377 firstForwardElem =
false;
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());
392 unsigned side =
i.first & 0xF;
393 unsigned disk = (
i.first & 0xF0) >> 4;
396 unsigned mapIdx = disk + (side - 1) * 3 - 1;
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];
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];
407 mat4 meanTransform = (
i.second.mat[0] +
i.second.mat[1]) * 0.5
f;
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};
414 float vertXPanel[2][4], vertYPanel[2][4];
415 float vertIn[3], vertOut[3];
432 for (
unsigned j = 0;
j < 4; ++
j) {
433 vertIn[0] = baseVertX[
j];
434 vertIn[1] = baseVertY[
j];
437 meanTransform.
MulVec(vertIn, vertOut);
442 vertOut[0] = -vertOut[0];
445 vertXPanel[0][
j - 1] = vertOut[0];
446 vertYPanel[0][
j - 1] = vertOut[1];
449 vertXPanel[1][
j] = vertOut[0];
450 vertYPanel[1][
j] = vertOut[1];
454 for (
unsigned j = 0;
j < 2; ++
j) {
455 vertXPanel[
j][3] = vertXPanel[
j][0];
456 vertYPanel[
j][3] = vertYPanel[
j][0];
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]));
467 for (
unsigned k = 0;
k < 4; ++
k) {
468 vertXPanel[
j][
k] += (
float(side) - 1.5f) * 40.0
f;
469 vertYPanel[
j][
k] += (disk - 1) * 35.0
f;
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]));
487 vector<std::ofstream*> verticesFiles[2];
488 for (
unsigned i = 0;
i < 4; ++
i) {
491 verticesFiles[0].push_back(
f);
494 for (
unsigned side = 1; side <= 2; ++side) {
495 for (
unsigned disk = 1; disk <= 3; ++disk) {
496 std::ofstream*
f =
new std::ofstream(
499 verticesFiles[1].push_back(
f);
506 unsigned subdetId =
id.subdetId();
511 double* vertX =
bin.second->GetX();
512 double* vertY =
bin.second->GetY();
516 unsigned layer =
tt->pxbLayer(pxbId);
519 *(verticesFiles[0][
layer - 1]) <<
rawId <<
" " << onlineName <<
" \"";
520 for (
unsigned i = 0;
i < 4; ++
i) {
521 *(verticesFiles[0][
layer - 1]) << vertX[
i] <<
"," << vertY[
i];
523 *(verticesFiles[0][
layer - 1]) <<
"\"\n";
525 *(verticesFiles[0][
layer - 1]) <<
" ";
529 unsigned side =
tt->pxfSide(pxfId);
530 unsigned disk =
tt->pxfDisk(pxfId);
532 unsigned mapIdx = disk + (side - 1) * 3 - 1;
534 *(verticesFiles[1][mapIdx]) <<
rawId <<
" " << onlineName <<
" \"";
535 for (
unsigned i = 0;
i < 3; ++
i) {
536 *(verticesFiles[1][mapIdx]) << vertX[
i] <<
"," << vertY[
i];
539 *(verticesFiles[1][mapIdx]) <<
"\"\n";
541 *(verticesFiles[1][mapIdx]) <<
" ";
546 for (
unsigned i = 0;
i < 2; ++
i) {
547 for (
auto&
j : verticesFiles[
i]) {
560 auto recHitsBegin =
track.recHitsBegin();
561 for (
unsigned i = 0;
i <
track.recHitsSize(); ++
i) {
562 auto recHit = *(recHitsBegin +
i);
567 unsigned subdetId =
id.subdetId();
609 th2PolyBarrelDebug[strName][
layer - 1]->Fill((globalPoint.
y() < 0 ? globalPoint.
z() + 0.5f : globalPoint.
z()),
611 (globalPoint.
y() < 0 ? -1 : 1));
625 int side =
tt->side(
id);
626 int disk =
tt->layer(
id);
628 unsigned mapIdx = disk + (side - 1) * 3 - 1;
634 pxfTh2PolyForwardDebug[strName][mapIdx]->Fill(globalPoint.
x(), globalPoint.
y(), 1);
665 bool problemWithHandles =
false;
667 for (
unsigned i = 0;
i < 4; ++
i) {
668 string fullFileName = (baseHistogramNameWithPath +
std::to_string(
i + 1) +
";1 ");
671 problemWithHandles =
true;
672 LogInfo(
"Analyzer") <<
"Histogram: " << fullFileName <<
" does not exist!\n";
678 if (!problemWithHandles) {
679 LogInfo(
"Analyzer") <<
"\nInput histograms: " << baseHistogramNameWithPath <<
" opened successfully\n";
686 for (
unsigned i = 0;
i < 4; ++
i) {
692 debugFile <<
"There are " << pxb.size() <<
" detector elements in the PXB." << endl;
694 for (
auto&
i : pxb) {
698 unsigned rawId =
id.rawId();
704 int signedOnlineModule =
module - 4;
705 if (signedOnlineModule <= 0)
706 --signedOnlineModule;
709 int onlineShell = pixelBarrelName.
shell();
711 int signedOnlineLadder = ((onlineShell & 1) ? -pixelBarrelName.
ladderName() : pixelBarrelName.
ladderName());
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);
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());
763 LogInfo(
"Analyzer") <<
"\nInput histograms: " << baseHistogramNameWithPath <<
" opened successfully\n";
768 currDir->Add(h_1->Clone());
769 currDir->Add(h_2->Clone());
771 for (
auto&
i : pxf) {
776 int side =
tt->side(
id);
777 int disk =
tt->layer(
id);
779 unsigned rawId =
id.rawId();
783 int blade =
tt->pxfBlade(
id);
785 int onlineBlade = pixelEndcapName.
bladeName();
786 bool isInnerOnlineBlade = !(pixelEndcapName.
halfCylinder() & 1);
788 int signedOnlineBlade = (isInnerOnlineBlade) ? onlineBlade : -onlineBlade;
789 int signedDisk = (side == 2) ? disk : -disk;
791 int pannel = pixelEndcapName.
pannelName() - 1;
794 unsigned mapIdx = disk + (side - 1) * 3 - 1;
801 if (pixelEndcapName.
ringName() == 1)
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);
828 "Creates TH2Poly Pixel Tracker maps by either analyzing the event or remapping exising DQM historams");
830 desc.addUntracked<
unsigned int>(
"opMode", 1);
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>>(
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"});
void BookForwardBins(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void FillBins(edm::Handle< reco::TrackCollection > *tracks, const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
T getParameter(std::string const &) const
std::vector< std::string > pathToHistograms
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
int ringName() const
ring Id
std::map< std::string, std::vector< TH2Poly * > > th2PolyBarrel
const DetContainer & detsPXB() const
std::map< uint32_t, TGraph * > binsSummary
int bladeName() const
blade id
std::vector< unsigned > isBarrelSource
const DetContainer & detsPXF() const
void BookBarrelBins(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
void BuildOrthographicMatrix(float left, float right, float top, float bottom, float near, float far)
std::map< std::string, std::vector< TH2Poly * > > pxfTh2PolyForward
static std::string to_string(const XMLCh *ch)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
std::map< unsigned short, complementaryElements > mapOfComplementaryElements
const Surface::RotationType & rotation() const
The rotation defining the local R.F.
std::vector< const GeomDet * > DetContainer
std::string debugFileName
std::map< std::string, TH2Poly * > pxfTh2PolyForwardSummary
mat4 orthoProjectionMatrix
edm::EDGetTokenT< reco::TrackCollection > tracksToken
std::vector< BaseVolumeHandle * > handles
int diskName() const
disk id
SiPixelPhase1Analyzer(const edm::ParameterSet &)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::string name() const override
from base class
#define CODE_FORWARD(s, d, b)
HalfCylinder halfCylinder() const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
#define DEFINE_FWK_MODULE(type)
void SaveDetectorData(bool isBarrel, unsigned rawId, int shell_hc, int layer_disk, int ladder_blade)
void FillBarrelBinsAnalyze(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt, unsigned rawId, const GlobalPoint &globalPoint)
TDirectory * getBareDirectory(const std::string &subdir="") const
DetId geographicalId() const
The label of this GeomDet.
std::vector< std::string > analazedRootFileName
const TrackerGeomDet * idToDet(DetId) const override
void MulVec(const float *vecIn, float *vecOut)
std::map< uint32_t, TGraph * > bins
void analyze(const edm::Event &, const edm::EventSetup &) override
void BookBarrelHistograms(TDirectory *currentDir, const std::string ¤tHistoName)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
~SiPixelPhase1Analyzer() override
Log< level::Info, false > LogInfo
const Plane & surface() const
The nominal surface of the GeomDet.
void SaveDetectorVertices(const TrackerTopology *tt)
std::string name() const override
from base class
void BookBins(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
int layerName() const
layer id
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::Service< TFileService > fs
void FillForwardBinsRemap(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
std::string fullPath() const
return the full path of the stored histograms
void FillForwardBinsAnalyze(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt, unsigned rawId, const GlobalPoint &globalPoint)
int ladderName() const
ladder id (index in phi)
T * make(const Args &...args) const
make new ROOT object
std::vector< std::string > baseHistogramName
void FillBarrelBinsRemap(const TrackerGeometry &theTrackerGeometry, const TrackerTopology *tt)
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.
int pannelName() const
pannel id
const Bounds & bounds() const
void BookForwardHistograms(TDirectory *currentDir, const std::string ¤tHistoName)