Skip to content

Commit a0cee84

Browse files
committed
Add a module to make event displays for OM.
1 parent f7bc1e9 commit a0cee84

3 files changed

Lines changed: 199 additions & 0 deletions

File tree

sbndcode/Commissioning/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(
2020
sbndcode_CRTUtils
2121
sbnobj::Common_CRT
2222
sbnobj::SBND_CRT
23+
sbndaq_artdaq_core::sbndaq-artdaq-core_Obj_SBND
2324
nusimdata::SimulationBase
2425
art::Framework_Core
2526
art::Framework_Principal
@@ -44,6 +45,7 @@ set(
4445
cet_build_plugin(HitDumper art::module SOURCE HitDumper_module.cc LIBRARIES ${MODULE_LIBRARIES})
4546
cet_build_plugin(MuonTrackFilter art::module SOURCE MuonTrackFilter_module.cc LIBRARIES ${MODULE_LIBRARIES})
4647
cet_build_plugin(MuonTrackProducer art::module SOURCE MuonTrackProducer_module.cc LIBRARIES ${MODULE_LIBRARIES})
48+
cet_build_plugin(OnlineEvd art::module SOURCE OnlineEvd_module.cc LIBRARIES ${MODULE_LIBRARIES})
4749

4850
install_source()
4951

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
////////////////////////////////////////////////////////////////////////
2+
// Class: OnlineEvd
3+
// Plugin Type: analyzer
4+
// File: OnlineEvd_module.cc
5+
// Author: tjyang@fnal.gov
6+
//
7+
// Analyzer module to make event display for DQM
8+
////////////////////////////////////////////////////////////////////////
9+
10+
#include "art/Framework/Core/EDAnalyzer.h"
11+
#include "art/Framework/Core/ModuleMacros.h"
12+
#include "art/Framework/Principal/Event.h"
13+
#include "art/Framework/Principal/Handle.h"
14+
#include "art/Framework/Principal/Run.h"
15+
#include "art/Framework/Principal/SubRun.h"
16+
#include "canvas/Utilities/InputTag.h"
17+
#include "fhiclcpp/ParameterSet.h"
18+
#include "messagefacility/MessageLogger/MessageLogger.h"
19+
#include "art_root_io/TFileService.h"
20+
21+
#include "lardataobj/RawData/RawDigit.h"
22+
#include "lardataobj/RawData/raw.h"
23+
#include "larcore/Geometry/Geometry.h"
24+
25+
#include "TH2D.h"
26+
#include "TStyle.h"
27+
#include "TCanvas.h"
28+
#include "TLatex.h"
29+
#include "TTimeStamp.h"
30+
31+
using namespace std;
32+
33+
namespace sbnd {
34+
class OnlineEvd;
35+
}
36+
37+
38+
class sbnd::OnlineEvd : public art::EDAnalyzer {
39+
public:
40+
explicit OnlineEvd(fhicl::ParameterSet const& p);
41+
// The compiler-generated destructor is fine for non-base
42+
// classes without bare pointers or other resource use.
43+
44+
// Plugins should not be copied or assigned.
45+
OnlineEvd(OnlineEvd const&) = delete;
46+
OnlineEvd(OnlineEvd&&) = delete;
47+
OnlineEvd& operator=(OnlineEvd const&) = delete;
48+
OnlineEvd& operator=(OnlineEvd&&) = delete;
49+
50+
// Required functions.
51+
void analyze(art::Event const& e) override;
52+
53+
// Selected optional functions.
54+
void beginJob() override;
55+
56+
private:
57+
58+
// Declare member data here.
59+
art::InputTag fRawDigitModuleLabel;
60+
TH2D *hrawadc[6];
61+
int padx;
62+
int pady;
63+
int palette;
64+
};
65+
66+
67+
sbnd::OnlineEvd::OnlineEvd(fhicl::ParameterSet const& p)
68+
: EDAnalyzer{p}
69+
, fRawDigitModuleLabel{p.get<art::InputTag>("RawDigitModuleLabel")}
70+
, padx{p.get<int>("padx", 1000)}
71+
, pady{p.get<int>("pady", 618)}
72+
, palette{p.get<int>("palette", 87)}
73+
{
74+
// Call appropriate consumes<>() for any products to be retrieved by this module.
75+
}
76+
77+
void sbnd::OnlineEvd::analyze(art::Event const& e)
78+
{
79+
// Implementation of required member function here.
80+
81+
int run = e.run();
82+
int event = e.id().event();
83+
art::Timestamp ts = e.time();
84+
TTimeStamp tts(ts.timeHigh(), ts.timeLow());
85+
86+
//art::ServiceHandle<art::TFileService> tfs;
87+
88+
int nbins[3] = {1984, 1984, 1664};
89+
for (int i = 0; i<6; ++i){
90+
int tpc = i/3;
91+
int plane = i%3;
92+
hrawadc[i] = new TH2D(Form("hrawadc%d",i),Form("Run %d Event %d TPC %d Plane %d;Wire;Tick;ADC", run, event, tpc, plane), nbins[plane], 0, nbins[plane]-1, 3400, 0, 3400);
93+
hrawadc[i]->SetMaximum(60);
94+
hrawadc[i]->SetMinimum(-20);
95+
hrawadc[i]->GetXaxis()->CenterTitle(true);
96+
hrawadc[i]->GetYaxis()->CenterTitle(true);
97+
hrawadc[i]->GetZaxis()->CenterTitle(true);
98+
}
99+
art::ServiceHandle<geo::Geometry> geo;
100+
101+
// Get raw digits
102+
auto const& rawdigts = e.getProduct<std::vector<raw::RawDigit>>(fRawDigitModuleLabel);
103+
for (const auto & rd : rawdigts){
104+
std::vector<short> rawadc; //UNCOMPRESSED ADC VALUES.
105+
rawadc.resize(rd.Samples());
106+
raw::Uncompress(rd.ADCs(), rawadc, rd.GetPedestal(), rd.Compression());
107+
int ch = rd.Channel();
108+
auto const & chids = geo->ChannelToWire(ch);
109+
int tpc = chids[0].TPC;
110+
int plane = chids[0].Plane;
111+
int wire = chids[0].Wire;
112+
//cout<<tpc<<" "<<plane<<" "<<wire<<endl;
113+
for (unsigned short i = 0; i<rawadc.size(); ++i){
114+
hrawadc[plane + 3*tpc]->Fill(wire, i, rawadc[i] - rd.GetPedestal());
115+
}
116+
}
117+
118+
TLatex t;
119+
t.SetNDC();
120+
t.SetTextFont(132);
121+
t.SetTextSize(0.03);
122+
123+
TCanvas *can = new TCanvas("can","can",padx,pady);
124+
for (int i = 0; i<6; ++i){
125+
int tpc = i/3;
126+
int plane = i%3;
127+
hrawadc[i]->Draw("colz");
128+
t.DrawLatex(0.01,0.01,Form("%d/%d/%d %d:%d:%d UTC",
129+
tts.GetDate()/10000,
130+
tts.GetDate()%10000/100,
131+
tts.GetDate()%10000%100,
132+
tts.GetTime()/10000,
133+
tts.GetTime()%10000/100,
134+
tts.GetTime()%10000%100));
135+
can->Print(Form("sbnd_run%d_event%d_tpc%d_plane%d.png",run,event,tpc,plane));
136+
delete hrawadc[i];
137+
}
138+
139+
delete can;
140+
}
141+
142+
void sbnd::OnlineEvd::beginJob()
143+
{
144+
// Implementation of optional member function here.
145+
gStyle->SetOptStat(0);
146+
gStyle->SetPadBottomMargin(0.085);
147+
gStyle->SetPadTopMargin (0.08);
148+
gStyle->SetPadLeftMargin (0.08);
149+
gStyle->SetPadRightMargin (0.11);
150+
gStyle->SetLabelFont ( 62 ,"XYZ");
151+
gStyle->SetTitleFont ( 62 ,"XYZ");
152+
gStyle->SetTitleOffset( 1.15 , "x");
153+
gStyle->SetTitleOffset( 1.15 , "y");
154+
gStyle->SetTitleOffset( .7 , "z");
155+
gStyle->SetNumberContours(256);
156+
//gStyle->SetPalette(kRainBow);
157+
//gStyle->SetPalette(kLightTemperature);
158+
//gStyle->SetPalette(kGreenPink);
159+
gStyle->SetPalette(palette);
160+
}
161+
162+
DEFINE_ART_MODULE(sbnd::OnlineEvd)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "services_sbnd.fcl"
2+
#include "TPCChannelMapService.fcl"
3+
4+
process_name: SBNDEVD
5+
6+
services: {
7+
# TFileService: { fileName: "sbndevd.root" }
8+
@table::sbnd_geometry_services
9+
}
10+
11+
physics:
12+
{
13+
14+
analyzers: {}
15+
16+
ana: [ evd ]
17+
18+
end_paths: [ ana ]
19+
}
20+
21+
source: {
22+
module_type: RootInput
23+
maxEvents: 1 # Number of events to create
24+
}
25+
26+
outputs: {
27+
}
28+
29+
physics.analyzers.evd: {
30+
module_type: "OnlineEvd"
31+
RawDigitModuleLabel: "daq"
32+
# palette: 87 #kLightTemperature
33+
# palette: 55 #kRainBow
34+
# palette: 104 #kTemperatureMap
35+
}

0 commit comments

Comments
 (0)