FEDRA emulsion software from the OPERA Collaboration
EdbAlignmentV Class Reference

universal basic alignment class More...

#include <EdbAlignmentV.h>

Inheritance diagram for EdbAlignmentV:
Collaboration diagram for EdbAlignmentV:

Public Member Functions

void AddSegCouple (EdbSegP *s1, EdbSegP *s2)
 
void ApplyLimitsOffset (float &xmin1, float &xmax1, float &xmin2, float &xmax2, float offsetMax)
 
Int_t CalcAffFull ()
 
Int_t CalcApplyFractMeanDiff ()
 
Int_t CalcApplyMeanDiff ()
 
Float_t CalcFractMeanDiff (int ivar, float fraction)
 
Float_t CalcMeanDiff (int ivar)
 
Float_t CalcMeanDZ (float tmin=0.1, float tmax=2.)
 
Float_t CalcMeanShr (float tmin=0.1, float tmax=2.)
 
Int_t CalculateAffTXTY (EdbAffine2D &aff)
 
Int_t CalculateAffTXTY (TObjArray &arr1, TObjArray &arr2, EdbAffine2D &aff)
 
Int_t CalculateAffTXTYTurn (TObjArray &arr1, TObjArray &arr2, EdbAffine2D &aff)
 
Int_t CalculateAffXY (EdbAffine2D &aff)
 
Int_t CalculateAffXY (TObjArray &arr1, TObjArray &arr2, EdbAffine2D &aff)
 
Int_t CalculateAffXYTurn (EdbAffine2D &aff)
 
Int_t CalculateAffXYTurn (TObjArray &arr1, TObjArray &arr2, EdbAffine2D &aff)
 
void CloseOutputFile ()
 
void Corr2Aff (EdbLayer &layer)
 
void Corr2Aff (EdbSegCorr &corr, EdbLayer &layer)
 
void CorrToCoG (int side, EdbPattern &p)
 functions alpplied to the individual patterns More...
 
void CorrToCoG (int side, TObjArray &p)
 
float CoupleQuality (EdbSegP &s1, EdbSegP &s2)
 
void DefineGuessCell (float xmin1, float xmax1, float ymin1, float ymax1, float xmin2, float xmax2, float ymin2, float ymax2, int np1, int np2, float binOK)
 Selector functions. More...
 
int DoubletsFilterOut (int checkview, TH2F *hxy=0, TH2F *htxty=0)
 
 EdbAlignmentV ()
 
void FillCell (int side, EdbPattern &pat)
 
void FillCell (int side, TObjArray &pat)
 
int FillCombinations ()
 
int FillCombinations (float dv[4], float dxMax, float dyMax, bool doFill)
 
void FillGuessCell (EdbPattern &p1, EdbPattern &p2, float binOK=1., float offsetMax=2000.)
 
void FillGuessCell (TObjArray &p1, TObjArray &p2, float binOK=1., float offsetMax=2000.)
 
void FillThetaHist (int side, EdbH2 &htxy)
 
Int_t FindCorrDiff (float dvsame[4], int side=0, int nlim=10)
 
Float_t FindDensityPeak (TArrayF &arr, float fraction)
 
Int_t FindDiff (TObjArray &arr1, TObjArray &arr2, float dvlim[4], float dvfound[4])
 
float FineCorrPhi (TObjArray &sel1, TObjArray &sel2)
 
float FineCorrZ ()
 
float FineCorrZ (TObjArray &sel1, TObjArray &sel2)
 
void HDistance (EdbPattern &p1, EdbPattern &p2, float dxMax, float dyMax)
 
void InitHphi (int n, float min, float max)
 
void InitHshr0 (int n, float min, float max)
 
void InitHshr1 (int n, float min, float max)
 
void InitHx (int n, float min, float max)
 
void InitHy (int n, float min, float max)
 
void InitHz (int n, float min, float max)
 
void InitOutputFile (const char *file="report_al.root", const char *option="RECREATE")
 IO, initialization and finalization functions. More...
 
void InitPatCellBin (int side, EdbPattern &pat, float binx, float biny)
 
void InitPatCellN (EdbCell2 &cell, EdbPattern &pat, int nx, int ny)
 
Bool_t IsInsideDVsame (EdbSegP &s1, EdbSegP &s2)
 
Int_t Ncoins (float dvlim[4], EdbH2 *hdxy=0, EdbH2 *hdtxty=0, TObjArray *sel1=0, TObjArray *sel2=0)
 
Int_t Ncp ()
 Functions applied to the selected parallel arrays. More...
 
int OptimiseVar1 (int side, int ivar, EdbH2 *hdxy=0, EdbH2 *hdtxy=0)
 
void OptimiseVar2 (int side1, int ivar1, int side2, int ivar2, EdbH2 &h12, EdbH2 *hdxy=0, EdbH2 *hdtxty=0)
 
int SelectBestCouple ()
 
int SelectIsolated ()
 
Bool_t SideOK (int side)
 
char * StrDVsame () const
 
float TX (int side, EdbSegP &s)
 
float TY (int side, EdbSegP &s)
 
Bool_t ValidCoinsidence (EdbSegP &s1, EdbSegP &s2, float dvlim[4], float dvfound[4])
 
float Var (int side, EdbSegP &s, int ivar)
 
float Var (int side, int iseg, int ivar)
 
float X (int side, EdbSegP &s)
 Correction parameters handling. More...
 
float Xmax (int side, EdbPattern &p)
 
float Xmax (int side, TObjArray &p)
 
float Xmin (int side, EdbPattern &p)
 
float Xmin (int side, TObjArray &p)
 
float Y (int side, EdbSegP &s)
 
float Ymax (int side, EdbPattern &p)
 
float Ymax (int side, TObjArray &p)
 
float Ymin (int side, EdbPattern &p)
 
float Ymin (int side, TObjArray &p)
 
virtual ~EdbAlignmentV ()
 

Static Public Member Functions

static Int_t CheckEqualArr (TObjArray &arr1, TObjArray &arr2)
 

Public Attributes

EdbSegCorr eCorr [2]
 corrections for side 1 and 2 (v[7]) - the result of the alignment More...
 
EdbLayer eCorrL [2]
 corrections in form of affine transformations - the final output More...
 
TH1I * eDoubletsRate
 can be filled in FillCombinations() More...
 
Float_t eDVsame [4]
 (dx,dy,dtx,dty) condition for the coinsidence More...
 
EdbH1 eH [2][7]
 
EdbH2 eHxy
 position 2d histo to be used in OptimiseVar2 More...
 
TFile * eOutputFile
 
EdbCell2 ePC [2]
 2-d position cells with patterns segments More...
 
TObjArray eS [2]
 "parallel" arrays with the selected combinations of segments More...
 
Bool_t eUseAffCorr
 if "true" - use eCorrL for corrections More...
 
Float_t eXmarg
 
Float_t eYmarg
 margins for the cell definition More...
 

Detailed Description

universal basic alignment class

Constructor & Destructor Documentation

◆ EdbAlignmentV()

EdbAlignmentV::EdbAlignmentV ( )

margins for the cell definition

by default use eCorr (separated corrections)

25{
26 eXmarg = eYmarg = 0.0001;
28 eUseAffCorr = false;
30}
TFile * eOutputFile
Definition: EdbAlignmentV.h:35
TH1I * eDoubletsRate
can be filled in FillCombinations()
Definition: EdbAlignmentV.h:33
Bool_t eUseAffCorr
if "true" - use eCorrL for corrections
Definition: EdbAlignmentV.h:23
Float_t eYmarg
margins for the cell definition
Definition: EdbAlignmentV.h:19
Float_t eXmarg
Definition: EdbAlignmentV.h:19

◆ ~EdbAlignmentV()

EdbAlignmentV::~EdbAlignmentV ( )
virtual
34{
35 eS[0].Clear();
36 eS[1].Clear();
37 SafeDelete(eDoubletsRate);
38}
TObjArray eS[2]
"parallel" arrays with the selected combinations of segments
Definition: EdbAlignmentV.h:21

Member Function Documentation

◆ AddSegCouple()

void EdbAlignmentV::AddSegCouple ( EdbSegP s1,
EdbSegP s2 
)
inline
77{ eS[0].Add(s1); eS[1].Add(s2); }
EdbSegP * s1
Definition: tlg2couples.C:29
EdbSegP * s2
Definition: tlg2couples.C:30

◆ ApplyLimitsOffset()

void EdbAlignmentV::ApplyLimitsOffset ( float &  xmin1,
float &  xmax1,
float &  xmin2,
float &  xmax2,
float  offsetMax 
)
848{
849 if(Abs(xmin2-xmin1)>offsetMax) // cut useless patterns margins
850 if(xmin2>xmin1) xmin1=xmin2-offsetMax;
851 else xmin2=xmin1-offsetMax;
852 if(Abs(xmax2-xmax1)>offsetMax)
853 if(xmax2>xmax1) xmax2=xmax1+offsetMax;
854 else xmax1=xmax2+offsetMax;
855}

◆ CalcAffFull()

