BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
CbmStsIdealDigitize.cxx
Go to the documentation of this file.
1
//* $Id: */
2
3
// -------------------------------------------------------------------------
4
// ----- CbmStsDigitize source file -----
5
// ----- Created 30/08/06 by V. Friese -----
6
// -------------------------------------------------------------------------
7
8
// Includes from STS
9
#include "
CbmStsIdealDigitize.h
"
10
11
#include "
CbmGeoStsPar.h
"
12
#include "
CbmStsDigi.h
"
13
#include "
CbmStsDigiMatch.h
"
14
#include "
CbmStsDigiPar.h
"
15
#include "
CbmStsDigiScheme.h
"
16
#include "CbmStsPoint.h"
17
#include "
CbmStsSector.h
"
18
#include "
CbmStsSensor.h
"
19
#include "
CbmStsStation.h
"
20
21
// Includes from base
22
#include "FairRootManager.h"
23
#include "FairRunAna.h"
24
#include "FairRuntimeDb.h"
25
26
// Includes from ROOT
27
#include "
TClonesArray.h
"
28
#include "
TGeoManager.h
"
29
#include "
TGeoNode.h
"
30
#include "
TMath.h
"
31
#include "
TObjArray.h
"
32
33
#include <iomanip>
34
#include <iostream>
35
#include <map>
36
37
using
std::cerr;
38
using
std::cout;
39
using
std::endl;
40
using
std::fixed;
41
using
std::left;
42
using
std::map;
43
using
std::pair;
44
using
std::right;
45
using
std::setprecision;
46
using
std::setw;
47
48
// ----- Default constructor ------------------------------------------
49
CbmStsIdealDigitize::CbmStsIdealDigitize
()
50
:
FairTask
(
"STS Digitizer"
, 1)
51
,
fGeoPar
(NULL)
52
,
fDigiPar
(NULL)
53
,
fDigiScheme
(NULL)
54
,
fPoints
(NULL)
55
,
fDigis
(NULL)
56
,
fDigiMatches
(NULL)
57
,
fNPoints
(0)
58
,
fNFailed
(0)
59
,
fNOutside
(0)
60
,
fNMulti
(0)
61
,
fNDigis
(0)
62
,
fTimer
()
63
,
fChannelMap
()
64
{
65
Reset
();
66
}
67
// -------------------------------------------------------------------------
68
69
// ----- Standard constructor ------------------------------------------
70
CbmStsIdealDigitize::CbmStsIdealDigitize
(
Int_t
iVerbose)
71
:
FairTask
(
"STSDigitize"
, iVerbose)
72
,
fGeoPar
(NULL)
73
,
fDigiPar
(NULL)
74
,
fDigiScheme
(NULL)
75
,
fPoints
(NULL)
76
,
fDigis
(NULL)
77
,
fDigiMatches
(NULL)
78
,
fNPoints
(0)
79
,
fNFailed
(0)
80
,
fNOutside
(0)
81
,
fNMulti
(0)
82
,
fNDigis
(0)
83
,
fTimer
()
84
,
fChannelMap
()
85
{
86
Reset
();
87
}
88
// -------------------------------------------------------------------------
89
90
// ----- Constructor with name -----------------------------------------
91
CbmStsIdealDigitize::CbmStsIdealDigitize
(
const
char
* name,
Int_t
iVerbose)
92
:
FairTask
(name, iVerbose)
93
,
fGeoPar
(NULL)
94
,
fDigiPar
(NULL)
95
,
fDigiScheme
(NULL)
96
,
fPoints
(NULL)
97
,
fDigis
(NULL)
98
,
fDigiMatches
(NULL)
99
,
fNPoints
(0)
100
,
fNFailed
(0)
101
,
fNOutside
(0)
102
,
fNMulti
(0)
103
,
fNDigis
(0)
104
,
fTimer
()
105
,
fChannelMap
()
106
{
107
fDigiScheme
=
new
CbmStsDigiScheme
();
108
Reset
();
109
}
110
// -------------------------------------------------------------------------
111
112
// ----- Destructor ----------------------------------------------------
113
CbmStsIdealDigitize::~CbmStsIdealDigitize
()
114
{
115
if
(
fGeoPar
)
116
delete
fGeoPar
;
117
if
(
fDigiPar
)
118
delete
fDigiPar
;
119
if
(
fDigis
) {
120
fDigis
->Delete();
121
delete
fDigis
;
122
}
123
if
(
fDigiMatches
) {
124
fDigiMatches
->Delete();
125
delete
fDigiMatches
;
126
}
127
if
(
fDigiScheme
)
128
delete
fDigiScheme
;
129
Reset
();
130
}
131
// -------------------------------------------------------------------------
132
133
// ----- Public method Exec --------------------------------------------
134
void
CbmStsIdealDigitize::Exec
(
Option_t
* opt)
135
{
136
137
// Reset all eventwise counters
138
fTimer
.Start();
139
Reset
();
140
141
// Verbose screen output
142
if
(fVerbose > 2) {
143
cout << endl <<
"-I- "
<< fName <<
": executing event"
<< endl;
144
cout <<
"----------------------------------------------"
<< endl;
145
}
146
147
// Loop over all StsPoints
148
if
(!
fPoints
) {
149
cerr <<
"-W- "
<< fName <<
"::Exec: No input array (STSPoint) "
<< endl;
150
cout <<
"- "
<< fName << endl;
151
return
;
152
}
153
154
for
(
Int_t
iPoint = 0; iPoint <
fPoints
->GetEntriesFast(); iPoint++) {
155
CbmStsPoint
* point = (
CbmStsPoint
*)
fPoints
->At(iPoint);
156
fNPoints
++;
157
158
Double_t
xIn = point->
GetXIn
();
159
Double_t
yIn = point->
GetYIn
();
160
Double_t
zIn = point->
GetZIn
();
161
162
gGeoManager
->FindNode(xIn, yIn, zIn);
163
TGeoNode
* curNode =
gGeoManager
->GetCurrentNode();
164
165
// AZ CbmStsSensor* sensor = fDigiScheme->GetSensorByName(curNode->GetName());
166
// AZ
167
CbmStsSensor
* sensor = NULL;
168
if
(
fDigiScheme
->IsNewGeometry()) {
169
TString
curPath =
fDigiScheme
->GetCurrentPath();
170
sensor =
fDigiScheme
->GetSensorByName(curPath);
171
}
else
172
sensor =
fDigiScheme
->GetSensorByName(curNode->
GetName
());
173
// AZ
174
175
if
(!sensor)
176
LOG(fatal) <<
"No sensor in DigiScheme with name: "
<< curNode->
GetName
();
177
178
Int_t
stationNr = sensor->
GetStationNr
();
179
Int_t
sectorNr = sensor->
GetSectorNr
();
180
181
// Take point coordinates in the midplane of the sensor
182
if
(!point->
IsUsable
())
183
continue
;
184
Double_t
xpt = point->
GetX
(sensor->
GetZ0
());
185
Double_t
ypt = point->
GetY
(sensor->
GetZ0
());
186
187
Int_t
iChan = -1;
188
Int_t
channelF = -1;
189
Int_t
channelB = -1;
190
191
iChan = sensor->
GetChannel
(xpt, ypt, 0);
192
193
// point outside active sensor area
194
if
(iChan < 0) {
195
if
(fVerbose) {
196
Float_t
tempX = sensor->
GetX0
();
197
Float_t
tempY = sensor->
GetY0
();
198
Float_t
rot = sensor->
GetRotation
();
199
Float_t
tempLX = sensor->
GetLx
() / 2. *
TMath::Cos
(rot) + sensor->
GetLy
() / 2. *
TMath::Sin
(rot);
200
Float_t
tempLY = sensor->
GetLy
() / 2. *
TMath::Cos
(rot) + sensor->
GetLx
() / 2. *
TMath::Sin
(rot);
201
202
cout.precision(8);
203
cout << fName <<
". Warning: Point "
<< xpt <<
", "
<< ypt <<
", "
<< sensor->
GetZ0
()
204
<<
" not inside sector."
<< endl;
205
}
206
continue
;
207
}
208
209
channelF = iChan;
210
211
Int_t
sectorDetId = 2 << 24 | stationNr << 16 | sectorNr << 4;
212
213
// Treat front side
214
pair<Int_t, Int_t> a(sectorDetId, channelF);
215
if
(
fChannelMap
.find(a) ==
fChannelMap
.end()) {
216
// Channel not yet active. Create new Digi and Match.
217
new
((*fDigis)[
fNDigis
])
CbmStsDigi
(stationNr, sectorNr, 0, channelF, 0, 0);
218
new
((*fDigiMatches)[
fNDigis
])
CbmStsDigiMatch
(iPoint);
219
fChannelMap
[a] =
fNDigis
;
220
fNDigis
++;
221
}
else
{
222
// Channel already active. Update DigiMatch.
223
Int_t
iDigi =
fChannelMap
[a];
224
CbmStsDigiMatch
*
match
=
dynamic_cast<
CbmStsDigiMatch
*
>
(
fDigiMatches
->At(iDigi));
225
if
(
match
) {
226
match
->AddPoint(iPoint);
227
fNMulti
++;
228
}
229
}
230
231
// Treat back side (strip sensors only)
232
if
(sensor->
GetType
() < 2 || sensor->
GetType
() > 3)
233
continue
;
234
235
iChan = sensor->
GetChannel
(xpt, ypt, 1);
236
if
(iChan < 0) {
237
cerr <<
"-W- "
<< fName <<
"::Exec: No back side channel "
238
<<
" for StsPoint "
<< iPoint <<
", station "
<< stationNr <<
", sector "
<< sectorNr
239
<<
", front side channel "
<< channelF << endl;
240
continue
;
241
}
242
sectorDetId = sectorDetId | (1 << 0);
// for back side channel
243
channelB = iChan;
244
pair<Int_t, Int_t> b(sectorDetId, channelB);
245
if
(
fChannelMap
.find(b) ==
fChannelMap
.end()) {
246
// Channel not yet active. Create new Digi and Match.
247
new
((*fDigis)[
fNDigis
])
CbmStsDigi
(stationNr, sectorNr, 1, channelB, 0, 0);
248
new
((*fDigiMatches)[
fNDigis
])
CbmStsDigiMatch
(iPoint);
249
fChannelMap
[b] =
fNDigis
;
250
fNDigis
++;
251
}
else
{
252
// Channel already active. Update DigiMatch.
253
Int_t
iDigi =
fChannelMap
[b];
254
CbmStsDigiMatch
*
match
=
dynamic_cast<
CbmStsDigiMatch
*
>
(
fDigiMatches
->At(iDigi));
255
if
(
match
) {
256
match
->AddPoint(iPoint);
257
fNMulti
++;
258
}
259
}
260
261
// Verbose screen output
262
if
(fVerbose > 2) {
263
cout.precision(6);
264
cout <<
"StsPoint "
<< iPoint <<
", station "
<< stationNr <<
", ("
<< xpt <<
", "
<< ypt <<
") cm, sector "
265
<< sectorNr <<
", front "
<< channelF <<
", back "
<< channelB << endl;
266
}
267
268
// Not found in any sector?
269
if
(sectorNr == -1)
270
fNOutside
++;
271
272
}
// StsPoint loop
273
274
// Screen output
275
fTimer
.Stop();
276
if
(fVerbose) {
277
cout <<
"+ "
;
278
cout << setw(15) << left << fName <<
": "
<< setprecision(4) << setw(8) << fixed << right <<
fTimer
.RealTime()
279
<<
" s, points "
<<
fNPoints
<<
", failed "
<<
fNFailed
<<
", outside "
<<
fNOutside
<<
", multihits "
280
<<
fNMulti
<<
", digis "
<<
fNDigis
<< endl;
281
}
282
}
283
// -------------------------------------------------------------------------
284
285
// ----- Private method SetParContainers -------------------------------
286
void
CbmStsIdealDigitize::SetParContainers
()
287
{
288
289
// Get run and runtime database
290
FairRunAna* run = FairRunAna::Instance();
291
if
(!run)
292
Fatal
(
"SetParContainers"
,
"No analysis run"
);
293
294
FairRuntimeDb* db = run->GetRuntimeDb();
295
if
(!db)
296
Fatal
(
"SetParContainers"
,
"No runtime database"
);
297
298
// Get STS geometry parameter container
299
fGeoPar
= (
CbmGeoStsPar
*)db->getContainer(
"CbmGeoStsPar"
);
300
301
// Get STS digitisation parameter container
302
fDigiPar
= (
CbmStsDigiPar
*)db->getContainer(
"CbmStsDigiPar"
);
303
}
304
// -------------------------------------------------------------------------
305
306
// ----- Private method Init -------------------------------------------
307
InitStatus
CbmStsIdealDigitize::Init
()
308
{
309
310
// Get input array
311
FairRootManager* ioman = FairRootManager::Instance();
312
if
(!ioman)
313
Fatal
(
"Init"
,
"No FairRootManager"
);
314
fPoints
= (
TClonesArray
*)ioman->GetObject(
"StsPoint"
);
315
316
// Register output array StsDigi
317
fDigis
=
new
TClonesArray
(
"CbmStsDigi"
, 1000);
318
ioman->Register(
"StsDigi"
,
"Digital response in STS"
,
fDigis
,
kTRUE
);
319
320
// Register output array StsDigiMatches
321
fDigiMatches
=
new
TClonesArray
(
"CbmStsDigiMatch"
, 1000);
322
ioman->Register(
"StsDigiMatch"
,
"Digi Match in STS"
,
fDigiMatches
,
kTRUE
);
323
324
// Build digitisation scheme
325
if
(
fDigiScheme
->Init(
fGeoPar
,
fDigiPar
)) {
326
if
(fVerbose == 1 || fVerbose == 2)
327
fDigiScheme
->Print(
kFALSE
);
328
else
if
(fVerbose > 2)
329
fDigiScheme
->Print(
kTRUE
);
330
cout <<
"-I- "
<< fName <<
"::Init: "
331
<<
"STS digitisation scheme succesfully initialised"
<< endl;
332
cout <<
" Stations: "
<<
fDigiScheme
->GetNStations() <<
", Sectors: "
<<
fDigiScheme
->GetNSectors()
333
<<
", Channels: "
<<
fDigiScheme
->GetNChannels() << endl;
334
return
kSUCCESS;
335
}
336
337
return
kERROR;
338
}
339
// -------------------------------------------------------------------------
340
341
// ----- Private method ReInit -----------------------------------------
342
InitStatus
CbmStsIdealDigitize::ReInit
()
343
{
344
345
// Clear digitisation scheme
346
fDigiScheme
->Clear();
347
348
// Build new digitisation scheme
349
if
(
fDigiScheme
->Init(
fGeoPar
,
fDigiPar
))
350
return
kSUCCESS;
351
352
return
kERROR;
353
}
354
// -------------------------------------------------------------------------
355
356
// ----- Private method Reset ------------------------------------------
357
void
CbmStsIdealDigitize::Reset
()
358
{
359
fNPoints
=
fNFailed
=
fNOutside
=
fNMulti
=
fNDigis
= 0;
360
fChannelMap
.clear();
361
// if ( fDigis ) fDigis->Clear();
362
// if ( fDigiMatches ) fDigiMatches->Clear();
363
if
(
fDigis
)
364
fDigis
->Delete();
365
if
(
fDigiMatches
)
366
fDigiMatches
->Delete();
367
}
368
// -------------------------------------------------------------------------
CbmStsIdealDigitize.h
Int_t
int Int_t
Float_t
float Float_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Option_t
const char Option_t
TClonesArray.h
Fatal
void Fatal(const char *location, const char *msgfmt,...)
TGeoManager.h
gGeoManager
R__EXTERN TGeoManager * gGeoManager
TGeoNode.h
TMath.h
TObjArray.h
CbmGeoStsPar
Definition
CbmGeoStsPar.h:8
CbmStsDigiMatch
CbmStsDigiMatch.h.
Definition
CbmStsDigiMatch.h:27
CbmStsDigiPar
Definition
CbmStsDigiPar.h:31
CbmStsDigiScheme
Definition
CbmStsDigiScheme.h:36
CbmStsDigi
CbmStsDigi.h.
Definition
CbmStsDigi.h:32
CbmStsIdealDigitize::~CbmStsIdealDigitize
virtual ~CbmStsIdealDigitize()
Destructor.
Definition
CbmStsIdealDigitize.cxx:113
CbmStsIdealDigitize::fNMulti
Int_t fNMulti
Definition
CbmStsIdealDigitize.h:62
CbmStsIdealDigitize::fPoints
TClonesArray * fPoints
Digitisation scheme.
Definition
CbmStsIdealDigitize.h:56
CbmStsIdealDigitize::fNPoints
Int_t fNPoints
Output array of CbmStsDigiMatches.
Definition
CbmStsIdealDigitize.h:59
CbmStsIdealDigitize::fDigiPar
CbmStsDigiPar * fDigiPar
Geometry parameter container.
Definition
CbmStsIdealDigitize.h:54
CbmStsIdealDigitize::fGeoPar
CbmGeoStsPar * fGeoPar
Definition
CbmStsIdealDigitize.h:53
CbmStsIdealDigitize::fDigiScheme
CbmStsDigiScheme * fDigiScheme
Digitisation parameter container.
Definition
CbmStsIdealDigitize.h:55
CbmStsIdealDigitize::Exec
virtual void Exec(Option_t *opt)
Execution.
Definition
CbmStsIdealDigitize.cxx:134
CbmStsIdealDigitize::fDigis
TClonesArray * fDigis
Input array of CbmStsPoint.
Definition
CbmStsIdealDigitize.h:57
CbmStsIdealDigitize::fNDigis
Int_t fNDigis
Definition
CbmStsIdealDigitize.h:63
CbmStsIdealDigitize::SetParContainers
virtual void SetParContainers()
Get parameter containers.
Definition
CbmStsIdealDigitize.cxx:286
CbmStsIdealDigitize::Reset
void Reset()
Reset eventwise counters.
Definition
CbmStsIdealDigitize.cxx:357
CbmStsIdealDigitize::fNOutside
Int_t fNOutside
Definition
CbmStsIdealDigitize.h:61
CbmStsIdealDigitize::fChannelMap
std::map< std::pair< Int_t, Int_t >, Int_t > fChannelMap
Map of active channels (pair detectorId, channel number) to index of StsDigi.
Definition
CbmStsIdealDigitize.h:68
CbmStsIdealDigitize::fDigiMatches
TClonesArray * fDigiMatches
Output array of CbmStsDigi.
Definition
CbmStsIdealDigitize.h:58
CbmStsIdealDigitize::CbmStsIdealDigitize
CbmStsIdealDigitize()
Default constructor.
Definition
CbmStsIdealDigitize.cxx:49
CbmStsIdealDigitize::Init
virtual InitStatus Init()
Intialisation.
Definition
CbmStsIdealDigitize.cxx:307
CbmStsIdealDigitize::ReInit
virtual InitStatus ReInit()
Reinitialisation.
Definition
CbmStsIdealDigitize.cxx:342
CbmStsIdealDigitize::fNFailed
Int_t fNFailed
Definition
CbmStsIdealDigitize.h:60
CbmStsIdealDigitize::fTimer
TStopwatch fTimer
Definition
CbmStsIdealDigitize.h:64
CbmStsPoint
Definition
CbmStsPoint.h:23
CbmStsPoint::IsUsable
Bool_t IsUsable() const
Check for distance between in and out.
Definition
CbmStsPoint.cxx:114
CbmStsPoint::GetY
Double_t GetY(Double_t z) const
Definition
CbmStsPoint.cxx:103
CbmStsPoint::GetX
Double_t GetX(Double_t z) const
Point coordinates at given z from linear extrapolation.
Definition
CbmStsPoint.cxx:92
CbmStsPoint::GetXIn
Double_t GetXIn() const
Accessors.
Definition
CbmStsPoint.h:64
CbmStsPoint::GetZIn
Double_t GetZIn() const
Definition
CbmStsPoint.h:66
CbmStsPoint::GetYIn
Double_t GetYIn() const
Definition
CbmStsPoint.h:65
CbmStsSensor
Definition
CbmStsSensor.h:44
CbmStsSensor::GetZ0
Double_t GetZ0() const
Definition
CbmStsSensor.h:110
CbmStsSensor::GetRotation
Double_t GetRotation() const
Definition
CbmStsSensor.h:111
CbmStsSensor::GetType
Int_t GetType() const
Definition
CbmStsSensor.h:107
CbmStsSensor::GetX0
Double_t GetX0() const
Definition
CbmStsSensor.h:108
CbmStsSensor::GetLy
Double_t GetLy() const
Definition
CbmStsSensor.h:113
CbmStsSensor::GetSectorNr
Int_t GetSectorNr() const
Definition
CbmStsSensor.h:97
CbmStsSensor::GetStationNr
Int_t GetStationNr() const
Definition
CbmStsSensor.h:96
CbmStsSensor::GetChannel
Int_t GetChannel(Double_t x, Double_t y, Int_t iSide)
Calculate channel number for a coordinate pair.
Definition
CbmStsSensor.cxx:373
CbmStsSensor::GetY0
Double_t GetY0() const
Definition
CbmStsSensor.h:109
CbmStsSensor::GetLx
Double_t GetLx() const
Definition
CbmStsSensor.h:112
FairTask
TClonesArray
TGeoNode
TNamed::GetName
const char * GetName() const override
TString
CbmGeoStsPar.h
CbmStsDigiMatch.h
CbmStsDigiPar.h
CbmStsDigiScheme.h
CbmStsDigi.h
CbmStsSector.h
CbmStsSensor.h
CbmStsStation.h
TMath::Cos
Double_t Cos(Double_t)
TMath::Sin
Double_t Sin(Double_t)
match
Definition
BmnMwpcTrackFinder.cxx:27
detectors
sts
CbmStsIdealDigitize.cxx
Generated on
for BmnRoot by
1.17.0