FEDRA emulsion software from the OPERA Collaboration
EdbLinking Class Reference

microtracks linking in one plate More...

#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 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)
 
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 ()
 

Public Attributes

float eBinOK
 mean cell occupancy More...
 
float eChi2Acorr
 acceptance to save into couples tree More...
 
float eCHI2Pmax
 acceptance to save into couples tree More...
 
EdbScanCond eCond
 scanning conditions for couples ranking More...
 
int eCPRankingAlg
 couples ranking algorithm (0-default, 1-likelihood used) More...
 
bool eDoCorrectAngles
 
bool eDoCorrectShrinkage
 
bool eDoDumpDoubletsTree
 
bool eDoFullLinking
 
bool eDoSaveCouples
 
float eDRfull
 
float eDShr
 range for the shrinkage correction More...
 
float eDTfull
 acceptance for the full linking More...
 
EdbH2 eHdxyShr [2]
 service histograms used for the shrinkage correction More...
 
EdbLayer eL1
 
EdbLayer eL2
 layers with the geometry and corrections More...
 
int eNcorrMin
 min number of segments for the correction calculation More...
 
int eNshr [2]
 number of coins found for shrinkage correction More...
 
float eNsigmaEQlnk
 equalization cut for linking More...
 
float eNsigmaEQshr
 equalization cut for shrinkage More...
 
struct EdbLinking::RemoveDoublets eRemoveDoublets
 
TObjArray eSegCouples
 segment couples objects to fill couples format tree More...
 
float eShr0
 starting value for shrinkage correction search More...
 
- Public Attributes inherited from EdbAlignmentV
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...
 

Additional Inherited Members

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

Detailed Description

microtracks linking in one plate

Constructor & Destructor Documentation

◆ EdbLinking()

EdbLinking::EdbLinking ( )
30{
31}

◆ ~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 
)

641{
642 //read tree using eCut, apply affine transformation if any and write tree
643 EdbPattern pat, p1, p2;
644
645 EdbCouplesTree ict;
646 if(cut) ict.eCut = (*cut);
647 ict.InitCouplesTree("couples",ifile,"READ");
648 int n = ict.GetCPData(eSegCouples);
649 ict.Close();
650
651 if(aff) {
652 for(int i=0; i<n; i++) {
653 EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.UncheckedAt(i));
654 if(sc->eS) sc->eS->Transform(aff);
655 if(sc->eS) sc->eS1->Transform(aff);
656 if(sc->eS) sc->eS2->Transform(aff);
657 }
658 }
659
660 SaveCouplesTree(ofile);
661}
Definition: EdbCouplesTree.h:17
TCut eCut
cut to be applied on read
Definition: EdbCouplesTree.h:31
bool InitCouplesTree(const char *name="couples", const char *fname=0, Option_t *mode="READ")
Definition: EdbCouplesTree.cxx:79
void Close()
Definition: EdbCouplesTree.cxx:62
int GetCPData(EdbPattern *pat, EdbPattern *p1=0, EdbPattern *p2=0, TIndex2 *trseg=0)
Definition: EdbCouplesTree.cxx:296
TObjArray eSegCouples
segment couples objects to fill couples format tree
Definition: EdbLinking.h:34
void SaveCouplesTree(const char *file=0)
Definition: EdbLinking.cxx:296
Definition: EdbPattern.h:273
Definition: EdbSegCouple.h:17
EdbSegP * eS
the result of the fit
Definition: EdbSegCouple.h:27
EdbSegP * eS2
Definition: EdbSegCouple.h:29
EdbSegP * eS1
pointers - useful when all segments are in memory
Definition: EdbSegCouple.h:28
virtual void Transform(const EdbAffine2D *a)
TCut cut
Definition: check_shower.C:6

◆ CorrectAngles()

