FEDRA emulsion software from the OPERA Collaboration
bitview.cxx File Reference
#include "bitview.h"
#include <math.h>
#include "EdbSegment.h"
#include "Riostream.h"
#include "TMath.h"
#include "deriv.h"
Include dependency graph for bitview.cxx:

Functions

 ClassImp (TBinTracking)
 
 ClassImp (TBitView)
 
int CommonClusters (EdbSegment *seg0, EdbSegment *seg1)
 
float Distance (float xp, float yp, float zp, float x0, float y0, float z0, float teta, float phi)
 
float Distance (float xp, float yp, float zp, track tr)
 
float DistanceInNormalizeSpace (float xp, float yp, float zp, track tr, double dx, double dy, double dz)
 
int In (float X, float Y, float Xmin, float Xmax, float Ymin, float Ymax)
 
float max (TClonesArray *t)
 
float min (TClonesArray *t)
 
int MY_LFIT (float *X, float *Y, int L, int KEY, float &A, float &B, float &erA, float &erB, float &s)
 
void PreciseBasePosition (float zmin, float zmax, TClonesArray *dc, float &zup, float &zdown)
 
int SatCondAccept (track *tr, float xc, float yc, float zc, double dx, double dy, double dz, float accept)
 
TClonesArray * Smoothing (EdbView *v)
 
float sqr (float x)
 
void TrackAngle (track tr, float *teta, float *phi)
 

Function Documentation

◆ ClassImp() [1/2]

ClassImp ( TBinTracking  )

◆ ClassImp() [2/2]

ClassImp ( TBitView  )

◆ CommonClusters()

int CommonClusters ( EdbSegment seg0,
EdbSegment seg1 
)
29 {
30  EdbCluster *c0 = 0,
31  *c1 = 0;
32  int numCl0 = seg0->GetNelements(),
33  numCl1 = seg1->GetNelements();
34  for (int cc0=0; cc0<numCl0; cc0++) {
35  c0 = (EdbCluster *)(seg0->GetElements()->At(cc0));
36  for (int cc1=0; cc1<numCl1; cc1++) {
37  c1 = (EdbCluster *)(seg1->GetElements()->At(cc1));
38  if (c0==c1) return true;
39  }
40  }
41  return false;
42 }
Definition: EdbCluster.h:19
Int_t GetNelements() const
Definition: EdbSegment.h:112
TObjArray * GetElements() const
Definition: EdbSegment.h:115
TCanvas * c1
Definition: energy.C:13

◆ Distance() [1/2]

float Distance ( float  xp,
float  yp,
float  zp,
float  x0,
float  y0,
float  z0,
float  teta,
float  phi 
)
89 {
90  float r2,cos2,sin2,pr;
91  float x = xp-x0;
92  float y = yp-y0;
93  float z = zp-z0;
94 
95  r2=x*x+y*y+z*z;
96  pr=x*TMath::Sin(teta)*TMath::Cos(phi)+y*TMath::Sin(teta)*TMath::Sin(phi)+z*TMath::Cos(teta);
97  if (r2==0.0) {return (0.0);}
98  cos2=pr*pr/r2;
99  sin2=1-cos2;
100 
101 // printf("r2=%lf \n",r2*sin2);
102 
103  return TMath::Sqrt(r2*sin2);
104 }
brick z0
Definition: RecDispMC.C:106

◆ Distance() [2/2]

float Distance ( float  xp,
float  yp,
float  zp,
track  tr 
)
107 {
108  float xt = tr.x;
109  float yt = tr.y;
110  float zt = tr.z;
111  float teta, phi;
112 
113  TrackAngle(tr,&teta,&phi);
114  return Distance(xp,yp,zp,xt,yt,zt,teta,phi);
115 }
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
float Distance(float xp, float yp, float zp, float x0, float y0, float z0, float teta, float phi)
Definition: bitview.cxx:88
void TrackAngle(track tr, float *teta, float *phi)
Definition: bitview.cxx:45

◆ DistanceInNormalizeSpace()

float DistanceInNormalizeSpace ( float  xp,
float  yp,
float  zp,
track  tr,
double  dx,
double  dy,
double  dz 
)
119 {
120  float xpNorm = xp/dx;
121  float ypNorm = yp/dy;
122  float zpNorm = zp/dz;
123  track trNorm;
124  trNorm.x = tr.x/dx;
125  trNorm.y = tr.y/dy;
126  trNorm.z = tr.z/dz;
127  trNorm.tgx = tr.tgx * dz/dx;
128  trNorm.tgy = tr.tgy * dz/dy;
129  return Distance(xpNorm,ypNorm,zpNorm,trNorm);
130 }
brick dz
Definition: RecDispMC.C:107
Definition: bitview.h:14
double tgy
Definition: bitview.h:17
double z
Definition: bitview.h:20
double tgx
Definition: bitview.h:16
double x
Definition: bitview.h:18
double y
Definition: bitview.h:19

◆ In()

