Skip to content

Commit

Permalink
Merge pull request cms-sw#27892 from mmusich/SiPixelLorentzAngleMaps
Browse files Browse the repository at this point in the history
SiPixel Payload Inspector improvements
  • Loading branch information
cmsbuild authored Sep 4, 2019
2 parents b589033 + 3241816 commit 411b633
Show file tree
Hide file tree
Showing 7 changed files with 620 additions and 248 deletions.
254 changes: 251 additions & 3 deletions CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
#include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"

//#define MMDEBUG
#ifdef MMDEBUG
#include <iostream>
#define COUT std::cout << "MM "
#else
#define COUT edm::LogVerbatim("")
#endif

namespace SiPixelPI {

// size of the phase-0 pixel detID list
Expand Down Expand Up @@ -130,8 +138,14 @@ namespace SiPixelPI {
}

//============================================================================
void dress_occup_plot(
TCanvas& canv, TH2* h, int lay, int ring = 0, int phase = 0, bool half_shift = true, bool mark_zero = true) {
void dress_occup_plot(TCanvas& canv,
TH2* h,
int lay,
int ring = 0,
int phase = 0,
bool half_shift = true,
bool mark_zero = true,
bool standard_palette = true) {
std::string s_title;

if (lay > 0) {
Expand All @@ -143,7 +157,21 @@ namespace SiPixelPI {
}

gStyle->SetPadRightMargin(0.125);
gStyle->SetPalette(1);

if (standard_palette) {
gStyle->SetPalette(1);
} else {
// this is the fine gradient palette
const Int_t NRGBs = 5;
const Int_t NCont = 255;

Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
}

h->SetMarkerSize(0.7);
h->Draw("colz");
Expand Down Expand Up @@ -626,5 +654,225 @@ namespace SiPixelPI {
return ret;
}

// overloaded method: mask entire module
/*--------------------------------------------------------------------*/
std::vector<std::pair<int, int> > maskedBarrelRocsToBins(int layer, int ladder, int module)
/*--------------------------------------------------------------------*/
{
std::vector<std::pair<int, int> > rocsToMask;

int nlad_list[4] = {6, 14, 22, 32};
int nlad = nlad_list[layer - 1];

int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (std::abs(module))) * 8) + 1;
int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (std::abs(ladder))) * 2) + 1;

int end_x = start_x + 7;
int end_y = start_y + 1;

COUT << "module: " << module << " start_x:" << start_x << " end_x:" << end_x << std::endl;
COUT << "ladder: " << ladder << " start_y:" << start_y << " end_y:" << end_y << std::endl;
COUT << "==================================================================" << std::endl;

for (int bin_x = 1; bin_x <= 72; bin_x++) {
for (int bin_y = 1; bin_y <= (nlad * 4 + 2); bin_y++) {
if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) {
rocsToMask.push_back(std::make_pair(bin_x, bin_y));
}
}
}
return rocsToMask;
}

// overloaded method: mask single ROCs
/*--------------------------------------------------------------------*/
std::vector<std::tuple<int, int, int> > maskedBarrelRocsToBins(
int layer, int ladder, int module, std::bitset<16> bad_rocs, bool isFlipped)
/*--------------------------------------------------------------------*/
{
std::vector<std::tuple<int, int, int> > rocsToMask;

int nlad_list[4] = {6, 14, 22, 32};
int nlad = nlad_list[layer - 1];

int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (std::abs(module))) * 8) + 1;
int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (std::abs(ladder))) * 2) + 1;

int roc0_x = ((layer == 1) || (layer > 1 && module > 0)) ? start_x + 7 : start_x;
int roc0_y = start_y - 1;

