-
Notifications
You must be signed in to change notification settings - Fork 0
/
AliXXXITSTracker.cxx
1474 lines (1412 loc) · 49.6 KB
/
AliXXXITSTracker.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "AliXXXITSTracker.h"
#include "AliXXXLayer.h"
#include "AliITSRecPoint.h"
#include "AliGeomManager.h"
#include "AliVParticle.h"
#include "AliSymMatrix.h"
//
#include "AliRunLoader.h"
#include "AliHeader.h"
#include "AliGenEventHeader.h"
#include "AliStack.h"
#include <TParticle.h>
#include <TParticlePDG.h>
#include <TFile.h>
ClassImp(AliXXXITSTracker)
const Float_t AliXXXITSTracker::fgkZSpanITS[AliXXXITSTracker::kMaxLrITS] =
{ 36. ,14.1,14.1, 38., 22.2,29.7, 51. ,43.1,48.9};
const Float_t AliXXXITSTracker::fgkRLayITS[AliXXXITSTracker::kMaxLrITS] =
{ 2.94, 3.9,7.6, 11.04, 15.0,23.9, 29.44 ,38.0,43.0};
const Float_t AliXXXITSTracker::fgkRSpanITS[AliXXXITSTracker::kMaxLrITS] = // half span in R
{ 0.04, 0.5,0.5, 0.5, 0.8, 0.8, 0.5 ,0.6,0.6};
const Int_t AliXXXITSTracker::fgkPassivLrITS[AliXXXITSTracker::kNLrPassive] =
{AliXXXITSTracker::kLrBeamPime,AliXXXITSTracker::kLrShield1,AliXXXITSTracker::kLrShield2};
const Int_t AliXXXITSTracker::fgkActiveLrITS[AliXXXITSTracker::kNLrActive] =
{AliXXXITSTracker::kLrSPD1,AliXXXITSTracker::kLrSPD2,
AliXXXITSTracker::kLrSDD1,AliXXXITSTracker::kLrSDD2,
AliXXXITSTracker::kLrSSD1,AliXXXITSTracker::kLrSSD2};
const Int_t AliXXXITSTracker::fgkLr2Active[AliXXXITSTracker::kMaxLrITS] = // conversion to active lr.
{-1, 0, 1, -1, 2, 3, -1, 4, 5};
const Float_t AliXXXITSTracker::fgkRhoLITS[AliXXXITSTracker::kMaxLrITS] = {
0.162802, 0.321960,0.354588, 0.274995, 0.193789,0.198168, 0.435372, 0.195828,0.226940};
const Float_t AliXXXITSTracker::fgkX2X0ITS[AliXXXITSTracker::kMaxLrITS] = {
0.002757, 0.011660,0.012614, 0.006488, 0.007714,0.007916, 0.012689, 0.007849,0.009128};
const Double_t AliXXXITSTracker::fgkClSystYErr2[AliXXXITSTracker::kNLrActive] =
{0.0010*0.0010, 0.0030*0.0030, 0.0500*0.0500, 0.0500*0.0500, 0.0020*0.0020, 0.0020*0.0020};
const Double_t AliXXXITSTracker::fgkClSystZErr2[AliXXXITSTracker::kNLrActive] =
{0.0050*0.0050, 0.0050*0.0050, 0.0050*0.0050, 0.0050*0.0050, 0.1000*0.1000, 0.1000*0.1000};
const Int_t AliXXXITSTracker::fgkLrDefBins[AliXXXITSTracker::kNLrActive][2] = // n bins in z, phi
{ {20,20}, {20,20}, {20,20}, {20,20}, {20,20}, {20,20} };
const Float_t AliXXXITSTracker::fgkDefMass = 0.14;
const Int_t AliXXXITSTracker::fgkDummyLabel = -3141593;
#ifdef _TIMING_
const char* AliXXXITSTracker::fgkSWNames[AliXXXITSTracker::kNSW] = {
"Total"
,"Tracklets"
,"Tracks"
,"Vertex"
};
#endif
//______________________________________________
AliXXXITSTracker::AliXXXITSTracker() :
fBlacklist(0)
,fPhiShift(0.0045)
,fSigThetaTracklet(0.025)
,fSigPhiTracklet(0.08)
,fChi2CutTracklet(1.5)
,fPhiShiftSc(0.)
,fDThetaTrackletSc(0)
,fDPhiTrackletSc(0)
,fBz(5.0)
,fDPhiTol(0.)
,fDThSig2Inv(0.)
,fDPhSig2Inv(0.)
//
,fMinPt(0.3)
,fCurvMax(0)
,fZSPD2CutMin(1e9)
,fZSPD2CutMax(-1e9)
,fMaxChi2Tr2Cl(40)
,fAddErr2YspdVtx(0.02*0.02)
,fAddErr2ZspdVtx(0.04*0.04)
//
,fMissChi2Penalty(3)
,fMaxMissedLayers(1)
,fNTracks(0)
,fFitVertex(kTRUE)
//
,fSPDVertex(0)
#ifdef _CONTROLH_
,fHTrackletMC(0),fHTrackletAll(0),fHTrackletFake(0),fHTrackMC(0),fHTrackAll(0),fHTrackFake(0)
,fHVtxDiffXY(0)
,fHVtxDiffXMlt(0),fHVtxDiffYMlt(0),fHVtxDiffZMlt(0)
,fHVtxPullXMlt(0),fHVtxPullYMlt(0),fHVtxPullZMlt(0)
,fHVtxMCSPDDiffXY(0)
,fHVtxMCSPDDiffXMlt(0),fHVtxMCSPDDiffYMlt(0),fHVtxMCSPDDiffZMlt(0)
,fHVtxMCSPDPullXMlt(0),fHVtxMCSPDPullYMlt(0),fHVtxMCSPDPullZMlt(0)
,fHChi2NDFvsPT(0),fHChi2vsNC(0)
,fHVtxMltRef(0),fHVtxOKMlt(0),fHVtxDiffZ(0),fHVtxMCSPDDiffZ(0)
#endif
{
// def. c-tor
for (int i=kNLrActive;i--;) fLayers[i] = 0;
}
//______________________________________________
AliXXXITSTracker::~AliXXXITSTracker()
{
// d-tor
for (int i=0;i<kNLrActive;i++) delete fLayers[i];
}
//______________________________________________
void AliXXXITSTracker::Init()
{
// init tracker
//
if (!AliGeomManager::GetGeometry()) {
AliGeomManager::LoadGeometry("geometry.root");
AliGeomManager::ApplyAlignObjsFromCDB("ITS");
}
//
for (int i=0;i<kNLrActive;i++) {
int iAct = fgkActiveLrITS[i];
fLayers[i] = new AliXXXLayer(i,fgkZSpanITS[iAct]+1,fgkLrDefBins[i][0],fgkLrDefBins[i][1]);
fSkipLayer[i] = kFALSE;
fNSigma2[i] = 7*7;
fYToler2[i] = 0.2*0.2;
fZToler2[i] = 0.2*0.2;
fChi2TotCut[i] = 0;
}
fChi2TotCut[1] = 40; // 2 cl+vtx -> NDF=1
fChi2TotCut[2] = 40;
fChi2TotCut[3] = 30;
fChi2TotCut[4] = 35;
fChi2TotCut[5] = 40;
//
fMissChi2Penalty = 3;
fMaxMissedLayers = 1;
//
// auxialary precalculated variables
if (fChi2CutTracklet<0.1) fChi2CutTracklet = 0.1;
double scl = TMath::Sqrt(fChi2CutTracklet);
fDThetaTrackletSc = fSigThetaTracklet*scl;
fDPhiTrackletSc = fSigPhiTracklet*scl;
//
fDThSig2Inv = 1./(fSigThetaTracklet*fSigThetaTracklet);
fDPhSig2Inv = 1./(fSigPhiTracklet*fSigPhiTracklet);
//
fBlacklist = new TBits(100*100);
//
#ifdef _TIMING_
for (int i=kNSW;i--;) {
fSW[i].Stop();
fSW[i].Reset();
}
#endif
//
#ifdef _CONTROLH_
BookHistos();
#endif
}
//______________________________________________
void AliXXXITSTracker::ProcessEvent()
{
// do full reconstruction
#ifdef _TIMING_
fSW[kSWTotal].Start(0);
fSW[kSWTracklets].Start(0);
#endif
//
fNTracks = 0;
FindTracklets();
//
#ifdef _TIMING_
fSW[kSWTracklets].Stop();
fSW[kSWTracks].Start(0);
#endif
//
Tracklets2Tracks();
RefitInward();
#ifdef _TIMING_
fSW[kSWTracks].Stop();
fSW[kSWVertex].Start(0);
#endif
if (fFitVertex) {
if (FitTrackVertex()) {
#ifdef _DEBUG_
printf("FittedVertex: "); fTrackVertex.Print();
printf("SPD Vertex: "); fSPDVertex->Print();
#endif
}
}
//
//
#ifdef _TIMING_
fSW[kSWVertex].Stop();
fSW[kSWTotal].Stop();
PrintTiming();
#endif
//
#ifdef _CONTROLH_
FillRecoStat();
#endif
}
//______________________________________________
void AliXXXITSTracker::Clear(Option_t*)
{
// reset event info
ClearTracklets();
ClearTracks();
for (int i=kNLrActive;i--;) {
fNClusters[i] = 0;
if (fLayers[i]) fLayers[i]->Clear();
}
}
//______________________________________________
void AliXXXITSTracker::ClearTracklets()
{
// reset tracklets info
fSPD2Discard.clear();
fTracklets.clear();
fSPD1Tracklet.clear();
if (fBlacklist) fBlacklist->ResetAllBits();
}
//______________________________________________
void AliXXXITSTracker::AddCluster(AliITSRecPoint* cl)
{
// add cluster to corresponding layer
if (!cl->Misalign()) AliWarning("Can't misalign this cluster !");
fLayers[cl->GetLayer()]->AddCluster(cl);
}
//______________________________________________
Bool_t AliXXXITSTracker::FindTracklets()
{
// find SPD tracklets
//
if (!fSPDVertex) {
AliInfo("No SPD vertex set");
return kFALSE;
}
float rv2 = fSPDVertex->GetX()*fSPDVertex->GetX()+fSPDVertex->GetY()*fSPDVertex->GetY();
if (rv2>0.25*fgkRLayITS[kLrBeamPime]*fgkRLayITS[kLrBeamPime]) {
AliInfo("SPD vertex is too far from beam line");
fSPDVertex->Print();
return kFALSE;
}
fPhiShiftSc = fPhiShift*TMath::Abs(fBz/5.0);
fDPhiTol = fDPhiTrackletSc + fPhiShiftSc;
//
AliXXXLayer &spdL1 = *fLayers[kALrSPD1];
AliXXXLayer &spdL2 = *fLayers[kALrSPD2];
spdL1.SortClusters(fSPDVertex);
spdL2.SortClusters(fSPDVertex);
fNClusters[0] = spdL1.GetNClusters();
fNClusters[1] = spdL2.GetNClusters();
//
if (fNClusters[0]<1 || fNClusters[1]<1) return kFALSE;
//
fSPD2Discard.resize(fNClusters[1]);
fSPD1Tracklet.resize(fNClusters[0]);
//
fBlacklist->SetBitNumber(TMath::Max(fNClusters[0]*fNClusters[1],10000),kFALSE); // to reserve the space
//
int nfound;
do {
nfound = 0;
for (int icl2=fNClusters[1];icl2--;) if (!fSPD2Discard[icl2]) nfound += AssociateClusterOfL2(icl2);
} while(nfound);
//
for (int itr=GetNTracklets();itr--;) CookLabel(fTracklets[itr]);
//
return kTRUE;
}
//______________________________________________
Int_t AliXXXITSTracker::AssociateClusterOfL2(int icl2)
{
// find SPD1 cluster matching to SPD2 cluster icl2
AliXXXLayer &spdL1 = *fLayers[kALrSPD1];
AliXXXLayer &spdL2 = *fLayers[kALrSPD2];
AliXXXLayer::ClsInfo* cli2 = spdL2.GetClusterInfo(icl2);
// expected z at SPD1
float zV = fSPDVertex->GetZ();
float z2 = cli2->z - zV;
float tg2Inv = z2/cli2->r;
float dzt = (1.+tg2Inv*tg2Inv)*fDThetaTrackletSc;
float dz = dzt*fgkRLayITS[kLrSPD1] + TMath::Abs(tg2Inv)*fgkRSpanITS[kLrSPD1]; // uncertainty from dTheta and from Layer1 R spread
float zL1 = zV + tg2Inv*fgkRLayITS[kLrSPD1]; // center of expected Z1
int nsel1 = spdL1.SelectClusters(zL1-dz,zL1+dz, cli2->phi-fDPhiTol,cli2->phi+fDPhiTol);
if (!nsel1) {
fSPD2Discard[icl2] = true;
return 0; // no candidates
}
float chiBest = 9999;
SPDtracklet_t trk;
trk.id1 = -1;
int icl1,nCand=0;
while ( (icl1=spdL1.GetNextClusterInfoID())!=-1) { // loop over matching clusters of lr1
if (IsBlacklisted(icl1,icl2)) continue;
AliXXXLayer::ClsInfo* cli1 = spdL1.GetClusterInfo(icl1);
float z1 = cli1->z - zV;
float tg1Inv = z1/cli1->r;
//
float dTheta = (tg2Inv-tg1Inv)/(1.+tg1Inv*tg1Inv); // fast check on theta
if (TMath::Abs(dTheta)>fDThetaTrackletSc) continue;
//
float dPhi = cli1->phi - cli2->phi; // fast check on phi
if (dPhi>TMath::Pi()) dPhi = TMath::TwoPi()-dPhi;
else if (dPhi<-TMath::Pi()) dPhi += TMath::TwoPi();
double dPhiS = TMath::Abs(dPhi)-fPhiShiftSc;
if (TMath::Abs(dPhiS)>fDPhiTrackletSc) continue;
//
float chi2 = dTheta*dTheta*fDThSig2Inv + dPhiS*dPhiS*fDPhSig2Inv; // check final chi2
if (chi2>1.) {
Blacklist(icl1,icl2);
continue;
}
nCand++;
if (chi2>chiBest) continue;
// check if cl1 is already associated with better
trk.id1 = icl1;
trk.id2 = icl2;
trk.dtht = dTheta;
trk.dphi = dPhi;
trk.chi2 = chiBest = chi2;
}
//
if (trk.id1!=-1) { // check if there is no better icl1 candidate for icl2
int oldId = fSPD1Tracklet[trk.id1];
if (!oldId) { // store new tracklet
fTracklets.push_back(trk);
fSPD1Tracklet[trk.id1] = fTracklets.size(); // refer from clusters to tracklet (id+1)
fSPD2Discard[icl2] = true; // mark as used
Blacklist(trk.id1,trk.id2);
return 1;
}
SPDtracklet_t& oldTrk = (SPDtracklet_t&)fTracklets[--oldId];
if (oldTrk.chi2 < trk.chi2) { // previous is better
Blacklist(trk.id1,trk.id2); // shall we blacklist new combination?
if (nCand==1) fSPD2Discard[icl2] = true; // there was just 1 candidate and it is discarded
return 0;
}
// new combination is better, overwrite the old one with new one, marking old L2 cluster free
fSPD2Discard[oldTrk.id2] = false; // mark as free
fSPD2Discard[icl2] = true; // mark as used
oldTrk = trk;
Blacklist(trk.id1,trk.id2);
return 1;
}
//
fSPD2Discard[icl2] = true; // no chance to find partner for this cluster
return 0;
//
}
//______________________________________________
void AliXXXITSTracker::Tracklets2Tracks()
{
// try to extend tracklets to outer layers
int nTrk = GetNTracklets();
if (!nTrk) return;
//
CalcAuxTracking(); // RS??? do we need to repeat this?
//
for (int ila=kALrSDD1;ila<kNLrActive;ila++) {
if (fSkipLayer[ila]) continue;
fLayers[ila]->SortClusters(0);
fNClusters[ila] = fLayers[ila]->GetNClusters();
}
//
fTracks.resize(nTrk);
//
for (int itr=0;itr<nTrk;itr++) {
SPDtracklet_t& trlet = fTracklets[itr];
// if (trlet.label<0) continue; //RSTMP
//
#ifdef _DEBUG_
printf("TestTracklet %d\t|",itr);
int stat = GetTrackletMCTruth(trlet);
//
int nmiss=0;
for (int i=2;i<kNLrActive;i++) {
printf("%c", (stat&(0x1<<i)) ? '*':'-');
if (!(stat&(0x1<<i))) nmiss++;
}
printf("|\n");
PrintTracklet(itr);
#endif
//
float zspd2 = fLayers[kALrSPD2]->GetClusterInfo(trlet.id2)->z;
if (zspd2<fZSPD2CutMin || zspd2>fZSPD2CutMax) continue;
ITStrack_t &track = fTracks[fNTracks];
if (!CreateTrack(track, trlet)) continue;
track.trackletID = itr;
Bool_t res;
#ifdef _DEBUG_
double xyz[3];
track.paramOut.GetXYZAt(0,fBz,xyz);
printf("process track pt:%f XYZ: %+.4f %+.4f %+.4f\n",track.paramOut.Pt(),xyz[0],xyz[1],xyz[2]);
#endif
for (int lrID=kLrShield1;lrID<kMaxLrITS;lrID++) {
res = FollowToLayer(track,lrID) && IsAcceptableTrack(track);
if (!res) break;
}
#ifdef _DEBUG_
printf("%s:%d\n",res ? "OK" : "Fail",nmiss<=fMaxMissedLayers);
#endif
if (!res) continue;
track.paramOut.ResetBit(kInvalidBit); // flag that outward fit succeeded
CookLabel(track);
fNTracks++;
//
}
}
//______________________________________________
Bool_t AliXXXITSTracker::IsAcceptableTrack(const AliXXXITSTracker::ITStrack_t& track) const
{
// check if the track is acceptable
return kTRUE;
}
//______________________________________________
void AliXXXITSTracker::PrintTrack(const AliXXXITSTracker::ITStrack_t& track) const
{
// print track info
printf("Chi2 = %f for %d clusters. Tracklet %d\n",track.chi2,track.ncl,track.trackletID);
//
for (int ilr=0;ilr<kNLrActive;ilr++) {
if (track.clID[ilr]<0) continue;
AliITSRecPoint* cl = fLayers[ilr]->GetClusterSorted(track.clID[ilr]);
printf("L%d #%4d ",ilr,track.clID[ilr]);
for (int i=0;i<3;i++) printf("%d ",cl->GetLabel(i)); printf("\n");
}
track.paramOut.Print();
track.paramInw.Print();
}
//______________________________________________
void AliXXXITSTracker::PrintTracklets() const
{
// print traklets info
int ntr = fTracklets.size();
printf("NTracklets: %d\n",ntr);
printf("Nspd1: %4d Nspd2: %4d, Ntracklets: %d\n",fNClusters[0],fNClusters[1],ntr);
for (int itr=0;itr<ntr;itr++) PrintTracklet(itr);
//
}
//______________________________________________
void AliXXXITSTracker::PrintTracklet(Int_t itr) const
{
// print single tracklet
const SPDtracklet_t* trk = &fTracklets[itr];
AliITSRecPoint* cl1 = fLayers[kALrSPD1]->GetClusterSorted(trk->id1);
AliITSRecPoint* cl2 = fLayers[kALrSPD2]->GetClusterSorted(trk->id2);
AliXXXLayer::ClsInfo_t* cli0 = fLayers[kALrSPD1]->GetClusterInfo(trk->id1);
printf("#%3d Phi:%+.3f Eta:%+.3f Dphi:%+.3f Dtht:%+.3f Chi2:%.3f | Lbl:",
itr,cli0->phi,
-TMath::Log(TMath::Tan(TMath::ATan2(cli0->r,cli0->z-fSPDVertex->GetZ())/2.)),
trk->dphi,trk->dtht,trk->chi2);
int lab=-1,lb = -1;
for (int i=0;i<3;i++) if ( (lb=cl1->GetLabel(i))>=0 ) {if (lab<0)lab=lb; printf(" %5d",lb);} printf("|");
for (int i=0;i<3;i++) if ( (lb=cl2->GetLabel(i))>=0 ) printf(" %5d",lb);
printf("| ->%d\n",trk->label);
lab = TMath::Abs(trk->label);
//
AliStack* stack = 0;
AliRunLoader* rl = AliRunLoader::Instance();
if (lab>=0 && rl && (stack=rl->Stack())) {
TParticle* mctr = stack->Particle(lab);
if (mctr) {
TParticlePDG* mctrPDG = mctr->GetPDG();
if (mctrPDG) {
double qpt = mctrPDG->Charge()>0 ? mctr->Pt() : -mctr->Pt();
printf("MCTrack: Prim:%d Vxyz: {%+.4f %+.4f %+.4f} 1/pt: %.3f tgl: %.3f\n",
stack->IsPhysicalPrimary(lab),
mctr->Vx(),mctr->Vy(),mctr->Vz(),
TMath::Abs(qpt)>0 ? 1./qpt : 9999., TMath::Tan(TMath::Pi()/2. - mctr->Theta()));
}
}
}
}
//______________________________________________
void AliXXXITSTracker::PrintTracks() const
{
// print tracks info
printf("NTracks: %d\n",fNTracks);
for (int itr=0;itr<fNTracks;itr++) PrintTrack(fTracks[itr]);
//
}
//______________________________________________
void AliXXXITSTracker::CalcAuxTracking()
{
// precalculate auxilarry variables for tracking
//
// largest track curvature to search
const double ztolerEdge = 1.0;
fCurvMax = TMath::Abs(fBz*kB2C/fMinPt);
double thMin =-1e9;
double thMax = 1e9;
for (int ilA=kNLrActive-1;ilA>kALrSPD2;ilA--) {
if (!IsObligatoryLayer(ilA)) continue;
int ilr=fgkActiveLrITS[ilA];
double r = fgkRLayITS[ilr] - fgkRSpanITS[ilr];
double dz = fgkZSpanITS[ilr]+ztolerEdge+fDThetaTrackletSc*r;
double ri = 1./r;
double tmin= (-dz-fSPDVertex->GetZ())*ri;
double tmax= ( dz-fSPDVertex->GetZ())*ri;
if (tmin>thMin) thMin = tmin;
if (tmax<thMax) thMax = tmax;
}
double r = fgkRLayITS[kLrSPD2] + fgkRSpanITS[kLrSPD2];
fZSPD2CutMin = fSPDVertex->GetZ()+thMin*r; // min Z of SPD2 in tracklet to consider tracking
fZSPD2CutMax = fSPDVertex->GetZ()+thMax*r; // max Z of SPD2 in tracklet to consider tracking
//
}
//______________________________________________
Bool_t AliXXXITSTracker::CreateTrack(AliXXXITSTracker::ITStrack_t& track,
AliXXXITSTracker::SPDtracklet_t& trlet)
{
// create track seed from tracklet
// init track
track.label = trlet.label;
//
AliXXXLayer::ClsInfo_t *cli1=fLayers[kALrSPD1]->GetClusterInfo(trlet.id1);
AliXXXLayer::ClsInfo_t *cli2=fLayers[kALrSPD2]->GetClusterInfo(trlet.id2);
AliITSRecPoint *cl1=fLayers[kALrSPD1]->GetClusterUnSorted(cli1->index);
AliITSRecPoint *cl2=fLayers[kALrSPD2]->GetClusterUnSorted(cli2->index);
int det1 = cl1->GetVolumeId()-fLayers[kALrSPD1]->GetVIDOffset();
int det2 = cl2->GetVolumeId()-fLayers[kALrSPD2]->GetVIDOffset();
AliXXXLayer::ITSDetInfo_t& detInfo1 = fLayers[kALrSPD1]->GetDetInfo(det1);
AliXXXLayer::ITSDetInfo_t& detInfo2 = fLayers[kALrSPD2]->GetDetInfo(det2);
//
// crude momentun estimate
float dx=cli1->x-cli2->x,dy=cli1->y-cli2->y,d=TMath::Sqrt(dx*dx+dy*dy);
float qptInv = fBz ? 2*TMath::Sin(cli2->phi-cli1->phi)/d/fBz/kB2C : 0; // positive particle goes anticlockwise in B+
//
// we initialize the seed in the tracking frame of 1st detector
float xv= fSPDVertex->GetX()*detInfo1.cosTF + fSPDVertex->GetY()*detInfo1.sinTF;
float yv=-fSPDVertex->GetX()*detInfo1.sinTF + fSPDVertex->GetY()*detInfo1.cosTF;
float zv= fSPDVertex->GetZ();
float par[5] = {yv, zv, (float)TMath::Sin(cli1->phi-detInfo1.phiTF), (cli1->z-zv)/cli1->r, qptInv};
double covVtx[6];
fSPDVertex->GetCovarianceMatrix(covVtx);
float cov[15] = {float(covVtx[0]+covVtx[2] + fAddErr2YspdVtx),
0, float(covVtx[5] + fAddErr2ZspdVtx),
0,0,1,
0,0,0,1,
0,0,0,0,100*100};
AliExternalTrackParam& param = track.paramOut;
param.Set(xv, detInfo1.phiTF, par, cov);
track.chi2 = 0; // chi2 at 1st two point is 0
// go to 1st layer, ignoring the MS (errors are anyway not defined)
if (!param.PropagateTo(detInfo1.xTF+cl1->GetX(), fBz)) return kFALSE;
Double_t cpar0[2]={ cl1->GetY(), cl1->GetZ()};
Double_t ccov0[3]={ cl1->GetSigmaY2() + GetClSystYErr2(kALrSPD1), 0., cl1->GetSigmaZ2() + GetClSystZErr2(kALrSPD1)};
if (!param.Update(cpar0,ccov0)) return kFALSE;
if (!param.CorrectForMeanMaterial(fgkX2X0ITS[kLrSPD1],-fgkRhoLITS[kLrSPD1],fgkDefMass)) return kFALSE;
// go to 2nd layer
if (!param.Rotate(detInfo2.phiTF)) return kFALSE;
if (!param.PropagateTo(detInfo2.xTF+cl2->GetX(), fBz)) return kFALSE;
Double_t cpar1[2]={ cl2->GetY(), cl2->GetZ()};
Double_t ccov1[3]={ cl2->GetSigmaY2() + GetClSystYErr2(kALrSPD2), 0., cl2->GetSigmaZ2() + GetClSystZErr2(kALrSPD2)};
track.chi2 += param.GetPredictedChi2(cpar1,ccov1);
if (!param.Update(cpar1,ccov1)) return kFALSE;
#ifdef _CONTROLH_
FillTrackingControlHistos(1,track.label,¶m,cpar1,ccov1,cl2);
#endif
//
track.clID[0] = trlet.id1;
track.clID[1] = trlet.id2;
track.clID[2] = track.clID[3] = track.clID[4] = track.clID[5] = -1;
track.ncl = 2;
track.nmiss=0;
//
param.SetBit(kInvalidBit); // flag that track is not yer refitted outward
track.paramOut.SetBit(kInvalidBit); // flag that track was not refitter inward
return kTRUE;
}
//______________________________________________
Bool_t AliXXXITSTracker::CrossPassiveLayer(AliExternalTrackParam& param, Int_t lrID)
{
// cross the layer, applying mat. corrections
double xStart=param.GetX();
double xToGo = GetXatLabRLin(param,fgkRLayITS[lrID]);
if (xToGo<0 || !param.PropagateTo(xToGo,fBz)) return kFALSE;
double x2x0=fgkX2X0ITS[lrID],xrho=fgkRhoLITS[lrID];
if (xStart<xToGo) xrho = -xrho; // inward propagation
return param.CorrectForMeanMaterial(x2x0,xrho,fgkDefMass,kFALSE);
//
}
//______________________________________________
Bool_t AliXXXITSTracker::FollowToLayer(AliXXXITSTracker::ITStrack_t& track, Int_t lrID)
{
// take track to given layer, searching hits if needed and applying mat. corrections
int lrIDA = fgkLr2Active[lrID]; // active layer ID
if (lrIDA<0 || fSkipLayer[lrIDA]) return CrossPassiveLayer(track.paramOut,lrID);
//
AliExternalTrackParam trCopy(track.paramOut);
double xToGo = GetXatLabRLin(trCopy,fgkRLayITS[lrID]); // aproximate X at lrID
if (!trCopy.PropagateTo(xToGo,fBz)) return kFALSE;
double xyz[3];
trCopy.GetXYZ(xyz);
double phi=TMath::ATan2(xyz[1],xyz[0]),z=trCopy.GetZ();
// we need track errors in the plane nearly tangential to crossing point
if (!trCopy.Rotate(phi)) return kFALSE;
double dphi = TMath::Sqrt(trCopy.GetSigmaY2()*fNSigma2[lrIDA]+fYToler2[lrIDA])/fgkRLayITS[lrID];
double dz = TMath::Sqrt(trCopy.GetSigmaZ2()*fNSigma2[lrIDA]+fZToler2[lrIDA]);
AliXXXLayer* lrA = fLayers[lrIDA];
int nCl = lrA->SelectClusters(z-dz,z+dz,phi-dphi,phi+dphi);
Bool_t updDone = kFALSE;
//
#ifdef _DEBUG_
printf("at Lr%d, Ncl:%d ",lrIDA,nCl);
trCopy.Print();
#endif
//
if (nCl) {
int icl,iclBest=-1;
double chi2Best = fMaxChi2Tr2Cl;
AliITSRecPoint* bestCl = 0;
AliExternalTrackParam bestTr;
//
#ifdef _DEBUG_
int iclt=0;
#endif
while ( (icl=lrA->GetNextClusterInfoID())!=-1) {
AliXXXLayer::ClsInfo_t *cli = lrA->GetClusterInfo(icl);
AliITSRecPoint *cl=lrA->GetClusterUnSorted(cli->index);
/* //RSTMP
Bool_t okcl = kFALSE;
for (int i=0;i<3;i++) {
if (cl->GetLabel(i)==track.label && track.label>=0) {okcl=kTRUE;nCl=1; break;}
}
if (!okcl) continue;
*/
int detId = cl->GetVolumeId()-lrA->GetVIDOffset();
AliXXXLayer::ITSDetInfo_t& detInfo = lrA->GetDetInfo(detId);
trCopy = track.paramOut;
if (!trCopy.Propagate(detInfo.phiTF, detInfo.xTF+cl->GetX(), fBz)) continue;
double cpar[2]={ cl->GetY(), cl->GetZ()};
double ccov[3]={ cl->GetSigmaY2() + GetClSystYErr2(lrIDA) , 0., cl->GetSigmaZ2() + GetClSystZErr2(lrIDA)};
double chi2cl = trCopy.GetPredictedChi2(cpar,ccov);
//
#ifdef _DEBUG_
float clXYZ[3]; cl->GetGlobalXYZ(clXYZ);
double trXYZ[3]; trCopy.GetXYZ(trXYZ);
Float_t xCl, alphaCl;
cl->GetXAlphaRefPlane(xCl,alphaCl);
printf("cl%d Chi2:%.2f Dyz: %+e %+e Err: %e %e %e |Lb:",iclt++,chi2cl,
cl->GetY()-trCopy.GetY(),cl->GetZ()-trCopy.GetZ(),
TMath::Sqrt(ccov[0]),ccov[1],TMath::Sqrt(ccov[2])); //TMP
for (int j=0;j<3;j++) if (cl->GetLabel(j)>=0) printf(" %d",cl->GetLabel(j)); printf("\n");
printf("CL: X:%.4f Alp:%+.4f XYZ: %+.4f %+.4f %+.4f\n",xCl,alphaCl,clXYZ[0],clXYZ[1],clXYZ[2]);
printf("TR: X:%.4f Alp:%+.4f XYZ: %+.4f %+.4f %+.4f\n",detInfo.xTF,detInfo.phiTF,trXYZ[0],trXYZ[1],trXYZ[2]);
trCopy.Print();
#endif
//
#ifdef _CONTROLH_
FillTrackingControlHistos(lrIDA,track.label,&trCopy,cpar,ccov,cl);
#endif
//
if (chi2cl>fMaxChi2Tr2Cl) continue;
// SaveCandidate(lrIDA,trCopy,chi2cl,icl); // RS: do we need this?
if (chi2cl>chi2Best) continue;
chi2Best = chi2cl;
iclBest = icl;
bestCl = cl;
bestTr = trCopy;
if (nCl==1) { // in absence of competitors, do the fit on spot
if (!bestTr.Update(cpar,ccov)) return kFALSE;
updDone = kTRUE;
}
}
#ifdef _DEBUG_
printf("Lr%d -> %f\n",lrIDA,chi2Best);
#endif
//
if (bestCl) {
if (!updDone) {
double cpar[2]={ bestCl->GetY(), bestCl->GetZ()};
double ccov[3]={ bestCl->GetSigmaY2(), 0., bestCl->GetSigmaZ2()}; // RS: add syst errors
if (!bestTr.Update(cpar,ccov)) return kFALSE;
updDone = kTRUE;
}
track.paramOut = bestTr;
track.clID[lrIDA] = iclBest;
track.ncl++;
track.chi2 += chi2Best;
//
#ifdef _CONTROLH_
// update label on the fly
Bool_t corrLB = kFALSE;
if (track.label>=0) {
for (int i=0;i<3;i++) if (bestCl->GetLabel(i)==track.label) {corrLB=kTRUE; break;}
if (!corrLB) track.label = -track.label;
}
#endif
}
}
//
if (!updDone) {
if (++track.nmiss > fMaxMissedLayers) return kFALSE;
track.paramOut = trCopy;
track.chi2 += fMissChi2Penalty;
}
//
#ifdef _CONTROLH_
int ndf = 2*track.ncl-5;
if (ndf>0) {
fHChi2vsNC->Fill(track.ncl,track.chi2);
if (lrID==kNLrActive-1) fHChi2NDFvsPT->Fill(track.paramOut.Pt(),track.chi2/ndf);
}
#endif
if (track.chi2 > GetChi2TotCut(track.ncl+1)) return kFALSE;
//
return track.paramOut.CorrectForMeanMaterial(fgkX2X0ITS[lrID],-fgkRhoLITS[lrID],fgkDefMass,kFALSE);
//
}
//______________________________________________
void AliXXXITSTracker::CookLabel(AliXXXITSTracker::ITStrack_t& track)
{
// cook mc label for the track
track.label = fgkDummyLabel;
if (!track.ncl) return;
const int kMaxLbPerCl = 3;
int lbID[kNLrActive*6],lbStat[kNLrActive*6];
Int_t nLab=0;
for (int i=kNLrActive;i--;) {
int clid = track.clID[i];
if (clid<0) continue;
AliITSRecPoint* cl = fLayers[i]->GetClusterSorted(clid);
for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster
int trLb = cl->GetLabel(imc);
if (trLb<0) break;
// search this mc track in already accounted ones
int iLab;
for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break;
if (iLab<nLab) lbStat[iLab]++;
else {
lbID[nLab] = trLb;
lbStat[nLab++] = 1;
}
} // loop over given cluster's labels
} // loop over all clusters
//
if (nLab) {
int maxLab=0;
for (int ilb=nLab;ilb--;) if (lbStat[maxLab]<lbStat[ilb]) maxLab=ilb;
track.label = lbStat[maxLab]==track.ncl ? lbID[maxLab] : -lbID[maxLab];
}
//
}
//______________________________________________
void AliXXXITSTracker::CookLabel(AliXXXITSTracker::SPDtracklet_t& tracklet)
{
// cook mc label for the tracklet
tracklet.label = fgkDummyLabel;
const int kMaxLbPerCl = 3;
int lbID[kNLrActive*6],lbStat[kNLrActive*6];
Int_t nLab=0;
for (int i=2;i--;) {
int clid = i ? tracklet.id2 : tracklet.id1;
AliITSRecPoint* cl = fLayers[i]->GetClusterSorted(clid);
for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster
int trLb = cl->GetLabel(imc);
if (trLb<0) break;
// search this mc track in already accounted ones
int iLab;
for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break;
if (iLab<nLab) lbStat[iLab]++;
else {
lbID[nLab] = trLb;
lbStat[nLab++] = 1;
}
} // loop over given cluster's labels
} // loop over all clusters
//
if (nLab) {
int maxLab=0;
for (int ilb=nLab;ilb--;) if (lbStat[maxLab]<lbStat[ilb]) maxLab=ilb;
tracklet.label = lbStat[maxLab]==2 ? lbID[maxLab] : -lbID[maxLab];
}
//
}
//______________________________________________
Double_t AliXXXITSTracker::GetXatLabRLin(AliExternalTrackParam& track, double r)
{
// X of track circle intersection in current tracking frame, neglecting the curvature
// Solution of equation (x+d)^2+(y+b*d)^2 - r^2, where x,y are current coordinates of
// track and d=X-x0. b = tg(phi)
//double sn=tr.GetSnp();
double sn=track.GetSnp();
if (TMath::Abs(sn)>kAlmost1) return -999;
double x=track.GetX(), y=track.GetY();
double cs2=(1.-sn)*(1.+sn), tg=sn/TMath::Sqrt(cs2);
double t0=x+tg*y, t1=x*x+y*y-r*r, det=t0*t0-t1/cs2;
if (det<0) return -999; // does not touch circle
det = TMath::Sqrt(det);
return x+(det-t0)*cs2;
//
}
//______________________________________________
Int_t AliXXXITSTracker::GetTrackletMCTruth(AliXXXITSTracker::SPDtracklet_t& trlet) const
{
int status = 0;
AliXXXLayer::ClsInfo_t *cli1=fLayers[kALrSPD1]->GetClusterInfo(trlet.id1);
AliXXXLayer::ClsInfo_t *cli2=fLayers[kALrSPD2]->GetClusterInfo(trlet.id2);
AliITSRecPoint *cl1=fLayers[kALrSPD1]->GetClusterUnSorted(cli1->index);
AliITSRecPoint *cl2=fLayers[kALrSPD2]->GetClusterUnSorted(cli2->index);
//
int lab = -1;
//
for (int i=0;i<3;i++) {
int lb1 = cl1->GetLabel(i);
if (lb1<0) continue;
for (int j=0;j<3;j++) {
int lb2 = cl2->GetLabel(i);
if (lb2<0) break;
if (lb1==lb2) {lab = lb1; break;}
}
if (lab>=0) break;
}
if (lab<0) return 0;
//
for (int ila=kALrSDD1;ila<kNLrActive;ila++) {
for (int icl=fNClusters[ila];icl--;) {
AliITSRecPoint *cl=fLayers[ila]->GetClusterUnSorted(icl);
for (int i=0;i<3;i++) {
if (cl->GetLabel(i)<0) break;
if (cl->GetLabel(i)==lab) {status |= 0x1<<ila; break;}
}
if (status & (0x1<<ila)) break;
}
}
return status;
}
//______________________________________________
Bool_t AliXXXITSTracker::RefitInward(int itr)
{
// refit track inward with material correction
ITStrack_t &track = fTracks[itr];
AliExternalTrackParam &trout = track.paramOut;
if (trout.TestBit(kInvalidBit)) return kFALSE;
AliExternalTrackParam &trin = track.paramInw;
trin = trout;
int ilA = kNLrActive;
for (;ilA--;) { // find outermost layer with cluster
if (track.clID[ilA]<0) continue;
break;
}
int ilStart = fgkActiveLrITS[ilA]; // corresponding total lr id
AliXXXLayer* lrA = fLayers[ilA];
AliITSRecPoint *cl=lrA->GetClusterSorted(track.clID[ilA]);
AliXXXLayer::ITSDetInfo_t& detInfo = lrA->GetDetInfo(cl->GetVolumeId()-lrA->GetVIDOffset());
if (!trin.RotateParamOnly(detInfo.phiTF)) return kFALSE;
if (!trin.PropagateParamOnlyTo(detInfo.xTF+cl->GetX(), fBz)) return kFALSE;
// init with outer cluster y,z and slopes, q/pt of outward track
double par[5] = {cl->GetY(), cl->GetZ(), trin.GetSnp(), trin.GetTgl(), trin.GetSigned1Pt()};
double cov[15] = {cl->GetSigmaY2() + GetClSystYErr2(kALrSPD1),
0., cl->GetSigmaZ2() + GetClSystZErr2(kALrSPD1),
0,0,1,
0,0,0,1,
0,0,0,0,100*100};
trin.Set(double(detInfo.xTF+cl->GetX()),double(detInfo.phiTF), par, cov);
// !!! no material correction is needed: errors are not defined yer
//
for (int ilr=ilStart;ilr--;) {
//
if ( (ilA=fgkLr2Active[ilr])<0 || track.clID[ilA]<0) { // either passive layer or no cluster
if (CrossPassiveLayer(trin,ilr)) continue;
else return kFALSE;
}
// there is a cluster, need to update
lrA = fLayers[ilA];
cl = lrA->GetClusterSorted(track.clID[ilA]);
AliXXXLayer::ITSDetInfo_t& detInfo1 = lrA->GetDetInfo(cl->GetVolumeId()-lrA->GetVIDOffset());
if (!trin.Propagate(detInfo1.phiTF, detInfo1.xTF+cl->GetX(), fBz)) return kFALSE;
double cpar[2]={ cl->GetY(), cl->GetZ()};
double ccov[3]={ cl->GetSigmaY2() + GetClSystYErr2(ilA) , 0., cl->GetSigmaZ2() + GetClSystZErr2(ilA)};
if (!trin.Update(cpar,ccov)) return kFALSE;
//
// correct for layer materials
if (!trin.CorrectForMeanMaterial(fgkX2X0ITS[ilr],fgkRhoLITS[ilr],fgkDefMass,kFALSE)) return kFALSE;
//
}
//
// now go to PCA to vertex
//double dca[2],dcaCov[3];
if (!trin.PropagateToDCA(fSPDVertex,fBz,fgkRLayITS[kLrBeamPime])) return kFALSE; //,dca,dcaCov);
//
trin.ResetBit(kInvalidBit); // flag that inward fit succeeded
return kTRUE;
//
}
//______________________________________________
void AliXXXITSTracker::RefitInward()
{
// refit tracks inward with material correction
for (int itr=fNTracks;itr--;) {
if (!RefitInward(itr)) {
#ifdef _DEBUG_
printf("RefitInward failed for track %d\n",itr);
PrintTrack(fTracks[itr]);
#endif
}
}
//
}
//______________________________________________
Bool_t AliXXXITSTracker::FitTrackVertex()
{
// Fit the vertexTracks. The inner tracks must be already propagated to the SPD vertex.
// In this case straight line extrapolation can be used
//
fTrackVertex.SetNContributors(0); // invalidate
//
if (fNTracks<3) return kFALSE;
double cxx=0,cxy=0,cxz=0,cx0=0,cyy=0,cyz=0,cy0=0,czz=0,cz0=0;
//
int ntAcc = 0;
for (int itr=fNTracks;itr--;) {
//
AliExternalTrackParam& trc = fTracks[itr].paramInw;
if (trc.TestBit(kInvalidBit)) continue; // the track is invalidated, skip
double *param = (double*)trc.GetParameter();
double *covar = (double*)trc.GetCovariance();
//
double x0=trc.GetX();
double &y0=param[0];
double &z0=param[1];
double sn=param[2];
double cs2=(1.-sn)*(1.+sn);
if (cs2<kAlmost0) continue;
double cs=TMath::Sqrt(cs2), tgp=sn/cs, tgl=trc.GetTgl()/cs;
// assume straight track equation Y=y0+tgp*X, Z=z0+tgl*X in tracking frame
//
double alp = trc.GetAlpha();
sn = TMath::Sin(alp); // parameters for rotation of vertex to
cs = TMath::Cos(alp); // tracking frame
//
double &syy=covar[0], &syz=covar[1], &szz=covar[2];
double detI = syy*szz - syz*syz;
if (TMath::Abs(detI)<kAlmost0) return kFALSE;
detI = 1./detI;
double syyI = szz*detI;
double szzI = syy*detI;
double syzI =-syz*detI;
//
double tmpSP = sn*tgp;
double tmpCP = cs*tgp;
double tmpSC = sn+tmpCP;
double tmpCS =-cs+tmpSP;
double tmpCL = cs*tgl;
double tmpSL = sn*tgl;
double tmpYXP = y0-tgp*x0;
double tmpZXL = z0-tgl*x0;
//
double tmpCLzz = tmpCL*szzI;
double tmpSLzz = tmpSL*szzI;
double tmpSCyz = tmpSC*syzI;
double tmpCSyz = tmpCS*syzI;
double tmpCSyy = tmpCS*syyI;
double tmpSCyy = tmpSC*syyI;