BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnHistMSC.cxx
Go to the documentation of this file.
1
#include "
BmnHistMSC.h
"
2
3
#include <algorithm>
4
#include <numeric>
5
// BmnRoot
6
#include <
BmnMSCZSDigit.h
>
7
8
BmnHistMSC::BmnHistMSC
(
TString
title,
TString
path,
Int_t
PeriodID,
BmnSetup
stp,
BmnTrigRaw2Digit
* trigMapper)
9
:
BmnHist
(PeriodID, stp)
10
,
fTrigMapper
(trigMapper)
11
{
12
sumMods
= 0;
13
maxLayers
= 0;
14
refPath
= path;
15
fTitle
= title;
16
fName
= title +
"_cl"
;
17
18
scalers2index_map
=
fTrigMapper
->GetScaler2IdxMap();
19
vector<string>& scaler_idx2name =
fTrigMapper
->GetScalerIdx2NameMap();
20
uint16_t scalers_ar_size = scaler_idx2name.size();
21
22
TString
name;
23
name =
fTitle
+
"_Scalers_Total"
;
24
TH1I
* h =
new
TH1I
(name, name, scalers_ar_size, 0, scalers_ar_size);
25
h->
GetXaxis
()->
SetTitle
(
"Scaler"
);
26
h->
GetYaxis
()->
SetTitle
(
"Activation Count"
);
27
TAxis
* xaTotal = h->
GetXaxis
();
28
for
(uint16_t
i
= 0;
i
< scalers_ar_size;
i
++) {
29
string
& sname = scaler_idx2name[
i
];
30
xaTotal->
SetBinLabel
(
i
+ 1, sname.data());
31
}
32
BmnHist::SetHistStyleTH1
(h);
33
h->
SetLineWidth
(2);
34
histMscAll
.push_back(h);
35
maxLayers
= 1;
36
sumMods
= 1;
37
// Create canvas
38
name =
fTitle
+
"Canvas"
;
39
canGemStrip
=
new
TCanvas
(name, name, PAD_WIDTH *
maxLayers
, PAD_HEIGHT *
sumMods
);
40
canGemStrip
->Divide(
maxLayers
,
sumMods
, 0.01 /
maxLayers
, 0.01 /
sumMods
);
41
// Int_t modCtr = 0; // filling GEM Canvas' pads
42
canStripPads
.resize(
sumMods
*
maxLayers
);
43
Names
.resize(
sumMods
*
maxLayers
);
44
PadInfo
* pad =
new
PadInfo
();
45
pad->
opt
=
"hist"
;
46
pad->
current
= h;
47
pad->
logy
=
true
;
48
Int_t
iPad = 0;
// modCtr * maxLayers + iLayer;
49
canStripPads
[iPad] = pad;
50
canGemStrip
->GetPad(iPad + 1)->SetGrid();
51
Names
[iPad] =
canStripPads
[iPad]->current->GetName();
52
}
53
54
BmnHistMSC::~BmnHistMSC
()
55
{
56
delete
canGemStrip
;
57
if
(
fDir
)
58
return
;
59
for
(
auto
pad :
canStripPads
)
60
delete
pad;
61
}
62
63
void
BmnHistMSC::Register
(
THttpServer
* serv)
64
{
65
fServer
= serv;
66
fServer
->Register(
"/"
,
this
);
67
TString
path =
"/"
+
fTitle
+
"/"
;
68
fServer
->Register(path,
canGemStrip
);
69
TString
cmd =
"/"
+
fName
+
"/->Reset()"
;
70
TString
cmdTitle = path +
"Reset"
;
71
fServer
->RegisterCommand(cmdTitle.
Data
(), cmd.
Data
(),
"button;"
);
72
// fServer->Restrict(cmdTitle.Data(), "visible=shift");
73
// fServer->Restrict(cmdTitle.Data(), "allow=shift");
74
// fServer->Restrict(cmdTitle.Data(), "deny=guest");
75
cmd =
"/"
+
fName
+
"/->SetRefRun(%arg1%)"
;
76
cmdTitle = path +
"SetRefRun"
;
77
fServer
->RegisterCommand(cmdTitle.
Data
(), cmd.
Data
(),
"button;"
);
78
}
79
80
void
BmnHistMSC::SetDir
(
TFile
* outFile,
TTree
* recoTree)
81
{
82
frecoTree
= recoTree;
83
fDir
= NULL;
84
if
(outFile != NULL)
85
fDir
= outFile->
mkdir
(
fTitle
+
"_hists"
);
86
for
(
auto
el :
histMscAll
)
87
el->SetDirectory(
fDir
);
88
}
89
90
void
BmnHistMSC::DrawBoth
()
91
{
92
BmnHist::DrawRef
(
canGemStrip
, &
canStripPads
);
93
}
94
95
void
BmnHistMSC::FillFromDigi
(
DigiArrays
* fDigiArrays)
96
{
97
TClonesArray
* digs = fDigiArrays->
msc
;
98
// printf("evtype %u\n", fDigiArrays->header->GetEventType());
99
// printf("entries %d\n", digs->GetEntriesFast());
100
if
(!digs)
101
return
;
102
if
(digs->
GetClass
() ==
BmnMSCZSDigit<uint8_t>::Class
()) {
103
for
(
Int_t
digIndex = 0; digIndex < digs->
GetEntriesFast
(); digIndex++) {
104
BmnMSCZSDigit<uint8_t>
* gs =
static_cast<
BmnMSCZSDigit<uint8_t>
*
>
(digs->
At
(digIndex));
105
auto
it =
scalers2index_map
.find(std::make_pair(gs->
GetSerial
(), gs->
GetChannel
()));
106
if
(it ==
scalers2index_map
.end())
107
continue
;
108
vector<uint8_t>&
vec
= gs->
GetValues
();
109
uint64_t sum = std::accumulate(
vec
.begin(),
vec
.end(), 0);
110
// printf("MSC[%2u] = %lu\n", it->second, sum);
111
histMscAll
[0]->Fill(it->second, sum);
112
}
113
}
114
}
115
116
BmnStatus
BmnHistMSC::SetRefRun
(
Int_t
id
)
117
{
118
if
(
refID
!=
id
) {
119
refID
= id;
120
refRunName
=
Form
(
"bmn_run%04u%s_hist.root"
,
refID
,
fHistFileNameAdd
.Data());
121
BmnHist::LoadRefRun
(
refID
,
refPath
+
refRunName
,
fTitle
,
canStripPads
,
Names
);
122
DrawBoth
();
123
}
124
125
return
kBMNSUCCESS
;
126
}
127
128
void
BmnHistMSC::ClearRefRun
()
129
{
130
for
(
auto
pad :
canStripPads
) {
131
if
(pad)
132
if
(pad->ref) {
133
delete
pad->ref;
134
pad->ref =
nullptr
;
135
}
136
}
137
refID
= 0;
138
}
139
140
void
BmnHistMSC::Reset
()
141
{
142
for
(
auto
el :
histMscAll
)
143
el->Reset();
144
}
BmnStatus
BmnStatus
Define status code.
Definition
BmnEnums.h:93
kBMNSUCCESS
@ kBMNSUCCESS
Success.
Definition
BmnEnums.h:94
BmnSetup
BmnSetup
Define experimental setup.
Definition
BmnEnums.h:165
BmnHistMSC.h
BmnMSCZSDigit.h
i
int i
Definition
P4_F32vec4.h:22
Int_t
int Int_t
Form
char * Form(const char *fmt,...)
BmnHistMSC::sumMods
UInt_t sumMods
Definition
BmnHistMSC.h:58
BmnHistMSC::fHistFileNameAdd
TString fHistFileNameAdd
Definition
BmnHistMSC.h:60
BmnHistMSC::maxLayers
UInt_t maxLayers
Definition
BmnHistMSC.h:59
BmnHistMSC::SetDir
void SetDir(TFile *outFile=NULL, TTree *recoTree=NULL)
Definition
BmnHistMSC.cxx:80
BmnHistMSC::scalers2index_map
map< std::pair< uint32_t, uint16_t >, uint16_t > scalers2index_map
Definition
BmnHistMSC.h:50
BmnHistMSC::histMscAll
vector< TH1I * > histMscAll
Definition
BmnHistMSC.h:54
BmnHistMSC::canStripPads
vector< PadInfo * > canStripPads
Definition
BmnHistMSC.h:57
BmnHistMSC::BmnHistMSC
BmnHistMSC(TString title, TString path="", Int_t periodID=7, BmnSetup setup=kBMNSETUP, BmnTrigRaw2Digit *trigMapper=nullptr)
Definition
BmnHistMSC.cxx:8
BmnHistMSC::ClearRefRun
void ClearRefRun()
Definition
BmnHistMSC.cxx:128
BmnHistMSC::Register
void Register(THttpServer *serv)
Definition
BmnHistMSC.cxx:63
BmnHistMSC::fTrigMapper
BmnTrigRaw2Digit * fTrigMapper
Definition
BmnHistMSC.h:47
BmnHistMSC::SetRefRun
BmnStatus SetRefRun(Int_t id)
Definition
BmnHistMSC.cxx:116
BmnHistMSC::FillFromDigi
void FillFromDigi(DigiArrays *fDigiArrays)
Definition
BmnHistMSC.cxx:95
BmnHistMSC::Reset
void Reset()
Definition
BmnHistMSC.cxx:140
BmnHistMSC::Names
vector< TString > Names
Definition
BmnHistMSC.h:52
BmnHistMSC::canGemStrip
TCanvas * canGemStrip
Definition
BmnHistMSC.h:55
BmnHistMSC::DrawBoth
void DrawBoth()
Definition
BmnHistMSC.cxx:90
BmnHistMSC::~BmnHistMSC
virtual ~BmnHistMSC()
Definition
BmnHistMSC.cxx:54
BmnHist::fServer
THttpServer * fServer
Definition
BmnHist.h:87
BmnHist::refID
Int_t refID
Definition
BmnHist.h:92
BmnHist::refPath
TString refPath
Definition
BmnHist.h:90
BmnHist::fDir
TDirectory * fDir
Definition
BmnHist.h:89
BmnHist::DrawRef
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
Definition
BmnHist.cxx:15
BmnHist::frecoTree
TTree * frecoTree
Definition
BmnHist.h:88
BmnHist::SetHistStyleTH1
static void SetHistStyleTH1(TH1 *h)
Definition
BmnHist.cxx:195
BmnHist::refRunName
TString refRunName
Definition
BmnHist.h:91
BmnHist::LoadRefRun
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
Definition
BmnHist.cxx:100
BmnHist::BmnHist
BmnHist(Int_t periodID=7, BmnSetup setup=kBMNSETUP)
Definition
BmnHist.cxx:3
BmnMSCZSDigit
Raw MSC block with zero suppression and for one specific channel.
Definition
BmnMSCZSDigit.h:20
BmnMSCZSDigit::GetValues
std::vector< IntType > & GetValues()
Definition
BmnMSCZSDigit.h:50
BmnMSCZSDigit::GetChannel
uint8_t GetChannel() const
Definition
BmnMSCZSDigit.h:48
BmnMSCZSDigit::GetSerial
uint32_t GetSerial() const
Definition
BmnMSCZSDigit.h:46
BmnTrigRaw2Digit
Definition
BmnTrigRaw2Digit.h:69
DigiArrays
Definition
DigiArrays.h:10
DigiArrays::msc
TClonesArray * msc
Definition
DigiArrays.h:143
PadInfo
Storage for pad content and it's options.
Definition
PadInfo.h:20
PadInfo::opt
string opt
Definition
PadInfo.h:88
PadInfo::current
TH1 * current
Definition
PadInfo.h:78
PadInfo::logy
bool logy
Definition
PadInfo.h:85
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
TAxis
TAxis::SetBinLabel
virtual void SetBinLabel(Int_t bin, const char *label)
TCanvas
TClonesArray::GetClass
TClass * GetClass() const
TDirectoryFile::mkdir
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
TFile
TH1I
TH1::GetXaxis
TAxis * GetXaxis()
TH1::GetYaxis
TAxis * GetYaxis()
THttpServer
TNamed::SetTitle
virtual void SetTitle(const char *title="")
TNamed::fTitle
TString fTitle
TNamed::fName
TString fName
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObject::TClonesArray
friend friend class TClonesArray
TObject::Class
static TClass * Class()
TString
TString::Data
const char * Data() const
TTree
vec
monitor
BmnHistMSC.cxx
Generated on
for BmnRoot by
1.17.0