int In ( float  X,
float  Y,
float  Xmin,
float  Xmax,
float  Ymin,
float  Ymax 
)
inline
19 {
20  if ((X>=Xmin)&&(X<Xmax)&&(Y>=Ymin)&&(Y<Ymax)) return 1;
21  else return 0;
22 }
Double_t X
Definition: tlg2pattern.C:77
Double_t Y
Definition: tlg2pattern.C:77

◆ max()

float max ( TClonesArray *  t)
297  {
298 
299 int num = t->GetEntries();
300 float d,z;
301 float dmax = ((Deriv *)(t->At(0)))->GetD();
302 float zmax = ((Deriv *)(t->At(0)))->GetZ();
303 for (int i=1; i<num; i++) {
304  d=((Deriv *)(t->At(i)))->GetD();
305  z=((Deriv *)(t->At(i)))->GetZ();
306  if (d>dmax) {
307  zmax=z;
308  dmax=d;
309  }
310 }
311 return zmax;
312 }
void d()
Definition: RecDispEX.C:381
TTree * t
Definition: check_shower.C:4
Definition: deriv.h:7

◆ min()

float min ( TClonesArray *  t)
275  {
276 
277 int num = t->GetEntries();
278 //cout<<num<<endl;
279 float d,z;
280 float dmin = ((Deriv *)(t->At(0)))->GetD();
281 float zmin = ((Deriv *)(t->At(0)))->GetZ();
282 //cout<<" "<<zmin<<" "<<dmin<<endl;
283 for (int i=1; i<num; i++) {
284  d=((Deriv *)(t->At(i)))->GetD();
285  z=((Deriv *)(t->At(i)))->GetZ();
286 // cout<<" "<<z<<" "<<d<<" "<<endl;
287  if (d<dmin) {
288  zmin=z;
289  dmin=d;
290  }
291 }
292 //cout<<endl;
293 return zmin;
294 }

◆ MY_LFIT()

int MY_LFIT ( float *  X,
float *  Y,
int  L,
int  KEY,
float &  A,
float &  B,
float &  erA,
float &  erB,
float &  s 
)
181 {
182 
183  A=0; B=0; erA=0; erB=0; s=0;
184 
185  // CALCULTE SUMS
186  if(L<2) return false;
187 
188  double Ex=0.;
189  double Ey=0.;
190  double Sxx=0.;
191  double Syy=0.;
192  double Syx=0.;
193  int ICNT=0;
194  double SSE;
195  int j;
196 
197  for(j=0; j<L; j++ ){
198  if( Y[j]==0. && KEY==0 ) continue;
199  Ex+=X[j];
200  Ey+=Y[j];
201  ICNT++;
202  }
203 
204  if(ICNT<3) return false;
205 
206  Ex=Ex/(double)ICNT;
207  Ey=Ey/(double)ICNT;
208 
209  for(j=0; j<L; j++ ){
210  if( Y[j]==0. && KEY==0 ) continue;
211  Syx+=(Y[j]-Ey)*(X[j]-Ex);
212  Sxx+=(X[j]-Ex)*(X[j]-Ex);
213  Syy+=(Y[j]-Ey)*(Y[j]-Ey);
214  }
215 
216  if(Sxx==0.) return false;
217 
218 
219  A=Syx/Sxx;
220  B=Ey-A*Ex;
221 
222  SSE=Syy-A*Syx;
223 
224  s=sqrt(SSE/(double)(ICNT-2));
225 
226  erA=s/sqrt(Sxx);
227  erB=s*sqrt(1./(double)ICNT+Ex*Ex/Sxx);
228 
229  // printf("MYTEST!!!!!!!!!!! A= %lf , erA= %lf , B= %lf , erB= %lf \n",A,erA,B,erB);
230 
231 
232  return true;
233 }
struct @6 B
EdbSegP * s
Definition: tlg2pattern.C:32

◆ PreciseBasePosition()

void PreciseBasePosition ( float  zmin,
float  zmax,
TClonesArray *  dc,
float &  zup,
float &  zdown 
)
316 {
317  TH1F *h1min = new TH1F("h1min","h1min",20,zmin-5.,zmin+5.);
318  TH1F *h1max = new TH1F("h1max","h1max",20,zmax-5.,zmax+5.);
319  float z,d;
320  Deriv *D=0;
321  int N=dc->GetEntries();
322  for (int i=0; i<N; i++) {
323  D=(Deriv *)(dc->At(i));
324  z=D->GetZ();
325  d=D->GetD();
326  if (TMath::Abs(z-zmin)<5.) h1min->Fill(z,d);
327  if (TMath::Abs(z-zmax)<5.) h1max->Fill(z,d);
328  }
329 // h1min->Fit("gaus","Q0");
330 // h1max->Fit("gaus","Q0");
331 // TF1 *fmin = h1min->GetFunction("gaus");
332 // TF1 *fmax = h1max->GetFunction("gaus");
333 // error->Fill(fmin->GetParameter(2));
334 // error->Fill(fmax->GetParameter(2));
335 // zdown = fmax->GetParameter(1);
336 // zup = fmin->GetParameter(1);
337  zdown = h1max->GetMean();
338  zup = h1min->GetMean();
339 // error->Fill(h1max->GetRMS());
340 // error->Fill(h1min->GetRMS());
341  delete h1min;
342  delete h1max;
343 }
float GetD()
Definition: deriv.h:22
float GetZ()
Definition: deriv.h:21