void EdbLinking::CorrectAngles ( TObjArray &  p1,
TObjArray &  p2 
)
234{
235 Log(2,"EdbLinking::CorrectAngles","arrays with %d and %d segments",p1.GetEntries(),p2.GetEntries());
236
237 eCorr[0].SetV(2,0); eCorr[1].SetV(2,0);
238 RankCouples( eS[0], eS[1] );
239
240 int nc=0;
241 double dtx1=0, dty1=0,dtx2=0, dty2=0;
242 int ncp = eSegCouples.GetEntries();
243 for(int i=0; i<ncp; i++) {
244 EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.At(i));
245 if(sc->CHI2P()>eChi2Acorr) continue;
246 dtx1+= TX( 0, *(sc->eS1) ) - sc->eS->TX();
247 dty1+= TY( 0, *(sc->eS1) ) - sc->eS->TY();
248 dtx2+= TX( 1, *(sc->eS2) ) - sc->eS->TX();
249 dty2+= TY( 1, *(sc->eS2) ) - sc->eS->TY();
250 nc++;
251 }
252 if(nc<eNcorrMin) {Log(1,"EdbLinking::CorrectAngles","Warning: number of the selected segments too small: %d < %d do not correct angles",
253 nc,eNcorrMin); return;}
254
255 float cc=1.8;
256 dtx1 /= nc; dty1 /= nc; dtx2 /= nc; dty2 /= nc;
257 eCorr[0].AddV(3,-cc*dtx1); eCorr[0].AddV(4,-cc*dty1);
258 eCorr[1].AddV(3,-cc*dtx2); eCorr[1].AddV(4,-cc*dty2);
259
260 Log(2,"EdbLinking::CorrectAngles","using %d segments dx1,dy1:( %6.3f %6.3f ) dx2,dy2:( %6.3f %6.3f )",
261 nc, dtx1*cc, dty1*cc, dtx2*cc, dty2*cc );
262}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
float TY(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:121
float TX(int side, EdbSegP &s)
Definition: EdbAlignmentV.h:120
EdbSegCorr eCorr[2]
corrections for side 1 and 2 (v[7]) - the result of the alignment
Definition: EdbAlignmentV.h:24
TObjArray eS[2]
"parallel" arrays with the selected combinations of segments
Definition: EdbAlignmentV.h:21
int eNcorrMin
min number of segments for the correction calculation
Definition: EdbLinking.h:32
float eChi2Acorr
acceptance to save into couples tree
Definition: EdbLinking.h:23
void RankCouples(TObjArray &arr1, TObjArray &arr2)
Definition: EdbLinking.cxx:438
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:62
Float_t TX() const
tangens = deltaX/deltaZ
Definition: EdbSegP.h:175
Float_t TY() const
tangens = deltaY/deltaZ
Definition: EdbSegP.h:176

◆ CorrectShrinkage() [1/3]

void EdbLinking::CorrectShrinkage ( EdbPattern p1,
EdbPattern p2,
float  dshr 
)
382{
383 float dz = eL2.Z()-eL1.Z();
384 Log(2,"EdbLinking::CorrectShrinkage","patterns with %d and %d segments and z1 = %f z2 = %f",p1.N(),p2.N(),eL1.Z(),eL2.Z());
385 if(p1.N()<1||p2.N()<1) return;
386 //DoubletsFilterOut(p1,p2);
387 eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
388 FillGuessCell(p1,p2,eBinOK,0);
389
390 CorrectShrinkage(dshr);
391}
brick dz
Definition: RecDispMC.C:107
void FillGuessCell(EdbPattern &p1, EdbPattern &p2, float binOK=1., float offsetMax=2000.)
Definition: EdbAlignmentV.cxx:880
float Z() const
Definition: EdbLayer.h:77
EdbLayer eL1
Definition: EdbLinking.h:36
EdbLayer eL2
layers with the geometry and corrections
Definition: EdbLinking.h:36
void CorrectShrinkage(TObjArray &p1, TObjArray &p2, float dshr)
Definition: EdbLinking.cxx:367
float eBinOK
mean cell occupancy
Definition: EdbLinking.h:28
Int_t N() const
Definition: EdbPattern.h:86

◆ CorrectShrinkage() [2/3]

void EdbLinking::CorrectShrinkage ( float  dshr)
395{
396 EdbSegCorr c0 = eCorr[0], c1 = eCorr[1]; //save initial values
397 float dz = eL2.Z()-eL1.Z();
398
399 eDVsame[0] = eDVsame[1] = 50; eDVsame[2] = eDVsame[3] = 0.03;
400 InitHshr0( 25, eCorr[0].V(5)/(1+dshr), eCorr[0].V(5)*(1+dshr) );
401 InitHshr1( 25, eCorr[1].V(5)/(1+dshr), eCorr[1].V(5)*(1+dshr) );
402
403 eHdxyShr[0].InitH2(7, -35, 35, 7, -35, 35);
404 eCorr[0].SetV(2,dz); eCorr[1].SetV(2, 0);
405 eNshr[0] = OptimiseVar1( 0, 5, &eHdxyShr[0] ); // variate shr1
406 EdbSegCorr c0_opt = eCorr[0];
407
408 eHdxyShr[1].InitH2(7, -35, 35, 7, -35, 35);
409 eCorr[0]=c0; // to remove the dependency on the correction order
410 eCorr[0].SetV(2, 0); eCorr[1].SetV(2, -dz);
411 eNshr[1] = OptimiseVar1( 1, 5, &eHdxyShr[1]); // variate shr2
412 eCorr[0]=c0_opt; // return to the optimized value
413
414 Log(2,"EdbLinking::CorrectShrinkage","side1: %f (%f) side2: %f (%f)", eCorr[0].V(5), c0.V(5), eCorr[1].V(5), c1.V(5) );
415}
Float_t eDVsame[4]
(dx,dy,dtx,dty) condition for the coinsidence
Definition: EdbAlignmentV.h:16
int OptimiseVar1(int side, int ivar, EdbH2 *hdxy=0, EdbH2 *hdtxy=0)
Definition: EdbAlignmentV.cxx:278
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:78
EdbH2 eHdxyShr[2]
service histograms used for the shrinkage correction
Definition: EdbLinking.h:38
int eNshr[2]
number of coins found for shrinkage correction
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 
)
368{
369 float dz = eL2.Z()-eL1.Z();
370 int n1 = p1.GetEntries(), n2=p2.GetEntries();
371 Log(2,"EdbLinking::CorrectShrinkage","arrays with %d and %d segments and z1 = %f z2 = %f",n1,n2,eL1.Z(),eL2.Z());
372 if(n1<1||n2<1) return;
373 //DoubletsFilterOut(p1,p2);
374 eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
375 FillGuessCell(p1,p2,eBinOK,0);
376
377 CorrectShrinkage(dshr);
378}

◆ DoubletsFilterOut()

