22 #include <fmt/format.h> 37 class SiStripFedCabling_TrackerMap :
public PlotImage<SiStripFedCabling, SINGLE_IOV> {
41 bool fill()
override {
42 auto tag = PlotBase::getTag<0>();
43 auto iov =
tag.iovs.front();
44 std::shared_ptr<SiStripFedCabling>
payload = fetchPayload(std::get<1>(iov));
46 std::unique_ptr<TrackerMap> tmap = std::make_unique<TrackerMap>(
"SiStripFedCabling");
49 tmap->setTitle(titleMap);
53 std::unique_ptr<SiStripDetCabling> detCabling_ = std::make_unique<SiStripDetCabling>(*(
payload.get()), &tTopo);
55 std::vector<uint32_t> activeDetIds;
56 detCabling_->addActiveDetectorsRawIds(activeDetIds);
58 for (
const auto&
detId : activeDetIds) {
60 for (uint32_t connDet_i = 0; connDet_i < detCabling_->getConnections(
detId).size(); connDet_i++) {
61 if (detCabling_->getConnections(
detId)[connDet_i] !=
nullptr &&
62 detCabling_->getConnections(
detId)[connDet_i]->isConnected() != 0)
66 tmap->fill(
detId, n_conn * 2);
71 tmap->save(
true, 0., 6.,
fileName, 4500, 2400);
80 class SiStripUncabledChannels_TrackerMap :
public PlotImage<SiStripFedCabling, SINGLE_IOV> {
82 SiStripUncabledChannels_TrackerMap()
85 bool fill()
override {
86 auto tag = PlotBase::getTag<0>();
87 auto iov =
tag.iovs.front();
88 std::shared_ptr<SiStripFedCabling>
payload = fetchPayload(std::get<1>(iov));
90 std::unique_ptr<TrackerMap> tmap = std::make_unique<TrackerMap>(
"SiStripFedCabling");
93 "TrackerMap of SiStrip Fraction of uncabled channels per module, IOV : " +
std::to_string(std::get<0>(iov));
94 tmap->setTitle(titleMap);
98 std::unique_ptr<SiStripDetCabling> detCabling_ = std::make_unique<SiStripDetCabling>(*(
payload.get()), &tTopo);
100 std::vector<uint32_t> activeDetIds;
101 detCabling_->addActiveDetectorsRawIds(activeDetIds);
105 std::vector<uint32_t> all_detids = detInfo.getAllDetIds();
108 for (
const auto&
detId : all_detids) {
109 if (!detCabling_->IsConnected(
detId)) {
110 tmap->fill(
detId, 1);
115 for (
const auto&
detId : activeDetIds) {
116 float frac = calculateConnectedFraction(detCabling_.get(),
detId);
123 tmap->save(
true, 0., 1.,
fileName, 4500, 2400);
133 for (uint32_t connDet_i = 0; connDet_i < detCabling->
getConnections(
detId).size(); connDet_i++) {
139 return n_conn / totAPVs;
147 template <
int ntags, IOVMultiplicity nIOVs>
148 class SiStripFedCablingComparisonTrackerMapBase :
public PlotImage<SiStripFedCabling, nIOVs, ntags> {
150 SiStripFedCablingComparisonTrackerMapBase()
153 bool fill()
override {
155 auto theIOVs = PlotBase::getTag<0>().iovs;
156 auto tagname1 = PlotBase::getTag<0>().
name;
158 auto firstiov = theIOVs.front();
159 std::tuple<cond::Time_t, cond::Hash> lastiov;
162 assert(this->m_plotAnnotations.ntags < 3);
164 if (this->m_plotAnnotations.ntags == 2) {
165 auto tag2iovs = PlotBase::getTag<1>().iovs;
166 tagname2 = PlotBase::getTag<1>().
name;
167 lastiov = tag2iovs.front();
169 lastiov = theIOVs.back();
172 std::shared_ptr<SiStripFedCabling> last_payload = this->fetchPayload(std::get<1>(lastiov));
173 std::shared_ptr<SiStripFedCabling> first_payload = this->fetchPayload(std::get<1>(firstiov));
178 std::unique_ptr<TrackerMap> tmap = std::make_unique<TrackerMap>(
"SiStripFedCabling Difference");
182 std::string commonPart =
"SiStrip Fed Cabling Map: #Delta connections per module";
183 if (this->m_plotAnnotations.ntags == 2) {
184 titleMap =
fmt::format(
"{}: {} - {}", commonPart, tagname2, tagname1);
186 titleMap =
fmt::format(
"{}: IOV : {} - {}", commonPart, std::get<0>(lastiov), std::get<0>(firstiov));
188 tmap->setTitle(titleMap);
194 std::unique_ptr<SiStripDetCabling> l_detCabling =
195 std::make_unique<SiStripDetCabling>(*(last_payload.get()), &tTopo);
196 std::unique_ptr<SiStripDetCabling> f_detCabling =
197 std::make_unique<SiStripDetCabling>(*(first_payload.get()), &tTopo);
199 std::vector<uint32_t> f_activeDetIds;
200 f_detCabling->addActiveDetectorsRawIds(f_activeDetIds);
202 std::vector<uint32_t> l_activeDetIds;
203 l_detCabling->addActiveDetectorsRawIds(l_activeDetIds);
205 const auto& setsToPlot = prepareSets(f_activeDetIds, l_activeDetIds);
208 <<
"Common Detids: " << setsToPlot.commonElements.size()
209 <<
" | only in last payload: " << setsToPlot.lExclusiveElements.size()
210 <<
" | only in first payload: " << setsToPlot.fExclusiveElements.size() << std::endl;
213 for (
const auto&
detId : setsToPlot.commonElements) {
214 int32_t f_n_conn = calculateConnections(f_detCabling.get(),
detId);
215 int32_t l_n_conn = calculateConnections(l_detCabling.get(),
detId);
217 if (l_n_conn != f_n_conn) {
218 tmap->fill(
detId, (l_n_conn - f_n_conn) * 2);
223 for (
const auto&
detId : setsToPlot.lExclusiveElements) {
224 int32_t l_n_conn = calculateConnections(l_detCabling.get(),
detId);
227 tmap->fill(
detId, l_n_conn * 2);
232 for (
const auto&
detId : setsToPlot.fExclusiveElements) {
233 int32_t f_n_conn = calculateConnections(f_detCabling.get(),
detId);
236 tmap->fill(
detId, -f_n_conn * 2);
241 tmap->save(
true, -6., 6.,
fileName, 4500, 2400);
247 struct setsOfDetids {
248 std::vector<uint32_t> commonElements;
249 std::vector<uint32_t> fExclusiveElements;
250 std::vector<uint32_t> lExclusiveElements;
256 for (uint32_t connDet_i = 0; connDet_i < detCabling->
getConnections(
detId).size(); connDet_i++) {
266 setsOfDetids prepareSets(std::vector<uint32_t> f_activeDetIds, std::vector<uint32_t> l_activeDetIds) {
269 std::sort(f_activeDetIds.begin(), f_activeDetIds.end());
270 std::sort(l_activeDetIds.begin(), l_activeDetIds.end());
273 output.commonElements.reserve(
std::min(f_activeDetIds.size(), l_activeDetIds.size()));
275 f_activeDetIds.end(),
276 l_activeDetIds.begin(),
277 l_activeDetIds.end(),
278 std::back_inserter(
output.commonElements));
281 output.fExclusiveElements.reserve(f_activeDetIds.size() -
output.commonElements.size());
283 f_activeDetIds.end(),
284 l_activeDetIds.begin(),
285 l_activeDetIds.end(),
286 std::back_inserter(
output.fExclusiveElements));
289 output.lExclusiveElements.reserve(l_activeDetIds.size() -
output.commonElements.size());
291 l_activeDetIds.end(),
292 f_activeDetIds.begin(),
293 f_activeDetIds.end(),
294 std::back_inserter(
output.lExclusiveElements));
300 using SiStripFedCablingComparisonTrackerMapSingleTag = SiStripFedCablingComparisonTrackerMapBase<1, MULTI_IOV>;
301 using SiStripFedCablingComparisonTrackerMapTwoTags = SiStripFedCablingComparisonTrackerMapBase<2, SINGLE_IOV>;
306 class SiStripFedCabling_Summary :
public PlotImage<SiStripFedCabling, SINGLE_IOV> {
310 bool fill()
override {
311 auto tag = PlotBase::getTag<0>();
312 auto iov =
tag.iovs.front();
313 std::shared_ptr<SiStripFedCabling>
payload = fetchPayload(std::get<1>(iov));
314 int IOV = std::get<0>(iov);
315 std::vector<uint32_t> activeDetIds;
319 std::unique_ptr<SiStripDetCabling> detCabling_ = std::make_unique<SiStripDetCabling>(*(
payload.get()), &tTopo);
321 detCabling_->addActiveDetectorsRawIds(activeDetIds);
324 containers allCounts;
328 for (
const auto&
it : detInfo.getAllData()) {
330 if (
it.first == 0 ||
it.first == 0xFFFFFFFF) {
332 <<
"Wrong det id: " <<
it.first <<
" ... neglecting!" << std::endl;
335 updateCounters(
it.first, allCounts, tTopo);
338 for (
const auto&
detId : activeDetIds) {
339 updateCounters(
detId, myCont, tTopo);
342 TH2D*
ME =
new TH2D(
"SummaryOfCabling",
"SummaryOfCabling", 6, 0.5, 6.5, 9, 0.5, 9.5);
343 ME->GetXaxis()->SetTitle(
"Sub Det");
344 ME->GetYaxis()->SetTitle(
"Layer");
348 ME->GetXaxis()->SetBinLabel(1,
"TIB");
349 ME->GetXaxis()->SetBinLabel(2,
"TID F");
350 ME->GetXaxis()->SetBinLabel(3,
"TID B");
351 ME->GetXaxis()->SetBinLabel(4,
"TOB");
352 ME->GetXaxis()->SetBinLabel(5,
"TEC F");
353 ME->GetXaxis()->SetBinLabel(6,
"TEC B");
355 for (
int i = 0;
i < 4;
i++) {
356 ME->Fill(1,
i + 1,
float(myCont.counterTIB[
i]) / allCounts.counterTIB[
i]);
359 for (
int i = 0;
i < 2;
i++) {
360 for (
int j = 0;
j < 3;
j++) {
361 ME->Fill(
i + 2,
j + 1,
float(myCont.counterTID[
i][
j]) / allCounts.counterTID[
i][
j]);
365 for (
int i = 0;
i < 6;
i++) {
366 ME->Fill(4,
i + 1,
float(myCont.counterTOB[
i]) / allCounts.counterTOB[
i]);
369 for (
int i = 0;
i < 2;
i++) {
370 for (
int j = 0;
j < 9;
j++) {
371 ME->Fill(
i + 5,
j + 1,
float(myCont.counterTEC[
i][
j]) / allCounts.counterTEC[
i][
j]);
375 TCanvas
c1(
"SiStrip FED cabling summary",
"SiStrip FED cabling summary", 800, 600);
376 c1.SetTopMargin(0.07);
377 c1.SetBottomMargin(0.10);
378 c1.SetLeftMargin(0.07);
379 c1.SetRightMargin(0.10);
382 ME->Draw(
"TEXTsame");
383 ME->SetStats(kFALSE);
388 t1.SetTextSize(0.05);
389 t1.DrawLatex(0.5, 0.96, Form(
"SiStrip FedCabling, IOV %i", IOV));
400 int counterTIB[4] = {0};
401 int counterTID[2][3] = {{0}};
402 int counterTOB[6] = {0};
403 int counterTEC[2][9] = {{0}};
409 switch (subdet.subdetId()) {
412 cont.counterTIB[
i]++;
419 cont.counterTID[0][
j]++;
420 }
else if (
side == 1) {
421 cont.counterTID[1][
j]++;
427 cont.counterTOB[
i]++;
434 cont.counterTEC[0][
j]++;
435 }
else if (
side == 1) {
436 cont.counterTEC[1][
j]++;
static constexpr auto TEC
unsigned int tobLayer(const DetId &id) const
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
std::string fullPath() const
unsigned int tidSide(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
ALPAKA_FN_ACC int side(int ieta, int iphi)
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
unsigned int tecSide(const DetId &id) const
SiStripDetInfo read(std::string filePath)
static constexpr auto TOB
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Log< level::Warning, true > LogPrint
static constexpr auto TIB
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
static constexpr char const *const kDefaultFile
unsigned int tibLayer(const DetId &id) const
static constexpr auto TID
const uint16_t nApvPairs(uint32_t det_id) const
cont
load Luminosity info ##