Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctpps diamond dqm 2021 #43

Open
wants to merge 6 commits into
base: CMSSW_11_0_X
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 95 additions & 77 deletions DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,14 @@ class CTPPSDiamondDQMSource : public one::DQMEDAnalyzer<edm::LuminosityBlockCach
static const double INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
static const double HPTDC_BIN_WIDTH_NS; // ns per HPTDC bin
static const int CTPPS_NUM_OF_ARMS;
static const int CTPPS_DIAMOND_STATION_ID;
static const int CTPPS_DIAMOND_RP_ID;
static const int CTPPS_PIXEL_STATION_ID;
static const int CTPPS_NEAR_RP_ID;
static const int CTPPS_FAR_RP_ID;
static const int CTPPS_DIAMOND_NUM_OF_PLANES;
static const int CTPPS_DIAMOND_NUM_OF_CHANNELS;
static const int CTPPS_FED_ID_45;
static const int CTPPS_FED_ID_56;

static const int CTPPS_DETECTORS[2];
edm::EDGetTokenT<edm::DetSetVector<TotemVFATStatus>> tokenStatus_;
edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelLocalTrack>> tokenPixelTrack_;
edm::EDGetTokenT<edm::DetSetVector<CTPPSDiamondDigi>> tokenDigi_;
Expand Down Expand Up @@ -209,15 +207,14 @@ const double CTPPSDiamondDQMSource::DISPLAY_RESOLUTION_FOR_HITS_MM = 0.1;
const double CTPPSDiamondDQMSource::INV_DISPLAY_RESOLUTION_FOR_HITS_MM = 1. / DISPLAY_RESOLUTION_FOR_HITS_MM;
const double CTPPSDiamondDQMSource::HPTDC_BIN_WIDTH_NS = 25. / 1024;
const int CTPPSDiamondDQMSource::CTPPS_NUM_OF_ARMS = 2;
const int CTPPSDiamondDQMSource::CTPPS_DIAMOND_STATION_ID = 1;
const int CTPPSDiamondDQMSource::CTPPS_PIXEL_STATION_ID = 2;
const int CTPPSDiamondDQMSource::CTPPS_DIAMOND_RP_ID = 6;
const int CTPPSDiamondDQMSource::CTPPS_NEAR_RP_ID = 2;
const int CTPPSDiamondDQMSource::CTPPS_FAR_RP_ID = 3;
const int CTPPSDiamondDQMSource::CTPPS_DIAMOND_NUM_OF_PLANES = 4;
const int CTPPSDiamondDQMSource::CTPPS_DIAMOND_NUM_OF_CHANNELS = 12;
const int CTPPSDiamondDQMSource::CTPPS_FED_ID_56 = 582;
const int CTPPSDiamondDQMSource::CTPPS_FED_ID_45 = 583;
const int CTPPSDiamondDQMSource::CTPPS_DETECTORS[2]={16,22};

//----------------------------------------------------------------------------------------------------

Expand All @@ -231,7 +228,7 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i
LeadingOnlyCounter(0),
TrailingOnlyCounter(0),
CompleteCounter(0),
pixelTracksMap("Pixel track maps for efficiency", "Pixel track maps for efficiency", 25, 0, 25, 12, -2, 10) {
pixelTracksMap("Pixel track maps for efficiency", "Pixel track maps for efficiency", 25, 0, 25, 12, -6, 6) {
std::string path, title;
CTPPSDiamondDetId(id).rpName(path, CTPPSDiamondDetId::nPath);
ibooker.setCurrentFolder(path);
Expand All @@ -250,33 +247,33 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i
10,
-0.5,
4.5,
19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
22. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
-0.5,
18.5);
21.5);
hitDistribution2d_lumisection = ibooker.book2D("hits in planes lumisection",
title + " hits in planes in the last lumisection;plane number;x (mm)",
10,
-0.5,
4.5,
19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
22. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
-0.5,
18.5);
21.5);
hitDistribution2dOOT = ibooker.book2D("hits with OOT in planes",
title + " hits with OOT in planes;plane number + 0.25 OOT;x (mm)",
17,
-0.25,
4,
19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
22. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
-0.5,
18.5);
21.5);
hitDistribution2dOOT_le = ibooker.book2D("hits with OOT in planes (le only)",
title + " hits with OOT in planes (le only);plane number + 0.25 OOT;x (mm)",
17,
-0.25,
4,
19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
22. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
-0.5,
18.5);
21.5);
activePlanes =
ibooker.book1D("active planes", title + " active planes (per event);number of active planes", 6, -0.5, 5.5);
activePlanesInclusive =
Expand All @@ -293,9 +290,9 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i
9,
-0.5,
4,
19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
22. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM,
-0.5,
18.5);
21.5);