void EdbLinking::DoubletsFilterOut ( TObjArray &  p1,
TObjArray &  p2,
bool  fillhist = 0 
)
595{
596 TH2F *hxy1=0, *htxty1=0, *hxy2=0, *htxty2=0;
597 if(fillhist) {
598 hxy1 = new TH2F("dblXY1","Doublets DX DY",50,-eRemoveDoublets.dr,eRemoveDoublets.dr,50,-eRemoveDoublets.dr,eRemoveDoublets.dr);
599 htxty1 = new TH2F("dblTXTY1","Doublets DTX DTY",50,-eRemoveDoublets.dt,eRemoveDoublets.dt,50,-eRemoveDoublets.dt,eRemoveDoublets.dt);
600 hxy2 = new TH2F("dblXY2","Doublets DX DY",50,-eRemoveDoublets.dr,eRemoveDoublets.dr,50,-eRemoveDoublets.dr,eRemoveDoublets.dr);
601 htxty2 = new TH2F("dblTXTY2","Doublets DTX DTY",50,-eRemoveDoublets.dt,eRemoveDoublets.dt,50,-eRemoveDoublets.dt,eRemoveDoublets.dt);
602 }
603 EdbAlignmentV adup;
604 adup.eDVsame[0]=adup.eDVsame[1]= eRemoveDoublets.dr;
605 adup.eDVsame[2]=adup.eDVsame[3]= eRemoveDoublets.dt;
606
607 adup.FillGuessCell(p1,p1,1.);
608 adup.FillCombinations();
609 adup.DoubletsFilterOut(eRemoveDoublets.checkview, hxy1, htxty1); // assign flag -10 to the duplicated segments
610 if(eDoDumpDoubletsTree) DumpDoubletsTree(adup,"doublets1");
611
612 adup.FillGuessCell(p2,p2,1.);
613 adup.FillCombinations();
614 adup.DoubletsFilterOut(eRemoveDoublets.checkview, hxy2, htxty2); // assign flag -10 to the duplicated segments
615 if(eDoDumpDoubletsTree) DumpDoubletsTree(adup,"doublets2");
616
617 if(hxy1) hxy1->Write();
618 if(hxy2) hxy2->Write();
619 if(htxty1) htxty1->Write();
620 if(htxty2) htxty2->Write();
621}
universal basic alignment class
Definition: EdbAlignmentV.h:13
int DoubletsFilterOut(int checkview, TH2F *hxy=0, TH2F *htxty=0)
Definition: EdbAlignmentV.cxx:67
int FillCombinations()
Definition: EdbAlignmentV.cxx:208
bool eDoDumpDoubletsTree
Definition: EdbLinking.h:18
void DumpDoubletsTree(EdbAlignmentV &adup, const char *name)
Definition: EdbLinking.cxx:624
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 
)
625{
626 EdbCouplesTree dup;
627 dup.InitCouplesTree(name, 0 ,"RECREATE");
628 int n=adup.CheckEqualArr(adup.eS[0],adup.eS[1]);
629 for(int i=0; i<n; i++)
630 {
631 EdbSegP *s0 = (EdbSegP*)(adup.eS[0].At(i));
632 EdbSegP *s1 = (EdbSegP*)(adup.eS[1].At(i));
633 if( s0->Flag() ==-10)
634 dup.Fill( s0, s1);
635 }
636 dup.WriteTree();
637}
static Int_t CheckEqualArr(TObjArray &arr1, TObjArray &arr2)
Definition: EdbAlignmentV.cxx:389
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:172
bool WriteTree()
Definition: EdbCouplesTree.cxx:163
Definition: EdbSegP.h:21
Int_t Flag() const
Definition: EdbSegP.h:149
EdbSegP * s1
Definition: tlg2couples.C:29
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24

◆ EstimatePatternArea()

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

◆ FillCombinationsAtMeanZ()

void EdbLinking::FillCombinationsAtMeanZ ( TObjArray &  p1,
TObjArray &  p2 
)
222{
223 float dz = eL2.Z()-eL1.Z();
224 int n1 = p1.GetEntries(), n2=p2.GetEntries();
225 if(n1<1||n2<1) return;
226 eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
227 FillGuessCell(p1,p2,eBinOK,0);
228 float dvcomb[4] = {50,50, 0.1, 0.1};
229 FillCombinations(dvcomb, 50,50, 1);
230}

◆ FullLinking() [1/2]

void EdbLinking::FullLinking ( EdbPattern p1,
EdbPattern p2 
)
282{
283 float z1 = eL1.Z(), z2 = eL2.Z(), dz = z2-z1;
284 Log(2,"EdbLinking::FullLinking","patterns with %d and %d segments and z1 = %f z2 = %f",p1.N(),p2.N(),z1,z2);
285
286 float dvcomb[4] = {eDRfull,eDRfull, eDTfull, eDTfull};
287 eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
288 FillGuessCell(p1,p2,eBinOK,0);
289 FillCombinations(dvcomb, eDRfull,eDRfull, 1);
290 eCorr[0].SetV(2,0); eCorr[1].SetV(2, 0);
291 RankCouples( eS[0], eS[1] );
293}
float eDTfull
acceptance for the full linking
Definition: EdbLinking.h:21
float eDRfull
Definition: EdbLinking.h:21

◆ FullLinking() [2/2]

void EdbLinking::FullLinking ( TObjArray &  p1,
TObjArray &  p2 
)
266{
267 float z1 = eL1.Z(), z2 = eL2.Z(), dz = z2-z1;
268 Log(2,"EdbLinking::FullLinking","arrays with %d and %d segments and z1 = %f z2 = %f",p1.GetEntries(),p2.GetEntries(),z1,z2);
269 Log(2,"EdbLinking::FullLinking","segments z1 = %f z2 = %f",((EdbSegP*)(p1.At(0)))->Z(),((EdbSegP*)(p2.At(0)))->Z());
270
271 float dvcomb[4] = {eDRfull,eDRfull, eDTfull, eDTfull};
272 eCorr[0].SetV(2,dz/2.); eCorr[1].SetV(2, -dz/2.);
273 FillGuessCell(p1,p2,eBinOK,0);
274 FillCombinations(dvcomb, eDRfull,eDRfull, 1);
275 eCorr[0].SetV(2,0); eCorr[1].SetV(2, 0);
276 RankCouples( eS[0], eS[1] );
278}

◆ GetDoubletsPar()

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

◆ GetPar()

void EdbLinking::GetPar ( TEnv &  env)
35{
36 eBinOK = env.GetValue("fedra.link.BinOK" , 6. );
37
38 eNcorrMin = env.GetValue("fedra.link.NcorrMin" , 50 );
39
40 eDoCorrectShrinkage = env.GetValue("fedra.link.DoCorrectShrinkage" , true );
41 eNsigmaEQshr = env.GetValue("fedra.link.shr.NsigmaEQ" , 7. );
42 eShr0 = env.GetValue("fedra.link.shr.Shr0" , .9 );
43 eDShr = env.GetValue("fedra.link.shr.DShr" , .25 );
44
45 eDoCorrectAngles = env.GetValue("fedra.link.DoCorrectAngles" , true );
46 eChi2Acorr = env.GetValue("fedra.link.ang.Chi2max" , 1.5 );
47
48 eDoFullLinking = env.GetValue("fedra.link.DoFullLinking" , true );
49 eNsigmaEQlnk = env.GetValue("fedra.link.full.NsigmaEQ" , 5. );
50 eDRfull = env.GetValue("fedra.link.full.DR" , 30. );
51 eDTfull = env.GetValue("fedra.link.full.DT" , 0.1 );
52 eCHI2Pmax = env.GetValue("fedra.link.full.CHI2Pmax" , 3. );
53 eCPRankingAlg = env.GetValue("fedra.link.CPRankingAlg" , 0 );
54
55 eDoSaveCouples = env.GetValue("fedra.link.DoSaveCouples" , true );
56
57 eDoDumpDoubletsTree = env.GetValue("fedra.link.DumpDoubletsTree" , false );
58
59 eCond.SetSigma0( env.GetValue("fedra.link.Sigma0" , "1 1 0.013 0.013") );
60 eCond.SetPulsRamp0( env.GetValue("fedra.link.PulsRamp0" , "6 9") );
61 eCond.SetPulsRamp04( env.GetValue("fedra.link.PulsRamp04" , "6 9") );
62 eCond.SetDegrad( env.GetValue("fedra.link.Degrad" , 5) );
63 eCond.DefineLLFunction( env.GetValue("fedra.link.LLfunction" , "0.256336-0.16489*x+2.11098*x*x") );
64
65 GetDoubletsPar(env);
66}
float eNsigmaEQlnk
equalization cut for linking
Definition: EdbLinking.h:25
float eNsigmaEQshr
equalization cut for shrinkage
Definition: EdbLinking.h:24
void GetDoubletsPar(TEnv &env)
Definition: EdbLinking.cxx:69
bool eDoSaveCouples
Definition: EdbLinking.h:14
bool eDoFullLinking
Definition: EdbLinking.h:17
EdbScanCond eCond
scanning conditions for couples ranking
Definition: EdbLinking.h:29
bool eDoCorrectShrinkage
Definition: EdbLinking.h:16
float eCHI2Pmax
acceptance to save into couples tree
Definition: EdbLinking.h:22
int eCPRankingAlg
couples ranking algorithm (0-default, 1-likelihood used)
Definition: EdbLinking.h:19
bool eDoCorrectAngles
Definition: EdbLinking.h:15
float eDShr
range for the shrinkage correction
Definition: EdbLinking.h:27
float eShr0
starting value for shrinkage correction search
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 
)
79{
80 const char *str=0;
81 float x1,x2;
82 str=env.GetValue("fedra.link.shr.XLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetXLimits(x1,x2);
83 str=env.GetValue("fedra.link.shr.YLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetYLimits(x1,x2);
84 str=env.GetValue("fedra.link.shr.WLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetWLimits(x1,x2);
85 str=env.GetValue("fedra.link.shr.ThetaLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetThetaLimits(x1,x2);
86 str=env.GetValue("fedra.link.shr.ChiLimits",""); if(str) if(sscanf(str,"%f %f",&x1,&x2) == 2) seq.SetChiLimits(x1,x2);
87}
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 
)
97{
98 // main linking function
99 // Input: p1,p2 - patterns, l1,l2 layers, env - linking parameters
100
101 Log(2,"EdbLinking::Link","patterns with %d and %d segments and z1 = %f z2 = %f",p1.N(),p2.N(),l1.Z(),l2.Z());
102 Log(2,"EdbLinking::Link","segments z1 = %f z2 = %f",p1.GetSegment(0)->Z(),p2.GetSegment(0)->Z());
103
104 GetPar(env);
105 eL1 = l1;
106 eL2 = l2;
107
108 if(area1<=0) area1 = EstimatePatternArea(p1);
109 if(area2<=0) area2 = EstimatePatternArea(p2);
110 EdbSEQ seq1; seq1.eArea = area1;
111 EdbSEQ seq2; seq2.eArea = area2;
112 GetPreselectionPar(seq1,env);
113 GetPreselectionPar(seq2,env);
116 seq1.PrintLimits();
117
118 TH1F *hTall1 = seq1.ThetaPlot(p1 , "hTall1","Theta plot all, side 1 "); hTall1->Write();
119 TH1F *hTall2 = seq2.ThetaPlot(p2 , "hTall2","Theta plot all, side 2 "); hTall2->Write();
120
121 TObjArray p1pre(p1.N()); seq1.PreSelection(p1,p1pre);
122 TObjArray p2pre(p2.N()); seq2.PreSelection(p2,p2pre);
123 Log(2,"EdbLinking::Link","after preselection: n1pre = %d n2pre = %d", p1pre.GetEntries(),p2pre.GetEntries() );
124 DoubletsFilterOut(p1pre,p2pre);
125
126 TObjArray p1shr,p2shr;
127
129 seq1.EqualizeMT(p1pre, p1shr, area1);
130 TH1F *hTshr1 = seq1.ThetaPlot(p1shr, "hTshr1","Theta plot shr, side 1 "); hTshr1->Write();
131 seq1.eHEq.DrawH1("eHEq1","eHEq1")->Write();
132
133 seq2.EqualizeMT(p2pre, p2shr, area2);
134 TH1F *hTshr2 = seq2.ThetaPlot(p2shr, "hTshr2","Theta plot shr, side 2 "); hTshr2->Write();
135 seq2.eHEq.DrawH1("eHEq2","eHEq2")->Write();
136
137 // DoubletsFilterOut(p1shr,p2shr);
138 FillCombinationsAtMeanZ(p1shr,p2shr);
139 Log(2,"EdbLinking::Link","A n1shr = %d n2shr = %d", p1shr.GetEntries(),p2shr.GetEntries() );
140 }
142 eCorr[0].SetV(5,eShr0);
143 eCorr[1].SetV(5,eShr0);
145 CorrectShrinkage( eDShr*0.8 );
147 }
148 if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
149 if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
151 CorrectShrinkage( eDShr*0.5 );
152 CorrectShrinkage( eDShr*0.5 );
153 CorrectShrinkage( eDShr*0.5 );
155 }
156 if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
157 if(eDoCorrectAngles) CorrectAngles( p1shr,p2shr );
159 ePC[0].DrawH2("hxy_shr1","xy for the shrinkage corr sample side 1")->Write();
160 ePC[1].DrawH2("hxy_shr2","xy for the shrinkage corr sample side 2")->Write();
161 EdbH2 htxy1(50,-1,1,50,-1,1);
162 FillThetaHist(0,htxy1);
163 htxy1.DrawH2("htxy_shr1","txy plot for shr corr sample side 1");
164 EdbH2 htxy2(50,-1,1,50,-1,1);
165 FillThetaHist(0,htxy2);
166 htxy2.DrawH2("htxy_shr2","txy plot for shr corr sample side 2");
167 }
168
169 eCorr[0].Write("corr1");
170 eCorr[1].Write("corr2");
171
172 if(eDoFullLinking) {
173 TObjArray p1lnk(p1pre.GetEntriesFast());
174 TObjArray p2lnk(p2pre.GetEntriesFast());
175 if(eNsigmaEQlnk>0.1) {
176 seq1.eNsigma = eNsigmaEQlnk;
177 seq2.eNsigma = eNsigmaEQlnk;
178 seq1.EqualizeMT(p1pre, p1lnk, area1);
179 seq2.EqualizeMT(p2pre, p2lnk, area2);
180 } else {
181 p1lnk=p1pre;
182 p2lnk=p2pre;
183 }
184 // DoubletsFilterOut(p1lnk,p2lnk, 1);
185
186 TH1F *hTlnk1 = seq1.ThetaPlot(p1lnk, "hTlnk1","Theta plot lnk, side 1 "); hTlnk1->Write();
187 TH1F *hTlnk2 = seq2.ThetaPlot(p2lnk, "hTlnk2","Theta plot lnk, side 2 "); hTlnk2->Write();
188
189 FullLinking(p1lnk,p2lnk);
190 ePC[0].DrawH2("hxy_full1","xy full 1")->Write();
191 ePC[1].DrawH2("hxy_full2","xy full 2")->Write();
192 }
193
195 Corr2Aff(eCorr[0],eL1);
196 Corr2Aff(eCorr[1],eL2);
197 //eL1.Print(); // layers with the corrections
198 //eL2.Print();
199}
void Corr2Aff(EdbLayer &layer)
Definition: EdbAlignmentV.cxx:1027
EdbCell2 ePC[2]
2-d position cells with patterns segments
Definition: EdbAlignmentV.h:18
void FillThetaHist(int side, EdbH2 &htxy)
Definition: EdbAlignmentV.cxx:196
TH1F * DrawH1(const char *name="EdbH1plot", const char *title="EdbH1plot1D")
Definition: EdbCell1.cpp:136
fast 2-dim histogram class (used as a basis for EdbCell2)
Definition: EdbCell2.h:19
TH2F * DrawH2(const char *name="plot2d", const char *title="EdbH2plot2D")
Definition: EdbCell2.cpp:187
void DoubletsFilterOut(TObjArray &p1, TObjArray &p2, bool fillhist=0)
Definition: EdbLinking.cxx:594
Double_t EstimatePatternArea(EdbPattern &p)
Definition: EdbLinking.cxx:90
void GetPreselectionPar(EdbSEQ &seq, TEnv &env)
Definition: EdbLinking.cxx:78
void GetPar(TEnv &env)
Definition: EdbLinking.cxx:34
void CorrectAngles(TObjArray &p1, TObjArray &p2)
Definition: EdbLinking.cxx:233
void WriteShrinkagePlots()
Definition: EdbLinking.cxx:418
bool VerifyShrinkageCorr(int side)
Definition: EdbLinking.cxx:202
void ProduceReport()
Definition: EdbLinking.cxx:505
void FillCombinationsAtMeanZ(TObjArray &p1, TObjArray &p2)
Definition: EdbLinking.cxx:221
void FullLinking(TObjArray &p1, TObjArray &p2)
Definition: EdbLinking.cxx:265
Definition: EdbSEQ.h:12
Double_t eArea
effective area of the pattern to be equalized
Definition: EdbSEQ.h:17
EdbH1 eHEq
Definition: EdbSEQ.h:22
void EqualizeMT(TObjArray &mti, TObjArray &mto, Double_t area)
Definition: EdbSEQ.cxx:220
void PrintLimits()
Definition: EdbSEQ.cxx:49
void PreSelection(EdbPattern &pi, TObjArray &po)
Definition: EdbSEQ.cxx:159
TH1F * ThetaPlot(TObjArray &arr, const char *name="theta", const char *title="EdbSEQ theta distribution normalised to area")
Definition: EdbSEQ.cxx:68
Double_t eNsigma
=4
Definition: EdbSEQ.h:16
Float_t Z() const
Definition: EdbSegP.h:153
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66

◆ ProduceReport()

void EdbLinking::ProduceReport ( )
506{
507 if(eOutputFile) {
508 Log(2,"Linking Report","Save to file %s", eOutputFile->GetName());
509 gStyle->SetPalette(1);
510 gStyle->SetOptStat(1);
511 bool batch = gROOT->IsBatch();
512 gROOT->SetBatch();
513
514 TH1F *h1=0; TH2F *h2=0;
515
516 gStyle->SetOptDate(1);
517 TCanvas *crep1 = new TCanvas("crep1","Linking report2",900,1000);
518
519 TPaveText *ctit = new TPaveText(0.01,0.943,0.99,0.998);
520 ctit->AddText( Form("Linking of %s",eOutputFile->GetName()) );
521
523 float dx,dy;
524 EdbPeak2 pk_shr1(eHdxyShr[0]);
525 pk_shr1.ProbPeak( dx, dy );
526 EdbPeak2 pk_shr2(eHdxyShr[1]);
527 pk_shr2.ProbPeak( dx, dy );
528 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 ",
529 eCorr[0].V(5),pk_shr1.Peak(0), pk_shr1.Mean(0),
530 eCorr[1].V(5),pk_shr2.Peak(0), pk_shr2.Mean(0));
531 Log(1,"Shrinkage corr:","%s", str);
532 ctit->AddText(str);
533 }
534 if(eDoCorrectAngles) {
535 ctit->AddText( Form("angular offsets: side1 %6.3f %6.3f side2 %6.3f %6.3f",
536 eCorr[0].V(3),eCorr[0].V(4), eCorr[1].V(3), eCorr[1].V(4) ));
537 }
538 ctit->Draw();
539
540 TPad *c = new TPad("c","plots",0.01,0.03,0.99,0.94);
541 c->Divide(4,4); c->Draw();
542
543 float densAll=0,densShr=0, densLnk=0;
544
545 h2 = (TH2F*)eOutputFile->Get("hxy_shr1");
546 if(!h2) h2 = (TH2F*)eOutputFile->Get("hxy_full1");
547 if(h2) {c->cd(1); h2->SetStats(0); h2->Draw("colz"); h2=0;}
548
549 h2 = (TH2F*)eOutputFile->Get("hxy_shr2");
550 if(!h2) h2 = (TH2F*)eOutputFile->Get("hxy_full2");
551 if(h2) {c->cd(2); h2->SetStats(0); h2->Draw("colz"); h2=0;}
552
553 h1 = (TH1F*)eOutputFile->Get("hTall1"); if(h1) {c->cd(3); h1->Draw(); densAll=h1->Integral();h1=0;}
554 h1 = (TH1F*)eOutputFile->Get("hTshr1"); if(h1) {c->cd(3); h1->Draw("same"); densShr=h1->Integral(); h1=0;}
555 h1 = (TH1F*)eOutputFile->Get("hTlnk1"); if(h1) {c->cd(3); h1->Draw("same"); densLnk=h1->Integral(); h1=0;}
556 c->cd(3);
557 TPaveText *lable1 = new TPaveText(0.2,0.6,0.6,0.8,"NDC");
558 lable1->AddText(Form("all: %7.0f",densAll));
559 lable1->AddText(Form("shr: %7.0f",densShr));
560 lable1->AddText(Form("lnk: %7.0f",densLnk));
561 lable1->Draw();
562 h1 = (TH1F*)eOutputFile->Get("hTall2"); if(h1) {c->cd(4); h1->Draw(); densAll=h1->Integral(); h1=0;}
563 h1 = (TH1F*)eOutputFile->Get("hTshr2"); if(h1) {c->cd(4); h1->Draw("same"); densShr=h1->Integral(); h1=0;}
564 h1 = (TH1F*)eOutputFile->Get("hTlnk2"); if(h1) {c->cd(4); h1->Draw("same"); densLnk=h1->Integral(); h1=0;}
565 c->cd(4);
566 TPaveText *lable2 = new TPaveText(0.2,0.6,0.6,0.8,"NDC");
567 lable2->AddText(Form("all: %7.0f",densAll));
568 lable2->AddText(Form("shr: %7.0f",densShr));
569 lable2->AddText(Form("lnk: %7.0f",densLnk));
570 lable2->Draw();
571
572 h2 = (TH2F*)eOutputFile->Get("hdxy_shr"); if(h2) {c->cd(5); h2->SetStats(0); h2->Draw("colz"); h2=0;}
573 h2 = (TH2F*)eOutputFile->Get("htxy_shr"); if(h2) {c->cd(6); h2->SetStats(0); h2->Draw("colz"); h2=0;}
574 h1 = (TH1F*)eOutputFile->Get("shr1"); if(h1) {c->cd(7); h1->Draw("hist"); h1=0;}
575 h1 = (TH1F*)eOutputFile->Get("shr2"); if(h1) {c->cd(8); h1->Draw("hist"); h1=0;}
576
577 h1 = (TH1F*)eOutputFile->Get("hdtx1"); if(h1) {c->cd(9); h1->Draw(); h1=0;}
578 h1 = (TH1F*)eOutputFile->Get("hdty1"); if(h1) {c->cd(10); h1->Draw(); h1=0;}
579 h1 = (TH1F*)eOutputFile->Get("hdtx2"); if(h1) {c->cd(11); h1->Draw(); h1=0;}
580 h1 = (TH1F*)eOutputFile->Get("hdty2"); if(h1) {c->cd(12); h1->Draw(); h1=0;}
581
582 h2 = (TH2F*)eOutputFile->Get("hxy_cp"); if(h2) {c->cd(13); h2->SetStats(0); h2->Draw("colz"); h2=0;}
583 h2 = (TH2F*)eOutputFile->Get("htxy_cp"); if(h2) {c->cd(14); h2->SetStats(0); h2->Draw("colz"); h2=0;}
584 h1 = (TH1F*)eOutputFile->Get("hchi"); if(h1) {c->cd(15); h1->Draw(); h1=0;}
585 h1 = (TH1F*)eOutputFile->Get("hchi20"); if(h1) {c->cd(16); h1->Draw(); h1=0;}
586
587 crep1->Write("report");
588 SafeDelete(crep1);
589 gROOT->SetBatch(batch);
590 }
591}
TFile * eOutputFile
Definition: EdbAlignmentV.h:35
peak analyser for EdbH2
Definition: EdbCell2.h:105
TH1F * h2
Definition: energy.C:19
TH1F * h1
Definition: energy.C:16
new TCanvas()