size_t idx = 0;
while (idx < bad_rocs.size()) {
if (bad_rocs.test(idx)) {
//////////////////////////////////////////////////////////////////////////////////////
// | //
// In BPix Layer1 and module>0 in L2,3,4 | In BPix Layer 2,3,4 module > 0 //
// | //
// ROCs are ordered in the following | ROCs are ordered in the following //
// fashion for unplipped modules | fashion for unplipped modules //
// | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | //
// if the module is flipped the ordering | if the module is flipped the ordering //
// is reveresed | is reversed //
// | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
//////////////////////////////////////////////////////////////////////////////////////

int roc_x(0), roc_y(0);

if ((layer == 1) || (layer > 1 && module > 0)) {
if (!isFlipped) {
roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
} else {
roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
}
} else {
if (!isFlipped) {
roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
} else {
roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
}
}

COUT << bad_rocs << " : (idx)= " << idx << std::endl;
COUT << " layer: " << layer << std::endl;
COUT << "module: " << module << " roc_x:" << roc_x << std::endl;
COUT << "ladder: " << ladder << " roc_y:" << roc_y << std::endl;
COUT << "==================================================================" << std::endl;

rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx));
}
++idx;
}
return rocsToMask;
}

// overloaded method: mask entire module
/*--------------------------------------------------------------------*/
std::vector<std::pair<int, int> > maskedForwardRocsToBins(int ring, int blade, int panel, int disk)
/*--------------------------------------------------------------------*/
{
std::vector<std::pair<int, int> > rocsToMask;

//int nblade_list[2] = {11, 17};
int nybins_list[2] = {92, 140};
//int nblade = nblade_list[ring - 1];
int nybins = nybins_list[ring - 1];

int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1;
//int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2;
int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3
: ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3;

int end_x = start_x + 7;
int end_y = start_y + 1;

COUT << "==================================================================" << std::endl;
COUT << "disk: " << disk << " start_x:" << start_x << " end_x:" << end_x << std::endl;
COUT << "blade: " << blade << " start_y:" << start_y << " end_y:" << end_y << std::endl;

for (int bin_x = 1; bin_x <= 56; bin_x++) {
for (int bin_y = 1; bin_y <= nybins; bin_y++) {
if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) {
rocsToMask.push_back(std::make_pair(bin_x, bin_y));
}
}
}
return rocsToMask;
}

// overloaded method: mask single ROCs
/*--------------------------------------------------------------------*/
std::vector<std::tuple<int, int, int> > maskedForwardRocsToBins(
int ring, int blade, int panel, int disk, std::bitset<16> bad_rocs, bool isFlipped)
/*--------------------------------------------------------------------*/
{
std::vector<std::tuple<int, int, int> > rocsToMask;

//int nblade_list[2] = {11, 17};
int nybins_list[2] = {92, 140};
//int nblade = nblade_list[ring - 1];
int nybins = nybins_list[ring - 1];

int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1;
//int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2;
int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3
: ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3;

int roc0_x = disk > 0 ? start_x + 7 : start_x;
int roc0_y = start_y - 1;

size_t idx = 0;
while (idx < bad_rocs.size()) {
if (bad_rocs.test(idx)) {
int roc_x(0), roc_y(0);

//////////////////////////////////////////////////////////////////////////////////////
// | //
// In FPix + (Disk 1,2,3) | In FPix - (Disk -1,-2,-3) //
// | //
// ROCs are ordered in the following | ROCs are ordered in the following //
// fashion for unplipped modules | fashion for unplipped modules //
// | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | //
// if the module is flipped the ordering | if the module is flipped the ordering //
// is reveresed | is reversed //
// | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
// | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
// +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
//////////////////////////////////////////////////////////////////////////////////////

if (disk > 0) {
if (!isFlipped) {
roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
} else {
roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
}
} else {
if (!isFlipped) {
roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
} else {
roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
}
}

COUT << bad_rocs << " : (idx)= " << idx << std::endl;
COUT << " panel: " << panel << " isFlipped: " << isFlipped << std::endl;
COUT << " disk: " << disk << " roc_x:" << roc_x << std::endl;
COUT << " blade: " << blade << " roc_y:" << roc_y << std::endl;
COUT << "===============================" << std::endl;

rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx));
}
++idx;
}
return rocsToMask;
}

}; // namespace SiPixelPI
#endif
Loading

0 comments on commit 411b633

Please sign in to comment.