FEDRA emulsion software from the OPERA Collaboration
EdbLinking Class Reference

#include <EdbLinking.h>

Inheritance diagram for EdbLinking:
Collaboration diagram for EdbLinking:

Classes

struct  RemoveDoublets
 

Public Member Functions

void CloneCouplesTree (const char *ifile, const char *ofile, EdbAffine2D *aff=0, TCut *cut=0)
 
void CorrectAngles (TObjArray &p1, TObjArray &p2)
 
void CorrectShrinkage (EdbPattern &p1, EdbPattern &p2, float dshr)
 
void CorrectShrinkage (float dshr)
 
void CorrectShrinkage (TObjArray &p1, TObjArray &p2, float dshr)
 
void DoubletsFilterOut (TObjArray &p1, TObjArray &p2, bool fillhist=0)
 
void DumpDoubletsTree (EdbAlignmentV &adup, const char *name)
 
 EdbLinking ()
 
Double_t EstimatePatternArea (EdbPattern &p)
 
void FillCombinationsAtMeanZ (TObjArray &p1, TObjArray &p2)
 
void FullLinking (EdbPattern &p1, EdbPattern &p2)
 
void FullLinking (TObjArray &p1, TObjArray &p2)
 
void GetDoubletsPar (TEnv &env)
 
void GetFillPattern (EdbPattern &p, int layer=0)
 
void GetPar (TEnv &env)
 
void GetPreselectionPar (EdbSEQ &seq, TEnv &env)
 
void Link (EdbPattern &p1, EdbPattern &p2, EdbLayer &l1, EdbLayer &l2, TEnv &env, Double_t area1=-1, Double_t area2=-1)
 
void ProduceReport ()
 
void RankCouples (TObjArray &arr1, TObjArray &arr2)
 
void SaveCouplesTree (const char *file=0)
 
void SetApplyCorr (bool corr)
 
bool VerifyShrinkageCorr (int side)
 
void WriteShrinkagePlots ()
 
virtual ~EdbLinking ()
 
- Public Member Functions inherited from EdbAlignmentV
void AddSegCouple (EdbSegP *s1, EdbSegP *s2)
 
void ApplyLimitsOffset (float &xmin1, float &xmax1, float &xmin2, float &xmax2, float offsetMax)
 
void AssignFlagToS (int flag)
 
Int_t CalcAffFull ()
 
Int_t CalcApplyFractMeanDiff ()
 
Int_t CalcApplyMeanDiff ()
 
Float_t CalcFractMeanDiff (int ivar, float fraction)
 
Float_t CalcMeanDiff (int ivar)
 
Float_t CalcMeanDiff2Const (int ivar, int side, float mean)
 
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 CalculateAffTXTYShift (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 CalculateAffXYShift (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)
 
void CorrToCoG (int side, TObjArray &p)
 
float CoupleQuality (EdbSegP &s1, EdbSegP &s2)
 
bool DefineGuessCell (float xmin1, float xmax1, float ymin1, float ymax1, float xmin2, float xmax2, float ymin2, float ymax2, int np1, int np2, float binOK)
 
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")
 
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 ()
 
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)
 
void PrintCorr ()
 
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)
 
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 ()
 

Public Attributes

float eBinOK
 
float eChi2Acorr
 
float eCHI2Pmax
 
EdbScanCond eCond
 
int eCPRankingAlg
 
bool eDoCorrectAngles
 
bool eDoCorrectShrinkage
 
bool eDoDumpDoubletsTree
 
bool eDoFullLinking
 
bool eDoSaveCouples
 
float eDRfull
 
float eDShr
 
float eDTfull
 
EdbH2 eHdxyShr [2]
 
EdbLayer eL1
 
EdbLayer eL2
 
int eNcorrMin
 
int eNshr [2]
 
float eNsigmaEQlnk
 
float eNsigmaEQshr
 
struct EdbLinking::RemoveDoublets eRemoveDoublets
 
TObjArray eSegCouples
 
float eShr0
 
- Public Attributes inherited from EdbAlignmentV
EdbSegCorr eCorr [2]
 
EdbLayer eCorrL [2]
 
TH1I * eDoubletsRate
 
Float_t eDVsame [4]
 
EdbH1 eH [2][7]
 
EdbH2 eHxy
 
TFile * eOutputFile
 
EdbCell2 ePC [2]
 
TObjArray eS [2]
 
Bool_t eUseAffCorr
 
Float_t eXmarg
 
Float_t eYmarg
 

Additional Inherited Members

- Static Public Member Functions inherited from EdbAlignmentV
static Int_t CheckEqualArr (TObjArray &arr1, TObjArray &arr2)
 

Constructor & Destructor Documentation

◆ EdbLinking()

EdbLinking::EdbLinking ( )
28 {
29  eSegCouples.SetOwner();
30 }
TObjArray eSegCouples
Definition: EdbLinking.h:34

◆ ~EdbLinking()

virtual EdbLinking::~EdbLinking ( )
inlinevirtual
49 {}

Member Function Documentation

◆ CloneCouplesTree()

void EdbLinking::CloneCouplesTree ( const char *  ifile,
const char *  ofile,
EdbAffine2D aff = 0,
TCut *  cut = 0 
)

665 {
666  //read tree using eCut, apply affine transformation if any and write tree
667  EdbPattern pat, p1, p2;
668 
669  EdbCouplesTree ict;
670  if(cut) ict.eCut = (*cut);
671  ict.InitCouplesTree("couples",ifile,"READ");
672  int n = ict.GetCPData(eSegCouples);
673  ict.Close();
674 
675  if(aff) {
676  for(int i=0; i<n; i++) {
677  EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.UncheckedAt(i));
678  if(sc->eS) sc->eS->Transform(aff);
679  if(sc->eS) sc->eS1->Transform(aff);
680  if(sc->eS) sc->eS2->Transform(aff);
681  }
682  }
683 
684  SaveCouplesTree(ofile);
685 }
TCut cut
Definition: check_shower.C:6
Definition: EdbCouplesTree.h:17
TCut eCut
Definition: EdbCouplesTree.h:31
bool InitCouplesTree(const char *name="couples", const char *fname=0, Option_t *mode="READ")
Definition: EdbCouplesTree.cxx:87
void Close()
Definition: EdbCouplesTree.cxx:70
int GetCPData(EdbPattern *pat, EdbPattern *p1=0, EdbPattern *p2=0, TIndex2 *trseg=0)
Definition: EdbCouplesTree.cxx:325
void SaveCouplesTree(const char *file=0)
Definition: EdbLinking.cxx:314
Definition: EdbPattern.h:280
Definition: EdbSegCouple.h:14
EdbSegP * eS
Definition: EdbSegCouple.h:24
EdbSegP * eS2
pointers - useful when all segments are in memory
Definition: EdbSegCouple.h:26
EdbSegP * eS1
the result of the fit
Definition: EdbSegCouple.h:25
virtual void Transform(const EdbAffine2D *a)

◆ CorrectAngles()

void EdbLinking::CorrectAngles ( TObjArray &  p1,
TObjArray &  p2 
)
252 {
253  Log(2,"EdbLinking::CorrectAngles","arrays with %d and %d segments",p1.GetEntries(),p2.GetEntries());
254 
255  eCorr[0].SetV(2,0); eCorr[1].SetV(2,0);
256  RankCouples( eS[0], eS[1] );
257 
258  int nc=0;
259  double dtx1=0, dty1=0,dtx2=0, dty2=0;
260  int ncp = eSegCouples.GetEntries();
261  for(int i=0; i<ncp; i++) {
262  EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.At(i));
263  if(sc->CHI2P()>eChi2Acorr) continue;
264  dtx1+= TX( 0, *(sc->eS1) ) - sc->eS->TX();
265  dty1+= TY( 0, *(sc->eS1) ) - sc->eS->TY();
266  dtx2+= TX( 1, *(sc->eS2) ) - sc->eS->TX();
267  dty2+= TY( 1, *(sc->eS2) ) - sc->eS->TY();
268  nc++;
269  }
270  if(nc<eNcorrMin) {Log(1,"EdbLinking::CorrectAngles","Warning: number of the selected segments too small: %d < %d do not correct angles",
271  nc,eNcorrMin); return;}
272 
273  float cc=1.8;
274  dtx1 /= nc; dty1 /= nc; dtx2 /= nc; dty2 /= nc;
275  eCorr[0].AddV(3,-cc*dtx1); eCorr[0].AddV(4,-cc*dty1);
276  eCorr[1].AddV(3,-cc*dtx2); eCorr[1].AddV(4,-cc*dty2);
277 
278  Log(2,"EdbLinking::CorrectAngles","using %d segments dx1,dy1:( %6.3f %6.3f ) dx2,dy2:( %6.3f %6.3f )",
279  nc, dtx1*cc, dty1*cc, dtx2*cc, dty2*cc );
280 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
float TY(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:125
float TX(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:124
EdbSegCorr eCorr[2]
Definition: EdbAlignmentV.h:24
TObjArray eS[2]
Definition: EdbAlignmentV.h:21
int eNcorrMin
Definition: EdbLinking.h:32
float eChi2Acorr
Definition: EdbLinking.h:23
void RankCouples(TObjArray &arr1, TObjArray &arr2)
Definition: EdbLinking.cxx:456
void SetV(int i, float x)
Definition: EdbSegCorr.h:21
void AddV(int i, float x)
Definition: EdbSegCorr.h:22
float CHI2P() const
Definition: EdbSegCouple.h:59
Float_t TX() const
Definition: EdbSegP.h:172
Float_t TY() const
Definition: EdbSegP.h:173

◆ CorrectShrinkage() [1/3]

void EdbLinking::CorrectShrinkage ( EdbPattern p1,
EdbPattern p2,
float  dshr 
)
400 {
401  float dz = eL2.Z()-eL1.Z();
402  Log(2,"EdbLinking::CorrectShrinkage","patterns with %d and %d segments and z1 = %f z2 = %f",p1.N(),p2.N(),eL1.Z(),eL2.Z());
403  if(p1.N()<1||p2.N()<1) return;
404  //DoubletsFilterOut(p1,p2);
405  eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
406  FillGuessCell(p1,p2,eBinOK,0);
407 
408  CorrectShrinkage(dshr);
409 }
brick dz
Definition: RecDispMC.C:107
void FillGuessCell(EdbPattern &p1, EdbPattern &p2, float binOK=1., float offsetMax=2000.)
Definition: EdbAlignmentV.cxx:919
float Z() const
Definition: EdbLayer.h:78
EdbLayer eL1
Definition: EdbLinking.h:36
EdbLayer eL2
Definition: EdbLinking.h:36
void CorrectShrinkage(TObjArray &p1, TObjArray &p2, float dshr)
Definition: EdbLinking.cxx:385
float eBinOK
Definition: EdbLinking.h:28
Int_t N() const
Definition: EdbPattern.h:89

◆ CorrectShrinkage() [2/3]

void EdbLinking::CorrectShrinkage ( float  dshr)
413 {
414  EdbSegCorr c0 = eCorr[0], c1 = eCorr[1]; //save initial values
415  float dz = eL2.Z()-eL1.Z();
416 
417  eDVsame[0] = eDVsame[1] = 50; eDVsame[2] = eDVsame[3] = 0.03;
418  InitHshr0( 25, eCorr[0].V(5)/(1+dshr), eCorr[0].V(5)*(1+dshr) );
419  InitHshr1( 25, eCorr[1].V(5)/(1+dshr), eCorr[1].V(5)*(1+dshr) );
420 
421  eHdxyShr[0].InitH2(7, -35, 35, 7, -35, 35);
422  eCorr[0].SetV(2,dz); eCorr[1].SetV(2, 0);
423  eNshr[0] = OptimiseVar1( 0, 5, &eHdxyShr[0] ); // variate shr1
424  EdbSegCorr c0_opt = eCorr[0];
425 
426  eHdxyShr[1].InitH2(7, -35, 35, 7, -35, 35);
427  eCorr[0]=c0; // to remove the dependency on the correction order
428  eCorr[0].SetV(2, 0); eCorr[1].SetV(2, -dz);
429  eNshr[1] = OptimiseVar1( 1, 5, &eHdxyShr[1]); // variate shr2
430  eCorr[0]=c0_opt; // return to the optimized value
431 
432  Log(2,"EdbLinking::CorrectShrinkage","side1: %f (%f) side2: %f (%f)", eCorr[0].V(5), c0.V(5), eCorr[1].V(5), c1.V(5) );
433 }
Float_t eDVsame[4]
Definition: EdbAlignmentV.h:16
int OptimiseVar1(int side, int ivar, EdbH2 *hdxy=0, EdbH2 *hdtxy=0)
Definition: EdbAlignmentV.cxx:304
void InitHshr0(int n, float min, float max)
Definition: EdbAlignmentV.h:48
void InitHshr1(int n, float min, float max)
Definition: EdbAlignmentV.h:49
int InitH2(const EdbH2 &h)
Definition: EdbCell2.cpp:79
EdbH2 eHdxyShr[2]
Definition: EdbLinking.h:38
int eNshr[2]
Definition: EdbLinking.h:31
Definition: EdbSegCorr.h:8
float V(int i)
Definition: EdbSegCorr.h:23
TCanvas * c1
Definition: energy.C:13

◆ CorrectShrinkage() [3/3]

void EdbLinking::CorrectShrinkage ( TObjArray &  p1,
TObjArray &  p2,
float  dshr 
)
386 {
387  float dz = eL2.Z()-eL1.Z();
388  int n1 = p1.GetEntries(), n2=p2.GetEntries();
389  Log(2,"EdbLinking::CorrectShrinkage","arrays with %d and %d segments and z1 = %f z2 = %f",n1,n2,eL1.Z(),eL2.Z());
390  if(n1<1||n2<1) return;
391  //DoubletsFilterOut(p1,p2);
392  eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
393  FillGuessCell(p1,p2,eBinOK,0);
394 
395  CorrectShrinkage(dshr);
396 }

◆ DoubletsFilterOut()

void EdbLinking::DoubletsFilterOut ( TObjArray &  p1,
TObjArray &  p2,
bool  fillhist = 0 
)
615 {
616  TH2F *hxy1=0, *htxty1=0, *hxy2=0, *htxty2=0;
617  if(fillhist) {
618  hxy1 = new TH2F("dblXY1","Doublets DX DY",50,-eRemoveDoublets.dr,eRemoveDoublets.dr,50,-eRemoveDoublets.dr,eRemoveDoublets.dr);
619  htxty1 = new TH2F("dblTXTY1","Doublets DTX DTY",50,-eRemoveDoublets.dt,eRemoveDoublets.dt,50,-eRemoveDoublets.dt,eRemoveDoublets.dt);
620  hxy2 = new TH2F("dblXY2","Doublets DX DY",50,-eRemoveDoublets.dr,eRemoveDoublets.dr,50,-eRemoveDoublets.dr,eRemoveDoublets.dr);
621  htxty2 = new TH2F("dblTXTY2","Doublets DTX DTY",50,-eRemoveDoublets.dt,eRemoveDoublets.dt,50,-eRemoveDoublets.dt,eRemoveDoublets.dt);
622  }
623  EdbAlignmentV adup;
624  adup.eDVsame[0]=adup.eDVsame[1]= eRemoveDoublets.dr;
625  adup.eDVsame[2]=adup.eDVsame[3]= eRemoveDoublets.dt;
626 
627  adup.FillGuessCell(p1,p1,1.);
628  adup.FillCombinations();
629  adup.DoubletsFilterOut(eRemoveDoublets.checkview, hxy1, htxty1); // assign flag -10 to the duplicated segments
630  if(eDoDumpDoubletsTree) DumpDoubletsTree(adup,"doublets1");
631 
632  adup.FillGuessCell(p2,p2,1.);
633  adup.FillCombinations();
634  adup.DoubletsFilterOut(eRemoveDoublets.checkview, hxy2, htxty2); // assign flag -10 to the duplicated segments
635  if(eDoDumpDoubletsTree) DumpDoubletsTree(adup,"doublets2");
636 
637  if(hxy1) hxy1->Write();
638  if(hxy2) hxy2->Write();
639  if(htxty1) htxty1->Write();
640  if(htxty2) htxty2->Write();
641  SafeDelete(hxy1);
642  SafeDelete(hxy2);
643  SafeDelete(htxty1);
644  SafeDelete(htxty2);
645 }
Definition: EdbAlignmentV.h:13
int DoubletsFilterOut(int checkview, TH2F *hxy=0, TH2F *htxty=0)
Definition: EdbAlignmentV.cxx:83
int FillCombinations()
Definition: EdbAlignmentV.cxx:234
bool eDoDumpDoubletsTree
Definition: EdbLinking.h:18
void DumpDoubletsTree(EdbAlignmentV &adup, const char *name)
Definition: EdbLinking.cxx:648
struct EdbLinking::RemoveDoublets eRemoveDoublets
float dt
Definition: EdbLinking.h:43
int checkview
Definition: EdbLinking.h:44
float dr
Definition: EdbLinking.h:42

◆ DumpDoubletsTree()

void EdbLinking::DumpDoubletsTree ( EdbAlignmentV adup,
const char *  name 
)
649 {
650  EdbCouplesTree dup;
651  dup.InitCouplesTree(name, 0 ,"RECREATE");
652  int n=adup.CheckEqualArr(adup.eS[0],adup.eS[1]);
653  for(int i=0; i<n; i++)
654  {
655  EdbSegP *s0 = (EdbSegP*)(adup.eS[0].At(i));
656  EdbSegP *s1 = (EdbSegP*)(adup.eS[1].At(i));
657  if( s0->Flag() ==-10)
658  dup.Fill( s0, s1);
659  }
660  dup.WriteTree();
661 }
static Int_t CheckEqualArr(TObjArray &arr1, TObjArray &arr2)
Definition: EdbAlignmentV.cxx:415
Int_t Fill(EdbSegP *s1, EdbSegP *s2, EdbSegP *s=0, EdbSegCouple *cp=0, float xv=0, float yv=0, int pid1=0, int pid2=0)
Definition: EdbCouplesTree.cxx:200
bool WriteTree()
Definition: EdbCouplesTree.cxx:191
Definition: EdbSegP.h:18
Int_t Flag() const
Definition: EdbSegP.h:146
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24
EdbSegP * s1
Definition: tlg2pattern.C:30

◆ EstimatePatternArea()

Double_t EdbLinking::EstimatePatternArea ( EdbPattern p)
90 {
91  return (p.Xmax()-p.Xmin())*(p.Ymax()-p.Ymin());
92 }
p
Definition: testBGReduction_AllMethods.C:8

◆ FillCombinationsAtMeanZ()

void EdbLinking::FillCombinationsAtMeanZ ( TObjArray &  p1,
TObjArray &  p2 
)
240 {
241  float dz = eL2.Z()-eL1.Z();
242  int n1 = p1.GetEntries(), n2=p2.GetEntries();
243  if(n1<1||n2<1) return;
244  eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
245  FillGuessCell(p1,p2,eBinOK,0);
246  float dvcomb[4] = {50,50, 0.1, 0.1};
247  FillCombinations(dvcomb, 50,50, 1);
248 }

◆ FullLinking() [1/2]

void EdbLinking::FullLinking ( EdbPattern p1,
EdbPattern p2 
)
300 {
301  float z1 = eL1.Z(), z2 = eL2.Z(), dz = z2-z1;
302  Log(2,"EdbLinking::FullLinking","patterns with %d and %d segments and z1 = %f z2 = %f",p1.N(),p2.N(),z1,z2);
303 
304  float dvcomb[4] = {eDRfull,eDRfull, eDTfull, eDTfull};
305  eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
306  FillGuessCell(p1,p2,eBinOK,0);
307  FillCombinations(dvcomb, eDRfull,eDRfull, 1);
308  eCorr[0].SetV(2,0); eCorr[1].SetV(2, 0);
309  RankCouples( eS[0], eS[1] );
311 }
bool eDoSaveCouples
Definition: EdbLinking.h:14
float eDTfull
Definition: EdbLinking.h:21
float eDRfull
Definition: EdbLinking.h:21

◆ FullLinking() [2/2]

void EdbLinking::FullLinking ( TObjArray &  p1,
TObjArray &  p2 
)
284 {
285  float z1 = eL1.Z(), z2 = eL2.Z(), dz = z2-z1;
286  Log(2,"EdbLinking::FullLinking","arrays with %d and %d segments and z1 = %f z2 = %f",p1.GetEntries(),p2.GetEntries(),z1,z2);
287  Log(2,"EdbLinking::FullLinking","segments z1 = %f z2 = %f",((EdbSegP*)(p1.At(0)))->Z(),((EdbSegP*)(p2.At(0)))->Z());
288 
289  float dvcomb[4] = {eDRfull,eDRfull, eDTfull, eDTfull};
290  eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
291  FillGuessCell(p1,p2,eBinOK,0);
292  FillCombinations(dvcomb, eDRfull,eDRfull, 1);
293  eCorr[0].SetV(2,0); eCorr[1].SetV(2, 0);
294  RankCouples( eS[0], eS[1] );
296 }

◆ GetDoubletsPar()

void EdbLinking::GetDoubletsPar ( TEnv &  env)
69 {
70  const char *str=env.GetValue("fedra.link.RemoveDoublets" , "");
71  if(str)
72  if(sscanf(str,"%d %f %f %d",&(eRemoveDoublets.remove),&eRemoveDoublets.dr,&eRemoveDoublets.dt,&eRemoveDoublets.checkview) == 4) return;
74 }
int remove
Definition: EdbLinking.h:41

◆ GetFillPattern()

void EdbLinking::GetFillPattern ( EdbPattern p,
int  layer = 0 
)
689 {
690  int ncp = eSegCouples.GetEntries();
691  for(int i=0; i<ncp; i++) {
692  EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.At(i));
693  if (layer==0) p.AddSegment(*(sc->eS));
694  else if(layer==1) p.AddSegment(*(sc->eS1));
695  else if(layer==2) p.AddSegment(*(sc->eS2));
696  }
697  Log(2,"EdbLinking::GetPattern","for layer %d with %d segments",layer,ncp);
698 }

◆ GetPar()

void EdbLinking::GetPar ( TEnv &  env)
34 {
35  eBinOK = env.GetValue("fedra.link.BinOK" , 6. );
36 
37  eNcorrMin = env.GetValue("fedra.link.NcorrMin" , 50 );
38 
39  eDoCorrectShrinkage = env.GetValue("fedra.link.DoCorrectShrinkage" , true );
40  eNsigmaEQshr = env.GetValue("fedra.link.shr.NsigmaEQ" , 7. );
41  eShr0 = env.GetValue("fedra.link.shr.Shr0" , .9 );
42  eDShr = env.GetValue("fedra.link.shr.DShr" , .25 );
43 
44  eDoCorrectAngles = env.GetValue("fedra.link.DoCorrectAngles" , true );
45  eChi2Acorr = env.GetValue("fedra.link.ang.Chi2max" , 1.5 );
46 
47  eDoFullLinking = env.GetValue("fedra.link.DoFullLinking" , true );
48  eNsigmaEQlnk = env.GetValue("fedra.link.full.NsigmaEQ" , 5. );
49  eDRfull = env.GetValue("fedra.link.full.DR" , 30. );
50  eDTfull = env.GetValue("fedra.link.full.DT" , 0.1 );
51  eCHI2Pmax = env.GetValue("fedra.link.full.CHI2Pmax" , 3. );
52  eCPRankingAlg = env.GetValue("fedra.link.CPRankingAlg" , 0 );
53 
54  eDoSaveCouples = env.GetValue("fedra.link.DoSaveCouples" , true );
55 
56  eDoDumpDoubletsTree = env.GetValue("fedra.link.DumpDoubletsTree" , false );
57 
58  eCond.SetSigma0( env.GetValue("fedra.link.Sigma0" , "1 1 0.013 0.013") );
59  eCond.SetPulsRamp0( env.GetValue("fedra.link.PulsRamp0" , "6 9") );
60  eCond.SetPulsRamp04( env.GetValue("fedra.link.PulsRamp04" , "6 9") );
61  eCond.SetDegrad( env.GetValue("fedra.link.Degrad" , 5) );
62  eCond.DefineLLFunction( env.GetValue("fedra.link.LLfunction" , "0.256336-0.16489*x+2.11098*x*x") );
63 
64  GetDoubletsPar(env);
65 }
float eNsigmaEQlnk
Definition: EdbLinking.h:25
float eNsigmaEQshr
Definition: EdbLinking.h:24
void GetDoubletsPar(TEnv &env)
Definition: EdbLinking.cxx:68
bool eDoFullLinking
Definition: EdbLinking.h:17
EdbScanCond eCond
Definition: EdbLinking.h:29
bool eDoCorrectShrinkage
Definition: EdbLinking.h:16
float eCHI2Pmax
Definition: EdbLinking.h:22
int eCPRankingAlg
Definition: EdbLinking.h:19
bool eDoCorrectAngles
Definition: EdbLinking.h:15
float eDShr
Definition: EdbLinking.h:27
float eShr0
Definition: EdbLinking.h:26
void SetPulsRamp0(float p1, float p2)
Definition: EdbScanCond.h:74
void SetDegrad(float d)
Definition: EdbScanCond.h:71
void SetSigma0(float x, float y, float tx, float ty)
Definition: EdbScanCond.h:62
void SetPulsRamp04(float p1, float p2)
Definition: EdbScanCond.h:75
void DefineLLFunction(const char *str)
Definition: EdbScanCond.cxx:135

◆ GetPreselectionPar()

void EdbLinking::GetPreselectionPar ( EdbSEQ seq,
TEnv &  env 
)
78 {
79  const char *str=0;
80  float x1,x2;
81  str=env.GetValue("fedra.link.shr.XLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetXLimits(x1,x2);
82  str=env.GetValue("fedra.link.shr.YLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetYLimits(x1,x2);
83  str=env.GetValue("fedra.link.shr.WLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetWLimits(x1,x2);
84  str=env.GetValue("fedra.link.shr.ThetaLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetThetaLimits(x1,x2);
85  str=env.GetValue("fedra.link.shr.ChiLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetChiLimits(x1,x2);
86 }
void SetWLimits(float wmin, float wmax)
Definition: EdbSEQ.h:39
void SetXLimits(float xmin, float xmax)
Definition: EdbSEQ.h:37
void SetYLimits(float ymin, float ymax)
Definition: EdbSEQ.h:38
void SetChiLimits(float cmin, float cmax)
Definition: EdbSEQ.h:41
void SetThetaLimits(float tmin, float tmax)
Definition: EdbSEQ.h:40

◆ Link()

void EdbLinking::Link ( EdbPattern p1,
EdbPattern p2,
EdbLayer l1,
EdbLayer l2,
TEnv &  env,
Double_t  area1 = -1,
Double_t  area2 = -1 
)
96 {
97  // main linking function
98  // Input: p1,p2 - patterns, l1,l2 layers, env - linking parameters
99 
100  Log(2,"EdbLinking::Link","patterns with %d and %d segments and z1 = %f z2 = %f",p1.N(),p2.N(),l1.Z(),l2.Z());
101  if(p1.N()<=0) return;
102  if(p2.N()<=0) return;
103  Log(2,"EdbLinking::Link","segments z1 = %f z2 = %f",
104  p1.GetSegment(0)->Z(),p2.GetSegment(0)->Z());
105 
106  GetPar(env);
107  eL1.Copy(l1,true);
108  eL2.Copy(l2,true);
109 
110  if(area1<=0) area1 = EstimatePatternArea(p1);
111  if(area2<=0) area2 = EstimatePatternArea(p2);
112  if(area1<0.0000001||area2<0.0000001) return;
113  EdbSEQ seq1; seq1.eArea = area1;
114  EdbSEQ seq2; seq2.eArea = area2;
115  GetPreselectionPar(seq1,env);
116  GetPreselectionPar(seq2,env);
117  seq1.eNsigma=eNsigmaEQshr;
118  seq2.eNsigma=eNsigmaEQshr;
119  if(gEDBDEBUGLEVEL>1) seq1.PrintLimits();
120 
121  if(eOutputFile)
122  {
123  TH1F *hTall1 = seq1.ThetaPlot(p1 , "hTall1","Theta plot all, side 1 ");
124  hTall1->Write();
125  TH1F *hTall2 = seq2.ThetaPlot(p2 , "hTall2","Theta plot all, side 2 ");
126  hTall2->Write();
127  }
128  TObjArray p1pre(p1.N()); seq1.PreSelection(p1,p1pre);
129  TObjArray p2pre(p2.N()); seq2.PreSelection(p2,p2pre);
130  Log(2,"EdbLinking::Link","after preselection: n1pre = %d n2pre = %d", p1pre.GetEntries(),p2pre.GetEntries() );
131  if(p1pre.GetEntries()<=0) return;
132  if(p2pre.GetEntries()<=0) return;
133  DoubletsFilterOut(p1pre,p2pre);
134 
135  TObjArray p1shr,p2shr;
136 
138  seq1.EqualizeMT(p1pre, p1shr, area1);
139  seq2.EqualizeMT(p2pre, p2shr, area2);
140  Log(2,"EdbLinking::Link","A n1shr = %d n2shr = %d", p1shr.GetEntries(),p2shr.GetEntries() );
141  if(eOutputFile)
142  {
143  TH1F *hTshr1 = seq1.ThetaPlot(p1shr, "hTshr1","Theta plot shr, side 1 "); hTshr1->Write();
144  seq1.eHEq.DrawH1("eHEq1","eHEq1")->Write();
145  TH1F *hTshr2 = seq2.ThetaPlot(p2shr, "hTshr2","Theta plot shr, side 2 "); hTshr2->Write();
146  seq2.eHEq.DrawH1("eHEq2","eHEq2")->Write();
147  }
148  FillCombinationsAtMeanZ(p1shr,p2shr);
149  }
150  if(eDoCorrectShrinkage) {
151  eCorr[0].SetV(5,eShr0);
152  eCorr[1].SetV(5,eShr0);
154  CorrectShrinkage( eDShr*0.8 );
156  }
157  if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
158  if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
159  if(eDoCorrectShrinkage) {
160  CorrectShrinkage( eDShr*0.5 );
161  CorrectShrinkage( eDShr*0.5 );
162  CorrectShrinkage( eDShr*0.5 );
164  }
165  if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
166  if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
168  if(eOutputFile)
169  {
170  ePC[0].DrawH2("hxy_shr1","xy for the shrinkage corr sample side 1")->Write();
171  ePC[1].DrawH2("hxy_shr2","xy for the shrinkage corr sample side 2")->Write();
172  EdbH2 htxy1(50,-1,1,50,-1,1);
173  FillThetaHist(0,htxy1);
174  htxy1.DrawH2("htxy_shr1","txy plot for shr corr sample side 1");
175  EdbH2 htxy2(50,-1,1,50,-1,1);
176  FillThetaHist(0,htxy2);
177  htxy2.DrawH2("htxy_shr2","txy plot for shr corr sample side 2");
178  }
179  }
180 
181  if(eOutputFile)
182  {
183  eCorr[0].Write("corr1");
184  eCorr[1].Write("corr2");
185  }
186 
187  if(eDoFullLinking) {
188  TObjArray p1lnk(p1pre.GetEntriesFast());
189  TObjArray p2lnk(p2pre.GetEntriesFast());
190  if(eNsigmaEQlnk>0.1) {
191  seq1.eNsigma = eNsigmaEQlnk;
192  seq2.eNsigma = eNsigmaEQlnk;
193  seq1.EqualizeMT(p1pre, p1lnk, area1);
194  seq2.EqualizeMT(p2pre, p2lnk, area2);
195  } else {
196  p1lnk=p1pre;
197  p2lnk=p2pre;
198  }
199 
200  FullLinking(p1lnk,p2lnk);
201  if(eOutputFile)
202  {
203  TH1F *hTlnk1 = seq1.ThetaPlot(p1lnk, "hTlnk1","Theta plot lnk, side 1 ");
204  hTlnk1->Write();
205  TH1F *hTlnk2 = seq2.ThetaPlot(p2lnk, "hTlnk2","Theta plot lnk, side 2 ");
206  hTlnk2->Write();
207  ePC[0].DrawH2("hxy_full1","xy full 1")->Write();
208  ePC[1].DrawH2("hxy_full2","xy full 2")->Write();
209  }
210  }
211 
213  Corr2Aff(eCorr[0],eL1);
214  Corr2Aff(eCorr[1],eL2);
215  //eL1.Print(); // layers with the corrections
216  //eL2.Print();
217 }
TFile * eOutputFile
Definition: EdbAlignmentV.h:35
void Corr2Aff(EdbLayer &layer)
Definition: EdbAlignmentV.cxx:1118
EdbCell2 ePC[2]
Definition: EdbAlignmentV.h:18
void FillThetaHist(int side, EdbH2 &htxy)
Definition: EdbAlignmentV.cxx:212
TH1F * DrawH1(const char *name="EdbH1plot", const char *title="EdbH1plot1D")
Definition: EdbCell1.cpp:135
Definition: EdbCell2.h:19
TH2F * DrawH2(const char *name="plot2d", const char *title="EdbH2plot2D")
Definition: EdbCell2.cpp:197
void Copy(const EdbLayer &l, bool nomap=false)
Definition: EdbLayer.cxx:36
void DoubletsFilterOut(TObjArray &p1, TObjArray &p2, bool fillhist=0)
Definition: EdbLinking.cxx:614
Double_t EstimatePatternArea(EdbPattern &p)
Definition: EdbLinking.cxx:89
void GetPreselectionPar(EdbSEQ &seq, TEnv &env)
Definition: EdbLinking.cxx:77
void GetPar(TEnv &env)
Definition: EdbLinking.cxx:33
void CorrectAngles(TObjArray &p1, TObjArray &p2)
Definition: EdbLinking.cxx:251
void WriteShrinkagePlots()
Definition: EdbLinking.cxx:436
bool VerifyShrinkageCorr(int side)
Definition: EdbLinking.cxx:220
void ProduceReport()
Definition: EdbLinking.cxx:524
void FillCombinationsAtMeanZ(TObjArray &p1, TObjArray &p2)
Definition: EdbLinking.cxx:239
void FullLinking(TObjArray &p1, TObjArray &p2)
Definition: EdbLinking.cxx:283
Definition: EdbSEQ.h:12
Double_t eArea
Definition: EdbSEQ.h:17
EdbH1 eHEq
Definition: EdbSEQ.h:22
void EqualizeMT(TObjArray &mti, TObjArray &mto, Double_t area)
Definition: EdbSEQ.cxx:218
void PrintLimits()
Definition: EdbSEQ.cxx:47
void PreSelection(EdbPattern &pi, TObjArray &po)
Definition: EdbSEQ.cxx:157
TH1F * ThetaPlot(TObjArray &arr, const char *name="theta", const char *title="EdbSEQ theta distribution normalised to area")
Definition: EdbSEQ.cxx:66
Double_t eNsigma
Definition: EdbSEQ.h:16
Float_t Z() const
Definition: EdbSegP.h:150
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
gEDBDEBUGLEVEL
Definition: energy.C:7

◆ ProduceReport()

void EdbLinking::ProduceReport ( )
525 {
526  if(eOutputFile) {
527  Log(2,"Linking Report","Save to file %s", eOutputFile->GetName());
528  gStyle->SetPalette(1);
529  gStyle->SetOptStat(1);
530  bool batch = gROOT->IsBatch();
531  gROOT->SetBatch();
532 
533  TH1F *h1=0; TH2F *h2=0;
534 
535  gStyle->SetOptDate(1);
536  TCanvas *crep1 = new TCanvas("crep1","Linking report2",900,1000);
537 
538  TPaveText *ctit = new TPaveText(0.01,0.943,0.99,0.998);
539  ctit->AddText( Form("Linking of %s",eOutputFile->GetName()) );
540 
541  if(eDoCorrectShrinkage) {
542  float dx,dy;
543  EdbPeak2 pk_shr1(eHdxyShr[0]);
544  pk_shr1.ProbPeak( dx, dy );
545  EdbPeak2 pk_shr2(eHdxyShr[1]);
546  pk_shr2.ProbPeak( dx, dy );
547  const char *str = Form( "Shrinkage side1 is %5.3f with peak of %5.0f/%6.1f side2 is %5.3f with peak of %5.0f/%6.1f ",
548  eCorr[0].V(5),pk_shr1.Peak(0), pk_shr1.Mean(0),
549  eCorr[1].V(5),pk_shr2.Peak(0), pk_shr2.Mean(0));
550  Log(1,"Shrinkage corr:","%s", str);
551  ctit->AddText(str);
552  }
553  if(eDoCorrectAngles) {
554  ctit->AddText( Form("angular offsets: side1 %6.3f %6.3f side2 %6.3f %6.3f",
555  eCorr[0].V(3),eCorr[0].V(4), eCorr[1].V(3), eCorr[1].V(4) ));
556  }
557  ctit->Draw();
558 
559  TPad *c = new TPad("c","plots",0.01,0.03,0.99,0.94);
560  c->Divide(4,4); c->Draw();
561 
562  float densAll=0,densShr=0, densLnk=0;
563 
564  h2 = (TH2F*)eOutputFile->Get("hxy_shr1");
565  if(!h2) h2 = (TH2F*)eOutputFile->Get("hxy_full1");
566  if(h2) {c->cd(1); h2->SetStats(0); h2->Draw("colz"); h2=0;}
567 
568  h2 = (TH2F*)eOutputFile->Get("hxy_shr2");
569  if(!h2) h2 = (TH2F*)eOutputFile->Get("hxy_full2");
570  if(h2) {c->cd(2); h2->SetStats(0); h2->Draw("colz"); h2=0;}
571 
572  h1 = (TH1F*)eOutputFile->Get("hTall1"); if(h1) {c->cd(3); h1->Draw(); densAll=h1->Integral();h1=0;}
573  h1 = (TH1F*)eOutputFile->Get("hTshr1"); if(h1) {c->cd(3); h1->Draw("same"); densShr=h1->Integral(); h1=0;}
574  h1 = (TH1F*)eOutputFile->Get("hTlnk1"); if(h1) {c->cd(3); h1->Draw("same"); densLnk=h1->Integral(); h1=0;}
575  c->cd(3);
576  TPaveText *lable1 = new TPaveText(0.2,0.6,0.6,0.8,"NDC");
577  lable1->AddText(Form("all: %7.0f",densAll));
578  lable1->AddText(Form("shr: %7.0f",densShr));
579  lable1->AddText(Form("lnk: %7.0f",densLnk));
580  lable1->Draw();
581  h1 = (TH1F*)eOutputFile->Get("hTall2"); if(h1) {c->cd(4); h1->Draw(); densAll=h1->Integral(); h1=0;}
582  h1 = (TH1F*)eOutputFile->Get("hTshr2"); if(h1) {c->cd(4); h1->Draw("same"); densShr=h1->Integral(); h1=0;}
583  h1 = (TH1F*)eOutputFile->Get("hTlnk2"); if(h1) {c->cd(4); h1->Draw("same"); densLnk=h1->Integral(); h1=0;}
584  c->cd(4);
585  TPaveText *lable2 = new TPaveText(0.2,0.6,0.6,0.8,"NDC");
586  lable2->AddText(Form("all: %7.0f",densAll));
587  lable2->AddText(Form("shr: %7.0f",densShr));
588  lable2->AddText(Form("lnk: %7.0f",densLnk));
589  lable2->Draw();
590 
591  h2 = (TH2F*)eOutputFile->Get("hdxy_shr"); if(h2) {c->cd(5); h2->SetStats(0); h2->Draw("colz"); h2=0;}
592  h2 = (TH2F*)eOutputFile->Get("htxy_shr"); if(h2) {c->cd(6); h2->SetStats(0); h2->Draw("colz"); h2=0;}
593  h1 = (TH1F*)eOutputFile->Get("shr1"); if(h1) {c->cd(7); h1->Draw("hist"); h1=0;}
594  h1 = (TH1F*)eOutputFile->Get("shr2"); if(h1) {c->cd(8); h1->Draw("hist"); h1=0;}
595 
596  h1 = (TH1F*)eOutputFile->Get("hdtx1"); if(h1) {c->cd(9); h1->Draw(); h1=0;}
597  h1 = (TH1F*)eOutputFile->Get("hdty1"); if(h1) {c->cd(10); h1->Draw(); h1=0;}
598  h1 = (TH1F*)eOutputFile->Get("hdtx2"); if(h1) {c->cd(11); h1->Draw(); h1=0;}
599  h1 = (TH1F*)eOutputFile->Get("hdty2"); if(h1) {c->cd(12); h1->Draw(); h1=0;}
600 
601  h2 = (TH2F*)eOutputFile->Get("hxy_cp"); if(h2) {c->cd(13); h2->SetStats(0); h2->Draw("colz"); h2=0;}
602  h2 = (TH2F*)eOutputFile->Get("htxy_cp"); if(h2) {c->cd(14); h2->SetStats(0); h2->Draw("colz"); h2=0;}
603  h1 = (TH1F*)eOutputFile->Get("hchi"); if(h1) {c->cd(15); h1->Draw(); h1=0;}
604  h1 = (TH1F*)eOutputFile->Get("hchi20"); if(h1) {c->cd(16); h1->Draw(); h1=0;}
605 
606  crep1->Write("report");
607  SafeDelete(crep1);
608  SafeDelete(ctit);
609  gROOT->SetBatch(batch);
610  }
611 }
Definition: EdbCell2.h:104
TH1F * h2
Definition: energy.C:19
TH1F * h1
Definition: energy.C:16
new TCanvas()

◆ RankCouples()

void EdbLinking::RankCouples ( TObjArray &  arr1,
TObjArray &  arr2 
)
457 {
458  int n = arr1.GetEntries();
459  Log(3,"RankCouples","%d" ,n);
460 
461  EdbTrackFitter tf;
462  eSegCouples.Delete();
463  EdbSegP seg, seg1, seg2;
464  for(int i=0; i<n; i++) {
465  EdbSegP *s1 = ((EdbSegP*)arr1.UncheckedAt(i));
466  EdbSegP *s2 = ((EdbSegP*)arr2.UncheckedAt(i));
467 
468  seg.Copy(*s1); // to set correctly vid, aid, etc
469  seg1.Copy(*s1);
470  seg2.Copy(*s2);
471 
472  eCorr[0].ApplyCorrections(seg1);
473  eCorr[1].ApplyCorrections(seg2);
474 
475  //tf.Chi2SegM( *s1, *s2, seg, cond1, cond2);
476  //seg.SetChi2( tf.Chi2ACP( *s1, *s2, cond1) ); //TODO test!!
477  if(eCPRankingAlg==1) tf.Chi2ASegLL( seg1, seg2, seg, eCond, eCond);
478  else tf.Chi2ASeg( seg1, seg2, seg, eCond, eCond);
479 
480  if(seg.Chi2() > eCHI2Pmax) continue;
481 
482  s1->SetFlag(0);
483  s2->SetFlag(0);
484  seg.SetFlag(0);
485  seg.SetSide(0);
486  seg.SetVolume(seg1.Volume()+seg2.Volume());
487  seg.SetDZ( Abs(seg1.eZ - seg2.eZ) );
488 
489  seg.SetDZem( seg1.Chi2() + seg2.Chi2() ); // HACK: use eDZem variable to keep microtracking Likelihood
490 
491  EdbSegCouple *sc=new EdbSegCouple();
492  sc->eS1=s1;
493  sc->eS2=s2;
494  sc->eS = new EdbSegP(seg);
495  sc->SetCHI2P( seg.Chi2() );
496  eSegCouples.Add(sc);
497  }
498 
499  eSegCouples.SetOwner();
500  EdbSegCouple::SetSortFlag(0); // sort by CHI2P
501  eSegCouples.UnSort();
502  eSegCouples.Sort();
503 
504  int ncp = eSegCouples.GetEntries();
505 
506  for(int i=0; i<ncp; i++) {
507  EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.UncheckedAt(i));
508  sc->eS1->SetFlag( sc->eS1->Flag()+1 );
509  sc->eS2->SetFlag( sc->eS2->Flag()+1 );
510  sc->SetN1(sc->eS1->Flag());
511  sc->SetN2(sc->eS2->Flag());
512  }
513 
514  for(int i=0; i<ncp; i++) {
515  EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.UncheckedAt(i));
516  sc->SetN1tot(sc->eS1->Flag());
517  sc->SetN2tot(sc->eS2->Flag());
518  }
519 
520  Log(2,"RankCouples","%d couples ok", ncp );
521 }
void ApplyCorrections(EdbSegP &s)
Definition: EdbSegCorr.cxx:13
void SetN1(int n1)
Definition: EdbSegCouple.h:40
void SetN2(int n2)
Definition: EdbSegCouple.h:41
void SetN1tot(int n)
Definition: EdbSegCouple.h:42
void SetN2tot(int n)
Definition: EdbSegCouple.h:43
void SetCHI2P(float chi2)
Definition: EdbSegCouple.h:45
static void SetSortFlag(int s=0)
Definition: EdbSegCouple.cxx:61
void SetVolume(float w)
Definition: EdbSegP.h:133
void SetSide(int side=0)
Definition: EdbSegP.h:136
void SetDZem(float dz)
Definition: EdbSegP.h:124
Float_t eZ
Definition: EdbSegP.h:28
Float_t Volume() const
Definition: EdbSegP.h:155
Float_t Chi2() const
Definition: EdbSegP.h:154
void SetDZ(float dz)
Definition: EdbSegP.h:123
void Copy(const EdbSegP &s)
Definition: EdbSegP.cxx:104
void SetFlag(int flag)
Definition: EdbSegP.h:127
Definition: EdbTrackFitter.h:16
static float Chi2ASegLL(EdbSegP &s1, EdbSegP &s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
Definition: EdbTrackFitter.cxx:169
static float Chi2ASeg(EdbSegP &s1, EdbSegP &s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
Definition: EdbTrackFitter.cxx:216
EdbSegP * s2
Definition: tlg2pattern.C:31

◆ SaveCouplesTree()

void EdbLinking::SaveCouplesTree ( const char *  file = 0)
315 {
316  EdbCouplesTree ect;
317  ect.InitCouplesTree("couples",file,"NEW");
318 
319  ect.eTree->SetAlias("dz1" ,"107.");
320  ect.eTree->SetAlias("dz2" ,"-107.");
321  ect.eTree->SetAlias("x1" ,"s1.eX+dz1*s1.eTX");
322  ect.eTree->SetAlias("x2" ,"s2.eX+dz2*s2.eTX");
323  ect.eTree->SetAlias("y1" ,"s1.eY+dz1*s1.eTY");
324  ect.eTree->SetAlias("y2" ,"s2.eY+dz2*s2.eTY");
325  ect.eTree->SetAlias("tx1c" , Form("s1.eTX/(%f)+(%f)",eCorr[0].V(5),eCorr[0].V(3)) );
326  ect.eTree->SetAlias("ty1c" , Form("s1.eTY/(%f)+(%f)",eCorr[0].V(5),eCorr[0].V(4)) );
327  ect.eTree->SetAlias("tx2c" , Form("s2.eTX/(%f)+(%f)",eCorr[1].V(5),eCorr[1].V(3)) );
328  ect.eTree->SetAlias("ty2c" , Form("s2.eTY/(%f)+(%f)",eCorr[1].V(5),eCorr[1].V(4)) );
329  ect.eTree->SetAlias("x1c" , "s1.eX+dz1*tx1c" );
330  ect.eTree->SetAlias("y1c" , "s1.eY+dz1*ty1c" );
331  ect.eTree->SetAlias("x2c" , "s2.eX+dz2*tx2c" );
332  ect.eTree->SetAlias("y2c" , "s2.eY+dz2*ty2c" );
333  ect.eTree->SetAlias("dx" , "x2c-x1c" );
334  ect.eTree->SetAlias("dy" , "y2c-y1c" );
335  ect.eTree->SetAlias("dtx" , "tx2c-tx1c" );
336  ect.eTree->SetAlias("dty" , "ty2c-ty1c" );
337  ect.eTree->SetAlias("dr" , "sqrt(dx*dx+dy*dy)" );
338  ect.eTree->SetAlias("dt" , "sqrt(dtx*dtx+dty*dty)" );
339 
340  EdbH2 hxy; hxy.InitH2(ePC[0]);
341  TH2F htxy("htxy_cp","s.eTY vs s.eTX for all couples",50,-1,1,50,-1,1);
342 
343  TH1F hchi("hchi" ,"chi of the couples",80,0,4);
344  TH1F hchi20("hchi20","chi of the couples [s.eW>20]",80,0,4);
345  TH1F hdtx1("hdtx1","s1.eTX-s.eTX [s.eW>20]",50,-0.2,0.2);
346  TH1F hdty1("hdty1","s1.eTY-s.eTY [s.eW>20]",50,-0.2,0.2);
347  TH1F hdtx2("hdtx2","s2.eTX-s.eTX [s.eW>20]",50,-0.2,0.2);
348  TH1F hdty2("hdty2","s2.eTY-s.eTY [s.eW>20]",50,-0.2,0.2);
349 
350  int ntr = eSegCouples.GetEntries();
351  for(int i=0; i<ntr; i++) {
352  EdbSegCouple *sc = (EdbSegCouple *)eSegCouples.At(i);
353  eCorr[0].ApplyCorrections( *(sc->eS1) );
354  eCorr[1].ApplyCorrections( *(sc->eS2) );
355  hxy.Fill(sc->eS->X(), sc->eS->Y());
356  htxy.Fill(sc->eS->TX(), sc->eS->TY());
357  hchi.Fill(sc->CHI2P());
358  if(sc->eS->W()>20) {
359  hchi20.Fill(sc->CHI2P());
360  hdtx1.Fill(sc->eS1->TX()-sc->eS->TX());
361  hdty1.Fill(sc->eS1->TY()-sc->eS->TY());
362  hdtx2.Fill(sc->eS2->TX()-sc->eS->TX());
363  hdty2.Fill(sc->eS2->TY()-sc->eS->TY());
364  }
365  //s->SetID(i); // basetrack id will be the tree entry number
366  int entr = ect.eTree->GetEntries();
367  sc->eS->SetID(entr); // basetrack id will be the tree entry number
368  EdbTraceBack::SetBaseTrackVid( *(sc->eS), 0, 0, entr ); //TODO: plate, piece if available
369  ect.Fill( sc->eS1, sc->eS2, sc->eS, sc );
370  }
371  ect.eTree->Write();
372  hxy.DrawH2("hxy_cp","xy of the output couples")->Write();
373  htxy.Write();
374  hchi.Write();
375  hchi20.Write();
376  hdtx1.Write();
377  hdtx2.Write();
378  hdty1.Write();
379  hdty2.Write();
380  Log(2,"EdbLinking::SaveCouplesTree","%d couples are stored into %s",ntr, ect.GetFileName() );
381 }
TTree * eTree
Definition: EdbCouplesTree.h:25
const char * GetFileName() const
Definition: EdbCouplesTree.h:52
int Fill(float x, float y)
Definition: EdbCell2.h:88
void SetID(int id)
Definition: EdbSegP.h:125
Float_t X() const
Definition: EdbSegP.h:170
Float_t Y() const
Definition: EdbSegP.h:171
Float_t W() const
Definition: EdbSegP.h:148
static void SetBaseTrackVid(EdbSegP &s, int plate, int piece, int entry)
TFile * file
Definition: write_pvr.C:3

◆ SetApplyCorr()

void EdbLinking::SetApplyCorr ( bool  corr)
inline
74 {eCorr[0].eApplyCorr=corr;eCorr[1].eApplyCorr=corr;}
Bool_t eApplyCorr
Definition: EdbSegCorr.h:13

◆ VerifyShrinkageCorr()

bool EdbLinking::VerifyShrinkageCorr ( int  side)
221 {
222  if( eCorr[side].V(5) > eShr0*(1+eDShr) || eCorr[side].V(5)< eShr0/(1+eDShr) ) {
223  Log(1,"EdbLinking::Link","Shrinkage correction side %d out of range: %f [%f %f] reset shrinkage to default: %f",
224  side, eCorr[side].V(5), eShr0/(1+eDShr), eShr0*(1+eDShr), eShr0 );
225  eCorr[side].SetV(5,eShr0);
226  return false;
227  }
228  if(eNshr[side]<eNcorrMin) {
229  Log(1,"EdbLinking::Link","Shrinkage correction side %d not enough coins: %d < %d reset shrinkage to default: %f",
230  side, eNshr[side],eNcorrMin,eShr0 );
231  eCorr[side].SetV(5,eShr0);
232  return false;
233  }
234 
235  return true;
236 }

◆ WriteShrinkagePlots()

void EdbLinking::WriteShrinkagePlots ( )
437 {
438  eH[0][5].DrawH1("shr1")->Write();
439  eH[1][5].DrawH1("shr2")->Write();
440 
441  float dz = eL2.Z()-eL1.Z();
442  float dvcomb[4] = {50,50, 0.03, 0.03};
443  EdbH2 hdxy; hdxy.InitH2(25, -50, 50, 25, -50, 50);
444  eCorr[0].SetV(2, dz/2.); eCorr[1].SetV(2, -dz/2.);
445  Int_t nc = Ncoins(dvcomb, &hdxy );
446  hdxy.DrawH2("hdxy_shr","DY vs DX at the same Z for shrinkage correction sample")->Write();
447 
448  EdbH2 htxy; htxy.InitH2(35, -0.175, 0.175, 35, -0.175, 0.175);
449  dvcomb[0]=dvcomb[1]=9;
450  dvcomb[2]=dvcomb[3]=0.15;
451  nc = Ncoins(dvcomb, 0, &htxy );
452  htxy.DrawH2("htxy_shr","s2.eTY-s1.eTY vs s2.eTX-s1.eTX for shrinkage correction sample")->Write();
453 }
Int_t Ncoins(float dvlim[4], EdbH2 *hdxy=0, EdbH2 *hdtxty=0, TObjArray *sel1=0, TObjArray *sel2=0)
Definition: EdbAlignmentV.cxx:763
EdbH1 eH[2][7]
Definition: EdbAlignmentV.h:27

Member Data Documentation

◆ eBinOK

float EdbLinking::eBinOK

◆ eChi2Acorr

float EdbLinking::eChi2Acorr

◆ eCHI2Pmax

float EdbLinking::eCHI2Pmax

◆ eCond

EdbScanCond EdbLinking::eCond

◆ eCPRankingAlg

int EdbLinking::eCPRankingAlg

◆ eDoCorrectAngles

bool EdbLinking::eDoCorrectAngles

◆ eDoCorrectShrinkage

bool EdbLinking::eDoCorrectShrinkage

◆ eDoDumpDoubletsTree

bool EdbLinking::eDoDumpDoubletsTree

◆ eDoFullLinking

bool EdbLinking::eDoFullLinking

◆ eDoSaveCouples

bool EdbLinking::eDoSaveCouples

◆ eDRfull

float EdbLinking::eDRfull

◆ eDShr

float EdbLinking::eDShr

◆ eDTfull

float EdbLinking::eDTfull

◆ eHdxyShr

EdbH2 EdbLinking::eHdxyShr[2]

◆ eL1

EdbLayer EdbLinking::eL1

◆ eL2

EdbLayer EdbLinking::eL2

◆ eNcorrMin

int EdbLinking::eNcorrMin

◆ eNshr

int EdbLinking::eNshr[2]

◆ eNsigmaEQlnk

float EdbLinking::eNsigmaEQlnk

◆ eNsigmaEQshr

float EdbLinking::eNsigmaEQshr

◆ eRemoveDoublets

struct EdbLinking::RemoveDoublets EdbLinking::eRemoveDoublets

◆ eSegCouples

TObjArray EdbLinking::eSegCouples

◆ eShr0

float EdbLinking::eShr0

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