4#include "BmnRawDataDecoder.h"
5#include "BmnTrigWaveDigit.h"
35 fName = title +
"_cl";
37 const Int_t rows4Summary = 3;
40 vector<TClonesArray*>* arrays =
fTrigMapper->GetTrigArrays();
43 for (
UInt_t iArr = 0; iArr < arrays->size(); ++iArr) {
51 if (!strcmp(tr.Data(), trName.
Data())) {
60 name =
fTitle +
"_" + trName +
"_Time";
62 mapTime.insert(make_pair(iArr, h));
67 name =
fTitle +
"_" + name +
"_Time";
69 mapTime.insert(make_pair(iArr, h2));
74 if (!strcmp(tr.Data(), trName.
Data())) {
88 name =
fTitle +
"CanvasTimesByChannel";
92 name =
fTitle +
"CanvasTimes";
99 canTimes->GetPad(iPad + 1)->SetGrid();
101 name =
fTitle +
"_BD_Channels";
105 name =
fTitle +
"_BD_Amp_by_Channels";
109 name =
fTitle +
"_BD_Simultaneous";
117 for (
size_t i = 0;
i <
hists.size(); ++
i) {
119 hists[
i]->GetYaxis()->SetTitle(
"Activation Count");
120 hists[
i]->GetXaxis()->SetTitle(
"Time, ns");
122 for (
size_t iPad = 0; iPad <
canTimesPads.size(); ++iPad) {
167 const vector<string> TrigName{
"TQDC_BC1",
"TQDC_BC2",
"TQDC_FD",
"TQDC_FHCAL",
"TQDC_tFHCal",
"BD"};
172 const size_t TrigBitsCnt =
TrigState.size();
173 const Int_t ColsStates = 2;
174 const size_t RowsStates = TrigName.size();
177 auto it_bm = bit_map.find(
string(state.Name.Data()));
178 if (it_bm != bit_map.end()) {
183 canTrigStates = make_unique<TCanvas>(canName, canName, PAD_WIDTH * ColsStates, PAD_HEIGHT * RowsStates);
184 canTrigStates->Divide(ColsStates, RowsStates, 0.01 / ColsStates, 0.01 / RowsStates);
185 for (
const string& detName : TrigName) {
186 bool isTDC = (detName.find(
"BD") != string::npos) || (detName.find(
"SI") != string::npos);
187 vector<TH1*> hist_vec;
188 vector<TH1*> hist_vec_log;
189 vector<TString> hist_vec_opt;
190 vector<TString> hist_vec_opt_log;
196 TLegend* legend_lin =
new TLegend(l_x0, l_y0, l_x0 + l_w, l_y0 + l_h);
198 TLegend* legend_log =
new TLegend(l_x0, l_y0, l_x0 + l_w, l_y0 + l_h);
202 TString hName(
fTitle +
"_" + detName +
"_" + state.Name +
"_Amp");
203 TString hTitle(detName +
"_" "_Amp");
205 legend_lin->
AddEntry(h, state.Name);
211 legend_log->
AddEntry(h_log, state.Name);
212 hist_vec.push_back(h);
213 hist_vec_log.push_back(h_log);
216 PadInfo* pad_lin =
new PadInfo(
nullptr, move(hist_vec), move(hist_vec_opt), legend_lin);
217 PadInfo* pad_log =
new PadInfo(
nullptr, move(hist_vec_log), move(hist_vec_opt_log), legend_log);
222 mapTBLin.insert(make_pair(it->second, pad_lin));
223 pad_log->
logy =
true;
224 mapTBLog.insert(make_pair(it->second, pad_log));
230 string full_name_first =
"TQDC_" + corrPair.first;
231 string full_name_second =
"TQDC_" + corrPair.second;
236 iFirst = itf->second;
241 iSecond = its->second;
245 TString hName(
fTitle +
"_" + corrPair.first +
"_vs_" + corrPair.second +
"_Amp");
255 canName =
fTitle +
"_Trig_States_2D";
258 size_t Rows2D = corrLen / Cols2D + ((corrLen % Cols2D) ? 1 : 0);
259 canCorrTQDC = make_unique<TCanvas>(canName, canName, PAD_WIDTH * Cols2D, PAD_HEIGHT * Rows2D);
260 canCorrTQDC->Divide(Cols2D, Rows2D, 0.01 / TrigBitsCnt, 0.01 / Rows2D);
302 const Int_t GridColsBD = 4;
303 const Int_t GroupSizeBD = 5;
307 canGridBD = make_unique<TCanvas>(canName, canName, PAD_WIDTH * GridColsBD, PAD_HEIGHT * GridRowsBD);
308 canGridBD->Divide(GridColsBD, GridRowsBD, 0.01 / GridColsBD, 0.01 / GridRowsBD);
310 for (
Int_t iRow = 0; iRow < GridRowsBD; ++iRow) {
311 for (
Int_t iCol = 0; iCol < GridColsBD; ++iCol) {
314 for (
Int_t iGr = 0; iGr < GroupSizeBD; ++iGr) {
328 canName =
fTitle +
"_ND_Grid";
329 Int_t GridRowsND = 4;
330 vector<string> endnamesND{
"F1",
"F2",
"S1",
"S2",
"V"};
331 Int_t GridColsND = endnamesND.size();
332 canGridND = make_unique<TCanvas>(canName, canName, PAD_WIDTH * GridColsND, PAD_HEIGHT * GridRowsND);
333 canGridND->Divide(GridColsND, GridRowsND, 0.01 / GridColsND, 0.01 / GridRowsND);
335 for (
Int_t iRow = 0; iRow < GridRowsND; ++iRow) {
336 for (
Int_t iCol = 0; iCol < GridColsND; ++iCol) {
337 char* detName =
Form(
"ND%s%d", endnamesND[iCol].data(), (iRow + 1));
339 string full_det_name(
string(
"TQDC_") + detName);
342 mapGridND.insert(make_pair(it->second, p));
370 regex reBD(
"BD\\S+");
371 regex reND(
"TQDC_ND\\S+");
372 regex reQBC2(
"TQDC_BC2\\S+");
373 regex reQBC1(
"TQDC_BC1");
374 regex reQUnit(
"TQDC_UNIT_\\d+");
375 regex reX10(
"TQDC_.+_X10.*");
377 Int_t arLen = trigAr->size();
390 if (regex_match(arName.
Data(), reBD) || regex_match(arName.
Data(), reND)) {
401 ? (regex_match(ar->
GetName(), reQBC2)
403 : (regex_match(ar->
GetName(), reQUnit)
409 TH1F* h =
new TH1F(name, name, 800, 0, maxTime);
418 pad_log->
logy =
true;
427 TH1F* h_match =
new TH1F(name, name, 800, 0, maxTime);
432 pad_lin->
aux.push_back(h_match);
433 pad_lin->
auxOpt.push_back(
"");
435 pad_log->
aux.push_back(h_match_log);
440 name =
fTitle +
"Canvas_Amplitudes";
451 const uint32_t timewin_begin = 312;
452 const uint32_t timewin_end = 362;
464 vector<TClonesArray*>* trigAr = fDigiArrays->
trigAr;
475 el->current->SetDirectory(
fDir);
479 if (el.second->current)
480 el.second->current->SetDirectory(
fDir);
481 for (
auto& aux_hist : el.second->aux)
482 aux_hist->SetDirectory(
fDir);
487 if (el.second->current)
488 el.second->current->SetDirectory(
fDir);
489 for (
auto& aux_hist : el.second->aux)
490 aux_hist->SetDirectory(
fDir);
495 for (
size_t iArr = 0; iArr < (*trigAr).size(); ++iArr) {
567 double time =
vec.size() ?
vec[0] : -DBL_MAX;
631 for (
size_t iCorr = 0; iCorr <
idxCorrTQDC.size(); ++iCorr) {
680 TString cmdTitle = path +
"SetRefRun";
682 fServer->Restrict(cmdTitle.
Data(),
"visible=shift");
685 cmdTitle = path +
"ChangeBDChannel";
686 fServer->RegisterCommand(cmdTitle.
Data(),
"/" +
fName +
"/->SetBDChannel(%arg1%)",
"button;");
687 fServer->Restrict(cmdTitle.
Data(),
"visible=shift");
689 fServer->Restrict(cmdTitle.
Data(),
"hidden=guest");
691 cmdTitle = path +
"Reset";
692 fServer->RegisterCommand(cmdTitle.
Data(),
"/" +
fName +
"/->Reset()",
"button;");
693 fServer->Restrict(cmdTitle.
Data(),
"visible=shift");
725 el->current->SetDirectory(
fDir);
730 el->current->SetDirectory(
fDir);
735 el->current->SetDirectory(
fDir);
740 el->current->SetDirectory(
fDir);
745 el->current->SetDirectory(
fDir);
746 for (
auto& aux_hist : el->aux)
747 aux_hist->SetDirectory(
fDir);
753 el->current->SetDirectory(
fDir);
758 el->current->SetDirectory(
fDir);
762 if (el.second->current)
763 el.second->current->SetDirectory(
fDir);
765 for (
auto& aux_hist : el.second->aux)
766 aux_hist->SetDirectory(
fDir);
819 TString FileName =
Form(
"bmn_run%04d_hist.root",
id);
820 printf(
"SetRefRun: %s\n", FileName.
Data());
char * Form(const char *fmt,...)
BmnStatus
Define status code.
BmnSetup
Define experimental setup.
const vector< TrigStateDesc > TrigState
vector< TString > shortNames
vector< TH1 * > histsGridBD
const Int_t MaxAmpTQDC_Beam
virtual ~BmnHistTrigger()
map< UInt_t, PadInfo * > mapTBLog
vector< PadInfo * > padsCanAmp
const Int_t MaxAmpTQDC_Corr
vector< PadInfo * > padsGridBD
map< UInt_t, PadInfo * > mapGridND
void SetDir(TFile *outFile, TTree *recoTree)
vector< TH2I * > histCorrTQDC
void InitHistsFromArr(vector< TClonesArray * > *trigAr)
vector< TString > trigNames
void SetBDChannel(Int_t iSelChannel)
map< string, UInt_t > mapArrayNames
vector< PadInfo * > padsCorrTQDC
map< UInt_t, TH1 * > mapTime
BmnTrigRaw2Digit * fTrigMapper
unique_ptr< TCanvas > canTrigStates
const Int_t MaxAmpTQDC_BC2
TTimeStamp fLastSpillStartTS
vector< PadInfo * > padsGridND
void FillFromDigi(DigiArrays *fDigiArrays)
vector< PadInfo * > canTimesPads
vector< pair< uint32_t, uint32_t > > idxCorrTQDC
void Register(THttpServer *serv)
const Int_t MaxAmpTQDC_Unit
unique_ptr< TCanvas > canGridND
vector< PadInfo * > padsScalers
unique_ptr< TCanvas > canGridBD
BmnHistTrigger(TString title="Triggers", TString path="", Int_t periodID=9, BmnSetup=kBMNSETUP, BmnTrigRaw2Digit *trigMapper=nullptr)
TH2I * histBDAmpByChannel
vector< uint16_t > trig_state_bit_index
map< UInt_t, PadInfo * > mapTBLin
BmnStatus SetRefRun(Int_t id)
vector< PadInfo * > canProfilePads
unique_ptr< TCanvas > canCorrTQDC
unique_ptr< TCanvas > canScalers
vector< PadInfo * > padsTrigStates
map< UInt_t, PadInfo * > mapAmpLin
vector< double > storeAmpTQDC
const vector< pair< string, string > > TrigNameCorrTQDC
map< UInt_t, PadInfo * > mapAmpLog
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
static void SetHistStyleTH1(TH1 *h)
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
BmnHist(Int_t periodID=7, BmnSetup setup=kBMNSETUP)
class for TQDC data including waveform can be initialized both from an std::vector and raw pointer to...
int16_t GetPeak(size_t start=0, size_t stop=SIZE_MAX) const
vector< Double_t > & TdcVector()
std::vector< TClonesArray * > * trigAr
Storage for pad content and it's options.
virtual void SetLineColor(Color_t lcolor)
virtual void SetTextSize(Float_t tsize=1)
TClass * GetClass() const
const char * GetName() const override
virtual Int_t Fill(const char *name, Double_t w)
TObject * Clone(const char *newname="") const override
TLegendEntry * AddEntry(const char *name, const char *label="", Option_t *option="lpf")
virtual void SetTitle(const char *title="")
const char * GetName() const override
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
friend friend class TClonesArray
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const