BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnProfQa.cxx
Go to the documentation of this file.
1
#include "
BmnProfQa.h
"
2
3
#include "
BmnAcceptanceFunction.h
"
4
#include "
BmnDchHit.h
"
5
#include "
BmnDchTrack.h
"
6
#include "
BmnEnums.h
"
7
#include "
BmnGemStripHit.h
"
8
#include "
BmnGlobalTrack.h
"
9
#include "
BmnHistManager.h
"
10
#include "
BmnMath.h
"
11
#include "
BmnSiBTHit.h
"
12
#include "
BmnSiliconHit.h
"
13
#include "
BmnUtils.h
"
14
#include "
CbmBaseHit.h
"
15
#include "
CbmStsTrack.h
"
16
#include "
CbmVertex.h
"
17
#include "FairRunAna.h"
18
#include "
TClonesArray.h
"
19
#include "
TF1.h
"
20
#include "
TH1.h
"
21
#include "
TH2F.h
"
22
23
#include <fstream>
24
#include <iostream>
25
26
using
lit::FindAndReplace
;
27
using
lit::Split
;
28
29
BmnProfQa::BmnProfQa
(
TString
name,
TString
gemConf)
30
:
BmnQaBase
(name, 1)
31
,
fProfHits
(nullptr)
32
,
fProfDigits
(nullptr)
33
,
fDstEventHeader
(nullptr)
34
,
fConfigProf
(gemConf)
35
,
fNItersSinceUpdate
(0)
36
{}
37
38
BmnProfQa::~BmnProfQa
() {}
39
40
InitStatus
BmnProfQa::Init
()
41
{
42
printf(
"BmnProfQa::Init()"
);
43
fHM
=
new
BmnHistManager
();
44
if
(
fMonitorMode
) {
45
fReport
=
new
BmnProfQaReport
(
fOutName
);
46
fReport
->SetHM(
fHM
);
47
fReport
->SetMonitorMode(
fMonitorMode
);
48
fReport
->SetObjServer(
fServer
);
49
fTicksLastUpdate
= chrono::system_clock::now();
50
SetDefaultDrawStyle
();
51
}
else
{
52
}
53
ReadDataBranches
();
54
CreateHistograms
();
55
if
(
fMonitorMode
) {
56
fReport
->CallDraw();
57
fReport
->Register(
"/"
);
58
RegisterCommands
();
59
// fServer->SetTimer(50, kFALSE);
60
}
else
{
61
}
62
printf(
"BmnProfQa::Init() finish"
);
63
return
kSUCCESS;
64
}
65
66
void
BmnProfQa::Exec
(
Option_t
* opt)
67
{
68
if
(
fEventNo
% 1000 == 0)
69
printf(
"EventCnt: %8d EventId: %8d RunId: %6u\n"
,
fEventNo
,
fEventId
,
fRunId
);
70
fEventNo
++;
71
ProcessGlobal
();
72
if
(
fMonitorMode
) {
73
fNItersSinceUpdate
++;
74
fServer
->ProcessRequests();
75
chrono::time_point<chrono::system_clock> now = chrono::system_clock::now();
76
chrono::seconds time = chrono::duration_cast<chrono::seconds>(now -
fTicksLastUpdate
);
77
// time_t tt = chrono::system_clock::to_time_t(now);
78
// printf("\ntime %s\n", ctime(&tt));
79
if
((time >
fTimeToUpdate
) || (
fNItersSinceUpdate
>
fNItersToUpdate
)) {
80
fReport
->CallDraw();
81
if
(fVerbose)
82
printf(
"Draw! iters %d\n"
,
fNItersSinceUpdate
);
83
fTicksLastUpdate
= now;
84
fNItersSinceUpdate
= 0;
85
}
86
}
87
fPrevRunId
=
fRunId
;
88
}
89
90
void
BmnProfQa::Finish
()
91
{
92
// fHM->WriteToFile();
93
if
(!
fMonitorMode
) {
94
fReport
=
new
BmnProfQaReport
(
fOutName
);
95
fReport
->Create(
fHM
,
fOutputDir
);
96
}
else
97
fReport
->CallDraw();
98
// fServer->SetTimer(50, kFALSE);
99
}
100
101
void
BmnProfQa::ReadDataBranches
()
102
{
103
FairRootManager* ioman = FairRootManager::Instance();
104
if
(
nullptr
== ioman)
105
Fatal
(
"Init"
,
"BmnRootManager is not instantiated"
);
106
fDstEventHeader
=
static_cast<
DstEventHeader
*
>
(ioman->GetObject(
"DstEventHeader."
));
107
108
if
(
fInnerTrackerSetup
[
kSiProf
]) {
109
// fProfHits = (TClonesArray*) ioman->GetObject("BmnProfHit");
110
fProfDigits
= (
TClonesArray
*)ioman->GetObject(
"BmnProfDigit"
);
111
printf(
"fProfDigits %p\n"
,
fProfDigits
);
112
fProfDetector
= make_unique<BmnSiProfStationSet>(
fConfigProf
);
113
fReport
->AddStationSet(
kSiProf
,
static_cast<
void
*
>
(
fProfDetector
.get()));
114
}
115
116
printf(
"\nBRANCHES READ\n\n"
);
117
}
118
119
void
BmnProfQa::CreateHistograms
()
120
{
121
Int_t
MaxSig = 2500;
122
const
Int_t
n_strips(32);
123
TString
detName;
124
BmnDetectorList::GetSystemNameCaps
(
kSiProf
, detName);
125
for
(
Short_t
iSt = 0; iSt <
fProfDetector
->GetNStations(); ++iSt) {
126
auto
* st =
fProfDetector
->GetStation(iSt);
127
for
(
Int_t
iModule = 0; iModule < st->GetNModules(); iModule++) {
128
auto
* mod = st->GetModule(iModule);
129
for
(
Int_t
iLayer = 0; iLayer < mod->GetNStripLayers(); iLayer++) {
130
// auto &lay = mod->GetStripLayer(iLayer);
131
string
name(
BmnProfQaReport::HistNameProfDigit
(detName, iSt, iModule, iLayer));
132
// CreateH1(BmnSimulationReport::HistNameStripDigit(name, iSt, iModule, iLayer), "Strip
133
// #", "Count", "",
134
CreateH1
(name,
"Strip #"
,
"Count"
, n_strips, 0, n_strips);
// lay.GetNStrips(), 0, lay.GetNStrips());
135
if
(iLayer) {
136
CreateH1
(name +
"_sig"
,
"Signal"
,
"Count"
, MaxSig, -MaxSig, 0);
137
CreateH2
(name +
"_pedestals"
,
"Strip #"
,
"Signal"
,
""
, n_strips, 0, n_strips, MaxSig, -MaxSig, 0);
138
}
else
{
139
CreateH1
(name +
"_sig"
,
"Signal"
,
"Count"
, MaxSig, 0, MaxSig);
140
CreateH2
(name +
"_pedestals"
,
"Strip #"
,
"Signal"
,
""
, n_strips, 0, n_strips, MaxSig, 0, MaxSig);
141
}
142
CreateH1
(name +
"_mean"
,
"Strip #"
,
"Count"
, n_strips, 0,
143
n_strips);
// lay.GetNStrips(), 0, lay.GetNStrips());
144
// BmnHist::SetHistStyleTH1(h);
145
}
146
string
name2d(
BmnProfQaReport::HistNameProfHits
(detName, iSt));
147
CreateH2
(name2d,
"Strip X"
,
"Strip Y"
,
""
, n_strips, 0, n_strips, n_strips, 0, n_strips);
148
}
149
}
150
151
// for (Int_t iMap = 0; iMap < NChars; ++iMap) {
152
// auto & map = channel_maps[iMap];
153
// TString detName;
154
//
155
// TH1 *h = new TH1F(
156
// Form("h%c_strips", map.LayerType),
157
// Form("%c side", map.LayerType), ASIC_channel, 0, ASIC_channel);
158
// TH1 *hMean = new TH1F(
159
// Form("h%c_strips_mean", map.LayerType),
160
// Form("%c side mean", map.LayerType), ASIC_channel, 0, ASIC_channel);
161
// TH1 *hSig = new TH1F(
162
// Form("h%c_sig", map.LayerType),
163
// Form("%c side signals", map.LayerType), 2 * ADCLimit + 1, -ADCLimit, ADCLimit);
164
// TH1 *hPed = new TH2F(
165
// Form("h%c_ped", map.LayerType),
166
// Form("%c side pedestals", map.LayerType), ASIC_channel, 0, ASIC_channel, NBins, -ADCLimit,
167
// ADCLimit);
168
// hVec[NCols * 0 + iMap] = h;
169
// hVec[NCols * 1 + iMap] = hSig;
170
// hVecOpt[NCols * 1 + iMap] = "logy";
171
// hVec[NCols * 2 + iMap] = hMean;
172
// hVec[NCols * 3 + iMap] = hPed;
173
// hVecOpt[NCols * 3 + iMap] = "colz";
174
// }
175
176
// if (fInnerTrackerSetup[kSiProf])
177
// CreateStripHits(fProfDetector, kSiProf);
178
179
printf(
"\nHISTOGRAMS CREATED!\n\n"
);
180
}
181
182
void
BmnProfQa::ProcessGlobal
()
183
{
184
// fRunId = fDstEventHeader->GetRunId();
185
// fEventId = fDstEventHeader->GetEventId();
186
// if (fRunId != fPrevRunId) {
187
// printf("run id change %u -> %u\n", fPrevRunId, fRunId);
188
// fHM->ResetHists();
189
// }
190
TString
detName;
191
BmnDetectorList::GetSystemNameCaps
(
kSiProf
, detName);
192
193
// for "hit making"
194
const
Int_t
n_strips(32);
195
// vector<bitset < n_strips >> x_hit(fProfDetector->GetNStations(), 0);
196
// vector<bitset < n_strips >> y_hit(fProfDetector->GetNStations(), 0);
197
vector<vector<Int_t>> x_hit(
fProfDetector
->GetNStations(), vector(n_strips, 0));
198
vector<vector<Int_t>> y_hit(
fProfDetector
->GetNStations(), vector(n_strips, 0));
199
200
for
(
Int_t
iDig = 0; iDig <
fProfDigits
->GetEntriesFast(); ++iDig) {
201
BmnSiProfDigit
* dig =
dynamic_cast<
BmnSiProfDigit
*
>
(
fProfDigits
->At(iDig));
202
Int_t
iSt = dig->
GetStation
();
203
Int_t
iMod = dig->
GetModule
();
204
Int_t
iLayer = dig->
GetStripLayer
();
205
Int_t
strip = dig->
GetStripNumber
();
206
Double_t
signal = dig->
GetStripSignal
();
207
string
name(
BmnProfQaReport::HistNameProfDigit
(detName, iSt, iMod, iLayer));
208
fHM
->H1(name)->Fill(strip,
abs
(signal));
209
fHM
->H1(name)->SetBinError(strip, 0);
210
fHM
->H1(name +
"_sig"
)->Fill(signal);
211
// fHM->H1(name + "_mean")->Fill(signal);
212
fHM
->H2(name +
"_pedestals"
)->Fill(strip, signal);
213
214
// temp crutches to make hits
215
if
(iLayer)
216
y_hit[iSt][strip] = -signal;
217
else
218
x_hit[iSt][strip] = signal;
219
}
220
for
(
Short_t
iSt = 0; iSt <
fProfDetector
->GetNStations(); ++iSt) {
221
string
name2d(
BmnProfQaReport::HistNameProfHits
(detName, iSt));
222
for
(
size_t
iX
= 0;
iX
< n_strips;
iX
++)
223
for
(
size_t
iY
= 0;
iY
< n_strips;
iY
++)
224
if
(x_hit[iSt][
iX
] && y_hit[iSt][
iY
])
225
fHM
->H2(name2d)->Fill(
iX
,
iY
,
abs
(x_hit[iSt][
iX
]) +
abs
(y_hit[iSt][
iY
]));
226
}
227
// if (fProfHits) {
228
// FillStripHits(kSiProf, fProfHits);
229
// }
230
}
231
232
// void BmnProfQa::FillProfHits(TClonesArray* hits) {
233
// TString detName;
234
// BmnDetectorList::GetSystemNameCaps(detId, detName);
235
// for (Int_t iHit = 0; iHit < hits->GetEntriesFast(); ++iHit) {
236
// BmnHit* hit = static_cast<BmnHit*> (hits->At(iHit));
237
// Short_t iSt = hit->GetStation();
238
// // if (detId==kCSC)
239
// // printf("hit! station %d {%2.3f, %2.3f}\n", iSt, hit->GetX(), hit->GetY());
240
// fHM->H2(BmnSimulationReport::HistNameHits(detName, iSt))->Fill(hit->GetX(), hit->GetY());
241
// }
242
// }
243
244
void
BmnProfQa::ResetProf
()
245
{
246
printf(
"Reset Prof QA\n"
);
247
fHM
->ResetHists();
248
}
249
250
void
BmnProfQa::RegisterCommands
()
251
{
252
fServer
->Register(
"/"
,
this
);
253
// TString path = "/" + fTitle + "/";
254
string
path = string(
"/"
) + fName.Data() +
"_cmd/"
;
255
string
cmd = string(
"/"
) + fName.Data() +
"/->ResetProf()"
;
256
string
cmdTitle = path +
"ResetProf"
;
257
fServer
->RegisterCommand(cmdTitle.data(), cmd.data(),
"button;"
);
258
}
BmnAcceptanceFunction.h
Global function to define the track acceptance. Used in QA.
iX
@ iX
Definition
BmnAlignDefines.h:25
iY
@ iY
Definition
BmnAlignDefines.h:26
BmnDchHit.h
BmnDchTrack.h
kSiProf
@ kSiProf
Definition
BmnDetectorList.h:29
SetDefaultDrawStyle
void SetDefaultDrawStyle()
Definition
BmnDrawHist.cxx:28
BmnEnums.h
Define enumerations used in tracking.
BmnGemStripHit.h
BmnGlobalTrack.h
BmnHistManager.h
Histogram manager.
BmnMath.h
BmnProfQa.h
BmnSiBTHit.h
BmnSiliconHit.h
BmnUtils.h
CbmBaseHit.h
CbmStsTrack.h
CbmVertex.h
Int_t
int Int_t
Short_t
short Short_t
Double_t
double Double_t
Option_t
const char Option_t
TClonesArray.h
Fatal
void Fatal(const char *location, const char *msgfmt,...)
TF1.h
TH1.h
TH2F.h
BmnDetectorList::GetSystemNameCaps
static void GetSystemNameCaps(DetectorId det, TString &name)
Get system name in capitals.
Definition
BmnDetectorList.cxx:103
BmnHistManager
Histogram manager.
Definition
BmnHistManager.h:42
BmnProfQaReport
Profilometer Report QA.
Definition
BmnProfQaReport.h:14
BmnProfQaReport::HistNameProfDigit
static char * HistNameProfDigit(TString &detName, Short_t iSt, Short_t iMod, Short_t iLayer)
Definition
BmnProfQaReport.h:36
BmnProfQaReport::HistNameProfHits
static char * HistNameProfHits(TString &detName, Short_t iSt)
Definition
BmnProfQaReport.h:40
BmnProfQa::fTimeToUpdate
const chrono::seconds fTimeToUpdate
Definition
BmnProfQa.h:98
BmnProfQa::ProcessGlobal
void ProcessGlobal()
Definition
BmnProfQa.cxx:182
BmnProfQa::fNItersSinceUpdate
Int_t fNItersSinceUpdate
Definition
BmnProfQa.h:99
BmnProfQa::CreateHistograms
void CreateHistograms()
Definition
BmnProfQa.cxx:119
BmnProfQa::fNItersToUpdate
const Int_t fNItersToUpdate
Definition
BmnProfQa.h:97
BmnProfQa::fProfDetector
unique_ptr< BmnSiProfStationSet > fProfDetector
Definition
BmnProfQa.h:90
BmnProfQa::ReadDataBranches
void ReadDataBranches()
Read data branches from input data files.
Definition
BmnProfQa.cxx:101
BmnProfQa::fProfDigits
TClonesArray * fProfDigits
Definition
BmnProfQa.h:85
BmnProfQa::fDstEventHeader
DstEventHeader * fDstEventHeader
Definition
BmnProfQa.h:87
BmnProfQa::ResetProf
void ResetProf()
Definition
BmnProfQa.cxx:244
BmnProfQa::fTicksLastUpdate
chrono::time_point< chrono::system_clock > fTicksLastUpdate
Definition
BmnProfQa.h:100
BmnProfQa::Exec
virtual void Exec(Option_t *opt)
Derived from FairTask.
Definition
BmnProfQa.cxx:66
BmnProfQa::fInnerTrackerSetup
map< DetectorId, Bool_t > fInnerTrackerSetup
Definition
BmnProfQa.h:81
BmnProfQa::fProfHits
TClonesArray * fProfHits
Definition
BmnProfQa.h:84
BmnProfQa::fConfigProf
TString fConfigProf
Definition
BmnProfQa.h:89
BmnProfQa::RegisterCommands
void RegisterCommands()
Definition
BmnProfQa.cxx:250
BmnProfQa::~BmnProfQa
virtual ~BmnProfQa()
Destructor.
Definition
BmnProfQa.cxx:38
BmnProfQa::Finish
virtual void Finish()
Derived from FairTask.
Definition
BmnProfQa.cxx:90
BmnProfQa::Init
virtual InitStatus Init()
Derived from FairTask.
Definition
BmnProfQa.cxx:40
BmnProfQa::BmnProfQa
BmnProfQa()
Constructor.
Definition
BmnProfQa.h:32
BmnQaBase::fMonitorMode
Bool_t fMonitorMode
Definition
BmnQaBase.h:157
BmnQaBase::fRunId
UInt_t fRunId
Definition
BmnQaBase.h:159
BmnQaBase::fEventId
Int_t fEventId
Definition
BmnQaBase.h:162
BmnQaBase::BmnQaBase
BmnQaBase()
Constructor.
Definition
BmnQaBase.h:39
BmnQaBase::CreateH1
void CreateH1(const string &name, const string &xTitle, const string &yTitle, Int_t nofBins, Double_t minBin, Double_t maxBin)
Definition
BmnQaBase.cxx:144
BmnQaBase::CreateH2
void CreateH2(const string &name, const string &xTitle, const string &yTitle, const string &zTitle, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Definition
BmnQaBase.cxx:155
BmnQaBase::fHM
BmnHistManager * fHM
Definition
BmnQaBase.h:152
BmnQaBase::fOutName
TString fOutName
Definition
BmnQaBase.h:150
BmnQaBase::fOutputDir
string fOutputDir
Definition
BmnQaBase.h:153
BmnQaBase::fServer
THttpServer * fServer
Definition
BmnQaBase.h:149
BmnQaBase::fReport
BmnSimulationReport * fReport
Definition
BmnQaBase.h:155
BmnQaBase::fPrevRunId
UInt_t fPrevRunId
Definition
BmnQaBase.h:160
BmnQaBase::fEventNo
Int_t fEventNo
Definition
BmnQaBase.h:161
BmnSiProfDigit
Definition
BmnSiProfDigit.h:9
BmnStripDigit::GetStripNumber
Int_t GetStripNumber()
Definition
BmnStripDigit.h:29
BmnStripDigit::GetStripLayer
Int_t GetStripLayer()
Definition
BmnStripDigit.h:28
BmnStripDigit::GetStation
Int_t GetStation()
Definition
BmnStripDigit.h:26
BmnStripDigit::GetStripSignal
Double_t GetStripSignal()
Definition
BmnStripDigit.h:30
BmnStripDigit::GetModule
Int_t GetModule()
Definition
BmnStripDigit.h:27
DstEventHeader
Definition
DstEventHeader.h:10
TClonesArray
TString
abs
RVec< PromoteType< T > > abs(const RVec< T > &v)
lit::FindAndReplace
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
Definition
BmnUtils.cxx:19
lit::Split
vector< string > Split(const string &name, char delimiter)
Definition
BmnUtils.cxx:27
QA
BmnProfQa.cxx
Generated on
for BmnRoot by
1.17.0