Int_t EdbAlignmentV::CalcAffFull ( )
615{
616 eUseAffCorr=true;
617 eCorrL[0].SetZcorr( FineCorrZ( eS[0], eS[1] ) );
618 EdbAffine2D aff1to2XY;
619 CalculateAffXY( eS[0], eS[1], aff1to2XY);
620 eCorrL[0].GetAffineXY()->Transform(&aff1to2XY);
621 EdbAffine2D aff2to1TXTY;
622 CalculateAffTXTY( eS[1], eS[0], aff2to1TXTY);
623 eCorrL[1].GetAffineTXTY()->Transform(&aff2to1TXTY);
624}
Definition: EdbAffine.h:17
void Transform(const EdbAffine2D *a)
Definition: EdbAffine.cxx:93
Int_t CalculateAffXY(EdbAffine2D &aff)
Definition: EdbAlignmentV.h:95
EdbLayer eCorrL[2]
corrections in form of affine transformations - the final output
Definition: EdbAlignmentV.h:25
Int_t CalculateAffTXTY(EdbAffine2D &aff)
Definition: EdbAlignmentV.h:96
float FineCorrZ()
Definition: EdbAlignmentV.h:89
void SetZcorr(float zcorr)
Definition: EdbLayer.h:106
EdbAffine2D * GetAffineTXTY()
Definition: EdbLayer.h:120
EdbAffine2D * GetAffineXY()
Definition: EdbLayer.h:119

◆ CalcApplyFractMeanDiff()

Int_t EdbAlignmentV::CalcApplyFractMeanDiff ( )

by default apply it to side 0

592{
594 int side=0;
595 int n = CheckEqualArr(eS[0],eS[1]);
596
597// if(n<nlim) return 0; //TODO
598
599 eCorr[side].AddV( 3, CalcFractMeanDiff( 2, 0.4 ) ); // calc and apply angles
600 eCorr[side].AddV( 4, CalcFractMeanDiff( 3, 0.4 ) );
601
602 //eCorr[side].SetV( 2, CalcMeanDZ() ); // calc and apply DZ
603
604 //eCorr[side].SetV( 5, eCorr[side].V(5) * CalcMeanShr() ); // calc and apply shrinkage
605
606
607 eCorr[side].AddV( 0, CalcFractMeanDiff( 0, 0.4 ) ); // then apply coord
608 eCorr[side].AddV( 1, CalcFractMeanDiff( 1, 0.4 ) );
609
610 return n;
611}
static Int_t CheckEqualArr(TObjArray &arr1, TObjArray &arr2)
Definition: EdbAlignmentV.cxx:389
Float_t CalcFractMeanDiff(int ivar, float fraction)
Definition: EdbAlignmentV.cxx:551
EdbSegCorr eCorr[2]
corrections for side 1 and 2 (v[7]) - the result of the alignment
Definition: EdbAlignmentV.h:24
void AddV(int i, float x)
Definition: EdbSegCorr.h:22

◆ CalcApplyMeanDiff()

Int_t EdbAlignmentV::CalcApplyMeanDiff ( )

by default apply it to side 0

643{
645 int side=0;
646 int n = CheckEqualArr(eS[0],eS[1]);
647
648// if(n<nlim) return 0; //TODO
649
650 eCorr[side].AddV( 3, CalcMeanDiff(2) ); // then apply angles
651 eCorr[side].AddV( 4, CalcMeanDiff(3) );
652
653 eCorr[side].SetV( 2, CalcMeanDZ() ); // at first calc and apply DZ
654
655 eCorr[side].SetV( 5, eCorr[side].V(5) * CalcMeanShr() ); // second calc and apply shrinkage
656
657
658 eCorr[side].AddV( 0, CalcMeanDiff(0) ); // then apply coord
659 eCorr[side].AddV( 1, CalcMeanDiff(1) );
660
661 return n;
662}
Float_t CalcMeanDZ(float tmin=0.1, float tmax=2.)
Definition: EdbAlignmentV.cxx:509
Float_t CalcMeanDiff(int ivar)
Definition: EdbAlignmentV.cxx:536
Float_t CalcMeanShr(float tmin=0.1, float tmax=2.)
Definition: EdbAlignmentV.cxx:488
void SetV(int i, float x)
Definition: EdbSegCorr.h:21

◆ CalcFractMeanDiff()

Float_t EdbAlignmentV::CalcFractMeanDiff ( int  ivar,
float  fraction 
)

Calculate mean difference for the highest density region

552{
554 int n = CheckEqualArr(eS[0],eS[1]);
555 TArrayF arr(n);
556 for(int i=0; i<n; i++) {
557 arr[i] = ( Var( 1, i, ivar ) - Var( 0, i, ivar) );
558 }
559 return FindDensityPeak( arr, fraction);
560}
Float_t FindDensityPeak(TArrayF &arr, float fraction)
Definition: EdbAlignmentV.cxx:563
float Var(int side, EdbSegP &s, int ivar)
Definition: EdbAlignmentV.h:122

◆ CalcMeanDiff()

Float_t EdbAlignmentV::CalcMeanDiff ( int  ivar)

Calculate mean difference for the given variable taking into account corrections

537{
539 int n = CheckEqualArr(eS[0],eS[1]);
540 int ic=0;
541 Double_t sd=0;
542 for(int i=0; i<n; i++) {
543 sd += ( Var( 1, i, ivar ) - Var( 0, i, ivar) );
544 ic++;
545 }
546 sd /= ic;
547 return sd;
548}
void sd()
Definition: check_vertex.C:185

◆ CalcMeanDZ()

Float_t EdbAlignmentV::CalcMeanDZ ( float  tmin = 0.1,
float  tmax = 2. 
)

Calculate mean shrinkage (to be applied to side 0 to get side 1)

