Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ add_subdirectory(CosmicReco)
add_subdirectory(CRVConditions)
add_subdirectory(CRVConfig)
add_subdirectory(CRVFilters)
add_subdirectory(DQMHelpers)
add_subdirectory(CRVReco)
add_subdirectory(CRVResponse)
add_subdirectory(CRVTools)
Expand Down
1 change: 1 addition & 0 deletions CRVReco/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ cet_build_plugin(CrvDQMcollector art::module
LIBRARIES REG
art_root_io::TFileService_service
Offline::CRVReco
Offline::DQMHelpers

Offline::CosmicRayShieldGeom
Offline::CRVConditions
Expand Down
4 changes: 4 additions & 0 deletions CRVReco/fcl/prolog_v12.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ BEGIN_PROLOG
module_type : CrvDQMcollector
useDQMcollector : true
crvDigiModuleLabel : "CrvDigi"
crvStatusModuleLabel : "CrvDigi"
#crvRecoPulsesModuleLabel : "CrvRecoPulses"
crvCoincidenceClusterFinderModuleLabel : "CrvCoincidenceClusterFinder"
crvDaqErrorModuleLabel : "CrvDigi"
crvDigiDQMDir : "CRVDigiDQM"
fillInclusiveDigiDQM : true
crvDigiDQMkppReadout : true # KPP FEB-axis sizing (ROC 1-2)
}

CrvRecoPulses:
Expand Down
106 changes: 65 additions & 41 deletions CRVReco/src/CrvDQMcollector_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include "Offline/GeometryService/inc/GeomHandle.hh"
#include "Offline/GeometryService/inc/GeometryService.hh"
#include "Offline/ProditionsService/inc/ProditionsHandle.hh"
#include "Offline/DQMHelpers/inc/CRVDigiDQM.hh"
#include "Offline/RecoDataProducts/inc/CrvDigi.hh"
#include "Offline/RecoDataProducts/inc/CrvStatus.hh"
#include "Offline/RecoDataProducts/inc/CrvRecoPulse.hh"
#include "Offline/RecoDataProducts/inc/CrvCoincidenceCluster.hh"
#include "Offline/RecoDataProducts/inc/CrvDAQerror.hh"
Expand All @@ -38,6 +40,7 @@
#include <TH1I.h>
#include <TTree.h>

#include <bitset>
#include <string>
#include <array>

Expand Down Expand Up @@ -172,9 +175,13 @@ namespace mu2e
using Comment=fhicl::Comment;
fhicl::Atom<bool> useDQMcollector{Name("useDQMcollector"), Comment("fill DQM values, histograms, ...")};
fhicl::Atom<std::string> crvDigiModuleLabel{Name("crvDigiModuleLabel"), Comment("label of CrvDigi module")};
fhicl::Atom<std::string> crvStatusModuleLabel{Name("crvStatusModuleLabel"), Comment("label of CrvStatus module; empty uses crvDigiModuleLabel"), ""};
//fhicl::Atom<std::string> crvRecoPulsesModuleLabel{Name("crvRecoPulsesModuleLabel"), Comment("label of CrvReco module")};
fhicl::Atom<std::string> crvCoincidenceClusterFinderModuleLabel{Name("crvCoincidenceClusterFinderModuleLabel"), Comment("label of CoincidenceClusterFinder module")};
fhicl::Atom<std::string> crvDaqErrorModuleLabel{Name("crvDaqErrorModuleLabel"), Comment("label of module that found the CRV-DAQ errors")};
fhicl::Atom<std::string> crvDigiDQMDir{Name("crvDigiDQMDir"), Comment("TFileService subdirectory for CRVDigiDQM histograms"), "CRVDigiDQM"};
fhicl::Atom<bool> fillInclusiveDigiDQM{Name("fillInclusiveDigiDQM"), Comment("also fill BarId/SiPM/ADC in CRVDigiDQM"), true};
fhicl::Atom<bool> crvDigiDQMkppReadout{Name("crvDigiDQMkppReadout"), Comment("KPP FEB-axis sizing (ROC 1-2); ROC4->ROC2 is the unpacker's job"), true};

fhicl::Atom<int> histPEsBins{Name("histPEsBins"), Comment("number of bins for PE histograms"), 75};
fhicl::Atom<double> histPEsStart{Name("histPEsStart"), Comment("range start for PE histograms"), 0};
Expand All @@ -196,16 +203,19 @@ namespace mu2e
typedef art::EDAnalyzer::Table<Config> Parameters;

explicit CrvDQMcollector(const Parameters& config);
void analyze(const art::Event& e);
void beginRun(const art::Run &run);
void endJob();
void beginJob() override;
void analyze(const art::Event& e) override;
void beginRun(const art::Run &run) override;
void endJob() override;

