R3BROOT
R3B analysis software
Toggle main menu visibility
Loading...
Searching...
No Matches
R3BNeulandCheckMapping.cxx
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3
* Copyright (C) 2019-2025 Members of R3B Collaboration *
4
* *
5
* This software is distributed under the terms of the *
6
* GNU General Public Licence (GPL) version 3, *
7
* copied verbatim in the file "LICENSE". *
8
* *
9
* In applying this license GSI does not waive the privileges and immunities *
10
* granted to it by virtue of its status as an Intergovernmental Organization *
11
* or submit itself to any jurisdiction. *
12
******************************************************************************/
13
14
#include "
R3BNeulandCheckMapping.h
"
15
#include "
R3BPaddleTamexMappedData.h
"
16
#include <FairRootManager.h>
17
#include <TClonesArray.h>
18
19
#include <iostream>
20
#include <sstream>
21
#include <stdlib.h>
22
23
#define TIME_HVON_MAX 5
24
#define PLANE_START 12
25
#define PLANE_END 13
26
27
R3BNeulandCheckMapping::R3BNeulandCheckMapping
()
28
: FairTask(
"NeulandCheckMapping"
, 1)
29
,
timestamp0
(0)
30
,
timestamp1
(0)
31
,
fMapped
(NULL)
32
,
fTrigger
(-1)
33
{
34
}
35
36
R3BNeulandCheckMapping::R3BNeulandCheckMapping
(
const
char
* name, Int_t iVerbose)
37
: FairTask(name, iVerbose)
38
,
timestamp0
(0)
39
,
timestamp1
(0)
40
,
fMapped
(NULL)
41
,
fTrigger
(-1)
42
{
43
}
44
45
R3BNeulandCheckMapping::~R3BNeulandCheckMapping
() {}
46
47
InitStatus
R3BNeulandCheckMapping::Init
()
48
{
49
std::cout <<
"Init "
<< std::endl;
50
51
FairRootManager* rm = FairRootManager::Instance();
52
if
(!rm)
53
{
54
return
kFATAL;
55
}
56
57
header
= (
R3BEventHeader
*)rm->GetObject(
"EventHeader."
);
58
59
fMapped
= (TClonesArray*)rm->GetObject(
"NeulandMappedData"
);
60
if
(!
fMapped
)
61
{
62
return
kFATAL;
63
}
64
65
h_countsok
=
new
TH1F(
"countsok"
,
"countsok"
, 1200, 0.5, 1200.5);
66
67
std::cout <<
"Setting all vtargets to -1...\n"
;
68
for
(Int_t pln = 0; pln <
fNofPlanes
; pln++)
69
{
70
for
(Int_t bar = 0; bar <
fPaddlesPerPlane
; bar++)
71
{
72
for
(Int_t pmt = 0; pmt < 2; pmt++)
73
{
74
75
std::ostringstream oss;
76
oss <<
"nl:hv:p"
<< pln + 1 <<
"b"
<< bar + 1 <<
"t"
<< pmt + 1;
77
78
auto
vmon = oss.str() +
":vmon"
;
79
auto
vtarget = oss.str() +
":vtarget.A"
;
80
81
auto
& entry =
ca
[pln][bar][pmt];
82
entry.group =
epics
.CreateGroup();
83
84
entry.vmon = entry.group->CreateChannel(vmon);
85
entry.vtarget = entry.group->CreateChannel(vtarget);
86
87
entry.vtarget->Set(-1);
88
entry.group->Commit();
89
90
cntOk
[pln][bar][pmt] = 0;
91
}
92
}
93
}
94
std::cout <<
"Waiting for tubes to go down...\n"
;
95
for
(Int_t pln = 0; pln <
fNofPlanes
; pln++)
96
{
97
for
(Int_t bar = 0; bar <
fPaddlesPerPlane
; bar++)
98
{
99
for
(Int_t pmt = 0; pmt < 2; pmt++)
100
{
101
102
auto
& entrycheck =
ca
[pln][bar][pmt];
103
104
for
(;;)
105
{
106
std::cout <<
"#"
;
107
entrycheck.group->Fetch();
108
if
(entrycheck.vmon->Get() < 20.)
109
break
;
110
sleep(1);
111
}
112
}
113
}
114
}
115
std::cout <<
"\nAll off! Enabling the first tube...\n"
;
116
iPlnHvOn
=
PLANE_START
;
117
iBarHvOn
= 0;
118
iPmtHvOn
= 0;
119
auto
& entryon =
ca
[
iPlnHvOn
][
iBarHvOn
][
iPmtHvOn
];
120
entryon.vtarget->Set(1050);
121
entryon.group->Commit();
122
for
(;;)
123
{
124
entryon.group->Fetch();
125
if
(fabs(entryon.vmon->Get() - entryon.vtarget->Get()) < 15.)
126
break
;
127
sleep(1);
128
}
129
timestamp0
.Set();
130
std::cout <<
"Done! Ready to rumble.\n"
;
131
132
finished
=
false
;
133
134
return
kSUCCESS;
135
}
136
137
void
R3BNeulandCheckMapping::Exec
(Option_t* option)
138
{
139
if
(
finished
)
140
FinishTask
();
141
142
timestamp1
.Set();
143
144
// test git ig, delete after test!
145
146
// std::cout << "Exec " << iPlnHvOn << " B " << iBarHvOn << " T " << iPmtHvOn << std::endl;
147
148
std::cout <<
"Exec ts0="
<<
timestamp0
<<
" ts1="
<<
timestamp1
<<
" diff="
<< difftime(
timestamp1
,
timestamp0
)
149
<< std::endl;
150
151
if
(difftime(
timestamp1
,
timestamp0
) >
TIME_HVON_MAX
)
152
{
153
154
std::cout <<
"5 seconds? "
<< std::endl;
155
156
auto
& entryoff =
ca
[
iPlnHvOn
][
iBarHvOn
][
iPmtHvOn
];
157
entryoff.vtarget->Set(-1);
158
entryoff.group->Commit();
159
160
for
(;;)
161
{
162
std::cout <<
"."
;
163
entryoff.group->Fetch();
164
if
(entryoff.vmon->Get() < 20.)
165
break
;
166
sleep(1);
167
}
168
169
iBarHvOn
++;
170
171
if
(
iBarHvOn
==
fPaddlesPerPlane
)
172
{
173
iBarHvOn
= 0;
174
iPmtHvOn
++;
175
if
(
iPmtHvOn
== 2)
176
{
177
iPmtHvOn
= 0;
178
iPlnHvOn
++;
179
if
(
iPlnHvOn
>
PLANE_END
)
180
{
181
finished
=
true
;
182
iPlnHvOn
=
fNofPlanes
- 1;
183
iBarHvOn
=
fPaddlesPerPlane
- 1;
184
iPmtHvOn
= 1;
185
std::cout <<
"ALL DONE!"
<< std::endl;
186
}
187
}
188
}
189
190
if
(
finished
)
191
FinishTask
();
192
193
std::cout <<
"Enabling "
<<
iPlnHvOn
<<
':'
<<
iBarHvOn
<<
':'
<<
iPmtHvOn
<<
"..."
<< std::flush;
194
auto
& entryon =
ca
[
iPlnHvOn
][
iBarHvOn
][
iPmtHvOn
];
195
entryon.vtarget->Set(1050);
196
entryon.group->Commit();
197
198
for
(;;)
199
{
200
std::cout <<
"$"
;
201
entryon.group->Fetch();
202
if
(fabs(entryon.vmon->Get() - entryon.vtarget->Get()) < 15.)
203
break
;
204
sleep(1);
205
}
206
std::cout <<
"Done!\n"
;
207
208
timestamp0
.Set();
209
}
210
211
// std::cout << "not 5 seconds? " << std::endl;
212
213
if
((
fTrigger
>= 0) && (
header
) && (
header
->
GetTrigger
() !=
fTrigger
))
214
return
;
215
216
Int_t nHits =
fMapped
->GetEntries();
217
218
// nHits should be 1 * number of planes --- check here?
219
220
// Loop over mapped hits
221
for
(Int_t i = 0; i < nHits; i++)
222
{
223
224
R3BPaddleTamexMappedData
* hit = (
R3BPaddleTamexMappedData
*)
fMapped
->At(i);
225
226
if
(!hit)
227
continue
;
// should not happen
228
229
Int_t iPlane = hit->
GetPlaneId
();
230
Int_t iBar = hit->
GetBarId
();
231
Int_t iSide = -1 == hit->
fCoarseTime1LE
? 2 : 1;
232
233
// check if there are signals in proper channel(s)
234
// std::cout << " CHECK!!!! xP " << iPlane << " B " << iBar << " T " << iSide << std::endl;
235
// std::cout << " HV !!!! xP " << iPlnHvOn << " B " << iBarHvOn << " T " << iPmtHvOn << std::endl;
236
237
if
(iPlane - 1 ==
iPlnHvOn
&& iBar - 1 ==
iBarHvOn
&& iSide - 1 ==
iPmtHvOn
)
238
{
239
// std::cout << " GOOD!!!! xP " << iPlane << " B " << iBar << " T " << iSide << std::endl;
240
cntOk
[
iPlnHvOn
][
iBarHvOn
][
iPmtHvOn
]++;
241
}
242
else
243
{
244
// std::cout << " BAD!!!! xP " << iPlane << " B " << iBar << " T " << iSide << std::endl;
245
// std::cout << " HV !!!! xP " << iPlnHvOn << " B " << iBarHvOn << " T " << iPmtHvOn << std::endl;
246
// WriteBadMappedChannel();
247
}
248
}
249
}
250
251
void
R3BNeulandCheckMapping::FinishEvent
() {}
252
253
void
R3BNeulandCheckMapping::FinishTask
()
254
{
255
// to do: cleanup resources
256
std::cout <<
" finish task "
<< std::endl;
257
for
(Int_t pln = 0; pln <
fNofPlanes
; pln++)
258
{
259
for
(Int_t bar = 0; bar <
fPaddlesPerPlane
; bar++)
260
{
261
for
(Int_t pmt = 0; pmt < 2; pmt++)
262
{
263
264
h_countsok
->SetBinContent(pln * 100 + bar * 2 + pmt + 1,
cntOk
[pln][bar][pmt]);
265
}
266
}
267
}
268
h_countsok
->Write();
269
}
PLANE_START
#define PLANE_START
Definition
R3BNeulandCheckMapping.cxx:24
TIME_HVON_MAX
#define TIME_HVON_MAX
Definition
R3BNeulandCheckMapping.cxx:23
PLANE_END
#define PLANE_END
Definition
R3BNeulandCheckMapping.cxx:25
R3BNeulandCheckMapping.h
R3BPaddleTamexMappedData.h
R3BEventHeader
Definition
R3BEventHeader.h:23
R3BEventHeader::GetTrigger
int GetTrigger() const
Definition
R3BEventHeader.h:42
R3BNeulandCheckMapping::fNofPlanes
UInt_t fNofPlanes
Number of planes.
Definition
R3BNeulandCheckMapping.h:83
R3BNeulandCheckMapping::epics
R3BChannelAccessMasterEPICS epics
Definition
R3BNeulandCheckMapping.h:95
R3BNeulandCheckMapping::h_countsok
TH1F * h_countsok
Definition
R3BNeulandCheckMapping.h:112
R3BNeulandCheckMapping::timestamp0
TTimeStamp timestamp0
Definition
R3BNeulandCheckMapping.h:94
R3BNeulandCheckMapping::cntOk
UInt_t cntOk[60][50][2]
Definition
R3BNeulandCheckMapping.h:107
R3BNeulandCheckMapping::Exec
virtual void Exec(Option_t *option)
Method for event loop implementation.
Definition
R3BNeulandCheckMapping.cxx:137
R3BNeulandCheckMapping::FinishTask
virtual void FinishTask()
Method for finish of the task execution.
Definition
R3BNeulandCheckMapping.cxx:253
R3BNeulandCheckMapping::Init
virtual InitStatus Init()
Method for task initialization.
Definition
R3BNeulandCheckMapping.cxx:47
R3BNeulandCheckMapping::FinishEvent
virtual void FinishEvent()
A method for finish of processing of an event.
Definition
R3BNeulandCheckMapping.cxx:251
R3BNeulandCheckMapping::fPaddlesPerPlane
UInt_t fPaddlesPerPlane
Number of bars per plane.
Definition
R3BNeulandCheckMapping.h:84
R3BNeulandCheckMapping::finished
Bool_t finished
Definition
R3BNeulandCheckMapping.h:92
R3BNeulandCheckMapping::~R3BNeulandCheckMapping
virtual ~R3BNeulandCheckMapping()
Destructor.
Definition
R3BNeulandCheckMapping.cxx:45
R3BNeulandCheckMapping::fTrigger
Int_t fTrigger
Trigger value.
Definition
R3BNeulandCheckMapping.h:86
R3BNeulandCheckMapping::iPmtHvOn
UInt_t iPmtHvOn
Definition
R3BNeulandCheckMapping.h:90
R3BNeulandCheckMapping::iPlnHvOn
UInt_t iPlnHvOn
Definition
R3BNeulandCheckMapping.h:88
R3BNeulandCheckMapping::timestamp1
TTimeStamp timestamp1
Definition
R3BNeulandCheckMapping.h:94
R3BNeulandCheckMapping::header
R3BEventHeader * header
Event header - input data.
Definition
R3BNeulandCheckMapping.h:110
R3BNeulandCheckMapping::ca
struct R3BNeulandCheckMapping::@240015161367143025021213366075002127224226233032 ca[60][50][2]
R3BNeulandCheckMapping::fMapped
TClonesArray * fMapped
Array with mapped data - input data.
Definition
R3BNeulandCheckMapping.h:109
R3BNeulandCheckMapping::iBarHvOn
UInt_t iBarHvOn
Definition
R3BNeulandCheckMapping.h:89
R3BNeulandCheckMapping::R3BNeulandCheckMapping
R3BNeulandCheckMapping()
Default constructor.
Definition
R3BNeulandCheckMapping.cxx:27
R3BPaddleTamexMappedData
Definition
R3BPaddleTamexMappedData.h:20
R3BPaddleTamexMappedData::GetPlaneId
const Int_t & GetPlaneId() const
Definition
R3BPaddleTamexMappedData.h:26
R3BPaddleTamexMappedData::GetBarId
const Int_t & GetBarId() const
Definition
R3BPaddleTamexMappedData.h:27
R3BPaddleTamexMappedData::fCoarseTime1LE
Int_t fCoarseTime1LE
Definition
R3BPaddleTamexMappedData.h:64
neuland
preexp
R3BNeulandCheckMapping.cxx
Generated by
1.18.0