39 #include <fmt/printf.h> 51 #include "TPaveStats.h" 61 template <SiPixelPI::DetType myType>
62 class SiPixelFEDChannelContainerMap :
public PlotImage<SiPixelFEDChannelContainer, SINGLE_IOV> {
64 SiPixelFEDChannelContainerMap()
72 m_condDbCabling =
"frontier://FrontierProd/CMS_CONDITIONS";
73 m_CablingTagName =
"SiPixelFedCablingMap_phase1_v7";
75 m_connectionPool.setParameters(m_connectionPset);
76 m_connectionPool.configure();
79 bool fill()
override {
80 std::vector<std::string> the_scenarios = {};
83 auto ip = paramValues.find(
"Scenarios");
84 if (ip != paramValues.end()) {
85 auto input = ip->second;
86 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
87 boost::char_separator<char> sep{
","};
88 tokenizer tok{
input, sep};
89 for (
const auto&
t : tok) {
90 the_scenarios.push_back(
t);
94 <<
"\n WARNING!!!! \n The needed parameter Scenarios has not been passed. Will use all the scenarios in " 96 <<
"\n Buckle your seatbelts... this might take a while... \n\n";
97 the_scenarios.push_back(
"all");
102 auto tag = PlotBase::getTag<0>();
104 auto iov =
tag.iovs.front();
107 edm::LogPrint(
"SiPixelFEDChannelContainerTest") <<
"[SiPixelFEDChannelContainerTest::" << __func__ <<
"] " 108 <<
"Query the condition database " << m_condDbCabling;
114 edm::LogPrint(
"SiPixelFEDChannelContainerTest") <<
"[SiPixelFEDChannelContainerTest::" << __func__ <<
"] " 115 <<
"Reading IOVs from tag " << m_CablingTagName;
121 std::vector<std::tuple<cond::Time_t, cond::Hash>> m_cabling_iovs;
124 std::vector<unsigned int> listOfCablingIOVs;
126 m_cabling_iovs.end(),
127 std::back_inserter(listOfCablingIOVs),
128 [](std::tuple<cond::Time_t, cond::Hash> myIOV2) ->
unsigned int {
return std::get<0>(myIOV2); });
131 <<
" Number of SiPixelFedCablngMap payloads: " << listOfCablingIOVs.size() << std::endl;
134 listOfCablingIOVs.begin(), listOfCablingIOVs.end(), closest_from_below(listOfCablingIOVs, std::get<0>(iov)));
138 <<
" using the SiPixelFedCablingMap with hash: " << std::get<1>(m_cabling_iovs.at(
index)) << std::endl;
141 theCablingMap->initializeRocs();
149 std::shared_ptr<SiPixelFEDChannelContainer>
payload = fetchPayload(std::get<1>(iov));
150 const auto& scenarioMap =
payload->getScenarioMap();
152 auto pIndexConverter =
PixelIndices(numColumns, numRows);
154 for (
const auto&
scenario : scenarioMap) {
157 if (std::find_if(the_scenarios.begin(), the_scenarios.end(), compareKeys(scenName)) != the_scenarios.end() ||
158 the_scenarios[0] ==
"all") {
159 edm::LogPrint(
"SiPixelFEDChannelContainerTest") <<
"\t Found Scenario: " << scenName <<
" ==> dumping it";
166 const auto& theDetSetBadPixelFedChannels =
payload->getDetSetBadPixelFedChannels(scenName);
167 for (
const auto& disabledChannels : *theDetSetBadPixelFedChannels) {
168 const auto t_detid = disabledChannels.detId();
170 LogDebug(
"SiPixelFEDChannelContainerTest") << fmt::sprintf(
"DetId : %i \n", t_detid) << std::endl;
172 std::bitset<16> badRocsFromFEDChannels;
174 for (
const auto& ch : disabledChannels) {
175 std::string toOut_ = fmt::sprintf(
"fed : %i | link : %2i | roc_first : %2i | roc_last: %2i \n",
181 LogDebug(
"SiPixelFEDChannelContainerTest") << toOut_ << std::endl;
182 const std::vector<sipixelobjects::CablingPathToDetUnit>&
path =
183 theCablingMap->pathToDetUnit(disabledChannels.detId());
184 for (
unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc) {
185 for (
const auto p :
path) {
187 if (myroc->
idInDetUnit() ==
static_cast<unsigned int>(i_roc)) {
190 int chipIndex(0), colROC(0), rowROC(0);
192 pIndexConverter.transformToROC(global.
col, global.
row, chipIndex, colROC, rowROC);
194 LogDebug(
"SiPixelFEDChannelContainerTest")
195 <<
" => i_roc:" << i_roc <<
" " << global.
col <<
"-" << global.
row <<
" | => " << chipIndex
196 <<
" : (" << colROC <<
"," << rowROC <<
")" << std::endl;
198 badRocsFromFEDChannels[chipIndex] =
true;
204 LogDebug(
"SiPixelFEDChannelContainerTest") << badRocsFromFEDChannels << std::endl;
206 auto myDetId =
DetId(t_detid);
209 theROCMap.fillSelectedRocs(myDetId, badRocsFromFEDChannels, 1.);
212 theROCMap.fillSelectedRocs(myDetId, badRocsFromFEDChannels, 1.);
215 throw cms::Exception(
"LogicError") <<
"Unknown Pixel SubDet ID " << std::endl;
220 gStyle->SetOptStat(0);
222 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
231 const auto headerText = fmt::sprintf(
"#color[4]{%s}, IOV: #color[4]{%s}",
tagname, IOVstring);
235 theROCMap.drawBarrelMaps(
canvas, headerText);
238 theROCMap.drawForwardMaps(
canvas, headerText);
241 theROCMap.drawMaps(
canvas, headerText);
244 throw cms::Exception(
"SiPixelQualityMap") <<
"\nERROR: unrecognized Pixel Detector part " << std::endl;
257 inline unsigned int closest_from_above(std::vector<unsigned int>
const& vec,
unsigned int value) {
259 return vec.at(it - vec.begin() - 1);
262 inline unsigned int closest_from_below(std::vector<unsigned int>
const& vec,
unsigned int value) {
264 return vec.at(it - vec.begin() - 1);
277 static constexpr
int numColumns = 416;
278 static constexpr
int numRows = 160;
279 static constexpr
int n_rings = 2;
280 static constexpr
int n_layers = 4;
283 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
292 using SiPixelBPixFEDChannelContainerMap = SiPixelFEDChannelContainerMap<SiPixelPI::t_barrel>;
293 using SiPixelFPixFEDChannelContainerMap = SiPixelFEDChannelContainerMap<SiPixelPI::t_forward>;
294 using SiPixelFullFEDChannelContainerMap = SiPixelFEDChannelContainerMap<SiPixelPI::t_all>;
300 class SiPixelFEDChannelContainerScenarios :
public PlotImage<SiPixelFEDChannelContainer, SINGLE_IOV> {
302 SiPixelFEDChannelContainerScenarios()
304 bool fill()
override {
305 auto tag = PlotBase::getTag<0>();
307 auto iov =
tag.iovs.front();
309 TGaxis::SetMaxDigits(3);
311 std::shared_ptr<SiPixelFEDChannelContainer>
payload = fetchPayload(std::get<1>(iov));
315 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
318 auto h1 = std::make_unique<TH1F>(
"Count",
319 "SiPixelFEDChannelContainer Bad Roc count;Scenario index;n. of bad ROCs",
325 canvas.SetTopMargin(0.06);
326 canvas.SetBottomMargin(0.12);
327 canvas.SetLeftMargin(0.12);
328 canvas.SetRightMargin(0.05);
331 int scenarioIndex = 0;
336 auto badChannelCollection =
payload->getDetSetBadPixelFedChannels(
scenario);
337 for (
const auto& disabledChannels : *badChannelCollection) {
338 for (
const auto& ch : disabledChannels) {
339 int local_bad_rocs = ch.roc_last - ch.roc_first;
340 badRocCount += local_bad_rocs;
344 h1->SetBinContent(scenarioIndex, badRocCount);
347 TGaxis::SetExponentOffset(-0.1, 0.01,
"y");
348 TGaxis::SetExponentOffset(-0.03, -0.10,
"x");
351 h1->GetYaxis()->SetRangeUser(0., h1->GetMaximum() * 1.30);
352 h1->SetFillColor(kRed);
353 h1->SetMarkerStyle(20);
354 h1->SetMarkerSize(1);
361 TLegend
legend = TLegend(0.30, 0.88, 0.95, 0.94);
364 legend.SetHeader(fmt::sprintf(
"Payload hash: #bf{%s}", std::get<1>(iov)).c_str(),
"C");
365 legend.AddEntry(h1.get(), fmt::sprintf(
"total scenarios: #bf{%s}",
std::to_string(scenarioIndex)).c_str(),
"F");
366 legend.SetTextSize(0.025);
373 ltx.SetTextSize(0.040);
375 gPad->GetLeftMargin(),
376 1 - gPad->GetTopMargin() + 0.01,
377 fmt::sprintf(
"#color[4]{%s} IOV: #color[4]{%s}",
tagname,
std::to_string(std::get<0>(iov))).c_str());
const TimeTypeSpecs timeTypeSpecs[]
void start(bool readOnly=true)
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Transaction & transaction()
identify pixel inside single ROC
static std::string to_string(const XMLCh *ch)
static std::string const input
global coordinates (row and column in DetUnit, as in PixelDigi)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
GlobalPixel toGlobal(const LocalPixel &loc) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Log< level::Warning, true > LogPrint
IOVProxy readIov(const std::string &tag)
const std::map< std::string, std::string > & inputParamValues() const
void addInputParam(const std::string ¶mName)
void makeNicePlotStyle(TH1 *hist)
row and collumn in ROC representation
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Log< level::Warning, false > LogWarning
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path