CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2024CheckBmonScvd.cxx
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5
7
8#include "CbmDefs.h"
9#include "CbmEvent.h"
10
11#include <FairRootManager.h>
12#include <Logger.h>
13
14#include <TCanvas.h>
15#include <TFile.h>
16#include <TH1.h>
17#include <TH2.h>
18#include <TROOT.h>
19#include <TStopwatch.h>
20
21#include <algorithm>
22#include <cassert>
23#include <iomanip>
24#include <vector>
25
26
27using namespace std;
28
29
30// ----- Constructor -----------------------------------------------------
32// ---------------------------------------------------------------------------
33
34
35// ----- Destructor ------------------------------------------------------
37// ---------------------------------------------------------------------------
38
39
40// ----- Execution -------------------------------------------------------
42{
43 // --- First TS: find boundaries of plots
45 if (0 == fNumTs) {
46 TDirectory* oldDir = gDirectory;
47 TFile* oldFile = gFile;
48 gROOT->cd();
49
50 fHistMapBmonOld = new TH1I("histMapBmonOld", "Channel map, old BMON; Strip []", 16, 0., 16.);
51 fHistMapBmonScvd = new TH2I("histMapBmonScvd", "Pad map, sCVD BMON; Pad X []; Pad Y []", //
52 2, 0., 2., 2, 0., 2.);
53 fHistMapEvoBmonOld = new TH2I("histMapEvoBmonOld", "Pad map, old BMON; TS []; Strip []", //
54 100, 0., 1000., 16, 0., 16.);
55 fHistMapEvoBmonScvd = new TH2I("histMapEvoBmonScvd", "Pad map, sCVD BMON; TS []; Channel []", //
56 100, 0., 1000., 4, 0., 4.);
57
58 fHistDtBmon = new TH1I("histDtBmon", "Time difference old vs sCVD BMON; dt [ns]", 1000, -500., 500.);
59 fHistDtEvoBmon = new TH2I("histDtEvoBmon", "Evolution Time difference old vs sCVD BMON ; TS []; dt [ns]", //
60 100, 0., 1000., 1000, -500., 500.);
61 fHistDtDxBmon = new TH2I("histDtDxBmon", "X correlation vs Time diff, old vs sCVD BMON; dt [ns]; dX []", //
62 1000, -500., 500., 33, -16.5, 16.5);
63 fHistDxCorBmon = new TH2I("histDxCorrBmon", "Pad map, old vs sCVD BMON; Strip []; Column []", //
64 16, 0., 16., 2, 0., 2.);
65
66 fCanvMap = new TCanvas("canvMap", "Channel counts mapping for old and sCVD BMON");
67 fCanvMap->Divide(2, 2);
68
69 fCanvMap->cd(1);
70 gPad->SetLogy();
71 gPad->SetGridx();
72 gPad->SetGridy();
73 fHistMapBmonOld->Draw("hist");
74
75 fCanvMap->cd(2);
76 gPad->SetLogz();
77 gPad->SetGridx();
78 gPad->SetGridy();
79 fHistMapBmonScvd->Draw("ColzText");
80
81 fCanvMap->cd(3);
82 gPad->SetLogz();
83 gPad->SetGridx();
84 gPad->SetGridy();
85 fHistMapEvoBmonOld->Draw("colz");
86
87 fCanvMap->cd(4);
88 gPad->SetLogz();
89 gPad->SetGridx();
90 gPad->SetGridy();
91 fHistMapEvoBmonScvd->Draw("colz");
92
93 fCanvCorr = new TCanvas("canvCorr", "Correlations (T, X) between old and sCVD BMON");
94 fCanvCorr->Divide(2, 2);
95
96 fCanvCorr->cd(1);
97 gPad->SetLogy();
98 gPad->SetGridx();
99 gPad->SetGridy();
100 fHistDtBmon->Draw("hist");
101
102 fCanvCorr->cd(2);
103 gPad->SetLogz();
104 gPad->SetGridx();
105 gPad->SetGridy();
106 fHistDtEvoBmon->Draw("colz");
107
108 fCanvCorr->cd(3);
109 gPad->SetLogz();
110 gPad->SetGridx();
111 gPad->SetGridy();
112 fHistDtDxBmon->Draw("colz");
113
114 fCanvCorr->cd(4);
115 gPad->SetLogz();
116 gPad->SetGridx();
117 gPad->SetGridy();
118 fHistDxCorBmon->Draw("colz");
119
120 gFile = oldFile;
121 gDirectory = oldDir;
122 }
123
124 size_t numEventsInTs = 0;
125 uint8_t ucScvdX[4] = {1, 1, 0, 0};
126 uint8_t ucScvdY[4] = {1, 0, 0, 1};
127 for (auto& event : *fEvents) {
128
129 std::vector<CbmBmonDigi> vDigisOld;
130 std::vector<CbmBmonDigi> vDigisScvd;
131 vDigisOld.reserve(event.fData.fBmon.Size());
132 vDigisScvd.reserve(event.fData.fBmon.Size());
133 for (auto& digi : event.fData.fBmon.fDigis) {
134 if (1 == CbmTofAddress::GetChannelSide(digi.GetAddress())) {
135 if (CbmTofAddress::GetChannelId(digi.GetAddress()) < 4) {
136 fHistMapBmonScvd->Fill(ucScvdX[CbmTofAddress::GetChannelId(digi.GetAddress())],
137 ucScvdY[CbmTofAddress::GetChannelId(digi.GetAddress())]);
138 fHistMapEvoBmonScvd->Fill(fNumTs, CbmTofAddress::GetChannelId(digi.GetAddress()));
139 vDigisScvd.push_back(digi);
140 }
141 else {
142 LOG(fatal) << "Bad sCVD channel: " << CbmTofAddress::GetChannelId(digi.GetAddress());
143 }
144 }
145 else {
146 fHistMapBmonOld->Fill(CbmTofAddress::GetChannelId(digi.GetAddress()));
147 fHistMapEvoBmonOld->Fill(fNumTs, CbmTofAddress::GetChannelId(digi.GetAddress()));
148 vDigisOld.push_back(digi);
149 }
150 }
151
152 for (auto& digiOld : vDigisOld) {
153 for (auto& digiScvd : vDigisScvd) {
154 double_t dDt = digiScvd.GetTime() - digiOld.GetTime();
155 fHistDtBmon->Fill(dDt);
156 fHistDtEvoBmon->Fill(fNumTs, dDt);
157 fHistDtDxBmon->Fill(dDt, 16 * ucScvdX[CbmTofAddress::GetChannelId(digiScvd.GetAddress())]
158 - CbmTofAddress::GetChannelId(digiOld.GetAddress()));
159 fHistDxCorBmon->Fill(CbmTofAddress::GetChannelId(digiOld.GetAddress()),
160 ucScvdX[CbmTofAddress::GetChannelId(digiScvd.GetAddress())]);
161 }
162 }
163
164 numEventsInTs++;
165 }
166
167 // --- Run statistics
168 fNumTs++;
169 fNumEvents += fEvents->size();
170}
171// ----------------------------------------------------------------------------
172
173
174// ----- End-of-timeslice action ------------------------------------------
176{
177 LOG(info) << "=====================================";
178 LOG(info) << GetName() << ": Run summary";
179 LOG(info) << "Timeslices : " << fNumTs;
180 LOG(info) << "Events : " << fNumEvents;
181 LOG(info) << "=====================================";
182}
183// ----------------------------------------------------------------------------
184
185
186// ----- Initialisation ---------------------------------------------------
188{
189 // --- Get FairRootManager instance
190 FairRootManager* ioman = FairRootManager::Instance();
191 assert(ioman);
192
193 LOG(info) << "==================================================";
194 LOG(info) << GetName() << ": Initialising...";
195
196 // --- Input data
197 fEvents = ioman->InitObjectAs<const std::vector<CbmDigiEvent>*>("DigiEvent");
198 if (!fEvents) {
199 LOG(error) << GetName() << ": No input branch DigiEvent!";
200 return kFATAL;
201 }
202 LOG(info) << "--- Found branch DigiEvent at " << fEvents;
203
204 LOG(info) << "==================================================";
205 return kSUCCESS;
206}
207// ----------------------------------------------------------------------------
208
ClassImp(CbmConverterManager)
Create and fills plots of time differences to trigger in DigiEvents.
virtual void Finish()
Finish timeslice.
const std::vector< CbmDigiEvent > * fEvents
size_t fNumEvents
Number of events.
size_t fNumTs
Input data (events)
virtual ~CbmMcbm2024CheckBmonScvd()
Destructor.
virtual void Exec(Option_t *opt)
Task execution.
virtual InitStatus Init()
Task initialisation.
static int32_t GetChannelSide(uint32_t address)
static int32_t GetChannelId(uint32_t address)
Hash for CbmL1LinkKey.