510{
512 int n = CheckEqualArr(eS[0],eS[1]);
513 int ic=0;
514 float dz = eCorr[0].V(2); if(Abs(dz)<0.000001) return 0;
515 eCorr[0].SetV(2,0.);
516 Double_t dzn=0;
517 for(int i=0; i<n; i++) {
518 EdbSegP *s1=(EdbSegP*)eS[0].UncheckedAt(i);
519 float t1 = eCorr[0].T(*s1);
520 if(t1<tmin) continue;
521 if(t1>tmax) continue;
522 EdbSegP *s2=(EdbSegP*)eS[1].UncheckedAt(i);
523 float tx = ( X(1,*s2) - X(0,*s1) ) / dz;
524 float ty = ( Y(1,*s2) - Y(0,*s1) ) / dz;
525 float t = TMath::Sqrt(tx*tx+ty*ty);
526 dzn += dz*t/t1;
527 ic++;
528 }
529 dzn /= ic;
530 eCorr[0].SetV(2,dz);
531 Log(3,"CalcMeanDZ","dz = %f dzn = %f n=%d",dz,dzn,ic);
532 return dzn;
533}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
brick dz
Definition: RecDispMC.C:107
float Y(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:119
float X(int side, EdbSegP &s)
Correction parameters handling.
Definition: EdbAlignmentV.h:118
float T(EdbSegP &s)
Definition: EdbSegCorr.h:36
float V(int i)
Definition: EdbSegCorr.h:23
Definition: EdbSegP.h:21
TTree * t
Definition: check_shower.C:4

◆ CalcMeanShr()

Float_t EdbAlignmentV::CalcMeanShr ( float  tmin = 0.1,
float  tmax = 2. 
)

Calculate mean shrinkage (to be applied to side 0 to get side 1)

489{
491 int n = CheckEqualArr(eS[0],eS[1]);
492 int ic=0;
493 Double_t shr=0;
494 for(int i=0; i<n; i++) {
495 float t1 = eCorr[0].T(*((EdbSegP*)eS[0].UncheckedAt(i)));
496 //float t1 = ((EdbSegP*)eS[0].UncheckedAt(i))->Theta();
497 if(t1<tmin) continue;
498 if(t1>tmax) continue;
499 float t2 = eCorr[1].T(*((EdbSegP*)eS[1].UncheckedAt(i)));
500 //float t2 = ((EdbSegP*)eS[1].UncheckedAt(i))->Theta();
501 shr += (t1/t2); // the angle is divided by shr - that's why it is inverse
502 ic++;
503 }
504 shr /= ic;
505 return shr;
506}

◆ CalculateAffTXTY() [1/2]

Int_t EdbAlignmentV::CalculateAffTXTY ( EdbAffine2D aff)
inline
96{return CalculateAffTXTY( eS[0], eS[1], aff);}

◆ CalculateAffTXTY() [2/2]

Int_t EdbAlignmentV::CalculateAffTXTY ( TObjArray &  arr1,
TObjArray &  arr2,
EdbAffine2D aff 
)
984{
985 int n = CheckEqualArr(arr1,arr2);
986 TArrayF x1(n), x2(n), y1(n), y2(n);
987 for(int i=0; i<n; i++ ) {
988 EdbSegP *s1 = (EdbSegP*)arr1.UncheckedAt(i);
989 EdbSegP *s2 = (EdbSegP*)arr2.UncheckedAt(i);
990 x1[i] = TX(0, *s1); y1[i] = TY(0, *s1);
991 x2[i] = TX(1, *s2); y2[i] = TY(1, *s2);
992 }
993 aff.Calculate(n,x1.GetArray(),y1.GetArray(),x2.GetArray(),y2.GetArray(),0);
994 return n;
995}
Int_t Calculate(EdbPointsBox2D *b1, EdbPointsBox2D *b2)
Definition: EdbAffine.cxx:231
float TY(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:121
float TX(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:120

◆ CalculateAffTXTYTurn()

Int_t EdbAlignmentV::CalculateAffTXTYTurn ( TObjArray &  arr1,
TObjArray &  arr2,
EdbAffine2D aff 
)
999{
1000 int n = CheckEqualArr(arr1,arr2);
1001 TArrayF x1(n), x2(n), y1(n), y2(n);
1002 for(int i=0; i<n; i++ ) {
1003 EdbSegP *s1 = (EdbSegP*)arr1.UncheckedAt(i);
1004 EdbSegP *s2 = (EdbSegP*)arr2.UncheckedAt(i);
1005 x1[i] = TX(0, *s1); y1[i] = TY(0, *s1);
1006 x2[i] = TX(1, *s2); y2[i] = TY(1, *s2);
1007 }
1008 aff.Calculate(n,x1.GetArray(),y1.GetArray(),x2.GetArray(),y2.GetArray(),2);
1009 return n;
1010}

◆ CalculateAffXY() [1/2]

Int_t EdbAlignmentV::CalculateAffXY ( EdbAffine2D aff)
inline
95{return CalculateAffXY( eS[0], eS[1], aff);}

◆ CalculateAffXY() [2/2]

Int_t EdbAlignmentV::CalculateAffXY ( TObjArray &  arr1,
TObjArray &  arr2,
EdbAffine2D aff 
)
954{
955 int n = CheckEqualArr(arr1,arr2);
956 TArrayF x1(n), x2(n), y1(n), y2(n);
957 for(int i=0; i<n; i++ ) {
958 EdbSegP *s1 = (EdbSegP*)arr1.UncheckedAt(i);
959 EdbSegP *s2 = (EdbSegP*)arr2.UncheckedAt(i);
960 x1[i] = X(0,*s1); y1[i] = Y(0,*s1);
961 x2[i] = X(1,*s2); y2[i] = Y(1,*s2);
962 }
963 aff.Calculate(n,x1.GetArray(),y1.GetArray(),x2.GetArray(),y2.GetArray(),0);
964 return n;
965}

◆ CalculateAffXYTurn() [1/2]

Int_t EdbAlignmentV::CalculateAffXYTurn ( EdbAffine2D aff)
inline
94{return CalculateAffXYTurn( eS[0], eS[1], aff);}
Int_t CalculateAffXYTurn(EdbAffine2D &aff)
Definition: EdbAlignmentV.h:94

◆ CalculateAffXYTurn() [2/2]

Int_t EdbAlignmentV::CalculateAffXYTurn ( TObjArray &  arr1,
TObjArray &  arr2,
EdbAffine2D aff 
)
969{
970 int n = CheckEqualArr(arr1,arr2);
971 TArrayF x1(n), x2(n), y1(n), y2(n);
972 for(int i=0; i<n; i++ ) {
973 EdbSegP *s1 = (EdbSegP*)arr1.UncheckedAt(i);
974 EdbSegP *s2 = (EdbSegP*)arr2.UncheckedAt(i);
975 x1[i] = X(0,*s1); y1[i] = Y(0,*s1);
976 x2[i] = X(1,*s2); y2[i] = Y(1,*s2);
977 }
978 aff.Calculate(n,x1.GetArray(),y1.GetArray(),x2.GetArray(),y2.GetArray(),2);
979 return n;
980}

◆ CheckEqualArr()

Int_t EdbAlignmentV::CheckEqualArr ( TObjArray &  arr1,
TObjArray &  arr2 
)
static
390{
391 int n1 = arr1.GetEntries();
392 int n2 = arr2.GetEntries();
393 int n = Min(n1,n2);
394 if(n1!=n2) Log(1,"CheckEqualArr","WARNING: arrays are not equal: %d %d, take first %d segs", n1,n2,n );
395 return n;
396}

◆ CloseOutputFile()

void EdbAlignmentV::CloseOutputFile ( )
49{
50 if(eOutputFile) {
51 eOutputFile->Close();
52 SafeDelete(eOutputFile);
53 }
54}

◆ Corr2Aff() [1/2]

void EdbAlignmentV::Corr2Aff ( EdbLayer layer)
1028{
1029/* EdbAffine2D &a0 = *(layer.GetAffineXY());
1030 a0.Reset();
1031 a0.ShiftX( eCorr[0].V(0) ); a0.ShiftY( eCorr[0].V(1) );
1032 a0.Rotate( eCorr[0].V(6) );
1033 a0.ShiftX( -eCorr[1].V(0) ); a0.ShiftY( -eCorr[1].V(1) );
1034 layer.SetShrinkage( eCorr[0].V(5) );
1035 layer.SetZcorr( eCorr[0].V(2) );*/
1036
1037 Corr2Aff(eCorr[0],layer);
1038 layer.GetAffineXY()->ShiftX( -eCorr[1].V(0) );
1039 layer.GetAffineXY()->ShiftY( -eCorr[1].V(1) );
1040}
void ShiftX(float d)
Definition: EdbAffine.h:64
void ShiftY(float d)
Definition: EdbAffine.h:65
void Corr2Aff(EdbLayer &layer)
Definition: EdbAlignmentV.cxx:1027

◆ Corr2Aff() [2/2]

void EdbAlignmentV::Corr2Aff ( EdbSegCorr corr,
EdbLayer layer 
)
1014{
1015 EdbAffine2D &a0 = *(layer.GetAffineXY());
1016 a0.Reset();
1017 a0.ShiftX( corr.V(0) ); a0.ShiftY( corr.V(1) );
1018 a0.Rotate( corr.V(6) );
1019 EdbAffine2D &atxty = *(layer.GetAffineTXTY());
1020 atxty.Reset();
1021 atxty.ShiftX(corr.V(3)); atxty.ShiftY(corr.V(4));
1022 layer.SetShrinkage( corr.V(5) );
1023 layer.SetZcorr( corr.V(2) );
1024}
void Reset()
Definition: EdbAffine.cxx:72
void Rotate(float angle)
Definition: EdbAffine.cxx:354
void SetShrinkage(float shr)
Definition: EdbLayer.h:99

◆ CorrToCoG() [1/2]

void EdbAlignmentV::CorrToCoG ( int  side,
EdbPattern p 
)

functions alpplied to the individual patterns

431{
432 int n=p.N();
433 Double_t x0=0, y0=0;
434 for(int i=0; i<n; i++) {
435 EdbSegP *s = p.GetSegment(i);
436 x0 += X(side, *s);
437 y0 += Y(side, *s);
438 }
439 x0/=n; y0/=n;
440 eCorr[0].AddV(0, -x0);
441 eCorr[0].AddV(1, -y0);
442 eCorr[1].AddV(0, -x0);
443 eCorr[1].AddV(1, -y0);
444}
s
Definition: check_shower.C:55
p
Definition: testBGReduction_AllMethods.C:8

◆ CorrToCoG() [2/2]

void EdbAlignmentV::CorrToCoG ( int  side,
TObjArray &  p 
)
448{
449 int n=p.GetEntries();
450 Double_t x0=0, y0=0;
451 for(int i=0; i<n; i++) {
452 EdbSegP *s = (EdbSegP*)p.UncheckedAt(i);
453 x0 += X(side,*s);
454 y0 += Y(side,*s);
455 }
456 x0/=n; y0/=n;
457 eCorr[0].AddV(0, -x0);
458 eCorr[0].AddV(1, -y0);
459 eCorr[1].AddV(0, -x0);
460 eCorr[1].AddV(1, -y0);
461}

◆ CoupleQuality()

float EdbAlignmentV::CoupleQuality ( EdbSegP s1,
EdbSegP s2 
)
190{
191 // TODO
192 return s1.W()+s2.W();
193}
Float_t W() const
Definition: EdbSegP.h:151

◆ DefineGuessCell()

void EdbAlignmentV::DefineGuessCell ( float  xmin1,
float  xmax1,
float  ymin1,
float  ymax1,
float  xmin2,
float  xmax2,
float  ymin2,
float  ymax2,
int  np1,
int  np2,
float  binOK 
)

Selector functions.

860{
861 float s1 = (xmax1-xmin1)*(ymax1-ymin1);
862 float xbin1 = Sqrt( s1/(np1/binOK) );
863
864 float s2 = (xmax2-xmin2)*(ymax2-ymin2);
865 float xbin2 = Sqrt( s2/(np2/binOK) );
866
867 float xbin = Min(xbin1,xbin2);
868
869 float min[2] = { Min(xmin1,xmin2)-eXmarg, Min(ymin1,ymin2)-eYmarg };
870 float max[2] = { Max(xmax1,xmax2)+eXmarg, Max(ymax1,ymax2)+eYmarg };
871 int n[2] = { (int)((max[0]-min[0])/xbin+1), (int)((max[1]-min[1])/xbin+1) };
872
873 int maxcell1 = np1/n[0]/n[1]+10; maxcell1 += (int)(5*Sqrt(maxcell1));
874 ePC[0].InitCell(maxcell1,n,min,max);
875 int maxcell2 = np2/n[0]/n[1]+10; maxcell2 += (int)(5*Sqrt(maxcell2));
876 ePC[1].InitCell(maxcell2,n,min,max);
877}
float min(TClonesArray *t)
Definition: bitview.cxx:275
EdbCell2 ePC[2]
2-d position cells with patterns segments
Definition: EdbAlignmentV.h:18
int InitCell(EdbCell2 &c)
Definition: EdbCell2.h:167
int max
Definition: check_shower.C:41

◆ DoubletsFilterOut()

int EdbAlignmentV::DoubletsFilterOut ( int  checkview,
TH2F *  hxy = 0,
TH2F *  htxty = 0 
)

assumed the same pattern's segments in eS[0] and eS[1]
checkview = 0 do not check if close tracks belongs to different views
checkview = 1 check views, select best and cancel the worst candidate
checkview = 2 check views but do not cancell worst candidate (debug option)

68{
73
74 int nout=0;
75 int n = CheckEqualArr(eS[0], eS[1]);
76 for(int i=0; i<n; i++) {
77 EdbSegP *s1 = (EdbSegP*)eS[0].UncheckedAt(i);
78 EdbSegP *s2 = (EdbSegP*)eS[1].UncheckedAt(i);
79 if( s1->Flag()==-10 && s2->Flag()==-10) continue;
80 if(checkview>0) if( s2->Aid(0)==s1->Aid(0) && s2->Aid(1)==s1->Aid(1) && s2->Side()==s1->Side() ) continue;
81 if( !IsInsideDVsame(*s1,*s2) ) continue;
82 if(s1->Flag()>-10 && s2->Flag()>-10) {
83 if(hxy) hxy->Fill( s1->X()-s2->X() , s1->Y()-s2->Y());
84 if(htxty) htxty->Fill(s1->TX()-s2->TX(),s1->TY()-s2->TY());
85 }
86 if(checkview==1||checkview==0) {
87 if( s2->W()>s1->W() ) s1->SetFlag(-10);
88 else if( s2->W() == s1->W() && s2->Chi2() < s1->Chi2() ) s1->SetFlag(-10);
89 else if( s2->W() == s1->W() && s2->Chi2() >= s1->Chi2() ) s2->SetFlag(-10);
90 else if( s2->W()<s1->W() ) s2->SetFlag(-10);
91 nout++;
92 }
93 }
94
95 //check
96 int miss=0, wrong=0;
97 for(int i=0; i<n; i++) {
98 EdbSegP *s1 = (EdbSegP*)eS[0].UncheckedAt(i);
99 EdbSegP *s2 = (EdbSegP*)eS[1].UncheckedAt(i);
100 if( s1->Flag()==-10 && s2->Flag()==-10 ) continue;
101 if( s1->Flag()!=-10 && s2->Flag()!=-10 ) { miss++; continue;}
102 if( s1->Flag()==-10 && (s1->W() > s2->W()) ) {
103 wrong++;
104 s1->SetFlag(0);
105 s2->SetFlag(-10);
106 }
107 }
108 Log(2,"DubletsFilterOut","miss: %d wrong: %d",miss,wrong);
109
110 Log(2,"DubletsFilterOut","%d segments discarded with DX,DY,DTX,DTY: (%8.4f %8.4f %7.5f %7.5f) checkview =%d",
111 nout,eDVsame[0],eDVsame[1],eDVsame[2],eDVsame[3], checkview );
112 return nout;
113}
Float_t eDVsame[4]
(dx,dy,dtx,dty) condition for the coinsidence
Definition: EdbAlignmentV.h:16
Bool_t IsInsideDVsame(EdbSegP &s1, EdbSegP &s2)
Definition: EdbAlignmentV.cxx:57
Float_t TX() const
tangens = deltaX/deltaZ
Definition: EdbSegP.h:175
Float_t X() const
Definition: EdbSegP.h:173
Float_t Chi2() const
Definition: EdbSegP.h:157
Int_t Side() const
mandatory virtual functions:
Definition: EdbSegP.h:170
Float_t Y() const
Definition: EdbSegP.h:174
Float_t TY() const
tangens = deltaY/deltaZ
Definition: EdbSegP.h:176
Int_t Aid(int i) const
Definition: EdbSegP.h:169
void SetFlag(int flag)
Definition: EdbSegP.h:130
Int_t Flag() const
Definition: EdbSegP.h:149

◆ FillCell() [1/2]

void EdbAlignmentV::FillCell ( int  side,
EdbPattern pat 
)

assume that the cell is already initialized

928{
930 if(!SideOK(side)) return;
931 EdbSegP *s=0;
932 int n = pat.N();
933 for(int i=0; i<n; i++) {
934 s = pat.GetSegment(i);
935 ePC[side].AddObject( X(side,*s), Y(side,*s), (TObject*)s );
936 }
937}
Bool_t SideOK(int side)
Definition: EdbAlignmentV.cxx:379
bool AddObject(float v[2], TObject *obj)
Definition: EdbCell2.h:173
Int_t N() const
Definition: EdbPattern.h:86
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66

◆ FillCell() [2/2]

void EdbAlignmentV::FillCell ( int  side,
TObjArray &  pat 
)

assume that the cell is already initialized

941{
943 if(!SideOK(side)) return;
944 EdbSegP *s=0;
945 int n = pat.GetEntriesFast();
946 for(int i=0; i<n; i++) {
947 s = (EdbSegP*)pat.UncheckedAt(i);
948 ePC[side].AddObject( X(side,*s), Y(side,*s), (TObject*)s );
949 }
950}

◆ FillCombinations() [1/2]

int EdbAlignmentV::FillCombinations ( )
209{
210 float dxMax = 2*Max( ePC[0].Xbin(), ePC[1].Xbin() );
211 float dyMax = 2*Max( ePC[0].Ybin(), ePC[1].Ybin() );
212 return FillCombinations( eDVsame, dxMax, dyMax, 1);
213}
int FillCombinations()
Definition: EdbAlignmentV.cxx:208

◆ FillCombinations() [2/2]

int EdbAlignmentV::FillCombinations ( float  dv[4],
float  dxMax,
float  dyMax,
bool  doFill 
)

input: dv = coinsidence condition (dx,dy,dtx,dty)
dxMax, dyMax - the area around each segment for the combinations
selection, it can be selected bigger then coinsidence condition due to
corrections displacements
the cells must be already filled

217{
224
225 eS[0].Clear();
226 eS[1].Clear();
227 int ir2[2] = { int((dxMax-0.0001)/ePC[0].Xbin())+1, int((dyMax-0.0001)/ePC[0].Ybin())+1 };
228
229 int nout=0;
230
231 TObjArray arr1(10000);
232 TObjArray arr2(100);
233 float v[2];
234 EdbSegP *s1,*s2;
235
236 int ncomb; // combinations rate counter
237 int n1 = ePC[0].SelectObjects(arr1);
238 for(int i=0; i<n1; i++) {
239 ncomb=0;
240 s1 = (EdbSegP*)arr1.UncheckedAt(i);
241 if(s1->Flag()==-10) continue;
242 arr2.Clear();
243 v[0] = X( 0, *s1);
244 v[1] = Y( 0, *s1);
245 int n2 = ePC[1].SelectObjectsC(v,ir2,arr2);
246
247 if(n2<1) continue;
248 float tx1 = TX(0, *s1);
249 float ty1 = TY(0, *s1);
250 for(int i2=0; i2<n2; i2++) {
251 s2 = (EdbSegP*)arr2.UncheckedAt(i2);
252 if(s2->Flag()==-10) continue;
253 if( s2==s1 ) continue;
254 if( Abs(X(1, *s2) - v[0]) > dv[0] ) continue;
255 if( Abs(Y(1, *s2) - v[1]) > dv[1] ) continue;
256 if( Abs(TX(1, *s2)- tx1) > dv[2] ) continue;
257 if( Abs(TY(1, *s2)- ty1) > dv[3] ) continue;
258
259 if(doFill) {
260 eS[0].Add(s1);
261 eS[1].Add(s2);
262 }
263 ncomb++;
264 }
265 nout+=ncomb;
266 if(eDoubletsRate) eDoubletsRate->Fill(ncomb);
267 }
268
269 arr1.Clear();
270 arr2.Clear();
271
272 Log(3,"FillCombinations","%d selected with the acceptance: %7.2f %7.2f (%d,%d) and tolerance (%7.2f %7.2f %7.4f %7.4f)",
273 nout, dxMax,dyMax, ir2[0], ir2[1], dv[0], dv[1], dv[2], dv[3] );
274 return nout;
275}
int SelectObjects(TObjArray &arr)
Definition: EdbCell2.cpp:738
int SelectObjectsC(int iv[2], int ir[2], TObjArray &arr)
Definition: EdbCell2.cpp:707
void Clear()
Definition: EdbSegP.h:86

◆ FillGuessCell() [1/2]

void EdbAlignmentV::FillGuessCell ( EdbPattern p1,
EdbPattern p2,
float  binOK = 1.,
float  offsetMax = 2000. 
)

binOK - is the mean number of entries requested per bin

881{
883
884 float xmin1=Xmin(0,p1), ymin1=Ymin(0,p1), xmax1=Xmax(0,p1), ymax1=Ymax(0,p1);
885 float xmin2=Xmin(1,p2), ymin2=Ymin(1,p2), xmax2=Xmax(1,p2), ymax2=Ymax(1,p2);
886 Log(3, "FillGuessCell", "x1:(%f %f) y1:(%f %f)",xmin1,xmax1, ymin1, ymax1);
887 Log(3, "FillGuessCell", "x2:(%f %f) y2:(%f %f)",xmin2,xmax2, ymin2, ymax2);
888 ApplyLimitsOffset( xmin1, xmax1, xmin2, xmax2, offsetMax);
889 ApplyLimitsOffset( ymin1, ymax1, ymin2, ymax2, offsetMax);
890 int np1 = p1.N(), np2 = p2.N();
891
892 DefineGuessCell( xmin1, xmax1, ymin1, ymax1, xmin2, xmax2, ymin2, ymax2, np1, np2, binOK);
893
894 FillCell( 0, p1 );
895 FillCell( 1, p2 );
896
897 if( Log(3, "FillGuessCell", "with patterns of %d %d statistics:",np1,np2) ) {
898 ePC[0].PrintStat();
899 ePC[1].PrintStat();
900 }
901}
float Ymin(int side, EdbPattern &p)
Definition: EdbAlignmentV.cxx:1065
void ApplyLimitsOffset(float &xmin1, float &xmax1, float &xmin2, float &xmax2, float offsetMax)
Definition: EdbAlignmentV.cxx:847
float Xmax(int side, EdbPattern &p)
Definition: EdbAlignmentV.cxx:1054
void DefineGuessCell(float xmin1, float xmax1, float ymin1, float ymax1, float xmin2, float xmax2, float ymin2, float ymax2, int np1, int np2, float binOK)
Selector functions.
Definition: EdbAlignmentV.cxx:858
float Ymax(int side, EdbPattern &p)
Definition: EdbAlignmentV.cxx:1076
float Xmin(int side, EdbPattern &p)
Definition: EdbAlignmentV.cxx:1043
void FillCell(int side, EdbPattern &pat)
Definition: EdbAlignmentV.cxx:927
void PrintStat()
Definition: EdbCell2.cpp:674

◆ FillGuessCell() [2/2]

void EdbAlignmentV::FillGuessCell ( TObjArray &  p1,
TObjArray &  p2,
float  binOK = 1.,
float  offsetMax = 2000. 
)

binOK - is the mean number of entries requested per bin

905{
907
908 float xmin1=Xmin(0,p1), ymin1=Ymin(0,p1), xmax1=Xmax(0,p1), ymax1=Ymax(0,p1);
909 float xmin2=Xmin(1,p2), ymin2=Ymin(1,p2), xmax2=Xmax(1,p2), ymax2=Ymax(1,p2);
910 ApplyLimitsOffset( xmin1, xmax1, xmin2, xmax2, offsetMax);
911 ApplyLimitsOffset( ymin1, ymax1, ymin2, ymax2, offsetMax);
912 int np1 = p1.GetEntries(), np2 = p2.GetEntries();
913
914 Log(3, "FillGuessCell", "xmin1, xmax1, ymin1, ymax1, xmin2, xmax2, ymin2, ymax2, np1, np2, binOK: %f %f %f %f %f %f %f %f %d %d %f",xmin1, xmax1, ymin1, ymax1, xmin2, xmax2, ymin2, ymax2, np1, np2, binOK);
915 DefineGuessCell( xmin1, xmax1, ymin1, ymax1, xmin2, xmax2, ymin2, ymax2, np1, np2, binOK);
916
917 FillCell( 0, p1 );
918 FillCell( 1, p2 );
919
920 if( Log(3, "FillGuessCell", "with arrays of %d %d statistics:",np1,np2) ) {
921 ePC[0].PrintStat();
922 ePC[1].PrintStat();
923 }
924}

◆ FillThetaHist()

void EdbAlignmentV::FillThetaHist ( int  side,
EdbH2 htxy 
)
197{
198 if( side<0 || side>1 ) return;
199 TObjArray arr(10000);
200 int n = ePC[side].SelectObjects(arr);
201 for(int i=0; i<n; i++) {
202 EdbSegP *s = (EdbSegP*)arr.UncheckedAt(i);
203 htxy.Fill( s->TY(), s->TX() );
204 }
205}
int Fill(float x, float y)
Definition: EdbCell2.h:88

◆ FindCorrDiff()

Int_t EdbAlignmentV::FindCorrDiff ( float  dvsame[4],
int  side = 0,
int  nlim = 10 
)

find diffs with the default settings and correct requested side

666{
668 if(!SideOK(side)) return 0;
669 float dvf[4];
670 int n = FindDiff(eS[0], eS[1], dvsame, dvf );
671 if(n<nlim) return n;
672 eCorr[side].AddV(0,dvf[0]);
673 eCorr[side].AddV(1,dvf[1]);
674 //eCorr[side].AddV(3,dvf[2]);
675 //eCorr[side].AddV(4,dvf[3]);
676 Log(3,"FindCorrDiff","correct side %d with %11.7f %11.7f %10.7f %10.7f using %5d coinsidences",
677 side, dvf[0] ,dvf[1] ,dvf[2] ,dvf[3],n);
678 return n;
679}
Int_t FindDiff(TObjArray &arr1, TObjArray &arr2, float dvlim[4], float dvfound[4])
Definition: EdbAlignmentV.cxx:682

◆ FindDensityPeak()

Float_t EdbAlignmentV::FindDensityPeak ( TArrayF &  arr,
float  fraction 
)
564{
565 if(fraction<=0||fraction>1) Log(1,"EdbAlignmentV::FindDensityPeak","ERROR! fraction out of limits: %f",fraction);
566 TArrayI ind(arr.fN);
567 Sort( arr.fN, arr.GetArray(), ind.GetArray(), 0 );
568 int nfra = (int)(fraction*arr.fN);
569 float dxmin = arr[ ind[nfra] ] - arr[ ind[0] ];
570 int ibest=0;
571 for(int i=1; i<arr.fN-nfra; i++) {
572 float dx = arr[ ind[nfra+i] ] - arr[ind[i]];
573 if( dx < dxmin) {
574 dxmin = dx;
575 ibest=i;
576 }
577 }
578
579 Double_t sd=0;
580 int ic=0;
581 for(int i=ibest; i<ibest+nfra-1; i++) {
582 sd += arr[ ind[i] ];
583 ic++;
584 }
585 sd /= ic;
586 Log(2,"EdbAlignmentV::FindDensityPeak", "nfra/n: %d/%d dxmin = %g sd = %g",nfra,arr.fN,dxmin,sd);
587 return (Float_t)sd;
588}

◆ FindDiff()

Int_t EdbAlignmentV::FindDiff ( TObjArray &  arr1,
TObjArray &  arr2,
float  dvlim[4],
float  dvfound[4] 
)
683{
684 int n = CheckEqualArr(arr1,arr2);
685 int ic=0;
686 EdbSegP *s1,*s2;
687 Double_t sdx=0, sdy=0, sdtx=0, sdty=0;
688 float dvf[4];
689 for(int i=0; i<n; i++) {
690 s1 = (EdbSegP*)arr1.UncheckedAt(i);
691 s2 = (EdbSegP*)arr2.UncheckedAt(i);
692 if( ValidCoinsidence(*s1, *s2, dvlim, dvf) ) {
693 sdx += dvf[0];
694 sdy += dvf[1];
695 sdtx += dvf[2];
696 sdty += dvf[3];
697 ic++;
698 }
699 }
700 dvfound[0] = sdx/ic;
701 dvfound[1] = sdy/ic;
702 dvfound[2] = sdtx/ic;
703 dvfound[3] = sdty/ic;
704 return ic;
705}
Bool_t ValidCoinsidence(EdbSegP &s1, EdbSegP &s2, float dvlim[4], float dvfound[4])
Definition: EdbAlignmentV.cxx:709

◆ FineCorrPhi()

Float_t EdbAlignmentV::FineCorrPhi ( TObjArray &  sel1,
TObjArray &  sel2 
)

for the correct answer the O,O should be in the CoG of the second pattern

465{
467 int n = CheckEqualArr(arr1,arr2);
468 if(n<3) return 0;
469 double x1=0, y1=0, x2=0,y2=0;
470 Double_t R=0, r=0, dPhi=0;
471 for(int i=0; i<n; i++) {
472 EdbSegP *s1 = (EdbSegP*)arr1.UncheckedAt(i);
473 EdbSegP *s2 = (EdbSegP*)arr2.UncheckedAt(i);
474 x1 = X(0,*s1);
475 y1 = Y(0,*s1);
476 x2 = X(1,*s2);
477 y2 = Y(1,*s2);
478 r = Sqrt(x1*x1+y1*y1);
479 dPhi += (ATan2(-y2,-x2) - ATan2(-y1,-x1)) * r;
480 R += r;
481 }
482 dPhi /= R;
483 Log(3,"FineCorrPhi","dPhi =%f with %d segments", (float)dPhi, n );
484 return (float)dPhi;
485}
void r(int rid=2)
Definition: test.C:201

◆ FineCorrZ() [1/2]

float EdbAlignmentV::FineCorrZ ( )
inline
89{ return FineCorrZ(eS[0], eS[1]); }

◆ FineCorrZ() [2/2]

Float_t EdbAlignmentV::FineCorrZ ( TObjArray &  sel1,
TObjArray &  sel2 
)
400{
401 double dzz=0, dzx=0, dzy=0;
402 int n = CheckEqualArr(arr1,arr2);
403 int icx=0, icy=0;
404 for(int i=0; i<n; i++) {
405 EdbSegP *s1 = (EdbSegP*)arr1.UncheckedAt(i);
406 EdbSegP *s2 = (EdbSegP*)arr2.UncheckedAt(i);
407 float tx1 = TX(0, *s1), ty1 = TY(0, *s1);
408 float x1 = X(0,*s1), y1 = Y(0,*s1);
409 float x2 = X(1,*s2), y2 = Y(1,*s2);
410
411 if(tx1>0.1) {
412 dzx += (x2-x1)/tx1;
413 icx++;
414 }
415 if(ty1>0.1) {
416 dzy += (y2-y1)/ty1;
417 icy++;
418 }
419 }
420
421 if(icx+icy>3) dzz = (dzx+dzy)/(icx+icy);
422
423 Log(3,"FineCorrZ","dzz =%f with icx=%d and icy=%d (of %d) segments",
424 (float)dzz, icx,icy, n );
425
426 return (float)dzz;
427}

◆ HDistance()

void EdbAlignmentV::HDistance ( EdbPattern p1,
EdbPattern p2,
float  dxMax,
float  dyMax 
)
753{
754 Log(3,"HDistance","preselection for patterns with %d and %d segments",p1.N(), p2.N());
755
756 int eITMAX=51; // angular normalization (def=50) (the step is ~1./eITMAX)
757 int eOCMAX=100; // occupancy (def=100)
758 int nx=201, ny=201, no=eOCMAX;
759
760 Long_t *ind1 = new Long_t[nx*ny*no];
761 Long_t *ind2 = new Long_t[nx*ny*no];
762 Int_t *oc1 = new Int_t[nx*ny];
763 Int_t *oc2 = new Int_t[nx*ny];
764 memset(ind1,0,nx*ny*no*sizeof(Long_t));
765 memset(ind2,0,nx*ny*no*sizeof(Long_t));
766 memset( oc1,0,nx*ny*sizeof(Int_t));
767 memset( oc2,0,nx*ny*sizeof(Int_t));
768
769 int itx,ity;
770
771 for(int i=0;i<eITMAX;i++) for(int j=0;j<eITMAX;j++) { oc1[i*nx+j]=0; oc2[i*nx+j]=0;}
772 for(int i=0;i<p1.N();i++){
773 itx=int( (p1.GetSegment(i)->TX()+1.)*eITMAX/2. );
774 ity=int( (p1.GetSegment(i)->TY()+1.)*eITMAX/2. );
775 if(itx<eITMAX)
776 if(ity<eITMAX)
777 if(itx>=0)
778 if(ity>=0)
779 if(oc1[itx*nx+ity]<eOCMAX-1)
780 { ind1[itx*nx*ny+ity*ny+oc1[itx*nx+ity]]=i; (oc1[itx*nx+ity])++;}
781 }
782 for(int i=0;i<p2.N();i++){
783 itx=int( (p2.GetSegment(i)->TX()+1.)*eITMAX/2 );
784 ity=int( (p2.GetSegment(i)->TY()+1.)*eITMAX/2 );
785 if(itx<eITMAX)
786 if(ity<eITMAX)
787 if(itx>=0)
788 if(ity>=0)
789 if(oc2[itx*nx+ity]<eOCMAX-1)
790 { ind2[itx*nx*ny+ity*ny+oc2[itx*nx+ity]]=i; (oc2[itx*nx+ity])++;}
791 }
792
793 eS[0].Clear();
794 eS[1].Clear();
795
796 EdbSegP *s1,*s2;
797 for(int itx=0;itx<eITMAX;itx++) for(int ity=0;ity<eITMAX;ity++)
798 for(int i=0;i<oc1[itx*nx+ity];i++) {
799 s1 = p1.GetSegment(ind1[itx*nx*ny+ity*ny+i]);
800 for(int j=0;j<oc2[itx*nx+ity];j++)
801 {
802 s2 = p2.GetSegment(ind2[itx*nx*ny+ity*ny+j]);
803 if(Abs(s2->eX-s1->eX)>dxMax) continue;
804 if(Abs(s2->eY-s1->eY)>dyMax) continue;
805 eS[0].Add( s1 );
806 eS[1].Add( s2 );
807 }
808 }
809 delete [] ind1;
810 delete [] ind2;
811 delete [] oc1;
812 delete [] oc2;
813 Log(3,"HDistance","preselection for patterns with %d and %d segments: %d comb",p1.N(), p2.N(), eS[0].GetEntries());
814}
Float_t eX
Definition: EdbSegP.h:31
Float_t eY
Definition: EdbSegP.h:31

◆ InitHphi()

void EdbAlignmentV::InitHphi ( int  n,
float  min,
float  max 
)
inline
47{ eH[0][6].InitH1(n, min, max); }
EdbH1 eH[2][7]
Definition: EdbAlignmentV.h:27
int InitH1(const EdbH1 &h)
Definition: EdbCell1.h:38

◆ InitHshr0()

void EdbAlignmentV::InitHshr0 ( int  n,
float  min,
float  max 
)
inline
48{ eH[0][5].InitH1(n, min, max); }

◆ InitHshr1()

void EdbAlignmentV::InitHshr1 ( int  n,
float  min,
float  max 
)
inline
49{ eH[1][5].InitH1(n, min, max); }

◆ InitHx()

void EdbAlignmentV::InitHx ( int  n,
float  min,
float  max 
)
inline
44{ eH[0][0].InitH1(n, min, max); }

◆ InitHy()

void EdbAlignmentV::InitHy ( int  n,
float  min,
float  max 
)
inline
45{ eH[0][1].InitH1(n, min, max); }

◆ InitHz()

void EdbAlignmentV::InitHz ( int  n,
float  min,
float  max 
)
inline
46{ eH[0][2].InitH1(n, min, max); }

◆ InitOutputFile()

void EdbAlignmentV::InitOutputFile ( const char *  file = "report_al.root",
const char *  option = "RECREATE" 
)

IO, initialization and finalization functions.

42{
44 eOutputFile = TFile::Open(file,option);
45}
void CloseOutputFile()
Definition: EdbAlignmentV.cxx:48
TFile * file
Definition: write_pvr.C:3

◆ InitPatCellBin()

void EdbAlignmentV::InitPatCellBin ( int  side,
EdbPattern pat,
float  binx,
float  biny 
)
831{
832 if(!SideOK(side)) return;
833
834 EdbSegP s1min(0,pat.Xmin(), pat.Ymin(), 0,0 );
835 EdbSegP s1max(0,pat.Xmax(), pat.Ymax(), 0,0 );
836 float min[2] = { X(side,s1min)-eXmarg, X(side,s1min)-eYmarg };
837 float max[2] = { X(side,s1max)+eXmarg, X(side,s1max)+eYmarg };
838
839 int n[2] = { (int)((max[0]-min[0])/binx+1), (int)((max[1]-min[1])/biny+1) };
840 int maxcell = pat.N()/n[0]/n[1]+10;
841 maxcell += (int)(5*Sqrt(maxcell));
842 Log(2, "InitPatCellBin", "maxcell = %d\n",maxcell);
843 ePC[side].InitCell(maxcell,n,min,max);
844}
virtual Float_t Xmax() const
Definition: EdbVirtual.cxx:196
virtual Float_t Ymin() const
Definition: EdbVirtual.cxx:206
virtual Float_t Xmin() const
Definition: EdbVirtual.cxx:186
virtual Float_t Ymax() const
Definition: EdbVirtual.cxx:216

◆ InitPatCellN()

void EdbAlignmentV::InitPatCellN ( EdbCell2 cell,
EdbPattern pat,
int  nx,
int  ny 
)

note: no correction (do we need tis function?)

818{
820 float min[2] = {pat.Xmin()-eXmarg, pat.Ymin()-eYmarg };
821 float max[2] = {pat.Xmax()+eXmarg, pat.Ymax()+eYmarg };
822 int n[2] = {nx,ny};
823 int maxcell = pat.N()/n[0]/n[1]+10;
824 maxcell += (int)(5*Sqrt(maxcell));
825 Log(2, "InitPatCellN", "maxcell = %d\n",maxcell);
826 cell.InitCell(maxcell,n,min,max);
827}

◆ IsInsideDVsame()

Bool_t EdbAlignmentV::IsInsideDVsame ( EdbSegP s1,
EdbSegP s2 
)
58{
59 if( Abs(s1.X()-s2.X()) > eDVsame[0] ) return 0;
60 if( Abs(s1.Y()-s2.Y()) > eDVsame[1] ) return 0;
61 if( Abs(s1.TX()-s2.TX()) > eDVsame[2] ) return 0;
62 if( Abs(s1.TY()-s2.TY()) > eDVsame[3] ) return 0;
63 return 1;
64}

◆ Ncoins()

Int_t EdbAlignmentV::Ncoins ( float  dvlim[4],
EdbH2 hdxy = 0,
EdbH2 hdtxty = 0,
TObjArray *  sel1 = 0,
TObjArray *  sel2 = 0 
)

calculate all coinsidences inside dv:(dx,dy, dtx,dty)
fill position and angular 2-d plots if requested
fill arrays with selected segments sel1, sel2 if requested

723{
727
728 int ic = 0; // counter
729 int n = CheckEqualArr(eS[0],eS[1]);
730
731 if(hdxy) hdxy->CleanCells();
732 if(hdtxy) hdtxy->CleanCells();
733
734 float dfound[4];
735 for(int i=0; i<n; i++)
736 {
737 EdbSegP *s1 = (EdbSegP*)eS[0].UncheckedAt(i);
738 EdbSegP *s2 = (EdbSegP*)eS[1].UncheckedAt(i);
739
740 if( !ValidCoinsidence(*s1, *s2, dv, dfound) ) continue;
741
742 ic++;
743 if(sel1) sel1->Add(s1);
744 if(sel2) sel2->Add(s2);
745 if(hdxy) hdxy->Fill(dfound[0],dfound[1]);
746 if(hdtxy) hdtxy->Fill(dfound[2],dfound[3]);
747 }
748 return ic;
749}
void CleanCells()
Definition: EdbCell2.cpp:114

◆ Ncp()

Int_t EdbAlignmentV::Ncp ( )
inline

Functions applied to the selected parallel arrays.

76{return CheckEqualArr( eS[0], eS[1]); }

◆ OptimiseVar1()

int EdbAlignmentV::OptimiseVar1 ( int  side,
int  ivar,
EdbH2 hdxy = 0,
EdbH2 hdtxy = 0 
)

use already preselected "couples" - useful to test small variations of parameters

279{
281 if(!SideOK(side)) return 0;
282
283 EdbH1 &h = eH[side][ivar];
284 if( h.N() < 1 ) {
285 Log(1,"OptimiseVar1","ERROR: var %d of side %d have %d steps - skipped", ivar,side, h.N() );
286 return 0;
287 }
288
289 h.CleanCells();
290
291 int npk0=0;
292 float dx0=0,dy0=0; //the position of the highest peak in xy
293 float var0=0; //the position of the highest peak on var
294 for(int i=0; i<h.N(); i++)
295 {
296 float var= h.X(i);
297 eCorr[side].SetV( ivar, var );
298
299 int npk = Ncoins(eDVsame, hdxy);
300
301 float dx=0, dy=0;
302 if(hdxy){
303 EdbPeak2 pk2(*hdxy);
304 npk = (int)(pk2.ProbPeak( dx, dy ));
305 //hdxy->DrawH2(Form("hdxy%d_%2.2d",side,i),Form("OptimiseVar1: ivar=%d var=%f npk=%d",ivar, var,npk) )->Write();
306 }
307 h.SetBin( i, npk );
308 if( npk > npk0 ) { npk0=npk; dx0 = dx; dy0=dy; var0 = var; }
309 Log(4,"OptimiseVar1"," %d %f %d (%f %f)", i, h.X(i), h.Bin(i), dx,dy );
310 }
311
312 //eCorr[side].AddV(0,dx0); // set x-y corrections if any
313 //eCorr[side].AddV(1,dy0);
314 eCorr[side].SetV(ivar,var0);
315 if(hdxy) Ncoins(eDVsame, hdxy); // to keep the optimal histogram in hdxy
316
317 Log(3,"OptimiseVar1"," side:var (%d:%d): found %d at var=%f xy:(%f %f)", side, ivar, npk0, var0, dx0,dy0 );
318 return npk0;
319}
Int_t Ncoins(float dvlim[4], EdbH2 *hdxy=0, EdbH2 *hdtxty=0, TObjArray *sel1=0, TObjArray *sel2=0)
Definition: EdbAlignmentV.cxx:722
fast 2-dim histogram class (used as a basis for EdbCell1)
Definition: EdbCell1.h:17
float X(int i) const
Definition: EdbCell1.h:53
int Bin(int ix) const
Definition: EdbCell1.h:57
int N() const
Definition: EdbCell1.h:48
void CleanCells()
Definition: EdbCell1.cpp:85
void SetBin(int ix, int n)
Definition: EdbCell1.h:65
peak analyser for EdbH2
Definition: EdbCell2.h:105

◆ OptimiseVar2()

void EdbAlignmentV::OptimiseVar2 ( int  side1,
int  ivar1,
int  side2,
int  ivar2,
EdbH2 h12,
EdbH2 hdxy = 0,
EdbH2 hdtxty = 0 
)

use already preselected "couples" - useful to test small variations of parameters
especially after Hdistance preselection
Input: 2 variables defoned as side1/ivar1 and side1/ivar1
Output: h12 - filled selections histo
Optional: hdxy, hdtxy - 2d- histograms defined outside and used for the peak selection

325{
331 if(!SideOK(side1)) return;
332 if(!SideOK(side2)) return;
333 EdbH1 &h1 = eH[side1][ivar1];
334 EdbH1 &h2 = eH[side2][ivar2];
335 if( h1.N() < 1 || h2.N() < 1) {
336 Log(1,"OptimiseVar2","ERROR: var %d of side %d have %d steps - skipped", ivar1,side1, h1.N() );
337 Log(1,"OptimiseVar2","ERROR: var %d of side %d have %d steps - skipped", ivar2,side2, h2.N() );
338 return;
339 }
340 Log(3,"OptimiseVar2","side/var: %d/%d and %d/%d with %d x %d = %d attempts",
341 side1, ivar1, side2, ivar2, h1.N(), h2.N(), h1.N()*h2.N() );
342
343 //h12.Delete();
344 int n12[2] = { h1.N(), h2.N() };
345 float min[2] = { h1.Xmin(), h2.Xmin() };
346 float max[2] = { h1.Xmax(), h2.Xmax() };
347 h12.InitH2(n12, min, max);
348
349 h1.CleanCells();
350 h2.CleanCells();
351
352 int npk0=0;
353 float dx0=0,dy0=0; //the position of the highest peak
354
355 for(int i1=0; i1<h1.N(); i1++)
356 {
357 eCorr[side1].SetV( ivar1, h1.X(i1) );
358 for(int i2=0; i2<h2.N(); i2++)
359 {
360 eCorr[side2].SetV( ivar2, h2.X(i2) );
361 int nc = Ncoins(eDVsame, hdxy);
362 if(!hdxy) h12.SetBin( i1, i2, nc );
363 else {
364 EdbPeak2 pk2(*hdxy);
365 float dx, dy;
366 int npk = pk2.FindPeak( dx, dy );
367 //int npk = pk2.FindPeak9( dx, dy );
368 if( npk > npk0 ) { npk0=npk; dx0 = dx; dy0=dy; }
369 h12.SetBin( i1, i2, npk );
370 }
371 }
372 }
373
374 eCorr[side1].AddV(0,dx0); // set x-y corrections
375 eCorr[side1].AddV(1,dy0);
376}
void SetBin(int ix, int iy, int n)
Definition: EdbCell2.h:90
int InitH2(const EdbH2 &h)
Definition: EdbCell2.cpp:78
TH1F * h2
Definition: energy.C:19
TH1F * h1
Definition: energy.C:16

◆ SelectBestCouple()

int EdbAlignmentV::SelectBestCouple ( )

assume the different pattern's segments in eS[0] and eS[1]
assume that the selection method in FillCombinations - "first s1 then s2"

153{
156
157 int nrem=0;
158 int n = CheckEqualArr(eS[0], eS[1]);
159 EdbSegP *s1=0,*s2=0;
160 EdbSegP *s1ok=0,*s2ok=0;
161 int iok=-1;
162 for(int i=0; i<n; i++) {
163 s1 = (EdbSegP*)eS[0].UncheckedAt(i);
164 s2 = (EdbSegP*)eS[1].UncheckedAt(i);
165 if(s1==s1ok) {
166 if( CoupleQuality(*s1,*s2) > CoupleQuality(*s1ok,*s2ok) ) {
167 s1ok = s1, s2ok = s2;
168 eS[0].RemoveAt(iok);
169 eS[1].RemoveAt(iok);
170 iok=i;
171 }
172 else {
173 eS[0].RemoveAt(i);
174 eS[1].RemoveAt(i);
175 }
176 nrem++;
177 }
178 else { s1ok = s1, s2ok = s2; iok=i; }
179 }
180
181 eS[0].Compress();
182 eS[1].Compress();
183
184 Log(2,"SelectBestCouple","%d couples discarded with", nrem );
185 return nrem;
186}
float CoupleQuality(EdbSegP &s1, EdbSegP &s2)
Definition: EdbAlignmentV.cxx:189

◆ SelectIsolated()

int EdbAlignmentV::SelectIsolated ( )

assume the different pattern's segments in eS[0] and eS[1]
assume that the selection method in FillCombinations - "first s1 then s2"
remove all duplicated combs

117{
121
122 int nrem=0;
123 int n = CheckEqualArr(eS[0], eS[1]);
124 EdbSegP *s1=0,*s2=0;
125 EdbSegP *s1ok=0,*s2ok=0;
126 int iok=-1;
127 for(int i=0; i<n; i++) {
128 s1 = (EdbSegP*)eS[0].UncheckedAt(i);
129 s2 = (EdbSegP*)eS[1].UncheckedAt(i);
130 if(s1==s1ok) {
131 eS[0].RemoveAt(i);
132 eS[1].RemoveAt(i);
133 nrem++;
134 }
135 else if(s1ok!=0) {
136 eS[0].RemoveAt(iok);
137 eS[1].RemoveAt(iok);
138 s1ok=0;
139 nrem++;
140 }
141 else { s1ok = s1, s2ok = s2; iok=i; }
142 }
143
144 eS[0].Compress();
145 eS[1].Compress();
146
147 Log(2,"SelectIsolated","%d couples discarded with", nrem );
148 return nrem;
149}

◆ SideOK()

bool EdbAlignmentV::SideOK ( int  side)
380{
381 if(side==0||side==1) return 1;
382 else {
383 Log(1,"SideOK","ERROR: invalid side index %d",side);
384 return 0;
385 }
386}

◆ StrDVsame()

char * EdbAlignmentV::StrDVsame ( ) const
inline
50{return Form("%7.2f %7.2f %8.5f %8.5f",eDVsame[0],eDVsame[1],eDVsame[2],eDVsame[3]); }

◆ TX()

float EdbAlignmentV::TX ( int  side,
EdbSegP s 
)
inline
120{ return eUseAffCorr? eCorrL[side].TX(s) : eCorr[side].TX(s); }
float TX() const
Definition: EdbLayer.h:78
float TX(EdbSegP &s)
Definition: EdbSegCorr.h:34

◆ TY()

float EdbAlignmentV::TY ( int  side,
EdbSegP s 
)
inline
121{ return eUseAffCorr? eCorrL[side].TY(s) : eCorr[side].TY(s); }
float TY() const
Definition: EdbLayer.h:79
float TY(EdbSegP &s)
Definition: EdbSegCorr.h:35

◆ ValidCoinsidence()

Bool_t EdbAlignmentV::ValidCoinsidence ( EdbSegP s1,
EdbSegP s2,
float  dvlim[4],
float  dvfound[4] 
)
710{
711 if(&s1==&s2) return 0;
712 if(s1.Flag()==-10) return 0;
713 if(s2.Flag()==-10) return 0;
714 dfound[0] = X(1,s2) - X(0,s1); if(Abs(dfound[0]) > dv[0]) return 0;
715 dfound[1] = Y(1,s2) - Y(0,s1); if(Abs(dfound[1]) > dv[1]) return 0;
716 dfound[2] = TX(1,s2) - TX(0,s1); if(Abs(dfound[2]) > dv[2]) return 0;
717 dfound[3] = TY(1,s2) - TY(0,s1); if(Abs(dfound[3]) > dv[3]) return 0;
718 return 1;
719}

◆ Var() [1/2]

float EdbAlignmentV::Var ( int  side,
EdbSegP s,
int  ivar 
)
inline
122 {switch(ivar) {
123 case(0): return X(side,s);
124 case(1): return Y(side,s);
125 case(2): return TX(side,s);
126 case(3): return TY(side,s); } return 0;
127 }

◆ Var() [2/2]

float EdbAlignmentV::Var ( int  side,
int  iseg,
int  ivar 
)
inline
128{ return Var(side,*((EdbSegP*)eS[side].UncheckedAt(iseg)),ivar); }

◆ X()

float EdbAlignmentV::X ( int  side,
EdbSegP s 
)
inline

Correction parameters handling.

118{ return eUseAffCorr? eCorrL[side].X(s) : eCorr[side].X(s); }
float X() const
Definition: EdbLayer.h:75
float X(EdbSegP &s)
Definition: EdbSegCorr.h:25

◆ Xmax() [1/2]

float EdbAlignmentV::Xmax ( int  side,
EdbPattern p 
)
1055{
1056 int n=p.N(); float xmax = 0;
1057 for(int i=0; i<n; i++) {
1058 EdbSegP *s = p.GetSegment(i);
1059 float x=X(side,*s);
1060 if(!i) xmax=x; else if( x>xmax) xmax=x;
1061 }
1062 return xmax;
1063}

◆ Xmax() [2/2]

float EdbAlignmentV::Xmax ( int  side,
TObjArray &  p 
)
1100{
1101 int n=p.GetEntries(); float xmax = 0;
1102 for(int i=0; i<n; i++) {
1103 EdbSegP *s = (EdbSegP*)(p.At(i));
1104 float x=X(side,*s);
1105 if(!i) xmax=x; else if( x>xmax) xmax=x;
1106 }
1107 return xmax;
1108}

◆ Xmin() [1/2]

float EdbAlignmentV::Xmin ( int  side,
EdbPattern p 
)
1044{
1045 int n=p.N(); float xmin = 0;
1046 for(int i=0; i<n; i++) {
1047 EdbSegP *s = p.GetSegment(i);
1048 float x=X(side,*s);
1049 if(!i) xmin=x; else if( x<xmin) xmin=x;
1050 }
1051 return xmin;
1052}

◆ Xmin() [2/2]

float EdbAlignmentV::Xmin ( int  side,
TObjArray &  p 
)
1089{
1090 int n=p.GetEntries(); float xmin = 0;
1091 for(int i=0; i<n; i++) {
1092 EdbSegP *s = (EdbSegP*)(p.At(i));
1093 float x=X(side,*s);
1094 if(!i) xmin=x; else if( x<xmin) xmin=x;
1095 }
1096 return xmin;
1097}

◆ Y()

float EdbAlignmentV::Y ( int  side,
EdbSegP s 
)
inline
119{ return eUseAffCorr? eCorrL[side].Y(s) : eCorr[side].Y(s); }
float Y() const
Definition: EdbLayer.h:76
float Y(EdbSegP &s)
Definition: EdbSegCorr.h:26

◆ Ymax() [1/2]

float EdbAlignmentV::Ymax ( int  side,
EdbPattern p 
)
1077{
1078 int n=p.N(); float ymax = 0;
1079 for(int i=0; i<n; i++) {
1080 EdbSegP *s = p.GetSegment(i);
1081 float y=Y(side,*s);
1082 if(!i) ymax=y; else if( y>ymax) ymax=y;
1083 }
1084 return ymax;
1085}

◆ Ymax() [2/2]

float EdbAlignmentV::Ymax ( int  side,
TObjArray &  p 
)
1122{
1123 int n=p.GetEntries(); float ymax = 0;
1124 for(int i=0; i<n; i++) {
1125 EdbSegP *s = (EdbSegP*)(p.At(i));
1126 float y=Y(side,*s);
1127 if(!i) ymax=y; else if( y>ymax) ymax=y;
1128 }
1129 return ymax;
1130}

◆ Ymin() [1/2]

float EdbAlignmentV::Ymin ( int  side,
EdbPattern p 
)
1066{
1067 int n=p.N(); float ymin = 0;
1068 for(int i=0; i<n; i++) {
1069 EdbSegP *s = p.GetSegment(i);
1070 float y=Y(side,*s);
1071 if(!i) ymin=y; else if( y<ymin) ymin=y;
1072 }
1073 return ymin;
1074}

◆ Ymin() [2/2]

float EdbAlignmentV::Ymin ( int  side,
TObjArray &  p 
)
1111{
1112 int n=p.GetEntries(); float ymin = 0;
1113 for(int i=0; i<n; i++) {
1114 EdbSegP *s = (EdbSegP*)(p.At(i));
1115 float y=Y(side,*s);
1116 if(!i) ymin=y; else if( y<ymin) ymin=y;
1117 }
1118 return ymin;
1119}

Member Data Documentation

◆ eCorr

EdbSegCorr EdbAlignmentV::eCorr[2]

corrections for side 1 and 2 (v[7]) - the result of the alignment

◆ eCorrL

EdbLayer EdbAlignmentV::eCorrL[2]

corrections in form of affine transformations - the final output

◆ eDoubletsRate

TH1I* EdbAlignmentV::eDoubletsRate

can be filled in FillCombinations()

◆ eDVsame

Float_t EdbAlignmentV::eDVsame[4]

(dx,dy,dtx,dty) condition for the coinsidence

◆ eH

EdbH1 EdbAlignmentV::eH[2][7]

conditions for the selection procedure for each var of each side variables: dx,dy,dz, dtx,dty, shr, phi 0 1 2 3 4 5 6

◆ eHxy

EdbH2 EdbAlignmentV::eHxy

position 2d histo to be used in OptimiseVar2

◆ eOutputFile

TFile* EdbAlignmentV::eOutputFile

◆ ePC

EdbCell2 EdbAlignmentV::ePC[2]

2-d position cells with patterns segments

◆ eS

TObjArray EdbAlignmentV::eS[2]

"parallel" arrays with the selected combinations of segments

◆ eUseAffCorr

Bool_t EdbAlignmentV::eUseAffCorr

if "true" - use eCorrL for corrections

◆ eXmarg

Float_t EdbAlignmentV::eXmarg

◆ eYmarg

Float_t EdbAlignmentV::eYmarg

margins for the cell definition


The documentation for this class was generated from the following files: