Skip to content

Commit

Permalink
Merge pull request #41923 from CTPPS/fo_nt2_dqm_final_backport130
Browse files Browse the repository at this point in the history
Backport of final DQM plot updates for Totem T2 run 25.6 (PR #41922)
  • Loading branch information
cmsbuild authored Jun 13, 2023
2 parents d77e58b + 49d15f3 commit efdc7b6
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 40 deletions.
5 changes: 1 addition & 4 deletions DQM/CTPPS/interface/TotemT2Segmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@
#define DQM_CTPPS_TotemT2Segmentation_h

#include "DataFormats/CTPPSDetId/interface/TotemT2DetId.h"
#include "Geometry/ForwardGeometry/interface/TotemGeometry.h"

#include <unordered_map>
#include <vector>

class TotemGeometry;
class TH2D;

class TotemT2Segmentation {
public:
explicit TotemT2Segmentation(const TotemGeometry&, size_t, size_t);
explicit TotemT2Segmentation(size_t, size_t);

void fill(TH2D*, const TotemT2DetId&, double value = 1.);

private:
std::vector<std::pair<short, short> > computeBins(const TotemT2DetId& detid) const;

const TotemGeometry geom_;
const size_t nbinsx_;
const size_t nbinsy_;

Expand Down
91 changes: 73 additions & 18 deletions DQM/CTPPS/plugins/TotemT2DQMSource.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/****************************************************************************
*
* This is a part of TOTEM offline software.
* Author:
* Authors:
* Laurent Forthomme
* Arkadiusz Cwikla
* Fredrik Oljemark
*
****************************************************************************/

Expand All @@ -26,6 +27,7 @@
#include "DQM/CTPPS/interface/TotemT2Segmentation.h"

#include <string>
#include <bitset>

class TotemT2DQMSource : public DQMEDAnalyzer {
public:
Expand All @@ -45,12 +47,14 @@ class TotemT2DQMSource : public DQMEDAnalyzer {
void bookErrorFlagsHistogram(DQMStore::IBooker&);
void fillErrorFlagsHistogram(const TotemT2Digi&, const TotemT2DetId&);
void fillEdges(const TotemT2Digi&, const TotemT2DetId&);
void fillBX(const TotemT2Digi&, const TotemT2DetId&, const int);
void fillToT(const TotemT2Digi&, const TotemT2DetId&);
void fillFlags(const TotemT2Digi&, const TotemT2DetId&);

const edm::ESGetToken<TotemGeometry, TotemGeometryRcd> geometryToken_;
const edm::EDGetTokenT<edmNew::DetSetVector<TotemT2Digi>> digiToken_;

std::unique_ptr<TotemT2Segmentation> segm_;

static constexpr double T2_BIN_WIDTH_NS_ = 25. / 4;
MonitorElement* totemT2ErrorFlags_2D_ = nullptr;

Expand All @@ -62,6 +66,7 @@ class TotemT2DQMSource : public DQMEDAnalyzer {
struct SectorPlots {
MonitorElement* activePlanes = nullptr;
MonitorElement* activePlanesCount = nullptr;
MonitorElement* activityPerBX = nullptr;

MonitorElement* triggerEmulator = nullptr;
std::bitset<(TotemT2DetId::maxPlane + 1) * (TotemT2DetId::maxChannel + 1)> hitTilesArray;
Expand All @@ -87,6 +92,7 @@ class TotemT2DQMSource : public DQMEDAnalyzer {
MonitorElement* trailingEdgeCh = nullptr;
MonitorElement* timeOverTresholdCh = nullptr;
MonitorElement* eventFlagsCh = nullptr;
MonitorElement* activityPerBXCh = nullptr;

ChannelPlots() = default;
ChannelPlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum);
Expand All @@ -106,26 +112,36 @@ TotemT2DQMSource::SectorPlots::SectorPlots(

TotemT2DetId(id).armName(title, TotemT2DetId::nFull);

activePlanes = ibooker.book1D("active planes", title + " which planes are active;plane number", 8, -0.5, 7.5);
activePlanes =
ibooker.book1D("active planes", title + " which planes are active (LE+TE digis);plane number", 8, -0.5, 7.5);

activePlanesCount = ibooker.book1D("number of active planes",
title + " how many planes are active (LE+TE digis);number of active planes",
9,
-0.5,
8.5);

activePlanesCount = ibooker.book1D(
"number of active planes", title + " how many planes are active;number of active planes", 9, -0.5, 8.5);
activityPerBX =
ibooker.book1D("activity per BX CMS", title + " Activity (=LE) per BX;Event.BX", 3600, -1.5, 3598. + 0.5);

triggerEmulator = ibooker.book2DD("trigger emulator",
title + " trigger emulator;arbitrary unit;arbitrary unit",
title + " trigger emulator (LE+TE digis);arbitrary unit;arbitrary unit",
nbinsx,
-0.5,
double(nbinsx) - 0.5,
nbinsy,
-0.5,
double(nbinsy) - 0.5);
leadingEdge = ibooker.book1D(
"leading edge", title + " leading edge (DIGIs); leading edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);
"leading edge", title + " leading edge (all DIGIs); leading edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);
trailingEdge = ibooker.book1D(
"trailing edge", title + " trailing edge (DIGIs); trailing edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);
"trailing edge", title + " trailing edge (all DIGIs); trailing edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);

timeOverTreshold = ibooker.book1D(
"time over threshold", title + " time over threshold (digi);time over threshold (ns)", 500, -50, 200);
timeOverTreshold = ibooker.book1D("time over threshold",
title + " time over threshold (digi, =0 if LE or TE=0);time over threshold (ns)",
500,
-50,
200);

eventFlags = ibooker.book1D(
"event flags", title + " event flags (digi);Event flags (TE/LE valid, TE/LE multiple)", 4, -0.5, 3.5);
Expand All @@ -144,7 +160,7 @@ TotemT2DQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker,
ibooker.setCurrentFolder(path);

digisMultiplicity = ibooker.book2DD("digis multiplicity",
title + " digis multiplicity;arbitrary unit;arbitrary unit",
title + " digis multiplicity (=LE);arbitrary unit;arbitrary unit",
nbinsx,
-0.5,
double(nbinsx) - 0.5,
Expand Down Expand Up @@ -174,23 +190,28 @@ TotemT2DQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, unsigne
ibooker.setCurrentFolder(path);

leadingEdgeCh = ibooker.book1D(
"leading edge", title + " leading edge (DIGIs); leading edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);
"leading edge", title + " leading edge (all DIGIs); leading edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);
trailingEdgeCh = ibooker.book1D(
"trailing edge", title + " trailing edge (DIGIs); trailing edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);
"trailing edge", title + " trailing edge (all DIGIs); trailing edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);

timeOverTresholdCh = ibooker.book1D(
"time over threshold", title + " time over threshold (digi);time over threshold (ns)", 500, -50, 200);
timeOverTresholdCh = ibooker.book1D("time over threshold",
title + " time over threshold (digi, =0 if LE or TE=0);time over threshold (ns)",
500,
-50,
200);

eventFlagsCh = ibooker.book1D(
"event flags", title + " event flags (digi);Event flags (TE/LE valid, TE/LE multiple)", 4, -0.5, 3.5);

activityPerBXCh =
ibooker.book1D("activity per BX", title + " Activity (=LE) per BX;Event.BX", 1000, -1.5, 998. + 0.5);

for (unsigned short flag_index = 1; flag_index <= 4; ++flag_index)
eventFlagsCh->setBinLabel(flag_index, "Flag " + std::to_string(flag_index));
}

TotemT2DQMSource::TotemT2DQMSource(const edm::ParameterSet& iConfig)
: geometryToken_(esConsumes<TotemGeometry, TotemGeometryRcd, edm::Transition::BeginRun>()),
digiToken_(consumes<edmNew::DetSetVector<TotemT2Digi>>(iConfig.getParameter<edm::InputTag>("digisTag"))),
: digiToken_(consumes<edmNew::DetSetVector<TotemT2Digi>>(iConfig.getParameter<edm::InputTag>("digisTag"))),
nbinsx_(iConfig.getParameter<unsigned int>("nbinsx")),
nbinsy_(iConfig.getParameter<unsigned int>("nbinsy")),
windowsNum_(iConfig.getParameter<unsigned int>("windowsNum")) {}
Expand Down Expand Up @@ -219,22 +240,48 @@ void TotemT2DQMSource::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run
}

// build a segmentation helper for the size of histograms previously booked
segm_ = std::make_unique<TotemT2Segmentation>(nbinsx_, nbinsy_);
}

void TotemT2DQMSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
// fill digis information
std::unordered_map<unsigned int, std::set<unsigned int>> planes;

for (const auto& ds_digis : iEvent.get(digiToken_)) {
if (!ds_digis.empty()) {
const TotemT2DetId detid(ds_digis.detId());
const TotemT2DetId planeId(detid.planeId());
for (const auto& digi : ds_digis) {
fillTriggerBitset(detid);
if (digi.hasLE()) {
segm_->fill(planePlots_[planeId].digisMultiplicity->getTH2D(), detid);
if (digi.hasTE())
fillTriggerBitset(detid);
}
fillErrorFlagsHistogram(digi, detid);
fillEdges(digi, detid);
fillToT(digi, detid);
fillFlags(digi, detid);
int bx = iEvent.bunchCrossing();
fillBX(digi, detid, bx);
if (digi.hasLE() && digi.hasTE()) //good digi
fillActivePlanes(planes, detid);
}
}
}

for (const auto& plt : sectorPlots_)
plt.second.activePlanesCount->Fill(planes[plt.first].size());

for (unsigned short arm = 0; arm <= CTPPSDetId::maxArm; ++arm)
for (unsigned short plane = 0; plane <= 1; ++plane)
for (unsigned short id = 0; id <= TotemT2DetId::maxChannel; ++id) {
const TotemT2DetId detid(arm, plane, id);
if (areChannelsTriggered(detid)) {
const TotemT2DetId secId(detid.armId());
segm_->fill(sectorPlots_[secId].triggerEmulator->getTH2D(), detid);
}
}

// fill rechits information

clearTriggerBitset();
Expand Down Expand Up @@ -305,6 +352,14 @@ void TotemT2DQMSource::fillEdges(const TotemT2Digi& digi, const TotemT2DetId& de
channelPlots_[detid].trailingEdgeCh->Fill(T2_BIN_WIDTH_NS_ * digi.trailingEdge());
}

void TotemT2DQMSource::fillBX(const TotemT2Digi& digi, const TotemT2DetId& detid, const int bx) {
const TotemT2DetId secId(detid.armId());
if (digi.hasLE()) {
sectorPlots_[secId].activityPerBX->Fill(bx);
channelPlots_[detid].activityPerBXCh->Fill(bx);
}
}

void TotemT2DQMSource::fillToT(const TotemT2Digi& digi, const TotemT2DetId& detid) {
const TotemT2DetId secId(detid.armId());

Expand Down
13 changes: 8 additions & 5 deletions DQM/CTPPS/src/TotemT2Segmentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

#include "TH2D.h"

TotemT2Segmentation::TotemT2Segmentation(const TotemGeometry& geom, size_t nbinsx, size_t nbinsy)
: geom_(geom), nbinsx_(nbinsx), nbinsy_(nbinsy) {
TotemT2Segmentation::TotemT2Segmentation(size_t nbinsx, size_t nbinsy) : nbinsx_(nbinsx), nbinsy_(nbinsy) {
for (unsigned short arm = 0; arm <= CTPPSDetId::maxArm; ++arm)
for (unsigned short plane = 0; plane <= TotemT2DetId::maxPlane; ++plane)
for (unsigned short id = 0; id <= TotemT2DetId::maxChannel; ++id) {
Expand Down Expand Up @@ -44,9 +43,13 @@ std::vector<std::pair<short, short> > TotemT2Segmentation::computeBins(const Tot
const auto ax = ceil(nbinsx_ * 0.5), by = ceil(nbinsy_ * 0.5);

const float max_half_angle_rad = 0.3;
// find the coordinates of the tile centre to extract its angle
const auto tile_centre = geom_.tile(detid).centre();
const auto tile_angle_rad = std::atan2(tile_centre.y(), tile_centre.x());

// Without use of the Totem Geometry, follow an octant-division of channels,
// with even and odd planes alternating around the circle. Starting at 9AM
// and going clockwise around in increments of 1h30min=45deg, we have
// Ch0 on even planes, Ch0+odd, Ch1+even, Ch1+odd, up to Ch3+odd at 7:30PM

const float tile_angle_rad = (180 - 45. / 2 - (detid.plane() % 2 ? 45 : 0) - (detid.channel() * 90)) * M_PI / 180.;
// Geometric way of associating a DetId to a vector<ix, iy> of bins given the size (nx_, ny_) of
// the TH2D('s) to be filled
for (size_t ix = 0; ix < nbinsx_; ++ix)
Expand Down
22 changes: 9 additions & 13 deletions DQM/CTPPS/test/totemt2_dqm_test_common_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@
process.dqmSaver.path = ""
process.dqmSaver.tag = "CTPPS"

# raw data source
#alignment run without T2, TimingDiamond and TrackingStrip not affected by PR changes
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(
'/store/data/Run2023A/HLTPhysics/RAW/v1/000/366/192/00000/f277ee80-e88b-41e8-b1ba-6c18af119fbc.root'
)
# raw data source, T2 + TrackingStrips test file in run 368593, not 368594 (wrong settings)
process.source = cms.Source("NewEventStreamFileReader",
fileNames = cms.untracked.vstring(
'/store/t0streamer/Minidaq/A/000/368/593/run368593_ls0001_streamA_StorageManager.dat',
# '/store/t0streamer/Minidaq/A/000/368/594/run368594_ls0001_streamA_StorageManager.dat',
)
)


process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(8000)
)

# raw-to-digi conversion
process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff")

# global tag - conditions for P5 cluster
process.load("DQM.Integration.config.FrontierCondition_GT_cfi")

#from Configuration.AlCa.GlobalTag import GlobalTag
#process.GlobalTag = GlobalTag(process.GlobalTag, '130X_dataRun3_HLT_v2', '')
#Latest PPS GT candidate
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, '130X_dataRun3_Prompt_Candidate_2023_06_06_21_34_08', '')

# local RP reconstruction chain with standard settings
process.load("RecoPPS.Configuration.recoCTPPS_cff")
Expand Down

0 comments on commit efdc7b6

Please sign in to comment.