BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnSiProfDigitizer.cxx
Go to the documentation of this file.
2
3#include "BmnSiProfPoint.h"
4#include "CbmMCTrack.h"
5#include "FairRootManager.h"
6#include "TSystem.h"
7
8static Float_t workTime = 0.0;
9static int entrys = 0;
10
14{
15
16 fInputBranchName = "SiProfPoint";
17 fOutputDigitsBranchName = "BmnSiProfDigit";
18 fOutputDigitMatchesBranchName = "BmnSiProfDigitMatch";
19
20 fVerbose = 1;
21
23 StationSet = nullptr;
24 GlobalModTransfSet = nullptr;
25}
26
29{
30 switch (run_period) {
31 case 8: // BM@N RUN-8
33 break;
34 case 9: // BM@N RUN-9
36 break;
37
38 default:
40 }
41}
42
44{
45 if (StationSet) {
46 delete StationSet;
47 }
48
50 delete GlobalModTransfSet;
51 }
52}
53
55{
56 if (fVerbose)
57 cout << "\nBmnSiProfDigitizer::Init()\n ";
58
59 if (fVerbose && fOnlyPrimary)
60 cout << " Only primary particles are processed!!! " << endl;
61
62 if (fVerbose && fStripMatching)
63 cout << " Strip Matching is activated!!! " << endl;
64 else
65 cout << " Strip Matching is deactivated!!! " << endl;
66
67 FairRootManager* ioman = FairRootManager::Instance();
68
71 cout << "BmnSiProfDigitizer::Init(): branch " << fInputBranchName << " not found! Task will be deactivated"
72 << endl;
73 SetActive(kFALSE);
74 return kERROR;
75 }
76
77 fMCTracksArray = (TClonesArray*)ioman->GetObject("MCTrack");
78
80 ioman->Register(fOutputDigitsBranchName, "SiProf_DIGIT", fBmnSiProfDigitsArray, kTRUE);
81
82 if (fStripMatching) {
84 ioman->Register(fOutputDigitMatchesBranchName, "SiProf_DIGIT", fBmnSiProfDigitMatchesArray, kTRUE);
85 }
86
87 TString gPathSiProfConfig = gSystem->Getenv("VMCWORKDIR");
88 gPathSiProfConfig += "/parameters/profilometer/XMLConfigs/";
89
90 // Create SiProf detector ------------------------------------------------------
91 switch (fCurrentConfig) {
93 XMLConfigFile = gPathSiProfConfig + "ProfRun8.xml";
94 if (fVerbose)
95 cout << " Current SiProf Configuration : Run8"
96 << "\n";
97 break;
98
100 XMLConfigFile = gPathSiProfConfig + "ProfRun9.xml";
101 if (fVerbose)
102 cout << " Current SiProf Configuration : Run9"
103 << "\n";
104 break;
105
106 default:;
107 }
108
109 if (!gSystem->AccessPathName(XMLConfigFile)) { // returns FALSE if the file exists
110 if (fVerbose)
111 cout << " XMLConfigFile : " << XMLConfigFile << "\n";
114 GlobalModTransfSet->LoadFromXMLFile(XMLConfigFile);
115 } else {
116 Fatal("BmnSiProfDigitizer::Init()", " !!! Current configuration is not set !!! ");
117 }
118
119 //--------------------------------------------------------------------------
120
121 if (fVerbose)
122 cout << "BmnSiProfDigitizer::Init() finished\n\n";
123 return kSUCCESS;
124}
125
127{
128
129 if (!IsActive())
130 return;
131
132 clock_t tStart = clock();
133 fBmnSiProfDigitsArray->Delete();
134
135 if (fStripMatching) {
137 }
138
140 Error("BmnSiProfDigitizer::Exec()", " !!! Unknown branch name !!! ");
141 return;
142 }
143
144 if (fVerbose) {
145 cout << " BmnSiProfDigitizer::Exec(), Number of BmnSiProfPoints = " << fBmnSiProfPointsArray->GetEntriesFast()
146 << "\n";
147 }
148
150
151 if (fVerbose)
152 cout << " BmnSiProfDigitizer::Exec() finished\n\n";
153 entrys++;
154 clock_t tFinish = clock();
155 workTime += ((Float_t)(tFinish - tStart)) / CLOCKS_PER_SEC;
156}
157
159{
160
161 FairMCPoint* SiProfPoint;
162 Int_t NNotPrimaries = 0;
163
164 for (Int_t ipoint = 0; ipoint < fBmnSiProfPointsArray->GetEntriesFast(); ipoint++) {
165 SiProfPoint = (FairMCPoint*)fBmnSiProfPointsArray->At(ipoint);
166
167 if (fOnlyPrimary) {
168 CbmMCTrack* track = (CbmMCTrack*)fMCTracksArray->UncheckedAt(SiProfPoint->GetTrackID());
169 if (!track)
170 continue;
171 if (track->GetMotherId() != -1) {
172 NNotPrimaries++;
173 continue;
174 }
175 }
176
177 Double_t x = -SiProfPoint->GetX(); // invert because in the current geometry +x is left, -x is right
178 Double_t y = SiProfPoint->GetY();
179 Double_t z = SiProfPoint->GetZ();
180
181 Double_t px = -SiProfPoint->GetPx(); // invert because in the current geometry +x is left, -x is right
182 Double_t py = SiProfPoint->GetPy();
183 Double_t pz = SiProfPoint->GetPz();
184
185 Double_t dEloss = SiProfPoint->GetEnergyLoss() * 1e6; // in keV
186 Int_t refId = ipoint;
187
188 // Information from MC-points
189 Int_t mc_station_num = ((BmnSiProfPoint*)SiProfPoint)->GetStation();
190 Int_t mc_module_num = ((BmnSiProfPoint*)SiProfPoint)->GetModule();
191
192 // test output
193 // cout << "mc_station_num = " << mc_station_num << "\n";
194 // cout << "mc_module_num = " << mc_module_num << "\n";
195
196 // Apply inverse global module transforms to MC-point (in right-handed system)
197 if (GlobalModTransfSet && mc_station_num < StationSet->GetNStations()) {
198 if (mc_module_num < StationSet->GetStation(mc_station_num)->GetNModules()) {
199 Plane3D::Point point_transformed =
200 GlobalModTransfSet->ApplyInverseTransforms(Plane3D::Point(-x, y, z), mc_station_num, mc_module_num);
201 Plane3D::Point direction_transformed = GlobalModTransfSet->ApplyInverseTransforms(
202 Plane3D::Point(-(px + x), (py + y), (pz + z)), mc_station_num, mc_module_num);
203 x = -point_transformed.X(); // convert to detector system (x-inverted)
204 y = point_transformed.Y();
205 z = point_transformed.Z();
206
207 px = -(direction_transformed.X() - point_transformed.X()); // convert to detector system (x-inverted)
208 py = direction_transformed.Y() - point_transformed.Y();
209 pz = direction_transformed.Z() - point_transformed.Z();
210 }
211 }
212
213 StationSet->AddPointToDetector(x, y, z, px, py, pz, dEloss, refId);
214 }
215
216 Int_t NAddedPoints = StationSet->CountNAddedToDetectorPoints();
217 if (fVerbose && fOnlyPrimary)
218 cout << " Number of not primaries points : " << NNotPrimaries << "\n";
219 if (fVerbose)
220 cout << " Processed MC points : " << NAddedPoints << "\n";
221
222 for (Int_t iStation = 0; iStation < StationSet->GetNStations(); ++iStation) {
223 BmnSiProfStation* station = StationSet->GetStation(iStation);
224
225 for (Int_t iModule = 0; iModule < station->GetNModules(); ++iModule) {
226 BmnSiProfModule* module = station->GetModule(iModule);
227
228 for (Int_t iLayer = 0; iLayer < module->GetNStripLayers(); ++iLayer) {
229 BmnSiProfLayer layer = module->GetStripLayer(iLayer);
230
231 for (Int_t iStrip = 0; iStrip < layer.GetNStrips(); ++iStrip) {
232 Double_t signal = layer.GetStripSignal(iStrip);
233 if (signal > 0.0) {
234 new ((*fBmnSiProfDigitsArray)[fBmnSiProfDigitsArray->GetEntriesFast()])
235 BmnSiProfDigit(iStation, iModule, iLayer, iStrip, signal);
236
237 if (fStripMatching) {
238 new ((*fBmnSiProfDigitMatchesArray)[fBmnSiProfDigitMatchesArray->GetEntriesFast()])
239 BmnMatch(layer.GetStripMatch(iStrip));
240 }
241 }
242 }
243 }
244 }
245 }
246 StationSet->Reset();
247}
248
250{
251 if (StationSet) {
252 delete StationSet;
253 StationSet = nullptr;
254 }
255
256 if (GlobalModTransfSet) {
257 delete GlobalModTransfSet;
258 GlobalModTransfSet = nullptr;
259 }
260
261 cout << "Work time of the SiProf digitizer: " << workTime << endl;
262}
static int entrys
int Int_t
float Float_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
void Error(const char *location, const char *msgfmt,...)
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TSystem * gSystem
TClonesArray * fBmnSiProfDigitsArray
Output array of SiProf Digits.
virtual InitStatus Init()
BmnSiProfStationSet * StationSet
TClonesArray * fBmnSiProfDigitMatchesArray
Output array of SiProf Digit Matches.
TClonesArray * fMCTracksArray
Input array of MC Tracks.
BmnSiProfTransform * GlobalModTransfSet
TString fOutputDigitMatchesBranchName
virtual void Exec(Option_t *opt)
TClonesArray * fBmnSiProfPointsArray
Input array of SiProf Points.
BmnSiProfConfiguration::SiProf_CONFIG fCurrentConfig
Double_t GetStripSignal(Int_t strip_num)
BmnMatch GetStripMatch(Int_t strip_num)
BmnSiProfModule * GetModule(Int_t module_num)
CbmMCTrack.h.
Definition CbmMCTrack.h:26
Int_t GetMotherId() const
Definition CbmMCTrack.h:57
PositionVector3D< Cartesian3D< T >, DefaultCoordinateSystemTag > Point