private:
bool _useDQMcollector;
std::string _crvDigiModuleLabel;
std::string _crvStatusModuleLabel;
//std::string _crvRecoPulsesModuleLabel;
std::string _crvCoincidenceClusterFinderModuleLabel;
std::string _crvDaqErrorModuleLabel;
std::string _crvDigiDQMDir;

int _histPEsBins;
double _histPEsStart;
Expand All @@ -230,35 +240,35 @@ namespace mu2e
std::pair<int,int> _lastRunSubrun;

std::vector<int> _nCoincidences; //for each sector
std::vector<int> _nDigis; //for each channel
std::vector<int> _nDigisROC; //for each channel
std::vector<TH1F*> _histPEs; //for each channel
std::vector<TH1F*> _histPEsROC; //for each channel
std::vector<bool> _notConnected; //for each channel

std::vector<TH1F*> _histDigisPerChannelAndEvent;
std::vector<TH1F*> _histDigiRatesROC;
std::vector<TH1F*> _histPEsMPV;
std::vector<TH1F*> _histPEsMPVROC;
std::vector<TH1F*> _histPedestals;
std::vector<TH1F*> _histCalibConstants;
TH2F* _hist2DDigiRatesROC;
TH2F* _hist2DPEsMPVROC;
TH1I* _histCoincidenceClusters;
TTree* _treeMetaData;

ProditionsHandle<CRVCalib> _calib;
ProditionsHandle<CRVStatus> _sipmStatus;
ProditionsHandle<mu2e::CRVOrdinal> _channelMap_h;

CRVDigiDQM _digiDQM;
};

CrvDQMcollector::CrvDQMcollector(const Parameters& conf) :
art::EDAnalyzer(conf),
_useDQMcollector(conf().useDQMcollector()),
_crvDigiModuleLabel(conf().crvDigiModuleLabel()),
_crvStatusModuleLabel(conf().crvStatusModuleLabel().empty() ?
conf().crvDigiModuleLabel() : conf().crvStatusModuleLabel()),
//_crvRecoPulsesModuleLabel(conf().crvRecoPulsesModuleLabel()),
_crvCoincidenceClusterFinderModuleLabel(conf().crvCoincidenceClusterFinderModuleLabel()),
_crvDaqErrorModuleLabel(conf().crvDaqErrorModuleLabel()),
_crvDigiDQMDir(conf().crvDigiDQMDir()),
_histPEsBins(conf().histPEsBins()),
_histPEsStart(conf().histPEsStart()),
_histPEsEnd(conf().histPEsEnd()),
Expand All @@ -276,12 +286,31 @@ namespace mu2e
_PEstart(conf().PEstart()),
_totalEvents(0),
_totalEventsWithCoincidenceClusters(0),
_totalEventsWithDAQerrors(0)
_totalEventsWithDAQerrors(0),
_hist2DPEsMPVROC(nullptr),
_histCoincidenceClusters(nullptr),
_treeMetaData(nullptr),
_digiDQM([] (bool fillInclusive, bool kppReadout) {
CRVDigiDQM::Config c;
c.fillInclusive = fillInclusive;
c.kppReadout = kppReadout;
return c;
}(conf().fillInclusiveDigiDQM(), conf().crvDigiDQMkppReadout()))
{
}

void CrvDQMcollector::beginJob()
{
art::ServiceHandle<art::TFileService> tfs;
_digiDQM.Book(tfs->mkdir(_crvDigiDQMDir));
}

void CrvDQMcollector::endJob()
{
_digiDQM.WriteGraphs();

if(_totalEvents<=0) return;

GeomHandle<CosmicRayShield> CRS;
auto &crvCounters = CRS->getAllCRSScintillatorBars();
for(size_t channel=0; channel<crvCounters.size()*CRVId::nChanPerBar; ++channel)
Expand All @@ -291,8 +320,6 @@ namespace mu2e
CRSScintillatorBarIndex barIndex(channel/CRVId::nChanPerBar);
int sectorNumber = CRS->getBar(barIndex).id().getShieldNumber();

_histDigisPerChannelAndEvent.at(sectorNumber)->Fill((float)(_nDigis.at(channel))/_totalEvents);

float MPV=0;
float FWHM=0;
float signals=0;
Expand All @@ -301,16 +328,13 @@ namespace mu2e
_histPEsMPV.at(sectorNumber)->Fill(MPV);
}