pixelTomographyAll[0] =
ibooker.book2D("tomography pixel 0 25",
Expand All @@ -304,26 +301,29 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i
0,
100,
8,
0,
8);
-4,
4);

pixelTomographyAll[1] =
ibooker.book2D("tomography pixel 25 50",
title + " tomography with pixel 25 - 50 ns (all planes);x + 25*plane(mm);y (mm)",
100,
0,
100,
8,
0,
8);
-4,
4);

pixelTomographyAll[2] =
ibooker.book2D("tomography pixel 50 75",
title + " tomography with pixel 50 - 75 ns (all planes);x + 25*plane(mm);y (mm)",
100,
0,
100,
8,
0,
8);
-4,
4);


leadingEdgeCumulative_both = ibooker.book1D(
"leading edge (le and te)", title + " leading edge (le and te) (recHits); leading edge (ns)", 75, 0, 75);
Expand Down Expand Up @@ -398,8 +398,8 @@ CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsign
0,
25,
12,
-2,
10) {
-6,
6) {
std::string path, title;
CTPPSDiamondDetId(id).planeName(path, CTPPSDiamondDetId::nPath);
ibooker.setCurrentFolder(path);
Expand All @@ -412,9 +412,9 @@ CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsign
hit_multiplicity = ibooker.book1D("channels per plane", title + " channels per plane; ch per plane", 13, -0.5, 12.5);

pixelTomography_far =
ibooker.book2D("tomography pixel", title + " tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8);
ibooker.book2D("tomography pixel", title + " tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, -4, 4);
EfficiencyWRTPixelsInPlane =
ibooker.book2D("Efficiency wrt pixels", title + " Efficiency wrt pixels;x (mm);y (mm)", 25, 0, 25, 12, -2, 10);
ibooker.book2D("Efficiency wrt pixels", title + " Efficiency wrt pixels;x (mm);y (mm)", 25, 0, 25, 12, -6, 6);
}

//----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -464,7 +464,7 @@ CTPPSDiamondDQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, un
75);

pixelTomography_far =
ibooker.book2D("tomography pixel", "tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8);
ibooker.book2D("tomography pixel", "tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, -4, 4);

hit_rate = ibooker.book1D("hit rate", title + "hit rate;rate (Hz)", 40, 0, 20);
}
Expand All @@ -482,15 +482,19 @@ CTPPSDiamondDQMSource::CTPPSDiamondDQMSource(const edm::ParameterSet& ps)
consumes<edm::DetSetVector<CTPPSDiamondLocalTrack>>(ps.getParameter<edm::InputTag>("tagDiamondLocalTracks"))),
tokenFEDInfo_(consumes<std::vector<TotemFEDInfo>>(ps.getParameter<edm::InputTag>("tagFEDInfo"))),
excludeMultipleHits_(ps.getParameter<bool>("excludeMultipleHits")),
horizontalShiftBwDiamondPixels_(0),
horizontalShiftOfDiamond_(0),
centralOOT_(-999),
verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
EC_difference_56_(-500),
EC_difference_45_(-500) {
for (const auto& pset : ps.getParameter<std::vector<edm::ParameterSet>>("offsetsOOT")) {
runParameters_.emplace_back(
std::make_pair(pset.getParameter<edm::EventRange>("validityRange"), pset.getParameter<int>("centralOOT")));
}
}
EC_difference_45_(-500)
{
for (const auto& pset : ps.getParameter<std::vector<edm::ParameterSet>>("offsetsOOT")) {
runParameters_.emplace_back(
std::make_pair(pset.getParameter<edm::EventRange>("validityRange"), pset.getParameter<int>("centralOOT")));
}
}


//----------------------------------------------------------------------------------------------------

Expand All @@ -508,19 +512,26 @@ void CTPPSDiamondDQMSource::dqmBeginRun(const edm::Run& iRun, const edm::EventSe
}

// Get detector shifts from the geometry
// Uncomment this to shift hits histogram to x=0 for 16 and 116
// Needs some code adjustments in filling to make it work properly for 22 and 122

/*
grzanka marked this conversation as resolved.
Show resolved Hide resolved
edm::ESHandle<CTPPSGeometry> geometry_;
iSetup.get<VeryForwardRealGeometryRecord>().get(geometry_);
const CTPPSGeometry* geom = geometry_.product();
const CTPPSDiamondDetId detid(0, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, 0, 0);
const DetGeomDesc* det = geom->getSensor(detid);
horizontalShiftOfDiamond_ = det->translation().x() - det->params().at(0);

// Rough alignement of pixel detector for diamond thomography
const CTPPSPixelDetId pixid(0, CTPPS_PIXEL_STATION_ID, CTPPS_FAR_RP_ID, 0);
if (iRun.run() > 300000) { //Pixel installed
det = geom->getSensor(pixid);
horizontalShiftBwDiamondPixels_ = det->translation().x() - det->params().at(0) - horizontalShiftOfDiamond_ - 1;
for(int detector:CTPPS_DETECTORS){
grzanka marked this conversation as resolved.
Show resolved Hide resolved
const CTPPSDiamondDetId detid(arm, detector/10, detector%10, 0, 0);
const DetGeomDesc* det = geom->getSensor(detid);
horizontalShiftOfDiamond_ = det->translation().x() - det->params().at(0);

// Rough alignement of pixel detector for diamond thomography
const CTPPSPixelDetId pixid(arm, CTPPS_PIXEL_STATION_ID, CTPPS_FAR_RP_ID, 0);
if (iRun.run() > 300000) { //Pixel installed
det = geom->getSensor(pixid);
horizontalShiftBwDiamondPixels_ = det->translation().x() - det->params().at(0) - horizontalShiftOfDiamond_ - 1;
}
}
*/
}

