CbmRoot
Loading...
Searching...
No Matches
CbmMuchTest.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2019 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Grigory Kozlov, Andrey Lebedev [committer] */
4
5/*
6 * CbmMuchTest.cxx
7 *
8 * Created on: May 2, 2012
9 * Author: kozlov
10 */
11
12#include "CbmMuchTest.h"
13
15#include "CbmMCTrack.h"
16#include "CbmMuchDigi.h"
17#include "CbmMuchGeoScheme.h"
18#include "CbmMuchLayer.h"
19#include "CbmMuchLayerSide.h"
20#include "CbmMuchModuleGem.h"
21#include "CbmMuchPad.h"
22#include "CbmMuchPixelHit.h"
23#include "CbmMuchPoint.h"
24#include "CbmMuchStation.h"
25#include "CbmStsHit.h"
26#include "CbmStsPoint.h"
27#include "FairRootManager.h"
28#include "TClonesArray.h"
29
30#include <cassert>
31#include <iostream>
32
33using std::cout;
34using std::endl;
35
37 : fMeanErrorOnXforSubCenters()
38 , fMeanErrorOnYforSubCenters()
39 , fErrorsOnXforSubCenters()
40 , fErrorsOnYforSubCenters()
41 , fEfficiencyForSubCenters()
42 , fEfficiency()
43 , fMeanErrorOnY()
44 , fMeanErrorOnX()
45 , fClusters()
46 , fErrorsOnX()
47 , fErrorsOnY()
48{
49 fNofPoints = 0;
50 //fNofHits = 0;
51 fSubStep = 0;
53 fNofClusters = 0;
54 fRealPoints = 0;
55}
56
57CbmMuchTest::CbmMuchTest(Int_t nofPoints, Float_t subStep)
58 : fMeanErrorOnXforSubCenters()
59 , fMeanErrorOnYforSubCenters()
60 , fErrorsOnXforSubCenters()
61 , fErrorsOnYforSubCenters()
62 , fMeanErrorOnY()
63 , fMeanErrorOnX()
64 , fErrorsOnX()
65 , fErrorsOnY()
66 , fEfficiencyForSubCenters()
67 , fEfficiency()
68 , fClusters()
69{
70 fNofPoints = nofPoints;
71 fSubStep = subStep;
74 fNofClusters = 0;
75}
76
78
80{
81 Float_t pLenght = 0;
82 for (Int_t iPoint = 0; iPoint < fNofPoints; iPoint++) {
83 pLenght =
84 sqrt((fRealPoints[iPoint].x1 - fRealPoints[iPoint].x2) * (fRealPoints[iPoint].x1 - fRealPoints[iPoint].x2)
85 + (fRealPoints[iPoint].y1 - fRealPoints[iPoint].y2) * (fRealPoints[iPoint].y1 - fRealPoints[iPoint].y2));
86 fRealPoints[iPoint].pLenght = pLenght;
87 //std::cout<<"pLenght: "<<pLenght<<"; Step: "<<fSubStep<<"\n";
88 if (pLenght < (fSubStep * 2)) {
89 fRealPoints[iPoint].xc = (fRealPoints[iPoint].x1 + fRealPoints[iPoint].x2) / 2;
90 fRealPoints[iPoint].yc = (fRealPoints[iPoint].y1 + fRealPoints[iPoint].y2) / 2;
91 fRealPoints[iPoint].nofSubCenters = 1;
92 fRealPoints[iPoint].xSC[0] = fRealPoints[iPoint].xc;
93 fRealPoints[iPoint].ySC[0] = fRealPoints[iPoint].yc;
95 }
96 else {
97 Int_t Dstep = pLenght / fSubStep;
98 //std::cout<<"---Dstep: "<<Dstep<<"\n";
99 for (Int_t iStep = 0; iStep < Dstep; iStep++) {
100 fRealPoints[iPoint].xSC[iStep] =
101 fRealPoints[iPoint].x1 + (((fRealPoints[iPoint].x2 - fRealPoints[iPoint].x1) / Dstep) * (iStep + 1));
102 fRealPoints[iPoint].ySC[iStep] =
103 fRealPoints[iPoint].y1 + (((fRealPoints[iPoint].y2 - fRealPoints[iPoint].y1) / Dstep) * (iStep + 1));
105 //std::cout<<"------iStep: "<<iStep<<"; xSC: "<<fRealPoints[iPoint].xSC[iStep]<<"; ySC: "<<fRealPoints[iPoint].ySC[iStep]<<"\n";
106 }
107 }
108 }
109 //std::cout<<"fNofSubCenters: "<<fNofSubCenters<<"\n";
110}
111
112void CbmMuchTest::SetNPoints(Int_t nofPoints)
113{
114 fNofPoints = nofPoints;
116}
117/*void CbmMuchTest::SetNHits(Int_t nofHits)
118{
119 fNofHits = nofHits;
120}*/
121
122void CbmMuchTest::SetXIn(Float_t xIn, Int_t iPoint)
123{
124 if (iPoint >= fNofPoints) //Bad condition!!!
125 {
126 std::cout << "Error! fRealPoint is not declared!\n";
127 }
128 else {
129 fRealPoints[iPoint].x1 = xIn;
130 //std::cout<<"-> XIn: "<<fRealPoints[iPoint].x1<<" <- "<<iPoint<<"\n";
131 }
132}
133
134void CbmMuchTest::SetYIn(Float_t yIn, Int_t iPoint)
135{
136 if (iPoint >= fNofPoints) //Bad condition!!!
137 {
138 std::cout << "Error! fRealPoint is not declared!\n";
139 }
140 else {
141 fRealPoints[iPoint].y1 = yIn;
142 }
143}
144
145void CbmMuchTest::SetXOut(Float_t xOut, Int_t iPoint)
146{
147 if (iPoint >= fNofPoints) //Bad condition!!!
148 {
149 std::cout << "Error! fRealPoint is not declared!\n";
150 }
151 else {
152 fRealPoints[iPoint].x2 = xOut;
153 }
154}
155
156void CbmMuchTest::SetYOut(Float_t yOut, Int_t iPoint)
157{
158 if (iPoint >= fNofPoints) //Bad condition!!!
159 {
160 std::cout << "Error! fRealPoint is not declared!\n";
161 }
162 else {
163 fRealPoints[iPoint].y2 = yOut;
164 }
165}
166
167void CbmMuchTest::SetSubStep(Int_t iStep) { fSubStep = iStep; }
168
170{
171 fNofClusters = NCl;
173 fErrorsOnX = new Float_t[fNofClusters];
174 fErrorsOnY = new Float_t[fNofClusters];
177 fEfficiency = 0;
179}
180void CbmMuchTest::SetNCl(Int_t nCl, Int_t iCl)
181{
182 if (fNofClusters == 0) {
183 std::cout << "Error! fClusters is not declared!\n";
184 }
185 else {
186 fClusters[iCl].nofCluster = nCl;
187 }
188}
189void CbmMuchTest::SetXCl(Float_t xCl, Int_t iCl)
190{
191 if (fNofClusters == 0) {
192 std::cout << "Error! fClusters is not declared!\n";
193 }
194 else {
195 fClusters[iCl].xc = xCl;
196 }
197}
198void CbmMuchTest::SetYCl(Float_t yCl, Int_t iCl)
199{
200 if (fNofClusters == 0) {
201 std::cout << "Error! fClusters is not declared!\n";
202 }
203 else {
204 fClusters[iCl].yc = yCl;
205 }
206}
207void CbmMuchTest::SetCharge(UInt_t chCl, Int_t iCl)
208{
209 if (fNofClusters == 0) {
210 std::cout << "Error! fClusters is not declared!\n";
211 }
212 else {
213 fClusters[iCl].sumClCharge = chCl;
214 }
215}
216void CbmMuchTest::SetNPads(Int_t nofPads, Int_t iCl)
217{
218 if (fNofClusters == 0) {
219 std::cout << "Error! fClusters is not declared!\n";
220 }
221 else {
222 fClusters[iCl].nofPads = nofPads;
223 }
224}
225void CbmMuchTest::SetPadInCl(Int_t nPad, Int_t iCl, Int_t iPad)
226{
227 if (fNofClusters == 0) {
228 std::cout << "Error! fClusters is not declared!\n";
229 }
230 else {
231 fClusters[iCl].padsInCluster[iPad] = nPad;
232 }
233}
234void CbmMuchTest::SetCluster(Int_t nCl, Float_t xCl, Float_t yCl, UInt_t chCl, Int_t nofPads, Int_t iCl)
235{
236 if (fNofClusters == 0) {
237 std::cout << "Error! fClusters is not declared!\n";
238 }
239 else {
240 fClusters[iCl].nofCluster = nCl;
241 fClusters[iCl].xc = xCl;
242 fClusters[iCl].yc = yCl;
243 fClusters[iCl].sumClCharge = chCl;
244 fClusters[iCl].nofPads = nofPads;
245 }
246}
247
249{
250 /*std::cout<<"Start\n";
251 std::cout<<"fNofClusters: "<<fNofClusters<<"\n";
252 std::cout<<"fNofPoints: "<<fNofPoints<<"\n";*/
253 fEfficiency = 100.0 * (Float_t) fNofClusters / (Float_t) fNofPoints;
254 fEfficiencyForSubCenters = 100.0 * (Float_t) fNofClusters / (Float_t) fNofSubCenters;
255}
257{
258 fMeanErrorOnX = 0;
259 fMeanErrorOnY = 0;
260 for (Int_t iCl = 0; iCl < fNofClusters; iCl++) {
261 fErrorsOnX[iCl] = 100000;
262 fErrorsOnY[iCl] = 100000;
263 fErrorsOnXforSubCenters[iCl] = 100000;
264 fErrorsOnYforSubCenters[iCl] = 100000;
265 //std::cout<<"-1----- "<<fMeanErrorOnX<<" --- "<<fMeanErrorOnY<<"\n";
266 Float_t r1 = 100000;
267 for (Int_t jCl = 0; jCl < fNofPoints; jCl++) {
268 Float_t r2 = sqrt((fClusters[iCl].xc - fRealPoints[jCl].xc) * (fClusters[iCl].xc - fRealPoints[jCl].xc)
269 + (fClusters[iCl].yc - fRealPoints[jCl].yc) * (fClusters[iCl].yc - fRealPoints[jCl].yc));
270 if (r2 < r1) {
271 r1 = r2;
272 fErrorsOnX[iCl] = fabs(fClusters[iCl].xc - fRealPoints[jCl].xc);
273 fErrorsOnY[iCl] = fabs(fClusters[iCl].yc - fRealPoints[jCl].yc);
274 }
275 /*Subcentral efficiency does not work
276 * The problem is in modules with different cell size.
277 * SV while calculating fErrorsOnYforSubCenters[iCl].
278 * The problem is with fRealPoints[jCl].ySC[kCl].
279 */
280 /*if(fRealPoints[jCl].nofSubCenters > 1)
281 {
282 for(Int_t kCl = 0; kCl < fRealPoints[jCl].nofSubCenters; kCl++)
283 {
284 r2 = sqrt((fClusters[iCl].xc - fRealPoints[jCl].xSC[kCl]) *
285 (fClusters[iCl].xc - fRealPoints[jCl].xSC[kCl]) +
286 (fClusters[iCl].yc - fRealPoints[jCl].ySC[kCl]) *
287 (fClusters[iCl].yc - fRealPoints[jCl].ySC[kCl]));
288 if(r2 < r1)
289 {
290 fErrorsOnXforSubCenters[iCl] = fabs(fClusters[iCl].xc - fRealPoints[jCl].xSC[kCl]);
291 fErrorsOnYforSubCenters[iCl] = fabs(fClusters[iCl].yc - fRealPoints[jCl].ySC[kCl]);
292 }
293 }
294 }
295 else
296 {*/
299 //}
300 }
305 //std::cout<<"-2----- "<<fMeanErrorOnX<<" --- "<<fMeanErrorOnY<<"\n";
306 }
311}
Class for pixel hits in MUCH detector.
Data class for a reconstructed hit in the STS.
friend fvec sqrt(const fvec &a)
void CalculateEfficiency()
Float_t * fErrorsOnYforSubCenters
void SetNCl(Int_t nCl, Int_t iCl)
Int_t fNofPoints
Definition CbmMuchTest.h:73
Float_t fSubStep
Definition CbmMuchTest.h:75
Float_t * fErrorsOnX
void SetPadInCl(Int_t nPad, Int_t iCl, Int_t iPad)
void CalculateAccuracy()
void SetNPoints(Int_t nofPoints)
Cluster * fClusters
void SetSubStep(Int_t iStep)
virtual ~CbmMuchTest()
Destructor.
Float_t fEfficiencyForSubCenters
void SetCluster(Int_t nCl, Float_t xCl, Float_t yCl, UInt_t chCl, Int_t nofPads, Int_t iCl)
Float_t * fErrorsOnY
void SetXCl(Float_t xCl, Int_t iCl)
void SetXIn(Float_t xIn, Int_t iPoint)
Float_t fMeanErrorOnY
M_Point * fRealPoints
Definition CbmMuchTest.h:85
Float_t fEfficiency
void SetCharge(UInt_t chCl, Int_t iCl)
Float_t * fErrorsOnXforSubCenters
void SetNPads(Int_t nofPads, Int_t iCl)
CbmMuchTest()
Constructor.
void SetYIn(Float_t yIn, Int_t iPoint)
void MainTesting()
Int_t fNofSubCenters
Definition CbmMuchTest.h:74
void SetXOut(Float_t xOut, Int_t iPoint)
void SetYCl(Float_t yCl, Int_t iCl)
Float_t fMeanErrorOnYforSubCenters
void SetYOut(Float_t yOut, Int_t iPoint)
Float_t fMeanErrorOnX
Int_t fNofClusters
Definition CbmMuchTest.h:94
void RebuildPoints()
Float_t fMeanErrorOnXforSubCenters
void SetNClusters(Int_t NCl)
Float_t ySC[fMaxSubCentersPerPoint]
Definition CbmMuchTest.h:83
Float_t xSC[fMaxSubCentersPerPoint]
Definition CbmMuchTest.h:82