◆ RankCouples()

void EdbLinking::RankCouples ( TObjArray &  arr1,
TObjArray &  arr2 
)
439{
440 int n = arr1.GetEntries();
441 Log(3,"RankCouples","%d" ,n);
442
444 eSegCouples.Delete();
445 EdbSegP seg, seg1, seg2;
446 for(int i=0; i<n; i++) {
447 EdbSegP *s1 = ((EdbSegP*)arr1.UncheckedAt(i));
448 EdbSegP *s2 = ((EdbSegP*)arr2.UncheckedAt(i));
449
450 seg.Copy(*s1); // to set correctly vid, aid, etc
451 seg1.Copy(*s1);
452 seg2.Copy(*s2);
453
454 eCorr[0].ApplyCorrections(seg1);
455 eCorr[1].ApplyCorrections(seg2);
456
457 //tf.Chi2SegM( *s1, *s2, seg, cond1, cond2);
458 //seg.SetChi2( tf.Chi2ACP( *s1, *s2, cond1) ); //TODO test!!
459 if(eCPRankingAlg==1) tf.Chi2ASegLL( seg1, seg2, seg, eCond, eCond);
460 else tf.Chi2ASeg( seg1, seg2, seg, eCond, eCond);
461
462 if(seg.Chi2() > eCHI2Pmax) continue;
463
464 s1->SetFlag(0);
465 s2->SetFlag(0);
466 seg.SetFlag(0);
467 seg.SetSide(0);
468 seg.SetVolume(seg1.Volume()+seg2.Volume());
469 seg.SetDZ( Abs(seg1.eZ - seg2.eZ) );
470
471 seg.SetDZem( seg1.Chi2() + seg2.Chi2() ); // HACK: use eDZem variable to keep microtracking Likelihood
472
473 EdbSegCouple *sc=new EdbSegCouple();
474 sc->eS1=s1;
475 sc->eS2=s2;
476 sc->eS = new EdbSegP(seg);
477 sc->SetCHI2P( seg.Chi2() );
478 eSegCouples.Add(sc);
479 }
480
481 EdbSegCouple::SetSortFlag(0); // sort by CHI2P
482 eSegCouples.UnSort();
483 eSegCouples.Sort();
484
485 int ncp = eSegCouples.GetEntries();
486
487 for(int i=0; i<ncp; i++) {
488 EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.UncheckedAt(i));
489 sc->eS1->SetFlag( sc->eS1->Flag()+1 );
490 sc->eS2->SetFlag( sc->eS2->Flag()+1 );
491 sc->SetN1(sc->eS1->Flag());
492 sc->SetN2(sc->eS2->Flag());
493 }
494
495 for(int i=0; i<ncp; i++) {
496 EdbSegCouple *sc = (EdbSegCouple*)(eSegCouples.UncheckedAt(i));
497 sc->SetN1tot(sc->eS1->Flag());
498 sc->SetN2tot(sc->eS2->Flag());
499 }
500
501 Log(2,"RankCouples","%d couples ok", ncp );
502}
void ApplyCorrections(EdbSegP &s)
Definition: EdbSegCorr.cxx:13
void SetN1(int n1)
Definition: EdbSegCouple.h:43
void SetN2(int n2)
Definition: EdbSegCouple.h:44
void SetN1tot(int n)
Definition: EdbSegCouple.h:45
void SetN2tot(int n)
Definition: EdbSegCouple.h:46
void SetCHI2P(float chi2)
Definition: EdbSegCouple.h:48
static void SetSortFlag(int s=0)
Definition: EdbSegCouple.cxx:62
void SetVolume(float w)
Definition: EdbSegP.h:136
void SetSide(int side=0)
Definition: EdbSegP.h:139
void SetDZem(float dz)
Definition: EdbSegP.h:127
Float_t eZ
coordinates
Definition: EdbSegP.h:31
Float_t Volume() const
Definition: EdbSegP.h:158
Float_t Chi2() const
Definition: EdbSegP.h:157
void SetDZ(float dz)
Definition: EdbSegP.h:126
void Copy(const EdbSegP &s)
Definition: EdbSegP.cxx:105
void SetFlag(int flag)
Definition: EdbSegP.h:130
Definition: EdbTrackFitter.h:17
static float Chi2ASegLL(EdbSegP &s1, EdbSegP &s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
Definition: EdbTrackFitter.cxx:170
static float Chi2ASeg(EdbSegP &s1, EdbSegP &s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
Definition: EdbTrackFitter.cxx:217
EdbSegP * s2
Definition: tlg2couples.C:30

◆ SaveCouplesTree()

void EdbLinking::SaveCouplesTree ( const char *  file = 0)
297{
298 EdbCouplesTree ect;
299 ect.InitCouplesTree("couples",file,"NEW");
300
301 ect.eTree->SetAlias("dz1" ,"107.");
302 ect.eTree->SetAlias("dz2" ,"-107.");
303 ect.eTree->SetAlias("x1" ,"s1.eX+dz1*s1.eTX");
304 ect.eTree->SetAlias("x2" ,"s2.eX+dz2*s2.eTX");
305 ect.eTree->SetAlias("y1" ,"s1.eY+dz1*s1.eTY");
306 ect.eTree->SetAlias("y2" ,"s2.eY+dz2*s2.eTY");
307 ect.eTree->SetAlias("tx1c" , Form("s1.eTX/(%f)+(%f)",eCorr[0].V(5),eCorr[0].V(3)) );
308 ect.eTree->SetAlias("ty1c" , Form("s1.eTY/(%f)+(%f)",eCorr[0].V(5),eCorr[0].V(4)) );
309 ect.eTree->SetAlias("tx2c" , Form("s2.eTX/(%f)+(%f)",eCorr[1].V(5),eCorr[1].V(3)) );
310 ect.eTree->SetAlias("ty2c" , Form("s2.eTY/(%f)+(%f)",eCorr[1].V(5),eCorr[1].V(4)) );
311 ect.eTree->SetAlias("x1c" , "s1.eX+dz1*tx1c" );
312 ect.eTree->SetAlias("y1c" , "s1.eY+dz1*ty1c" );
313 ect.eTree->SetAlias("x2c" , "s2.eX+dz2*tx2c" );
314 ect.eTree->SetAlias("y2c" , "s2.eY+dz2*ty2c" );
315 ect.eTree->SetAlias("dx" , "x2c-x1c" );
316 ect.eTree->SetAlias("dy" , "y2c-y1c" );
317 ect.eTree->SetAlias("dtx" , "tx2c-tx1c" );
318 ect.eTree->SetAlias("dty" , "ty2c-ty1c" );
319 ect.eTree->SetAlias("dr" , "sqrt(dx*dx+dy*dy)" );
320 ect.eTree->SetAlias("dt" , "sqrt(dtx*dtx+dty*dty)" );
321
322 EdbH2 hxy; hxy.InitH2(ePC[0]);
323 TH2F htxy("htxy_cp","s.eTY vs s.eTX for all couples",50,-1,1,50,-1,1);
324
325 TH1F hchi("hchi" ,"chi of the couples",80,0,4);
326 TH1F hchi20("hchi20","chi of the couples [s.eW>20]",80,0,4);
327 TH1F hdtx1("hdtx1","s1.eTX-s.eTX [s.eW>20]",50,-0.2,0.2);
328 TH1F hdty1("hdty1","s1.eTY-s.eTY [s.eW>20]",50,-0.2,0.2);
329 TH1F hdtx2("hdtx2","s2.eTX-s.eTX [s.eW>20]",50,-0.2,0.2);
330 TH1F hdty2("hdty2","s2.eTY-s.eTY [s.eW>20]",50,-0.2,0.2);
331
332 int ntr = eSegCouples.GetEntries();
333 for(int i=0; i<ntr; i++) {
335 eCorr[0].ApplyCorrections( *(sc->eS1) );
336 eCorr[1].ApplyCorrections( *(sc->eS2) );
337 hxy.Fill(sc->eS->X(), sc->eS->Y());
338 htxy.Fill(sc->eS->TX(), sc->eS->TY());
339 hchi.Fill(sc->CHI2P());
340 if(sc->eS->W()>20) {
341 hchi20.Fill(sc->CHI2P());
342 hdtx1.Fill(sc->eS1->TX()-sc->eS->TX());
343 hdty1.Fill(sc->eS1->TY()-sc->eS->TY());
344 hdtx2.Fill(sc->eS2->TX()-sc->eS->TX());
345 hdty2.Fill(sc->eS2->TY()-sc->eS->TY());
346 }
347 //s->SetID(i); // basetrack id will be the tree entry number
348 int entr = ect.eTree->GetEntries();
349 sc->eS->SetID(entr); // basetrack id will be the tree entry number
350 EdbTraceBack::SetBaseTrackVid( *(sc->eS), 0, 0, entr ); //TODO: plate, piece if available
351 ect.Fill( sc->eS1, sc->eS2, sc->eS, sc );
352 }
353 ect.eTree->Write();
354 hxy.DrawH2("hxy_cp","xy of the output couples")->Write();
355 htxy.Write();
356 hchi.Write();
357 hchi20.Write();
358 hdtx1.Write();
359 hdtx2.Write();
360 hdty1.Write();
361 hdty2.Write();
362 Log(2,"EdbLinking::SaveCouplesTree","%d couples are stored into %s",ntr, ect.GetFileName() );
363}
TTree * eTree
couples tree
Definition: EdbCouplesTree.h:25
const char * GetFileName() const
Definition: EdbCouplesTree.h:51
int Fill(float x, float y)
Definition: EdbCell2.h:88
void SetID(int id)
Definition: EdbSegP.h:128
Float_t X() const
Definition: EdbSegP.h:173
Float_t Y() const
Definition: EdbSegP.h:174
Float_t W() const
Definition: EdbSegP.h:151
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;eCorr[2].eApplyCorr=corr;}
Bool_t eApplyCorr
do correction
Definition: EdbSegCorr.h:13

◆ VerifyShrinkageCorr()

bool EdbLinking::VerifyShrinkageCorr ( int  side)
203{
204 if( eCorr[side].V(5) > eShr0*(1+eDShr) || eCorr[side].V(5)< eShr0/(1+eDShr) ) {
205 Log(1,"EdbLinking::Link","Shrinkage correction side %d out of range: %f [%f %f] reset shrinkage to default: %f",
206 side, eCorr[side].V(5), eShr0/(1+eDShr), eShr0*(1+eDShr), eShr0 );
207 eCorr[side].SetV(5,eShr0);
208 return false;
209 }
210 if(eNshr[side]<eNcorrMin) {
211 Log(1,"EdbLinking::Link","Shrinkage correction side %d not enough coins: %d < %d reset shrinkage to default: %f",
212 side, eNshr[side],eNcorrMin,eShr0 );
213 eCorr[side].SetV(5,eShr0);
214 return false;
215 }
216
217 return true;
218}

◆ WriteShrinkagePlots()

void EdbLinking::WriteShrinkagePlots ( )
419{
420 eH[0][5].DrawH1("shr1")->Write();
421 eH[1][5].DrawH1("shr2")->Write();
422
423 float dz = eL2.Z()-eL1.Z();
424 float dvcomb[4] = {50,50, 0.03, 0.03};
425 EdbH2 hdxy; hdxy.InitH2(25, -50, 50, 25, -50, 50);
426 eCorr[0].SetV(2, dz/2.); eCorr[1].SetV(2, -dz/2.);
427 Int_t nc = Ncoins(dvcomb, &hdxy );
428 hdxy.DrawH2("hdxy_shr","DY vs DX at the same Z for shrinkage correction sample")->Write();
429
430 EdbH2 htxy; htxy.InitH2(35, -0.175, 0.175, 35, -0.175, 0.175);
431 dvcomb[0]=dvcomb[1]=9;
432 dvcomb[2]=dvcomb[3]=0.15;
433 nc = Ncoins(dvcomb, 0, &htxy );
434 htxy.DrawH2("htxy_shr","s2.eTY-s1.eTY vs s2.eTX-s1.eTX for shrinkage correction sample")->Write();
435}
Int_t Ncoins(float dvlim[4], EdbH2 *hdxy=0, EdbH2 *hdtxty=0, TObjArray *sel1=0, TObjArray *sel2=0)
Definition: EdbAlignmentV.cxx:722
EdbH1 eH[2][7]
Definition: EdbAlignmentV.h:27

Member Data Documentation

◆ eBinOK

float EdbLinking::eBinOK

mean cell occupancy

◆ eChi2Acorr

float EdbLinking::eChi2Acorr

acceptance to save into couples tree

◆ eCHI2Pmax

float EdbLinking::eCHI2Pmax

acceptance to save into couples tree

◆ eCond

EdbScanCond EdbLinking::eCond

scanning conditions for couples ranking

◆ eCPRankingAlg

int EdbLinking::eCPRankingAlg

couples ranking algorithm (0-default, 1-likelihood used)

◆ 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

range for the shrinkage correction

◆ eDTfull

float EdbLinking::eDTfull

acceptance for the full linking

◆ eHdxyShr

EdbH2 EdbLinking::eHdxyShr[2]

service histograms used for the shrinkage correction

◆ eL1

EdbLayer EdbLinking::eL1

◆ eL2

EdbLayer EdbLinking::eL2

layers with the geometry and corrections

◆ eNcorrMin

int EdbLinking::eNcorrMin

min number of segments for the correction calculation

◆ eNshr

int EdbLinking::eNshr[2]

number of coins found for shrinkage correction

◆ eNsigmaEQlnk

float EdbLinking::eNsigmaEQlnk

equalization cut for linking

◆ eNsigmaEQshr

float EdbLinking::eNsigmaEQshr

equalization cut for shrinkage

◆ eRemoveDoublets

struct EdbLinking::RemoveDoublets EdbLinking::eRemoveDoublets

◆ eSegCouples

TObjArray EdbLinking::eSegCouples

segment couples objects to fill couples format tree

◆ eShr0

float EdbLinking::eShr0

starting value for shrinkage correction search


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