◆ SatCondAccept()

int SatCondAccept ( track tr,
float  xc,
float  yc,
float  zc,
double  dx,
double  dy,
double  dz,
float  accept 
)
154 {
155 /* float xt = tr->x;
156  float yt = tr->y;
157  float zt = tr->z;
158  float tgx = tr->tgx;
159  float tgy = tr->tgy;
160 
161  float x = xt + (zc-zt)*tgx;
162  float y = yt + (zc-zt)*tgy;
163 
164  float teta, phi;
165  TrackAngle(*tr,&teta,&phi);
166 */
167 /* if (Distance(xc,yc,zc,xt,yt,zt,teta,phi)<=accept) return true;
168  else return false;
169 */
170  if (DistanceInNormalizeSpace(xc,yc,zc,*tr,dx,dy,dz)<=accept) return true;
171  else return false;
172 
173 /* if (sqrt((x-xc)*(x-xc)+(y-yc)*(y-yc))<=accept) return true;
174  else return false;
175  */
176 }
float DistanceInNormalizeSpace(float xp, float yp, float zp, track tr, double dx, double dy, double dz)
Definition: bitview.cxx:118

◆ Smoothing()

TClonesArray* Smoothing ( EdbView v)
238 {
239  TClonesArray *t = new TClonesArray("EdbFrame");
240  EdbFrame *fpp=0,*fpred=0,*f=0,*fsucc=0,*fss=0;
241  int nFrame = v->GetNframes();
242  for (int i=0; i<nFrame; i++) {
243  int Nclpp,Nclp,Ncl,Ncls,Nclss;
244  if (i>1) {
245  fpp = (EdbFrame *)(v->GetFrames()->At(i-2));
246  Nclpp = fpp->GetNcl();
247  }
248  else Nclpp = 0;
249  if (i>0) {
250  fpred = (EdbFrame *)(v->GetFrames()->At(i-1));
251  Nclp = fpred->GetNcl();
252  }
253  else Nclp = 0;
254  f = (EdbFrame *)(v->GetFrames()->At(i));
255  Ncl = f->GetNcl();
256  if (i<nFrame-1) {
257  fsucc = (EdbFrame *)(v->GetFrames()->At(i+1));
258  Ncls = fsucc->GetNcl();
259  }
260  else Ncls = 0;
261  if (i<nFrame-2) {
262  fss = (EdbFrame *)(v->GetFrames()->At(i+2));
263  Nclss = fss->GetNcl();
264  }
265  else Nclss = 0;
266  int ncl = (Nclpp+2*Nclp+3*Ncl+2*Ncls+Nclss)/9;
267  new((*t)[i]) EdbFrame(f->GetID(),f->GetZ(),ncl,f->GetNpix());
268 // h2->Fill(f->GetZ(),ncl);
269 // t->Add(new EdbFrame(f->GetID(),f->GetZ(),ncl,f->GetNpix()));
270  }
271  return t;
272 }
FILE * f
Definition: RecDispMC.C:150
Definition: EdbFrame.h:20
int GetNcl() const
Definition: EdbFrame.h:43
Int_t GetNframes() const
Definition: EdbView.h:206
TClonesArray * GetFrames() const
Definition: EdbView.h:167

◆ sqr()

float sqr ( float  x)
inline
25 {return x*x;}

◆ TrackAngle()

void TrackAngle ( track  tr,
float *  teta,
float *  phi 
)
46 {
47  float tgx = tr.tgx;
48  float tgy = tr.tgy;
49 
50  float tgteta = TMath::Sqrt(tgx*tgx+tgy*tgy);
51  *teta = TMath::ATan(tgteta);
52  float tgphi;
53 
54  if (tgx!=0.0) {
55  tgphi=(tgy)/(tgx);
56  // printf("tgphi=%lf, \n ",tgphi);
57  if (tgphi>=0) {
58  if (tgx>0) {
59  *phi=TMath::ATan(tgphi);
60  }
61  else {
62  *phi=TMath::ATan(tgphi)+TMath::Pi();
63  }
64  }
65  else {
66  if (tgx>0) {
67  *phi=2*TMath::Pi()-TMath::ATan(-tgphi);
68  }
69  else {
70  *phi=TMath::Pi()-TMath::ATan(-tgphi);
71  }
72  }
73  }
74  else {
75  if (tgy>0) {
76  *phi=TMath::Pi()/2.0;
77  }
78  else if (tgy<0) {
79  *phi=3.0*TMath::Pi()/2.0;
80  }
81  else {
82  *phi=0.0;
83  }
84  // printf("phi=%lf ,a=%lf, c=%lf\n", phi,a,c);
85  }
86 }