art::ServiceHandle<art::TFileService> tfs;
for(size_t ROC=1; ROC<=CRVId::nROC; ++ROC)
{
for(size_t FEB=1; FEB<=CRVId::nFEBPerROC; ++FEB)
for(size_t FEBchannel=0; FEBchannel<CRVId::nChanPerFEB; ++FEBchannel)
{
size_t ROCchannel=(FEB-1)*CRVId::nChanPerFEB+FEBchannel;

_histDigiRatesROC.at(ROC-1)->Fill(ROCchannel,(float)(_nDigisROC.at((ROC-1)*CRVId::nFEBPerROC*CRVId::nChanPerFEB+ROCchannel))/_totalEvents);

float MPV=0;
float FWHM=0;
float signals=0;
Expand All @@ -319,8 +343,6 @@ namespace mu2e
_histPEsMPVROC.at(ROC-1)->Fill(ROCchannel,MPV);

size_t portIndex=(ROC-1)*CRVId::nFEBPerROC+FEB-1;

_hist2DDigiRatesROC->Fill(FEBchannel,portIndex,(float)(_nDigisROC.at((ROC-1)*CRVId::nFEBPerROC*CRVId::nChanPerFEB+ROCchannel))/_totalEvents);
_hist2DPEsMPVROC->Fill(FEBchannel,portIndex,MPV);
}
}
Expand All @@ -339,11 +361,7 @@ namespace mu2e
_histPEsMPVROC.reserve(CRVId::nROC);
_histPedestals.reserve(crvSectors.size());
_histCalibConstants.reserve(crvSectors.size());
_histDigisPerChannelAndEvent.reserve(crvSectors.size());
_histDigiRatesROC.reserve(CRVId::nROC);
_nCoincidences.resize(crvSectors.size());
_nDigis.resize(crvCounters.size()*CRVId::nChanPerBar);
_nDigisROC.resize(CRVId::nROC*CRVId::nFEBPerROC*CRVId::nChanPerFEB);
_histPEs.reserve(crvCounters.size()*CRVId::nChanPerBar);
_histPEsROC.reserve(CRVId::nROC*CRVId::nFEBPerROC*CRVId::nChanPerFEB);
_notConnected.resize(crvCounters.size()*CRVId::nChanPerBar);
Expand All @@ -370,21 +388,14 @@ namespace mu2e
_histCalibConstants.emplace_back(tfs->make<TH1F>(Form("crvCalibConstants_CRVsector%s",crvSectors.at(i).name("").c_str()),
Form("crvCalibConstants_CRVsector%s",crvSectors.at(i).name("").c_str()),
_histCalibConstsBins,_histCalibConstsStart,_histCalibConstsEnd));
_histDigisPerChannelAndEvent.emplace_back(tfs->make<TH1F>(Form("crvDigisPerChannelAndEvent_CRVsector%s",crvSectors.at(i).name("").c_str()),
Form("crvDigisPerChannelAndEvent_CRVsector%s",crvSectors.at(i).name("").c_str()),
_histDigisBins,_histDigisStart,_histDigisEnd));
}
for(size_t ROC=1; ROC<=CRVId::nROC; ++ROC)
{
_histPEsMPVROC.emplace_back(tfs->make<TH1F>(Form("crvPEsMPV_ROC%zu",ROC),
Form("crvPEsMPV_ROC%zu",ROC),
CRVId::nFEBPerROC*CRVId::nChanPerFEB,0,CRVId::nFEBPerROC*CRVId::nChanPerFEB));
_histDigiRatesROC.emplace_back(tfs->make<TH1F>(Form("crvDigiRates_ROC%zu",ROC),
Form("crvDigiRates_ROC%zu",ROC),
CRVId::nFEBPerROC*CRVId::nChanPerFEB,0,CRVId::nFEBPerROC*CRVId::nChanPerFEB));
}
_hist2DPEsMPVROC=tfs->make<TH2F>("crvPEsMPV","crvPEsMPV:FEBchannel:FEB", CRVId::nChanPerFEB,0,CRVId::nChanPerFEB, CRVId::nROC*CRVId::nFEBPerROC,0,CRVId::nROC*CRVId::nFEBPerROC);
_hist2DDigiRatesROC=tfs->make<TH2F>("crvDigiRates","crvDigiRates:FEBchannel:FEB", CRVId::nChanPerFEB,0,CRVId::nChanPerFEB, CRVId::nROC*CRVId::nFEBPerROC,0,CRVId::nROC*CRVId::nFEBPerROC);
_histCoincidenceClusters=tfs->make<TH1I>("crvCoincidencesClusters","crvCoincidenceClusters:sectorType",10,0,10);

_treeMetaData=tfs->make<TTree>("crvMetaData","crvMetaData");
Expand All @@ -409,6 +420,8 @@ namespace mu2e
art::Handle<CrvDAQerrorCollection> crvDaqErrorCollection;

