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