//----------------------------------------------------------------------------------------------------
Expand All @@ -532,14 +543,18 @@ void CTPPSDiamondDQMSource::bookHistograms(DQMStore::IBooker& ibooker, const edm
globalPlot_ = GlobalPlots(ibooker);

for (unsigned short arm = 0; arm < CTPPS_NUM_OF_ARMS; ++arm) {
const CTPPSDiamondDetId rpId(arm, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID);
potPlots_[rpId] = PotPlots(ibooker, rpId);
for (unsigned short pl = 0; pl < CTPPS_DIAMOND_NUM_OF_PLANES; ++pl) {
const CTPPSDiamondDetId plId(arm, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, pl);
planePlots_[plId] = PlanePlots(ibooker, plId);
for (unsigned short ch = 0; ch < CTPPS_DIAMOND_NUM_OF_CHANNELS; ++ch) {
const CTPPSDiamondDetId chId(arm, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, pl, ch);
channelPlots_[chId] = ChannelPlots(ibooker, chId);
for(unsigned short detector : CTPPS_DETECTORS){
const short station=detector/10;
const short pot=detector%10;
const CTPPSDiamondDetId rpId(arm, station, pot);
potPlots_[rpId] = PotPlots(ibooker, rpId);
for (unsigned short pl = 0; pl < CTPPS_DIAMOND_NUM_OF_PLANES; ++pl) {
const CTPPSDiamondDetId plId(arm, station, pot, pl);
planePlots_[plId] = PlanePlots(ibooker, plId);
for (unsigned short ch = 0; ch < CTPPS_DIAMOND_NUM_OF_CHANNELS; ++ch) {
const CTPPSDiamondDetId chId(arm, station, pot, pl, ch);
channelPlots_[chId] = ChannelPlots(ibooker, chId);
}
}
}
}
Expand Down Expand Up @@ -790,7 +805,7 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
potPlots_[detId_pot].activity_per_bx.at(rechit.getOOTIndex())->Fill(event.bunchCrossing());
}
}

for (const auto& plt : potPlots_) {
plt.second.activePlanes->Fill(planes[plt.first].size());
plt.second.activePlanesInclusive->Fill(planes_inclusive[plt.first].size());
Expand Down Expand Up @@ -864,7 +879,7 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
potPlots_[detId_pot].effTriplecountingChMap[map_index] = 0;
potPlots_[detId_pot].effDoublecountingChMap[map_index] = 0;
}
CTPPSDiamondDetId detId(detId_pot.arm(), CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, plane, channel);
CTPPSDiamondDetId detId(detId_pot.arm(), detId_pot.station(), detId_pot.rp(), plane, channel);
if (channelAlignedWithTrack(geometry_.product(), detId, track, 0.2)) {
// Channel should fire
++(potPlots_[detId_pot].effDoublecountingChMap[map_index]);
Expand Down Expand Up @@ -1008,33 +1023,37 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
continue;
for (const auto& lt : ds) {
if (lt.isValid()) {
// For efficieny
CTPPSDiamondDetId detId_pot(pixId.arm(), CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID);
potPlots_[detId_pot].pixelTracksMap.Fill(lt.getX0() - horizontalShiftBwDiamondPixels_, lt.getY0());

std::set<CTPPSDiamondDetId> planesWitHits_set;
for (const auto& rechits : *diamondRecHits) {
CTPPSDiamondDetId detId_plane(rechits.detId());
detId_plane.setChannel(0);
for (const auto& rechit : rechits) {
if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
continue;
if (rechit.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.getToT() == 0)
continue;
if (planePlots_.find(detId_plane) == planePlots_.end())
continue;
if (pixId.arm() == detId_plane.arm() && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24) {
planePlots_[detId_plane].pixelTomography_far->Fill(
lt.getX0() - horizontalShiftBwDiamondPixels_ + 25 * rechit.getOOTIndex(), lt.getY0());
if (centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_)
planesWitHits_set.insert(detId_plane);
// For efficiency
for(int detector:CTPPS_DETECTORS){
const short station=detector/10;
const short pot=detector%10;
CTPPSDiamondDetId detId_pot(pixId.arm(),station, pot);
potPlots_[detId_pot].pixelTracksMap.Fill(lt.getX0() - horizontalShiftBwDiamondPixels_, lt.getY0());

std::set<CTPPSDiamondDetId> planesWitHits_set;
for (const auto& rechits : *diamondRecHits) {
CTPPSDiamondDetId detId_plane(rechits.detId());
detId_plane.setChannel(0);
for (const auto& rechit : rechits) {
if (excludeMultipleHits_ && rechit.getMultipleHits() > 0)
continue;
if (rechit.getOOTIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.getToT() == 0)
continue;
if (planePlots_.find(detId_plane) == planePlots_.end())
continue;
if (pixId.arm() == detId_plane.arm() && lt.getX0() - horizontalShiftBwDiamondPixels_ < 24) {
planePlots_[detId_plane].pixelTomography_far->Fill(
lt.getX0() - horizontalShiftBwDiamondPixels_ + 25 * rechit.getOOTIndex(), lt.getY0());
if (centralOOT_ != -999 && rechit.getOOTIndex() == centralOOT_)
planesWitHits_set.insert(detId_plane);
}
}
}
}

for (auto& planeId : planesWitHits_set)
planePlots_[planeId].pixelTracksMapWithDiamonds.Fill(lt.getX0() - horizontalShiftBwDiamondPixels_,
lt.getY0());
for (auto& planeId : planesWitHits_set)
planePlots_[planeId].pixelTracksMapWithDiamonds.Fill(lt.getX0() - horizontalShiftBwDiamondPixels_,
lt.getY0());
}
}
}
}
Expand Down Expand Up @@ -1195,7 +1214,6 @@ void CTPPSDiamondDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock&

CTPPSDiamondDetId detId_pot(plot.first);
detId_pot.setPlane(0);

hitHistoTmp->Divide(&(plot.second.pixelTracksMapWithDiamonds), &(potPlots_[detId_pot].pixelTracksMap));
}
}
Expand Down