event.getByLabel(_crvDigiModuleLabel,"",crvDigiCollection);
art::Handle<CrvStatusCollection> crvStatusCollection;
event.getByLabel(_crvStatusModuleLabel,"",crvStatusCollection);
//event.getByLabel(_crvRecoPulsesModuleLabel,"",crvRecoPulseCollection);
event.getByLabel(_crvCoincidenceClusterFinderModuleLabel,"",crvCoincidenceClusterCollection);
event.getByLabel(_crvDaqErrorModuleLabel,"",crvDaqErrorCollection);
Expand All @@ -417,20 +430,15 @@ namespace mu2e
auto const& sipmStatus = _sipmStatus.get(event.id());
auto const& channelMap = _channelMap_h.get(event.id());

for(size_t i=0; i<crvDigiCollection->size(); ++i)
{
const CrvDigi &digi = crvDigiCollection->at(i);
int barIndex = digi.GetScintillatorBarIndex().asUint();
int SiPM = digi.GetSiPMNumber();
size_t channel = barIndex*CRVId::nChanPerBar + SiPM;
++_nDigis.at(channel);

int ROC=digi.GetROC();
int ROCport=digi.GetFEB();
int FEBchannel=digi.GetFEBchannel();
size_t channelOnline = (ROC-1)*CRVId::nFEBPerROC*CRVId::nChanPerFEB + (ROCport-1)*CRVId::nChanPerFEB + FEBchannel;
++_nDigisROC.at(channelOnline);
}
const CrvStatusCollection emptyStatus;
const CrvDigiCollection emptyDigis;
const CrvDigiCollection& digis =
(crvDigiCollection.isValid() && crvDigiCollection.product()!=nullptr) ?
*crvDigiCollection : emptyDigis;
const CrvStatusCollection& status =
(crvStatusCollection.isValid() && crvStatusCollection.product()!=nullptr) ?
*crvStatusCollection : emptyStatus;
_digiDQM.Fill(digis, status);

static bool first=true;
if(first)
Expand All @@ -455,6 +463,22 @@ namespace mu2e
_histPedestals.at(sectorNumber)->Fill(pedestal);
_histCalibConstants.at(sectorNumber)->Fill(calibPulseArea);
}
//helper owns crvDigisPerChannelAndEvent_*; -1 drops notConnected channels
std::vector<std::string> sectorNames;
auto &crvSectors = CRS->getCRSScintillatorShields();
sectorNames.reserve(crvSectors.size());
for(size_t i=0; i<crvSectors.size(); ++i) sectorNames.emplace_back(crvSectors.at(i).name(""));

std::vector<int> channelToSector(crvCounters.size()*CRVId::nChanPerBar, -1);
for(size_t channel=0; channel<channelToSector.size(); ++channel)
{
if(_notConnected.at(channel)) continue;
CRSScintillatorBarIndex barIndex(channel/CRVId::nChanPerBar);
channelToSector.at(channel)=CRS->getBar(barIndex).id().getShieldNumber();
}
_digiDQM.BookSectorOccupancy(sectorNames, channelToSector,
_histDigisBins, _histDigisStart, _histDigisEnd);

_firstRunSubrun=std::pair<int,int>(event.run(),event.subRun());
}
_lastRunSubrun=std::pair<int,int>(event.run(),event.subRun());
Expand Down
1 change: 1 addition & 0 deletions CRVReco/src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mainlib = helper.make_mainlib ( [ 'CLHEP',
)

helper.make_plugins( [ mainlib,
'mu2e_DQMHelpers',
'mu2e_SeedService',
'mu2e_Mu2eUtilities',
'mu2e_GeometryService',
Expand Down
32 changes: 32 additions & 0 deletions DQMHelpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cet_make_library(
SOURCE
src/CRVDigiDQM.cc
src/CRVStatusDQM.cc
LIBRARIES PUBLIC
Offline::RecoDataProducts
Offline::DataProducts
art_root_io::tfile_support
messagefacility::MF_MessageLogger
ROOT::Hist
ROOT::Gpad
)

cet_build_plugin(CRVDigiDQMAnalyzer art::module
REG_SOURCE src/CRVDigiDQMAnalyzer_module.cc
LIBRARIES REG
Offline::DQMHelpers
Offline::GeometryService
Offline::CosmicRayShieldGeom
art_root_io::TFileService_service
)

cet_build_plugin(CRVStatusDQMAnalyzer art::module
REG_SOURCE src/CRVStatusDQMAnalyzer_module.cc
LIBRARIES REG
Offline::DQMHelpers
art_root_io::TFileService_service
)

install_source(SUBDIRS src)
install_headers(USE_PROJECT_NAME SUBDIRS inc)
install_fhicl(SUBDIRS fcl SUBDIRNAME Offline/DQMHelpers/fcl)
Loading