diff --git a/DQM/CTPPS/plugins/BuildFile.xml b/DQM/CTPPS/plugins/BuildFile.xml index 6e804109707e8..545d763e6edea 100644 --- a/DQM/CTPPS/plugins/BuildFile.xml +++ b/DQM/CTPPS/plugins/BuildFile.xml @@ -14,4 +14,5 @@ + diff --git a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc index adba4530d145e..1d6afd266755a 100644 --- a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc @@ -1,10 +1,11 @@ /**************************************************************************** * -* This is a part of CTPPS offline software. +* This is a part of CTPPSDQM software. * Authors: * Jan Kašpar (jan.kaspar@gmail.com) * Nicola Minafra * Laurent Forthomme +* Christopher Misan * ****************************************************************************/ @@ -37,6 +38,9 @@ #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" #include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" +// #include "CondFormats/RunInfo/interface/LHCInfo.h" +// #include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + #include //---------------------------------------------------------------------------------------------------- @@ -68,10 +72,10 @@ namespace dds { class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer> { public: CTPPSDiamondDQMSource(const edm::ParameterSet&); - ~CTPPSDiamondDQMSource() override; protected: void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override; + void dqmEndRun(edm::Run const&, edm::EventSetup const&) override; void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; std::shared_ptr globalBeginLuminosityBlock(const edm::LuminosityBlock&, @@ -80,48 +84,39 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer> tokenStatus_; - edm::EDGetTokenT> tokenPixelTrack_; - edm::EDGetTokenT> tokenDigi_; - edm::EDGetTokenT> tokenDiamondHit_; - edm::EDGetTokenT> tokenDiamondTrack_; - edm::EDGetTokenT> tokenFEDInfo_; - - edm::ESGetToken ctppsGeometryRunToken_; - edm::ESGetToken ctppsGeometryEventToken_; - - bool excludeMultipleHits_; - bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py - double horizontalShiftBwDiamondPixels_; - double horizontalShiftOfDiamond_; - std::vector> runParameters_; - int centralOOT_; - unsigned int verbosity_; + /// Number of seconds per lumisection: used to compute hit rates in Hz + static constexpr double SEC_PER_LUMI_SECTION = 23.31; + /// Channel ID of the VFAT that contains clock data + static constexpr unsigned short CHANNEL_OF_VFAT_CLOCK = 30; + /// Bin width of histograms showing hits and tracks (in mm) + static constexpr double DISPLAY_RESOLUTION_FOR_HITS_MM = 0.1; + static constexpr double INV_DISPLAY_RESOLUTION_FOR_HITS_MM = 1. / DISPLAY_RESOLUTION_FOR_HITS_MM; + /// ns per HPTDC bin + static constexpr double HPTDC_BIN_WIDTH_NS = 25. / 1024; + static constexpr unsigned short CTPPS_PIXEL_STATION_ID = 2; + static constexpr unsigned short CTPPS_FAR_RP_ID = 3; + static constexpr unsigned short CTPPS_DIAMOND_NUM_OF_CHANNELS = 12; + static constexpr unsigned short CTPPS_FED_ID_45 = 583; + static constexpr unsigned short CTPPS_FED_ID_56 = 582; + static constexpr unsigned short HPTDC_0_CHANNEL = 6; + static constexpr unsigned short HPTDC_1_CHANNEL = 7; + /// Number of OOT indices monitored + static constexpr unsigned int FIRST_RUN_W_PIXELS = 300000; /// plots related to the whole system struct GlobalPlots { - GlobalPlots() {} + GlobalPlots() = default; GlobalPlots(DQMStore::IBooker& ibooker); }; - - GlobalPlots globalPlot_; - + /// plots related to one sector + struct SectorPlots { + // Tracks + MonitorElement* trackCorrelation = nullptr; + MonitorElement* trackCorrelationLowMultiplicity = nullptr; + MonitorElement* digiSentPercentage = nullptr; + SectorPlots(){}; + SectorPlots(DQMStore::IBooker& ibooker, unsigned int id, bool plotOnline); + }; /// plots related to one Diamond detector package struct PotPlots { std::unordered_map activity_per_bx; @@ -139,7 +134,7 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer potPlots_; - int EC_difference_56_, EC_difference_45_; + // MonitorElement* TOTVsLSProfile = nullptr; + // MonitorElement* trackTimeVsLSProfile = nullptr; + MonitorElement* trackTimeVsBXProfile = nullptr; + // MonitorElement* trackTimeVsXAngleProfile = nullptr; + PotPlots() = default; + PotPlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum, bool plotOnline, bool plotOffline); + }; /// plots related to one Diamond plane struct PlanePlots { MonitorElement* digiProfileCumulativePerPlane = nullptr; @@ -177,12 +180,9 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer planePlots_; - /// plots related to one Diamond channel struct ChannelPlots { std::unordered_map activity_per_bx; @@ -191,46 +191,90 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer> tokenStatus_; + edm::EDGetTokenT> tokenPixelTrack_; + edm::EDGetTokenT> tokenDigi_; + edm::EDGetTokenT> tokenDiamondHit_; + edm::EDGetTokenT> tokenDiamondTrack_; + edm::EDGetTokenT> tokenFEDInfo_; + + edm::ESGetToken ctppsGeometryRunToken_; + edm::ESGetToken ctppsGeometryEventToken_; + // edm::ESGetToken ctppsLhcInfoToken_; + + bool excludeMultipleHits_; + bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py + const bool extract_digi_info_; + struct DiamondShifts { + double global, withPixels; }; + std::unordered_map diamShifts_; + std::vector> runParameters_; + int centralOOT_; + unsigned int verbosity_; + const bool plotOnline_; + const bool plotOffline_; + unsigned int windowsNum_; + unsigned int trackCorrelationThreshold_; + GlobalPlots globalPlot_; + std::unordered_map potPlots_; + std::unordered_map sectorPlots_; + std::unordered_map planePlots_; std::unordered_map channelPlots_; + + int EC_difference_56_, EC_difference_45_; }; //---------------------------------------------------------------------------------------------------- -// Values for all constants -const double CTPPSDiamondDQMSource::SEC_PER_LUMI_SECTION = 23.31; -const int CTPPSDiamondDQMSource::CHANNEL_OF_VFAT_CLOCK = 30; -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; +CTPPSDiamondDQMSource::GlobalPlots::GlobalPlots(DQMStore::IBooker& ibooker) { ibooker.setCurrentFolder("CTPPS"); } //---------------------------------------------------------------------------------------------------- -CTPPSDiamondDQMSource::GlobalPlots::GlobalPlots(DQMStore::IBooker& ibooker) { ibooker.setCurrentFolder("CTPPS"); } +CTPPSDiamondDQMSource::SectorPlots::SectorPlots(DQMStore::IBooker& ibooker, unsigned int id, bool plotOnline) { + std::string path, title; + CTPPSDiamondDetId(id).armName(path, CTPPSDiamondDetId::nPath); + ibooker.setCurrentFolder(path); -//---------------------------------------------------------------------------------------------------- + CTPPSDiamondDetId(id).armName(title, CTPPSDiamondDetId::nFull); + + trackCorrelation = ibooker.book2D("tracks correlation near-far", + title + " tracks correlation near-far;x (mm);x (mm)", + 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, + -1, + 18, + 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, + -1, + 18); + trackCorrelationLowMultiplicity = + ibooker.book2D("tracks correlation with low multiplicity near-far", + title + " tracks correlation with low multiplicity near-far;x (mm);x (mm)", + 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, + -1, + 18, + 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, + -1, + 18); +} -CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned int id) +//---------------------------------------------------------------------------------------------------- +CTPPSDiamondDQMSource::PotPlots::PotPlots( + DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum, bool plotOnline, bool plotOffline) : HitCounter(0), MHCounter(0), LeadingOnlyCounter(0), @@ -243,12 +287,85 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i CTPPSDiamondDetId(id).rpName(title, CTPPSDiamondDetId::nFull); - activity_per_bx[0] = - ibooker.book1D("activity per BX 0 25", title + " Activity per BX 0 - 25 ns;Event.BX", 3600, -1.5, 3598. + 0.5); - activity_per_bx[1] = - ibooker.book1D("activity per BX 25 50", title + " Activity per BX 25 - 50 ns;Event.BX", 3600, -1.5, 3598. + 0.5); - activity_per_bx[2] = - ibooker.book1D("activity per BX 50 75", title + " Activity per BX 50 - 75 ns;Event.BX", 3600, -1.5, 3598. + 0.5); + if (plotOnline) { + 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, + -0.5, + 18.5); + + hitDistribution2dOOT_le = + ibooker.book2D("hits with OOT in planes (le only)", + title + " hits with OOT in planes (le only);plane number, OOT index;x (mm)", + 1 + windowsNum * 4, + -1. / windowsNum, + 4, + 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, + -0.5, + 18.5); + + activePlanesInclusive = + ibooker.book1D("active planes inclusive", + title + " active planes, MH and le only included (per event);number of active planes", + 6, + -0.5, + 5.5); + + ECCheck = ibooker.book1D("optorxEC(8bit) - vfatEC", title + " EC Error;optorxEC-vfatEC", 50, -25, 25); + + EfficiencyOfChannelsInPot = + ibooker.book2D("Efficiency in channels", + title + " Efficiency (%) in channels (diamonds only);plane number;ch number", + 10, + -0.5, + 4.5, + 14, + -1, + 13); + } + + if (plotOffline) { + ibooker.setCurrentFolder(path + "/timing_profiles"); + // TOTVsLS=ibooker.book2D("ToT vs LS",title +" ToT vs LS;LS;ToT(ns)",4000,0,4000, 200,5,25); + // trackTimeVsLS=ibooker.book2D("track time vs LS",title+" track time vs LS;LS;track_time(ns)",4000,0,4000, 500, -25, 25); + trackTimeVsBX = + ibooker.book2D("track time vs BX", title + " track time vs BX;BX;track_time(ns)", 4000, 0, 4000, 500, -25, 25); + // trackTimeVsXAngle = ibooker.book2D( + // "track time vs xangle", title + " track time vs xangle;xangle;track_time(ns)", 60, 120, 180, 500, -25, 25); + + // TOTVsLSProfile=ibooker.bookProfile("ToT vs LS profile",title+" ToT vs LS profile;LS;track_time(ns)", 500, -25, 25,4000,0,4000); + // trackTimeVsLSProfile=ibooker.bookProfile("track time vs LS profile",title+" track time vs LS profile;LS;track_time(ns)", 500, -25, 25,4000,0,4000); + trackTimeVsBXProfile = ibooker.bookProfile( + "track time vs BX profile", title + " track time vs BX profile;BX;track_time(ns)", 500, -25, 25, 4000, 0, 4000); + // trackTimeVsXAngleProfile = ibooker.bookProfile("track time vs xangle profile", + // title + " track time vs xangle profile;xangle;track_time(ns)", + // 500, + // -25, + // 25, + // 60, + // 120, + // 180); + ibooker.setCurrentFolder(path); + } + + for (unsigned int i = 0; i < windowsNum; i++) { + std::string window = std::to_string(i * 25) + "-" + std::to_string((i + 1) * 25); + activity_per_bx[i] = ibooker.book1D( + "activity per BX " + window, title + " Activity per BX " + window + " ns;Event.BX", 3600, -1.5, 3598. + 0.5); + pixelTomographyAll[i] = + ibooker.book2D("tomography pixel " + window, + title + " tomography with pixel " + window + " ns (all planes);x + 25*plane(mm);y (mm)", + 100, + 0, + 100, + 10, + -5, + 5); + } hitDistribution2d = ibooker.book2D("hits in planes", title + " hits in planes;plane number;x (mm)", @@ -258,38 +375,33 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.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, - -0.5, - 18.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, + title + " hits with OOT in planes;plane number, OOT index;x (mm)", + 1 + windowsNum * 4, + -1. / windowsNum, 4, 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.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, - -0.5, - 18.5); + + { // bin labelling (for clarity) + int idx = 2; // start counting at 1, first bin is empty + for (int pl = 0; pl < 4; ++pl) + for (unsigned int oot = 0; oot < windowsNum; ++oot) { + const std::string bin_label = + (oot == 0 ? "Plane " + std::to_string(pl) + ", " : "") + "OOT" + std::to_string(oot); + hitDistribution2dOOT->setBinLabel(idx, bin_label); + if (plotOnline) + hitDistribution2dOOT_le->setBinLabel(idx, bin_label); + ++idx; + } + } + + recHitTime = ibooker.book1D("recHit time", title + " recHit time; t (ns)", 500, -25, 25); + activePlanes = ibooker.book1D("active planes", title + " active planes (per event);number of active planes", 6, -0.5, 5.5); - activePlanesInclusive = - ibooker.book1D("active planes inclusive", - title + " active planes, MH and le only included (per event);number of active planes", - 6, - -0.5, - 5.5); trackDistribution = ibooker.book1D("tracks", title + " tracks;x (mm)", 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.5); @@ -302,53 +414,37 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i -0.5, 18.5); - pixelTomographyAll[0] = - ibooker.book2D("tomography pixel 0 25", - title + " tomography with pixel 0 - 25 ns (all planes);x + 25*plane(mm);y (mm)", - 100, - 0, - 100, - 8, - 0, - 8); - 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); - 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); - - leadingEdgeCumulative_both = ibooker.book1D( - "leading edge (le and te)", title + " leading edge (le and te) (recHits); leading edge (ns)", 75, 0, 75); - leadingEdgeCumulative_all = ibooker.book1D( - "leading edge (all)", title + " leading edge (with or without te) (DIGIs); leading edge (ns)", 75, 0, 75); - leadingEdgeCumulative_le = - ibooker.book1D("leading edge (le only)", title + " leading edge (le only) (DIGIs); leading edge (ns)", 75, 0, 75); - trailingEdgeCumulative_te = ibooker.book1D( - "trailing edge (te only)", title + " trailing edge (te only) (DIGIs); trailing edge (ns)", 75, 0, 75); + leadingEdgeCumulative_both = ibooker.book1D("leading edge (le and te)", + title + " leading edge (le and te) (recHits); leading edge (ns)", + 25 * windowsNum, + 0, + 25 * windowsNum); + leadingEdgeCumulative_all = ibooker.book1D("leading edge (all)", + title + " leading edge (with or without te) (DIGIs); leading edge (ns)", + 25 * windowsNum, + 0, + 25 * windowsNum); + leadingEdgeCumulative_le = ibooker.book1D("leading edge (le only)", + title + " leading edge (le only) (DIGIs); leading edge (ns)", + 25 * windowsNum, + 0, + 25 * windowsNum); + trailingEdgeCumulative_te = ibooker.book1D("trailing edge (te only)", + title + " trailing edge (te only) (DIGIs); trailing edge (ns)", + 25 * windowsNum, + 0, + 25 * windowsNum); timeOverThresholdCumulativePot = ibooker.book1D("time over threshold", title + " time over threshold;time over threshold (ns)", 250, -25, 100); - leadingTrailingCorrelationPot = - ibooker.book2D("leading trailing correlation", - title + " leading trailing correlation;leading edge (ns);trailing edge (ns)", - 75, - 0, - 75, - 75, - 0, - 75); + // leadingTrailingCorrelationPot = + // ibooker.book2D("leading trailing correlation", + // title + " leading trailing correlation;leading edge (ns);trailing edge (ns)", + // 75, + // 0, + // 75, + // 75, + // 0, + // 75); leadingWithoutTrailingCumulativePot = ibooker.book1D("event category", title + " leading edges without trailing;;%", 3, 0.5, 3.5); @@ -356,8 +452,6 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i leadingWithoutTrailingCumulativePot->setBinLabel(2, "Trailing only"); leadingWithoutTrailingCumulativePot->setBinLabel(3, "Both"); - ECCheck = ibooker.book1D("optorxEC(8bit) - vfatEC", title + " EC Error;optorxEC-vfatEC", 50, -25, 25); - HPTDCErrorFlags_2D = ibooker.book2D("HPTDC Errors", title + " HPTDC Errors", 16, -0.5, 16.5, 9, -0.5, 8.5); for (unsigned short error_index = 1; error_index < 16; ++error_index) HPTDCErrorFlags_2D->setBinLabel(error_index, HPTDCErrorFlags::hptdcErrorName(error_index - 1)); @@ -376,16 +470,6 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i MHComprensive = ibooker.book2D("MH in channels", title + " MH (%) in channels;plane number;ch number", 10, -0.5, 4.5, 14, -1, 13); - EfficiencyOfChannelsInPot = - ibooker.book2D("Efficiency in channels", - title + " Efficiency (%) in channels (diamonds only);plane number;ch number", - 10, - -0.5, - 4.5, - 14, - -1, - 13); - // ibooker.setCurrentFolder( path+"/clock/" ); // clock_Digi1_le = ibooker.book1D( "clock1 leading edge", title+" clock1;leading edge (ns)", 250, 0, 25 ); // clock_Digi1_te = ibooker.book1D( "clock1 trailing edge", title+" clock1;trailing edge (ns)", 75, 0, 75 ); @@ -395,7 +479,7 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker, unsigned i //---------------------------------------------------------------------------------------------------- -CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsigned int id) +CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum) : pixelTracksMapWithDiamonds("Pixel track maps for efficiency with coincidence", "Pixel track maps for efficiency with coincidence", 25, @@ -410,20 +494,30 @@ CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsign CTPPSDiamondDetId(id).planeName(title, CTPPSDiamondDetId::nFull); - digiProfileCumulativePerPlane = ibooker.book1D("digi profile", title + " digi profile; ch number", 12, -0.5, 11.5); + digiProfileCumulativePerPlane = ibooker.book1D("digi profile", + title + " digi profile; ch number", + CTPPS_DIAMOND_NUM_OF_CHANNELS, + -0.5, + CTPPS_DIAMOND_NUM_OF_CHANNELS - 0.5); hitProfile = ibooker.book1D( "hit profile", title + " hit profile;x (mm)", 19. * INV_DISPLAY_RESOLUTION_FOR_HITS_MM, -0.5, 18.5); 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); + pixelTomography_far = ibooker.book2D("tomography pixel", + title + " tomography with pixel;x + 25 OOT (mm);y (mm)", + 25 * windowsNum, + 0, + 25 * windowsNum, + 8, + 0, + 8); EfficiencyWRTPixelsInPlane = ibooker.book2D("Efficiency wrt pixels", title + " Efficiency wrt pixels;x (mm);y (mm)", 25, 0, 25, 12, -2, 10); } //---------------------------------------------------------------------------------------------------- -CTPPSDiamondDQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, unsigned int id) +CTPPSDiamondDQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum) : HitCounter(0), MHCounter(0), LeadingOnlyCounter(0), TrailingOnlyCounter(0), CompleteCounter(0) { std::string path, title; CTPPSDiamondDetId(id).channelName(path, CTPPSDiamondDetId::nPath); @@ -436,62 +530,77 @@ CTPPSDiamondDQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, un leadingWithoutTrailing->setBinLabel(2, "Trailing only"); leadingWithoutTrailing->setBinLabel(3, "Full"); - activity_per_bx[0] = - ibooker.book1D("activity per BX 0 25", title + " Activity per BX 0 - 25 ns;Event.BX", 500, -1.5, 498. + 0.5); - activity_per_bx[1] = - ibooker.book1D("activity per BX 25 50", title + " Activity per BX 25 - 50 ns;Event.BX", 500, -1.5, 498. + 0.5); - activity_per_bx[2] = - ibooker.book1D("activity per BX 50 75", title + " Activity per BX 50 - 75 ns;Event.BX", 500, -1.5, 498. + 0.5); + for (unsigned int i = 0; i < windowsNum; i++) { + std::string window = std::to_string(i * 25) + "-" + std::to_string((i + 1) * 25); + activity_per_bx[i] = ibooker.book1D( + "activity per BX " + window, title + " Activity per BX " + window + " ns;Event.BX", 3600, -1.5, 3598. + 0.5); + } HPTDCErrorFlags = ibooker.book1D("hptdc_Errors", title + " HPTDC Errors", 16, -0.5, 16.5); for (unsigned short error_index = 1; error_index < 16; ++error_index) HPTDCErrorFlags->setBinLabel(error_index, HPTDCErrorFlags::hptdcErrorName(error_index - 1)); HPTDCErrorFlags->setBinLabel(16, "MH (%)"); - leadingEdgeCumulative_both = - ibooker.book1D("leading edge (le and te)", title + " leading edge (recHits); leading edge (ns)", 75, 0, 75); - leadingEdgeCumulative_le = - ibooker.book1D("leading edge (le only)", title + " leading edge (DIGIs); leading edge (ns)", 75, 0, 75); - trailingEdgeCumulative_te = ibooker.book1D( - "trailing edge (te only)", title + " trailing edge (te only) (DIGIs); trailing edge (ns)", 75, 0, 75); + leadingEdgeCumulative_both = ibooker.book1D("leading edge (le and te)", + title + " leading edge (recHits); leading edge (ns)", + 25 * windowsNum, + 0, + 25 * windowsNum); + leadingEdgeCumulative_le = ibooker.book1D( + "leading edge (le only)", title + " leading edge (DIGIs); leading edge (ns)", 25 * windowsNum, 0, 25 * windowsNum); + trailingEdgeCumulative_te = ibooker.book1D("trailing edge (te only)", + title + " trailing edge (te only) (DIGIs); trailing edge (ns)", + 25 * windowsNum, + 0, + 25 * windowsNum); TimeOverThresholdCumulativePerChannel = ibooker.book1D("time over threshold", title + " time over threshold;time over threshold (ns)", 75, -25, 50); - LeadingTrailingCorrelationPerChannel = - ibooker.book2D("leading trailing correlation", - title + " leading trailing correlation;leading edge (ns);trailing edge (ns)", - 75, - 0, - 75, - 75, - 0, - 75); - - pixelTomography_far = - ibooker.book2D("tomography pixel", "tomography with pixel;x + 25 OOT (mm);y (mm)", 75, 0, 75, 8, 0, 8); + // LeadingTrailingCorrelationPerChannel = + // ibooker.book2D("leading trailing correlation", + // title + " leading trailing correlation;leading edge (ns);trailing edge (ns)", + // 75, + // 0, + // 75, + // 75, + // 0, + // 75); + + pixelTomography_far = ibooker.book2D( + "tomography pixel", "tomography with pixel;x + 25 OOT (mm);y (mm)", 25 * windowsNum, 0, 25 * windowsNum, 8, 0, 8); hit_rate = ibooker.book1D("hit rate", title + "hit rate;rate (Hz)", 40, 0, 20); + + recHitTime = ibooker.book1D("recHit Time", title + " recHit Time; t (ns)", 500, -25, 25); } //---------------------------------------------------------------------------------------------------- CTPPSDiamondDQMSource::CTPPSDiamondDQMSource(const edm::ParameterSet& ps) - : tokenStatus_(consumes>(ps.getParameter("tagStatus"))), - tokenPixelTrack_( + : tokenPixelTrack_( consumes>(ps.getParameter("tagPixelLocalTracks"))), - tokenDigi_(consumes>(ps.getParameter("tagDigi"))), tokenDiamondHit_( consumes>(ps.getParameter("tagDiamondRecHits"))), tokenDiamondTrack_( consumes>(ps.getParameter("tagDiamondLocalTracks"))), - tokenFEDInfo_(consumes>(ps.getParameter("tagFEDInfo"))), ctppsGeometryRunToken_(esConsumes()), ctppsGeometryEventToken_(esConsumes()), + // ctppsLhcInfoToken_(esConsumes()), excludeMultipleHits_(ps.getParameter("excludeMultipleHits")), perLSsaving_(ps.getUntrackedParameter("perLSsaving", false)), + extract_digi_info_(ps.getParameter("extractDigiInfo")), centralOOT_(-999), verbosity_(ps.getUntrackedParameter("verbosity", 0)), + plotOnline_(ps.getUntrackedParameter("plotOnline", true)), + plotOffline_(ps.getUntrackedParameter("plotOffline", false)), + windowsNum_(ps.getUntrackedParameter("windowsNum", 3)), + trackCorrelationThreshold_(ps.getUntrackedParameter("trackCorrelationThreshold", 3)), EC_difference_56_(-500), EC_difference_45_(-500) { + if (extract_digi_info_) { + tokenStatus_ = consumes>(ps.getParameter("tagStatus")); + tokenFEDInfo_ = consumes>(ps.getParameter("tagFEDInfo")); + tokenDigi_ = consumes>(ps.getParameter("tagDigi")); + } for (const auto& pset : ps.getParameter>("offsetsOOT")) { runParameters_.emplace_back( std::make_pair(pset.getParameter("validityRange"), pset.getParameter("centralOOT"))); @@ -500,10 +609,6 @@ CTPPSDiamondDQMSource::CTPPSDiamondDQMSource(const edm::ParameterSet& ps) //---------------------------------------------------------------------------------------------------- -CTPPSDiamondDQMSource::~CTPPSDiamondDQMSource() {} - -//---------------------------------------------------------------------------------------------------- - void CTPPSDiamondDQMSource::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { centralOOT_ = -999; for (const auto& oot : runParameters_) { @@ -515,38 +620,52 @@ void CTPPSDiamondDQMSource::dqmBeginRun(const edm::Run& iRun, const edm::EventSe // Get detector shifts from the geometry const CTPPSGeometry& geom = iSetup.getData(ctppsGeometryRunToken_); - const CTPPSDiamondDetId detid(0, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, 0, 0); - const DetGeomDesc* det = geom.sensor(detid); - horizontalShiftOfDiamond_ = det->translation().x() - det->getDiamondDimensions().xHalfWidth; - - // 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.sensor(pixid); - horizontalShiftBwDiamondPixels_ = - det->translation().x() - det->getDiamondDimensions().xHalfWidth - horizontalShiftOfDiamond_ - 1; - } + for (auto it = geom.beginRP(); it != geom.endRP(); ++it) + if (CTPPSDiamondDetId::check(it->first)) { + const CTPPSDiamondDetId diam_id(it->first); + const auto diam = geom.sensor(it->first); + diamShifts_[diam_id].global = diam->translation().x() - diam->getDiamondDimensions().xHalfWidth; + if (iRun.run() > FIRST_RUN_W_PIXELS) { // pixel installed + const CTPPSPixelDetId pixid(diam_id.arm(), CTPPS_PIXEL_STATION_ID, CTPPS_FAR_RP_ID); + auto pix = geom.sensor(pixid); + // Rough alignement of pixel detector for diamond tomography + diamShifts_[diam_id].withPixels = + pix->translation().x() - pix->getDiamondDimensions().xHalfWidth - diamShifts_[diam_id].global - 1.; + } + } } //---------------------------------------------------------------------------------------------------- -void CTPPSDiamondDQMSource::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) { +void CTPPSDiamondDQMSource::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup& iSetup) { ibooker.cd(); ibooker.setCurrentFolder("CTPPS"); 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); - } - } + // book plots from the geometry + const CTPPSGeometry& geom = iSetup.getData(ctppsGeometryRunToken_); + for (auto it = geom.beginSensor(); it != geom.endSensor(); ++it) { + if (!CTPPSDiamondDetId::check(it->first)) + continue; + // per-channel plots + const CTPPSDiamondDetId chId(it->first); + if (plotOnline_ && channelPlots_.count(chId) == 0) + channelPlots_[chId] = ChannelPlots(ibooker, chId, windowsNum_); + + // per-plane plots + const CTPPSDiamondDetId plId(chId.planeId()); + if (planePlots_.count(plId) == 0) + planePlots_[plId] = PlanePlots(ibooker, plId, windowsNum_); + // per-pot plots + const CTPPSDiamondDetId rpId(chId.rpId()); + if (potPlots_.count(rpId) == 0) + potPlots_[rpId] = PotPlots(ibooker, rpId, windowsNum_, plotOnline_, plotOffline_); + + // per-sector plots + const CTPPSDiamondDetId secId(chId.armId()); + if (plotOffline_ && sectorPlots_.count(secId) == 0) + sectorPlots_[secId] = SectorPlots(ibooker, secId, plotOnline_); } } @@ -556,7 +675,7 @@ std::shared_ptr CTPPSDiamondDQMSource::globalBeginLuminosityBlock(co const edm::EventSetup&) const { auto d = std::make_shared(); d->hitDistribution2dMap.reserve(potPlots_.size()); - if (!perLSsaving_) { + if (!perLSsaving_ && plotOnline_) { for (auto& plot : potPlots_) d->hitDistribution2dMap[plot.first] = std::unique_ptr(static_cast(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone())); @@ -568,18 +687,19 @@ std::shared_ptr CTPPSDiamondDQMSource::globalBeginLuminosityBlock(co void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSetup& iSetup) { // get event data + edm::Handle> diamondVFATStatus; - event.getByToken(tokenStatus_, diamondVFATStatus); + edm::Handle> diamondDigis; + edm::Handle> fedInfo; + if (extract_digi_info_) { + event.getByToken(tokenStatus_, diamondVFATStatus); + event.getByToken(tokenDigi_, diamondDigis); + event.getByToken(tokenFEDInfo_, fedInfo); + } edm::Handle> pixelTracks; event.getByToken(tokenPixelTrack_, pixelTracks); - edm::Handle> diamondDigis; - event.getByToken(tokenDigi_, diamondDigis); - - edm::Handle> fedInfo; - event.getByToken(tokenFEDInfo_, fedInfo); - edm::Handle> diamondRecHits; event.getByToken(tokenDiamondHit_, diamondRecHits); @@ -587,32 +707,82 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet event.getByToken(tokenDiamondTrack_, diamondLocalTracks); const CTPPSGeometry* ctppsGeometry = &iSetup.getData(ctppsGeometryEventToken_); + // const LHCInfo* hLhcInfo = &iSetup.getData(ctppsLhcInfoToken_); // check validity bool valid = true; - valid &= diamondVFATStatus.isValid(); + if (extract_digi_info_) { // drop DIGI-level validity checks if not monitored + valid &= diamondVFATStatus.isValid(); + valid &= diamondDigis.isValid(); + valid &= fedInfo.isValid(); + } valid &= pixelTracks.isValid(); - valid &= diamondDigis.isValid(); - valid &= fedInfo.isValid(); valid &= diamondRecHits.isValid(); valid &= diamondLocalTracks.isValid(); if (!valid) { - if (verbosity_) { + if (verbosity_) edm::LogProblem("CTPPSDiamondDQMSource") << "ERROR in CTPPSDiamondDQMSource::analyze > some of the required inputs are not valid. Skipping this " "event.\n" + << " DIGI-level: (checked? " << std::boolalpha << extract_digi_info_ << ")\n" << " diamondVFATStatus.isValid = " << diamondVFATStatus.isValid() << "\n" - << " pixelTracks.isValid = " << pixelTracks.isValid() << "\n" << " diamondDigis.isValid = " << diamondDigis.isValid() << "\n" << " fedInfo.isValid = " << fedInfo.isValid() << "\n" + << " RECO-level:\n" + << " pixelTracks.isValid = " << pixelTracks.isValid() << "\n" << " diamondRecHits.isValid = " << diamondRecHits.isValid() << "\n" << " diamondLocalTracks.isValid = " << diamondLocalTracks.isValid(); - } - return; } + //------------------------------ + // Sector Plots + //------------------------------ + // Using CTPPSDiamondLocalTrack + if (plotOffline_) + for (const auto& tracks : *diamondLocalTracks) { + const CTPPSDiamondDetId detId_near(tracks.detId()); + + for (const auto& track : tracks) { + if (!track.isValid()) + continue; + if (potPlots_.count(detId_near.rpId()) == 0) + continue; + TH1F* trackHistoInTimeTmp = potPlots_[detId_near.rpId()].trackDistribution->getTH1F(); + int startBin_near = + trackHistoInTimeTmp->FindBin(track.x0() - diamShifts_[detId_near.rpId()].global - track.x0Sigma()); + int numOfBins_near = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; + + for (const auto& tracks_far : *diamondLocalTracks) { + CTPPSDiamondDetId detId_far(tracks_far.detId()); + if (detId_near.arm() != detId_far.arm() || detId_near.station() == detId_far.station()) + continue; + for (const auto& track_far : tracks_far) { + if (!track.isValid()) + continue; + if (sectorPlots_.count(detId_far.armId()) == 0) + continue; + TH2F* trackHistoTmp = sectorPlots_[detId_far.armId()].trackCorrelation->getTH2F(); + TAxis* trackHistoTmpXAxis = trackHistoTmp->GetXaxis(); + TAxis* trackHistoTmpYAxis = trackHistoTmp->GetYaxis(); + int startBin_far = trackHistoTmpYAxis->FindBin(track_far.x0() - diamShifts_[detId_far.rpId()].global - + track_far.x0Sigma()); + int numOfBins_far = 2 * track_far.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; + for (int i = 0; i < numOfBins_near; ++i) + for (int y = 0; y < numOfBins_far; ++y) { + trackHistoTmp->Fill(trackHistoTmpXAxis->GetBinCenter(startBin_near + i), + trackHistoTmpYAxis->GetBinCenter(startBin_far + y)); + if (tracks.size() < 3 && tracks_far.size() < trackCorrelationThreshold_) + sectorPlots_[detId_far.armId()].trackCorrelationLowMultiplicity->Fill( + trackHistoTmpXAxis->GetBinCenter(startBin_near + i), + trackHistoTmpYAxis->GetBinCenter(startBin_far + y)); + } + } + } + } + } + //------------------------------ // RP Plots //------------------------------ @@ -621,97 +791,69 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet // Correlation Plots //------------------------------ - // Using CTPPSDiamondDigi - for (const auto& digis : *diamondDigis) { - const CTPPSDiamondDetId detId(digis.detId()); - CTPPSDiamondDetId detId_pot(digis.detId()); - - for (const auto& digi : digis) { - detId_pot.setPlane(0); - detId_pot.setChannel(0); - if (detId.channel() == CHANNEL_OF_VFAT_CLOCK) - continue; - if (potPlots_.find(detId_pot) == potPlots_.end()) - continue; - //Leading without trailing investigation - if (digi.leadingEdge() != 0 || digi.trailingEdge() != 0) { - ++(potPlots_[detId_pot].HitCounter); - if (digi.leadingEdge() != 0) { - potPlots_[detId_pot].leadingEdgeCumulative_all->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge()); - } - if (digi.leadingEdge() != 0 && digi.trailingEdge() == 0) { - ++(potPlots_[detId_pot].LeadingOnlyCounter); - potPlots_[detId_pot].leadingEdgeCumulative_le->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge()); - } - if (digi.leadingEdge() == 0 && digi.trailingEdge() != 0) { - ++(potPlots_[detId_pot].TrailingOnlyCounter); - potPlots_[detId_pot].trailingEdgeCumulative_te->Fill(HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); - } - if (digi.leadingEdge() != 0 && digi.trailingEdge() != 0) { - ++(potPlots_[detId_pot].CompleteCounter); - potPlots_[detId_pot].leadingTrailingCorrelationPot->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge(), - HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); + if (extract_digi_info_) { + // Using CTPPSDiamondDigi + for (const auto& digis : *diamondDigis) { + const CTPPSDiamondDetId detId(digis.detId()), detId_pot(detId.rpId()); + for (const auto& digi : digis) { + if (detId.channel() == CHANNEL_OF_VFAT_CLOCK) + continue; + if (potPlots_.count(detId_pot) == 0) + continue; + //Leading without trailing investigation + if (digi.leadingEdge() != 0 || digi.trailingEdge() != 0) { + ++potPlots_[detId_pot].HitCounter; + if (digi.leadingEdge() != 0) { + potPlots_[detId_pot].leadingEdgeCumulative_all->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge()); + } + if (digi.leadingEdge() != 0 && digi.trailingEdge() == 0) { + ++potPlots_[detId_pot].LeadingOnlyCounter; + potPlots_[detId_pot].leadingEdgeCumulative_le->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge()); + } + if (digi.leadingEdge() == 0 && digi.trailingEdge() != 0) { + ++potPlots_[detId_pot].TrailingOnlyCounter; + potPlots_[detId_pot].trailingEdgeCumulative_te->Fill(HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); + } + if (digi.leadingEdge() != 0 && digi.trailingEdge() != 0) { + ++potPlots_[detId_pot].CompleteCounter; + // potPlots_[detId_pot].leadingTrailingCorrelationPot->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge(), + // HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); + } } - } - // HPTDC Errors - const HPTDCErrorFlags hptdcErrors = digi.hptdcErrorFlags(); - if (detId.channel() == 6 || detId.channel() == 7) // ch6 for HPTDC 0 and ch7 for HPTDC 1 - { - int verticalIndex = 2 * detId.plane() + (detId.channel() - 6); - for (unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex) - if (hptdcErrors.errorId(hptdcErrorIndex - 1)) - potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(hptdcErrorIndex, verticalIndex); + // HPTDC Errors + const HPTDCErrorFlags hptdcErrors = digi.hptdcErrorFlags(); + if (detId.channel() == HPTDC_0_CHANNEL || + detId.channel() == HPTDC_1_CHANNEL) { // ch6 for HPTDC 0 and ch7 for HPTDC 1 + int verticalIndex = 2 * detId.plane() + (detId.channel() - HPTDC_0_CHANNEL); + for (unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex) + if (hptdcErrors.errorId(hptdcErrorIndex - 1)) + potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(hptdcErrorIndex, verticalIndex); + } + if (digi.multipleHit()) + ++potPlots_[detId_pot].MHCounter; } - if (digi.multipleHit()) - ++(potPlots_[detId_pot].MHCounter); } } // EC Errors - for (const auto& vfat_status : *diamondVFATStatus) { - const CTPPSDiamondDetId detId(vfat_status.detId()); - CTPPSDiamondDetId detId_pot(vfat_status.detId()); - detId_pot.setPlane(0); - detId_pot.setChannel(0); - for (const auto& status : vfat_status) { - if (!status.isOK()) - continue; - if (potPlots_.find(detId_pot) == potPlots_.end()) - continue; - if (channelPlots_.find(detId) == channelPlots_.end()) - continue; + if (extract_digi_info_) { + for (const auto& vfat_status : *diamondVFATStatus) { + const CTPPSDiamondDetId detId(vfat_status.detId()); + for (const auto& status : vfat_status) { + if (!status.isOK()) + continue; + if (potPlots_.count(detId.rpId()) == 0) + continue; + if (channelPlots_.count(detId) == 0) + continue; - // Check Event Number - for (const auto& optorx : *fedInfo) { - if (detId.arm() == 1 && optorx.fedId() == CTPPS_FED_ID_56) { - potPlots_[detId_pot].ECCheck->Fill((int)((optorx.lv1() & 0xFF) - ((unsigned int)status.ec() & 0xFF)) & 0xFF); - if ((static_cast((optorx.lv1() & 0xFF) - status.ec()) != EC_difference_56_) && - (static_cast((optorx.lv1() & 0xFF) - status.ec()) < 128)) - EC_difference_56_ = static_cast(optorx.lv1() & 0xFF) - (static_cast(status.ec()) & 0xFF); - if (EC_difference_56_ != 1 && EC_difference_56_ != -500 && std::abs(EC_difference_56_) < 127) { - if (detId.channel() == 6 || detId.channel() == 7) - potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(16, 2 * detId.plane() + (detId.channel() - 6)); - if (verbosity_) - edm::LogProblem("CTPPSDiamondDQMSource") - << "FED " << CTPPS_FED_ID_56 << ": ECError at EV: 0x" << std::hex << optorx.lv1() << "\t\tVFAT EC: 0x" - << static_cast(status.ec()) << "\twith ID: " << std::dec << detId - << "\tdiff: " << EC_difference_56_; - } - } else if (detId.arm() == 0 && optorx.fedId() == CTPPS_FED_ID_45) { - potPlots_[detId_pot].ECCheck->Fill((int)((optorx.lv1() & 0xFF) - status.ec()) & 0xFF); - if ((static_cast((optorx.lv1() & 0xFF) - status.ec()) != EC_difference_45_) && - (static_cast((optorx.lv1() & 0xFF) - status.ec()) < 128)) - EC_difference_45_ = static_cast(optorx.lv1() & 0xFF) - (static_cast(status.ec()) & 0xFF); - if (EC_difference_45_ != 1 && EC_difference_45_ != -500 && std::abs(EC_difference_45_) < 127) { - if (detId.channel() == 6 || detId.channel() == 7) - potPlots_[detId_pot].HPTDCErrorFlags_2D->Fill(16, 2 * detId.plane() + (detId.channel() - 6)); - if (verbosity_) - edm::LogProblem("CTPPSDiamondDQMSource") - << "FED " << CTPPS_FED_ID_45 << ": ECError at EV: 0x" << std::hex << optorx.lv1() << "\t\tVFAT EC: 0x" - << static_cast(status.ec()) << "\twith ID: " << std::dec << detId - << "\tdiff: " << EC_difference_45_; - } + // Check Event Number + for (const auto& optorx : *fedInfo) { + if (detId.arm() == 1 && optorx.fedId() == CTPPS_FED_ID_56) + checkEventNumber(detId, optorx, status, potPlots_[detId.rpId()], EC_difference_56_); + else if (detId.arm() == 0 && optorx.fedId() == CTPPS_FED_ID_45) + checkEventNumber(detId, optorx, status, potPlots_[detId.rpId()], EC_difference_45_); } } } @@ -723,10 +865,8 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet auto lumiCache = luminosityBlockCache(event.getLuminosityBlock().index()); for (const auto& rechits : *diamondRecHits) { - CTPPSDiamondDetId detId_pot(rechits.detId()); - detId_pot.setPlane(0); - detId_pot.setChannel(0); - const CTPPSDiamondDetId detId(rechits.detId()); + const CTPPSDiamondDetId detId(rechits.detId()), detId_pot(detId.rpId()); + const auto& x_shift = diamShifts_.at(detId_pot); for (const auto& rechit : rechits) { planes_inclusive[detId_pot].insert(detId.plane()); @@ -735,9 +875,11 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet if (rechit.toT() != 0 && centralOOT_ != -999 && rechit.ootIndex() == centralOOT_) planes[detId_pot].insert(detId.plane()); - if (potPlots_.find(detId_pot) == potPlots_.end()) + if (potPlots_.count(detId_pot) == 0) continue; + potPlots_[detId_pot].recHitTime->Fill(rechit.time()); + float UFSDShift = 0.0; if (rechit.yWidth() < 3) UFSDShift = 0.5; // Display trick for UFSD that have 2 pixels with same X @@ -745,20 +887,18 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet if (rechit.toT() != 0 && centralOOT_ != -999 && rechit.ootIndex() == centralOOT_) { TH2F* hitHistoTmp = potPlots_[detId_pot].hitDistribution2d->getTH2F(); TAxis* hitHistoTmpYAxis = hitHistoTmp->GetYaxis(); - int startBin = hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth()); + int startBin = hitHistoTmpYAxis->FindBin(rechit.x() - x_shift.global - 0.5 * rechit.xWidth()); int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) { + for (int i = 0; i < numOfBins; ++i) hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i)); - } - if (!perLSsaving_) { + if (!perLSsaving_ && plotOnline_) { hitHistoTmp = lumiCache->hitDistribution2dMap[detId_pot].get(); hitHistoTmpYAxis = hitHistoTmp->GetYaxis(); - startBin = hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth()); + startBin = hitHistoTmpYAxis->FindBin(rechit.x() - x_shift.global - 0.5 * rechit.xWidth()); numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) { + for (int i = 0; i < numOfBins; ++i) hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i)); - } } } @@ -769,42 +909,41 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT->getTH2F(); TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis(); - int startBin = hitHistoOOTTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth()); + int startBin = hitHistoOOTTmpYAxis->FindBin(rechit.x() - x_shift.global - 0.5 * rechit.xWidth()); + int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; + for (int i = 0; i < numOfBins; ++i) + hitHistoOOTTmp->Fill(detId.plane() + 0.25 * rechit.ootIndex(), + hitHistoOOTTmpYAxis->GetBinCenter(startBin + i)); + } else if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && plotOnline_) { + // Only leading + TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT_le->getTH2F(); + TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis(); + int startBin = hitHistoOOTTmpYAxis->FindBin(rechit.x() - x_shift.global - 0.5 * rechit.xWidth()); int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; for (int i = 0; i < numOfBins; ++i) { hitHistoOOTTmp->Fill(detId.plane() + 0.25 * rechit.ootIndex(), hitHistoOOTTmpYAxis->GetBinCenter(startBin + i)); } - } else { - if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING) { - // Only leading - TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT_le->getTH2F(); - TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis(); - int startBin = hitHistoOOTTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth()); - int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) { - hitHistoOOTTmp->Fill(detId.plane() + 0.25 * rechit.ootIndex(), - hitHistoOOTTmpYAxis->GetBinCenter(startBin + i)); - } - } } if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && potPlots_[detId_pot].activity_per_bx.count(rechit.ootIndex()) > 0) potPlots_[detId_pot].activity_per_bx.at(rechit.ootIndex())->Fill(event.bunchCrossing()); + + // if(plotOffline_) + // potPlots_[detId_pot].TOTVsLS->Fill(event.luminosityBlock(),rechit.toT()); } } for (const auto& plt : potPlots_) { plt.second.activePlanes->Fill(planes[plt.first].size()); - plt.second.activePlanesInclusive->Fill(planes_inclusive[plt.first].size()); + if (plotOnline_) + plt.second.activePlanesInclusive->Fill(planes_inclusive[plt.first].size()); } // Using CTPPSDiamondLocalTrack for (const auto& tracks : *diamondLocalTracks) { - CTPPSDiamondDetId detId_pot(tracks.detId()); - detId_pot.setPlane(0); - detId_pot.setChannel(0); - const CTPPSDiamondDetId detId(tracks.detId()); + const CTPPSDiamondDetId detId(tracks.detId()), detId_pot(detId.rpId()); + const auto& x_shift = diamShifts_.at(detId_pot); for (const auto& track : tracks) { if (!track.isValid()) @@ -813,33 +952,34 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet continue; if (excludeMultipleHits_ && track.multipleHits() > 0) continue; - if (potPlots_.find(detId_pot) == potPlots_.end()) + if (potPlots_.count(detId_pot) == 0) continue; TH2F* trackHistoOOTTmp = potPlots_[detId_pot].trackDistributionOOT->getTH2F(); TAxis* trackHistoOOTTmpYAxis = trackHistoOOTTmp->GetYaxis(); - int startBin = trackHistoOOTTmpYAxis->FindBin(track.x0() - horizontalShiftOfDiamond_ - track.x0Sigma()); + int startBin = trackHistoOOTTmpYAxis->FindBin(track.x0() - x_shift.global - track.x0Sigma()); int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) { + for (int i = 0; i < numOfBins; ++i) trackHistoOOTTmp->Fill(track.ootIndex(), trackHistoOOTTmpYAxis->GetBinCenter(startBin + i)); - } if (centralOOT_ != -999 && track.ootIndex() == centralOOT_) { TH1F* trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution->getTH1F(); - int startBin = trackHistoInTimeTmp->FindBin(track.x0() - horizontalShiftOfDiamond_ - track.x0Sigma()); + int startBin = trackHistoInTimeTmp->FindBin(track.x0() - x_shift.global - track.x0Sigma()); int numOfBins = 2 * track.x0Sigma() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) { + for (int i = 0; i < numOfBins; ++i) trackHistoInTimeTmp->Fill(trackHistoInTimeTmp->GetBinCenter(startBin + i)); - } + } + if (plotOffline_) { + // potPlots_[detId_pot].trackTimeVsLS->Fill(event.luminosityBlock(),track.time()); + potPlots_[detId_pot].trackTimeVsBX->Fill(event.bunchCrossing(), track.time()); + //potPlots_[detId_pot].trackTimeVsXAngle->Fill(hLhcInfo->crossingAngle(), track.time()); } } } // Channel efficiency using CTPPSDiamondLocalTrack for (const auto& tracks : *diamondLocalTracks) { - CTPPSDiamondDetId detId_pot(tracks.detId()); - detId_pot.setPlane(0); - detId_pot.setChannel(0); + const CTPPSDiamondDetId detId(tracks.detId()), detId_pot(detId.rpId()); for (const auto& track : tracks) { // Find hits and planes in the track int numOfHits = 0; @@ -859,29 +999,24 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet } if (numOfHits > 0 && numOfHits <= 10 && planesInTrackSet.size() > 2) { - for (int plane = 0; plane < 4; ++plane) { - for (int channel = 0; channel < 12; ++channel) { - int map_index = plane * 100 + channel; - if (potPlots_[detId_pot].effDoublecountingChMap.find(map_index) == - potPlots_[detId_pot].effDoublecountingChMap.end()) { - 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); - if (channelAlignedWithTrack(ctppsGeometry, detId, track, 0.2)) { - // Channel should fire - ++(potPlots_[detId_pot].effDoublecountingChMap[map_index]); - for (const auto& rechits : *diamondRecHits) { - CTPPSDiamondDetId detId_hit(rechits.detId()); - if (detId_hit == detId) { - for (const auto& rechit : rechits) { - if (track.containsHit(rechit, 1)) { - // Channel fired - ++(potPlots_[detId_pot].effTriplecountingChMap[map_index]); - } - } - } - } + for (const auto& plt_vs_ch : channelPlots_) { // loop over all channels registered in geometry + const CTPPSDiamondDetId detId(plt_vs_ch.first); + if (detId.rpId() != detId_pot) + continue; + const unsigned short map_index = detId.plane() * 100 + detId.channel(); + if (potPlots_[detId_pot].effDoublecountingChMap.count(map_index) == 0) { + potPlots_[detId_pot].effTriplecountingChMap[map_index] = 0; + potPlots_[detId_pot].effDoublecountingChMap[map_index] = 0; + } + if (channelAlignedWithTrack(ctppsGeometry, detId, track, 0.2)) { + // Channel should fire + ++potPlots_[detId_pot].effDoublecountingChMap[map_index]; + for (const auto& rechits : *diamondRecHits) { + const CTPPSDiamondDetId detId_hit(rechits.detId()); + if (detId_hit == detId) + for (const auto& rechit : rechits) + if (track.containsHit(rechit, 1)) // Channel fired + ++potPlots_[detId_pot].effTriplecountingChMap[map_index]; } } } @@ -891,10 +1026,8 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet // Tomography of diamonds using pixel for (const auto& rechits : *diamondRecHits) { - CTPPSDiamondDetId detId_pot(rechits.detId()); - detId_pot.setPlane(0); - detId_pot.setChannel(0); - const CTPPSDiamondDetId detId(rechits.detId()); + const CTPPSDiamondDetId detId(rechits.detId()), detId_pot(detId.rpId()); + const auto pix_shift = diamShifts_.at(detId_pot).withPixels; for (const auto& rechit : rechits) { if (excludeMultipleHits_ && rechit.multipleHits() > 0) continue; @@ -902,7 +1035,7 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet continue; if (!pixelTracks.isValid()) continue; - if (potPlots_.find(detId_pot) == potPlots_.end()) + if (potPlots_.count(detId_pot) == 0) continue; for (const auto& ds : *pixelTracks) { @@ -914,11 +1047,10 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet for (const auto& lt : ds) { if (lt.isValid() && pixId.arm() == detId_pot.arm()) { if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.ootIndex() >= 0 && - potPlots_[detId_pot].pixelTomographyAll.count(rechit.ootIndex()) > 0 && - lt.x0() - horizontalShiftBwDiamondPixels_ < 24) + potPlots_[detId_pot].pixelTomographyAll.count(rechit.ootIndex()) > 0 && lt.x0() - pix_shift < 24) potPlots_[detId_pot] .pixelTomographyAll.at(rechit.ootIndex()) - ->Fill(lt.x0() - horizontalShiftBwDiamondPixels_ + 25 * detId.plane(), lt.y0()); + ->Fill(lt.x0() - pix_shift + 25 * detId.plane(), lt.y0()); } } } @@ -930,11 +1062,8 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet //------------------------------ // Commented out to save space in the DQM files, but code should be kept // for ( const auto& digis : *diamondDigis ) { - // const CTPPSDiamondDetId detId( digis.detId() ); - // CTPPSDiamondDetId detId_pot( digis.detId() ); + // const CTPPSDiamondDetId detId(digis.detId()), detId_pot(detId.rpId()); // if ( detId.channel() == CHANNEL_OF_VFAT_CLOCK ) { - // detId_pot.setPlane( 0 ); - // detId_pot.setChannel( 0 ); // for ( const auto& digi : digis ) { // if ( digi.leadingEdge() != 0 ) { // if ( detId.plane() == 1 ) { @@ -956,47 +1085,41 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet // Using CTPPSDiamondDigi std::unordered_map channelsPerPlane; - for (const auto& digis : *diamondDigis) { - const CTPPSDiamondDetId detId(digis.detId()); - CTPPSDiamondDetId detId_plane(digis.detId()); - for (const auto& digi : digis) { - detId_plane.setChannel(0); - if (detId.channel() == CHANNEL_OF_VFAT_CLOCK) - continue; - if (planePlots_.find(detId_plane) == planePlots_.end()) - continue; + if (extract_digi_info_) { + for (const auto& digis : *diamondDigis) { + const CTPPSDiamondDetId detId(digis.detId()), detId_plane(detId.planeId()); + for (const auto& digi : digis) { + if (detId.channel() == CHANNEL_OF_VFAT_CLOCK) + continue; + if (planePlots_.count(detId_plane) == 0) + continue; - if (digi.leadingEdge() != 0) { - planePlots_[detId_plane].digiProfileCumulativePerPlane->Fill(detId.channel()); - if (channelsPerPlane.find(detId_plane) != channelsPerPlane.end()) + if (digi.leadingEdge() != 0) { + planePlots_[detId_plane].digiProfileCumulativePerPlane->Fill(detId.channel()); channelsPerPlane[detId_plane]++; - else - channelsPerPlane[detId_plane] = 0; + } } } } - for (const auto& plt : channelsPerPlane) { + for (const auto& plt : channelsPerPlane) planePlots_[plt.first].hit_multiplicity->Fill(plt.second); - } // Using CTPPSDiamondRecHit for (const auto& rechits : *diamondRecHits) { - CTPPSDiamondDetId detId_plane(rechits.detId()); - detId_plane.setChannel(0); + const CTPPSDiamondDetId detId(rechits.detId()), detId_plane(detId.planeId()), detId_pot(detId.rpId()); for (const auto& rechit : rechits) { if (excludeMultipleHits_ && rechit.multipleHits() > 0) continue; if (rechit.toT() == 0) continue; - if (planePlots_.find(detId_plane) != planePlots_.end()) { + if (planePlots_.count(detId_plane) != 0) { if (centralOOT_ != -999 && rechit.ootIndex() == centralOOT_) { TH1F* hitHistoTmp = planePlots_[detId_plane].hitProfile->getTH1F(); - int startBin = hitHistoTmp->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth()); + int startBin = hitHistoTmp->FindBin(rechit.x() - diamShifts_.at(detId_pot).global - 0.5 * rechit.xWidth()); int numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM; - for (int i = 0; i < numOfBins; ++i) { + for (int i = 0; i < numOfBins; ++i) hitHistoTmp->Fill(hitHistoTmp->GetBinCenter(startBin + i)); - } } } } @@ -1011,24 +1134,27 @@ 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.x0() - horizontalShiftBwDiamondPixels_, lt.y0()); + for (const auto& sh_vs_id : diamShifts_) { + const CTPPSDiamondDetId& detId_pot = sh_vs_id.first; + const auto& shift = sh_vs_id.second; + if (detId_pot.arm() == pixId.arm()) + // For efficieny + potPlots_[detId_pot].pixelTracksMap.Fill(lt.x0() - shift.withPixels, lt.y0()); + } std::set planesWitHits_set; for (const auto& rechits : *diamondRecHits) { - CTPPSDiamondDetId detId_plane(rechits.detId()); - detId_plane.setChannel(0); + const CTPPSDiamondDetId detId(rechits.detId()), detId_plane(detId.planeId()), detId_pot(detId.rpId()); + const auto pix_shift = diamShifts_.at(detId_pot).withPixels; for (const auto& rechit : rechits) { if (excludeMultipleHits_ && rechit.multipleHits() > 0) continue; if (rechit.ootIndex() == CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING || rechit.toT() == 0) continue; - if (planePlots_.find(detId_plane) == planePlots_.end()) + if (planePlots_.count(detId_plane) == 0) continue; - if (pixId.arm() == detId_plane.arm() && lt.x0() - horizontalShiftBwDiamondPixels_ < 24) { - planePlots_[detId_plane].pixelTomography_far->Fill( - lt.x0() - horizontalShiftBwDiamondPixels_ + 25 * rechit.ootIndex(), lt.y0()); + if (pixId.arm() == detId_plane.arm() && lt.x0() - pix_shift < 24) { + planePlots_[detId_plane].pixelTomography_far->Fill(lt.x0() - pix_shift + 25 * rechit.ootIndex(), lt.y0()); if (centralOOT_ != -999 && rechit.ootIndex() == centralOOT_) planesWitHits_set.insert(detId_plane); } @@ -1036,7 +1162,8 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet } for (auto& planeId : planesWitHits_set) - planePlots_[planeId].pixelTracksMapWithDiamonds.Fill(lt.x0() - horizontalShiftBwDiamondPixels_, lt.y0()); + planePlots_[planeId].pixelTracksMapWithDiamonds.Fill(lt.x0() - diamShifts_.at(planeId.rpId()).withPixels, + lt.y0()); } } } @@ -1046,35 +1173,35 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet //------------------------------ // digi profile cumulative - for (const auto& digis : *diamondDigis) { - const CTPPSDiamondDetId detId(digis.detId()); - for (const auto& digi : digis) { - if (detId.channel() == CHANNEL_OF_VFAT_CLOCK) - continue; - if (channelPlots_.find(detId) != channelPlots_.end()) { - // HPTDC Errors - const HPTDCErrorFlags hptdcErrors = digi.hptdcErrorFlags(); - for (unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex) - if (hptdcErrors.errorId(hptdcErrorIndex - 1)) - channelPlots_[detId].HPTDCErrorFlags->Fill(hptdcErrorIndex); - if (digi.multipleHit()) - ++(channelPlots_[detId].MHCounter); - - // Check dropped trailing edges - if (digi.leadingEdge() != 0 || digi.trailingEdge() != 0) { - ++(channelPlots_[detId].HitCounter); - if (digi.leadingEdge() != 0 && digi.trailingEdge() == 0) { - ++(channelPlots_[detId].LeadingOnlyCounter); - channelPlots_[detId].leadingEdgeCumulative_le->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge()); - } - if (digi.leadingEdge() == 0 && digi.trailingEdge() != 0) { - ++(channelPlots_[detId].TrailingOnlyCounter); - channelPlots_[detId].trailingEdgeCumulative_te->Fill(HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); - } - if (digi.leadingEdge() != 0 && digi.trailingEdge() != 0) { - ++(channelPlots_[detId].CompleteCounter); - channelPlots_[detId].LeadingTrailingCorrelationPerChannel->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge(), - HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); + if (extract_digi_info_) { + for (const auto& digis : *diamondDigis) { + const CTPPSDiamondDetId detId(digis.detId()); + for (const auto& digi : digis) { + if (detId.channel() == CHANNEL_OF_VFAT_CLOCK) + continue; + if (channelPlots_.count(detId) != 0) { + // HPTDC Errors + const HPTDCErrorFlags hptdcErrors = digi.hptdcErrorFlags(); + for (unsigned short hptdcErrorIndex = 1; hptdcErrorIndex < 16; ++hptdcErrorIndex) + if (hptdcErrors.errorId(hptdcErrorIndex - 1)) + channelPlots_[detId].HPTDCErrorFlags->Fill(hptdcErrorIndex); + if (digi.multipleHit()) + ++channelPlots_[detId].MHCounter; + + // Check dropped trailing edges + if (digi.leadingEdge() != 0 || digi.trailingEdge() != 0) { + ++channelPlots_[detId].HitCounter; + if (digi.trailingEdge() == 0) { + ++channelPlots_[detId].LeadingOnlyCounter; + channelPlots_[detId].leadingEdgeCumulative_le->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge()); + } else if (digi.leadingEdge() == 0) { + ++channelPlots_[detId].TrailingOnlyCounter; + channelPlots_[detId].trailingEdgeCumulative_te->Fill(HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); + } else { + ++channelPlots_[detId].CompleteCounter; + // channelPlots_[detId].LeadingTrailingCorrelationPerChannel->Fill(HPTDC_BIN_WIDTH_NS * digi.leadingEdge(), + // HPTDC_BIN_WIDTH_NS * digi.trailingEdge()); + } } } } @@ -1088,23 +1215,25 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet for (const auto& rechit : rechits) { if (excludeMultipleHits_ && rechit.multipleHits() > 0) continue; - if (channelPlots_.find(detId) != channelPlots_.end()) { + if (channelPlots_.count(detId) != 0) { + channelPlots_[detId].recHitTime->Fill(rechit.time()); if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && rechit.toT() != 0) { channelPlots_[detId].leadingEdgeCumulative_both->Fill(rechit.time() + 25 * rechit.ootIndex()); channelPlots_[detId].TimeOverThresholdCumulativePerChannel->Fill(rechit.toT()); } - ++(lumiCache->hitsCounterMap[detId]); - } + ++lumiCache->hitsCounterMap[detId]; - if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && - channelPlots_[detId].activity_per_bx.count(rechit.ootIndex()) > 0) - channelPlots_[detId].activity_per_bx.at(rechit.ootIndex())->Fill(event.bunchCrossing()); + if (rechit.ootIndex() != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING && + channelPlots_[detId].activity_per_bx.count(rechit.ootIndex()) > 0) + channelPlots_[detId].activity_per_bx.at(rechit.ootIndex())->Fill(event.bunchCrossing()); + } } } // Tomography of diamonds using pixel for (const auto& rechits : *diamondRecHits) { - const CTPPSDiamondDetId detId(rechits.detId()); + const CTPPSDiamondDetId detId(rechits.detId()), detId_pot(detId.rpId()); + const auto shift_pix = diamShifts_.at(detId_pot).withPixels; for (const auto& rechit : rechits) { if (excludeMultipleHits_ && rechit.multipleHits() > 0) continue; @@ -1112,7 +1241,7 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet continue; if (!pixelTracks.isValid()) continue; - if (channelPlots_.find(detId) == channelPlots_.end()) + if (channelPlots_.count(detId) == 0) continue; for (const auto& ds : *pixelTracks) { @@ -1122,9 +1251,8 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet if (ds.size() > 1) continue; for (const auto& lt : ds) { - if (lt.isValid() && pixId.arm() == detId.arm() && lt.x0() - horizontalShiftBwDiamondPixels_ < 24) - channelPlots_[detId].pixelTomography_far->Fill( - lt.x0() - horizontalShiftBwDiamondPixels_ + 25 * rechit.ootIndex(), lt.y0()); + if (lt.isValid() && pixId.arm() == detId.arm() && lt.x0() - shift_pix < 24) + channelPlots_[detId].pixelTomography_far->Fill(lt.x0() - shift_pix + 25 * rechit.ootIndex(), lt.y0()); } } } @@ -1136,9 +1264,10 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet void CTPPSDiamondDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup&) { auto lumiCache = luminosityBlockCache(iLumi.index()); if (!perLSsaving_) { - for (auto& plot : potPlots_) { - *(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]); - } + if (plotOnline_) + for (auto& plot : potPlots_) { + *(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]); + } for (auto& plot : channelPlots_) { auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first]; @@ -1167,9 +1296,9 @@ void CTPPSDiamondDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& 3, HundredOverHitCounterPot * plot.second.CompleteCounter); plot.second.MHComprensive->Reset(); - CTPPSDiamondDetId rpId(plot.first); + const CTPPSDiamondDetId rpId(plot.first); for (auto& chPlot : channelPlots_) { - CTPPSDiamondDetId chId(chPlot.first); + const CTPPSDiamondDetId chId(chPlot.first); if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) { plot.second.MHComprensive->Fill( chId.plane(), chId.channel(), chPlot.second.HPTDCErrorFlags->getBinContent(16)); @@ -1177,29 +1306,28 @@ void CTPPSDiamondDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& } } // Efficiencies of single channels - for (auto& plot : potPlots_) { - plot.second.EfficiencyOfChannelsInPot->Reset(); - for (auto& element : plot.second.effTriplecountingChMap) { - if (plot.second.effDoublecountingChMap[element.first] > 0) { - int plane = element.first / 100; - int channel = element.first % 100; - double counted = element.second; - double total = plot.second.effDoublecountingChMap[element.first]; - double efficiency = counted / total; - // double error = std::sqrt( efficiency * ( 1 - efficiency ) / total ); - - plot.second.EfficiencyOfChannelsInPot->Fill(plane, channel, 100 * efficiency); + if (plotOnline_) + for (auto& plot : potPlots_) { + plot.second.EfficiencyOfChannelsInPot->Reset(); + for (auto& element : plot.second.effTriplecountingChMap) { + if (plot.second.effDoublecountingChMap[element.first] > 0) { + int plane = element.first / 100; + int channel = element.first % 100; + double counted = element.second; + double total = plot.second.effDoublecountingChMap[element.first]; + double efficiency = counted / total; + // double error = std::sqrt( efficiency * ( 1 - efficiency ) / total ); + + plot.second.EfficiencyOfChannelsInPot->Fill(plane, channel, 100 * efficiency); + } } } - } // Efficeincy wrt pixels //TODO for (auto& plot : planePlots_) { TH2F* hitHistoTmp = plot.second.EfficiencyWRTPixelsInPlane->getTH2F(); - CTPPSDiamondDetId detId_pot(plot.first); - detId_pot.setPlane(0); - + const CTPPSDiamondDetId detId(plot.first), detId_pot(detId.rpId()); hitHistoTmp->Divide(&(plot.second.pixelTracksMapWithDiamonds), &(potPlots_[detId_pot].pixelTracksMap)); } } //perLSsaving @@ -1207,4 +1335,40 @@ void CTPPSDiamondDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& //---------------------------------------------------------------------------------------------------- +void CTPPSDiamondDQMSource::checkEventNumber(const CTPPSDiamondDetId& detId, + const TotemFEDInfo& optorx, + const TotemVFATStatus& status, + CTPPSDiamondDQMSource::PotPlots& plots, + int& EC_difference) const { + const CTPPSDiamondDetId detId_pot(detId.rpId()); + if (plotOnline_) + plots.ECCheck->Fill((int)((optorx.lv1() & 0xFF) - ((unsigned int)status.ec() & 0xFF)) & 0xFF); + if ((static_cast((optorx.lv1() & 0xFF) - status.ec()) != EC_difference) && + (static_cast((optorx.lv1() & 0xFF) - status.ec()) < 128)) + EC_difference = static_cast(optorx.lv1() & 0xFF) - (static_cast(status.ec()) & 0xFF); + if (EC_difference != 1 && EC_difference != -500 && std::abs(EC_difference) < 127) { + if (detId.channel() == HPTDC_0_CHANNEL || detId.channel() == HPTDC_1_CHANNEL) + plots.HPTDCErrorFlags_2D->Fill(16, 2 * detId.plane() + (detId.channel() - HPTDC_0_CHANNEL)); + if (verbosity_) + edm::LogProblem("CTPPSDiamondDQMSource") + << "FED " << optorx.fedId() << ": ECError at EV: 0x" << std::hex << optorx.lv1() << "\t\tVFAT EC: 0x" + << static_cast(status.ec()) << "\twith ID: " << std::dec << detId + << "\tdiff: " << EC_difference; + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDiamondDQMSource::dqmEndRun(edm::Run const&, edm::EventSetup const&) { + if (plotOffline_) + for (const auto& rpPlots : potPlots_) { + auto plots = rpPlots.second; + // *(plots.TOTVsLSProfile->getTProfile())=*plots.TOTVsLS->getTH2F()->ProfileX(); + // *(plots.trackTimeVsLSProfile->getTProfile())=*plots.trackTimeVsLS->getTH2F()->ProfileX(); + *(plots.trackTimeVsBXProfile->getTProfile()) = *plots.trackTimeVsBX->getTH2F()->ProfileX(); + // *(plots.trackTimeVsXAngleProfile->getTProfile()) = *plots.trackTimeVsXAngle->getTH2F()->ProfileX(); + } +} + +//---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSDiamondDQMSource); diff --git a/DQM/CTPPS/python/ctppsDQM_cff.py b/DQM/CTPPS/python/ctppsDQM_cff.py index ba65ef53dca15..f8e1a0980914c 100644 --- a/DQM/CTPPS/python/ctppsDQM_cff.py +++ b/DQM/CTPPS/python/ctppsDQM_cff.py @@ -59,7 +59,7 @@ _ctppsDQMOfflineSource = cms.Sequence( ctppsPixelDQMOfflineSource - + ctppsDiamondDQMSource + + ctppsDiamondDQMOfflineSource + diamondSampicDQMSourceOffline + ctppsCommonDQMSourceOffline ) @@ -72,7 +72,7 @@ _ctppsDQMOfflineSource, cms.Sequence( ctppsPixelDQMOfflineSource - + ctppsDiamondDQMSource + + ctppsDiamondDQMOfflineSource + totemTimingDQMSource + ctppsCommonDQMSourceOffline ) diff --git a/DQM/CTPPS/python/ctppsDiamondDQMSource_cfi.py b/DQM/CTPPS/python/ctppsDiamondDQMSource_cfi.py index 7611902ba1a6c..905c436dfcebf 100644 --- a/DQM/CTPPS/python/ctppsDiamondDQMSource_cfi.py +++ b/DQM/CTPPS/python/ctppsDiamondDQMSource_cfi.py @@ -8,9 +8,56 @@ tagDiamondRecHits = cms.InputTag("ctppsDiamondRecHits"), tagDiamondLocalTracks = cms.InputTag("ctppsDiamondLocalTracks"), tagPixelLocalTracks = cms.InputTag("ctppsPixelLocalTracks"), + + excludeMultipleHits = cms.bool(True), + extractDigiInfo = cms.bool(True), + + plotOnline = cms.untracked.bool(True), + plotOffline= cms.untracked.bool(False), + + offsetsOOT = cms.VPSet( # cut on the OOT bin for physics hits + # 2016, after TS2 + cms.PSet( + validityRange = cms.EventRange("1:min - 292520:max"), + centralOOT = cms.int32(1), + ), + # 2017 + cms.PSet( + validityRange = cms.EventRange("292521:min - 301417:max"), + centralOOT = cms.int32(3), + ), + # 2017, after channel delays corrections + cms.PSet( + validityRange = cms.EventRange("301418:min - 301517:max"), + centralOOT = cms.int32(1), + ), + # 2017, after channel delays corrections + cms.PSet( + validityRange = cms.EventRange("301518:min - 9999999:max"), + centralOOT = cms.int32(0), + ), + ), + + perLSsaving = cms.untracked.bool(False), #driven by DQMServices/Core/python/DQMStore_cfi.py + + verbosity = cms.untracked.uint32(10), +) + +ctppsDiamondDQMOfflineSource = DQMEDAnalyzer('CTPPSDiamondDQMSource', + tagStatus = cms.InputTag("ctppsDiamondRawToDigi", "TimingDiamond"), + tagDigi = cms.InputTag("ctppsDiamondRawToDigi", "TimingDiamond"), + tagFEDInfo = cms.InputTag("ctppsDiamondRawToDigi", "TimingDiamond"), + tagDiamondRecHits = cms.InputTag("ctppsDiamondRecHits"), + tagDiamondLocalTracks = cms.InputTag("ctppsDiamondLocalTracks"), + tagPixelLocalTracks = cms.InputTag("ctppsPixelLocalTracks"), + excludeMultipleHits = cms.bool(True), + extractDigiInfo = cms.bool(True), + plotOnline = cms.untracked.bool(False), + plotOffline= cms.untracked.bool(True), + offsetsOOT = cms.VPSet( # cut on the OOT bin for physics hits # 2016, after TS2 cms.PSet( @@ -35,6 +82,6 @@ ), perLSsaving = cms.untracked.bool(False), #driven by DQMServices/Core/python/DQMStore_cfi.py - + verbosity = cms.untracked.uint32(10), ) diff --git a/DQM/CTPPS/test/diamond_dqm_test_cfg.py b/DQM/CTPPS/test/diamond_dqm_test_cfg.py index 78eeebdfa86c8..b3aa3a277c22c 100644 --- a/DQM/CTPPS/test/diamond_dqm_test_cfg.py +++ b/DQM/CTPPS/test/diamond_dqm_test_cfg.py @@ -1,21 +1,19 @@ import FWCore.ParameterSet.Config as cms -import string +from Configuration.Eras.Era_Run2_2018_cff import Run2_2018 -process = cms.Process('RECODQM') +process = cms.Process('RECODQM', Run2_2018) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) process.verbosity = cms.untracked.PSet( input = cms.untracked.int32(-1) ) # minimum of logs process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), cerr = cms.untracked.PSet( threshold = cms.untracked.string('WARNING') ) ) - - # import of standard configurations + +# import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') @@ -30,47 +28,31 @@ # raw data source process.source = cms.Source("PoolSource", - # replace '*.root',',' with the source file you want to use fileNames = cms.untracked.vstring( - *( -'/store/data/Run2017C/ZeroBias/AOD/PromptReco-v2/000/300/088/00000/469D8C89-1477-E711-A6A4-02163E01190C.root', - ) +'/store/data/Run2018D/ZeroBias/AOD/12Nov2019_UL2018_rsb-v1/280000/FE61A0D8-CEDC-2142-81AA-06301F452792.root', ), ) - from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_hlt_relval', '') +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_hlt_relval', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '120X_dataRun2_v2', '') # raw-to-digi conversion process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") # local RP reconstruction chain with standard settings process.load("RecoPPS.Configuration.recoCTPPS_cff") - -# rechits production -process.load('RecoPPS.Local.ctppsDiamondRecHits_cfi') - -# local tracks fitter -process.load('RecoPPS.Local.ctppsDiamondLocalTracks_cfi') - -# pixel -process.load('RecoPPS.Local.ctppsPixelLocalTracks_cfi') - +process.load('Geometry.VeryForwardGeometry.geometryRPFromDD_2021_cfi') # CTPPS DQM modules process.load("DQM.CTPPS.ctppsDQM_cff") -process.ctppsDiamondDQMSource.excludeMultipleHits = cms.bool(True); - +process.ctppsDiamondDQMSource.excludeMultipleHits = cms.bool(True) +process.ctppsDiamondDQMSource.plotOnline = cms.untracked.bool(True) +process.ctppsDiamondDQMSource.plotOffline = cms.untracked.bool(False) process.path = cms.Path( - #process.ctppsRawToDigi * - process.recoCTPPS * - #process.ctppsDiamondRawToDigi * - process.ctppsDiamondRecHits * - process.ctppsDiamondLocalTracks * - process.ctppsPixelLocalTracks * - process.ctppsDQM - ) - + process.recoCTPPS* + process.ctppsDQMOnlineSource* + process.ctppsDQMOnlineHarvest +) process.end_path = cms.EndPath( process.dqmEnv +