-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDetectorK.cxx
2652 lines (2269 loc) · 93.5 KB
/
DetectorK.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 "DetectorK.h"
#include "AliLog.h"
#include <TMath.h>
#include <TMatrixD.h>
#include <TGraph.h>
#include <TAxis.h>
#include <TFormula.h>
#include <TCanvas.h>
#include <TEllipse.h>
#include <TText.h>
#include <TGraphErrors.h>
#include "AliExternalTrackParam.h"
/***********************************************************
Fast Simulation tool for Inner Tracker Systems
original code of using the billoir technique was developed
for the HFT (STAR), James H. Thomas, [email protected]
http://rnc.lbl.gov/~jhthomas
Changes by S. Rossegger -> see header file
***********************************************************/
Bool_t DetectorK::verboseR=0;
#define RIDICULOUS 999999 // A ridiculously large resolution (cm) to flag a dead detector
#define xrhosteps 10 // steps for dEdx correction
#define Luminosity 1.e27 // Luminosity of the beam (LHC HI == 1.e27, RHIC II == 8.e27 )
#define SigmaD 6.0 // Size of the interaction diamond (cm) (LHC = 6.0 cm)
#define dNdEtaMinB 1//950//660//950 // Multiplicity per unit Eta (AuAu MinBias = 170, Central = 700)
// #define dNdEtaCent 2300//15000 //1600//2300 // Multiplicity per unit Eta (LHC at 5.5 TeV not known)
#define CrossSectionMinB 8 // minB Cross section for event under study (PbPb MinBias ~ 8 Barns)
#define AcceptanceOfTpcAndSi 1 //1//0.60 //0.35 // Assumed geometric acceptance (efficiency) of the TPC and Si detectors
#define UPCBackgroundMultiplier 1.0 // Increase multiplicity in detector (0.0 to 1.0 * UPCRate ) (eg 1.0)
#define OtherBackground 0.0 // Increase multiplicity in detector (0.0 to 1.0 * minBias) (eg 0.0)
#define EfficiencySearchFlag 2 // Define search method:
// -> ChiSquarePlusConfLevel = 2, ChiSquare = 1, Simple = 0.
#define PionMass 0.139 // Mass of the Pion
#define KaonMass 0.498 // Mass of the Kaon
#define D0Mass 1.865 // Mass of the D0
ClassImp(TrackSol)
const double DetectorK::kPtMinFix = 0.050;
const double DetectorK::kPtMaxFix = 31.5;
//TMatrixD *probKomb; // table for efficiency kombinatorics
class ForwardLayer : public TNamed {
public:
ForwardLayer(char *name) : TNamed(name,name) {}
Float_t GetZ() const {return zPos;}
Float_t GetXRes() const {return xRes;}
Float_t GetYRes() const {return yRes;}
Float_t GetThickness() const {return thickness;}
Float_t Getdensity() const {return density;}
Float_t GetLayerEff() const {return eff;}
// void Print() {printf(" r=%3.1lf X0=%1.6lf sigPhi=%1.4lf sigZ=%1.4lf\n",radius,radL,phiRes,zRes); }
Float_t zPos; Float_t xRes; Float_t yRes;
Float_t radL;
Float_t thickness;
Float_t density;
Float_t eff;
Bool_t isDead;
ClassDef(ForwardLayer,1);
};
ClassImp(DetectorK)
DetectorK::DetectorK()
: TNamed("test_detector","detector"),
fNumberOfLayers(0),
fNumberOfActiveLayers(0),
fNumberOfActiveITSLayers(0),
fBField(0.5),
fLhcUPCscale(1.0),
fIntegrationTime(0.02), // in ms
fConfLevel(0.0027), // 0.27 % -> 3 sigma confidence
fAvgRapidity(0.45), // Avg rapidity, MCS calc is a function of crossing angle
fParticleMass(0.140), // Standard: pion mass
fMaxSnp(0.85),
fMaxRadiusSlowDet(10.),
fAtLeastHits(-1), // if -1, then require hit on all ITS layers
fAtLeastCorr(-1), // if -1, then correct hit on all ITS layers
fAtLeastFake(1), // if at least x fakes, track is considered fake ...
fMaxSeedRadius(50000),
fptScale(10.),
fdNdEtaCent(2200),
kDetLayer(-1),
fMinRadTrack(132.)
{
//
// default constructor
//
// fLayers = new TObjArray();
SetMaxSnp();
}
DetectorK::DetectorK(char *name, char *title)
: TNamed(name,title),
fNumberOfLayers(0),
fNumberOfActiveLayers(0),
fNumberOfActiveITSLayers(0),
fBField(0.5),
fLhcUPCscale(1.0),
fIntegrationTime(0.02), // in ms
fConfLevel(0.0027), // 0.27 % -> 3 sigma confidence
fAvgRapidity(0.45), // Avg rapidity, MCS calc is a function of crossing angle
fParticleMass(0.140), // Standard: pion mass
fMaxSnp(0.85),
fMaxRadiusSlowDet(10.),
fAtLeastHits(-1), // if -1, then require hit on all ITS layers
fAtLeastCorr(-1), // if -1, then correct hit on all ITS layers
fAtLeastFake(1), // if at least x fakes, track is considered fake ...
fMaxSeedRadius(50000),
fptScale(10.),
fdNdEtaCent(2200),
kDetLayer(-1),
fMinRadTrack(132.)
{
//
// default constructor, that set the name and title
//
// fLayers = new TObjArray();
SetMaxSnp();
}
DetectorK::~DetectorK() { //
// virtual destructor
//
// delete fLayers;
}
void DetectorK::AddLayer(char *name, Float_t radius, Float_t radL, Float_t xrho, Float_t phiRes, Float_t zRes, Float_t eff) {
//
// Add additional layer to the list of layers (ordered by radius)
//
CylLayerK *newLayer = (CylLayerK*) fLayers.FindObject(name);
if (!newLayer) {
newLayer = new CylLayerK(name);
newLayer->radius = radius;
newLayer->radL = radL;
newLayer->xrho = xrho;
newLayer->phiRes = phiRes;
newLayer->zRes = zRes;
newLayer->eff = eff;
if (newLayer->zRes==RIDICULOUS && newLayer->zRes==RIDICULOUS)
newLayer->isDead = kTRUE;
else
newLayer->isDead = kFALSE;
if (fLayers.GetEntries()==0)
fLayers.Add(newLayer);
else {
for (Int_t i = 0; i<fLayers.GetEntries(); i++) {
CylLayerK *l = (CylLayerK*)fLayers.At(i);
if (radius<l->radius) {
fLayers.AddBefore(l,newLayer);
break;
}
if (radius>l->radius && (i+1)==fLayers.GetEntries() ) {
// even bigger then last one
fLayers.Add(newLayer);
}
}
}
fNumberOfLayers += 1;
if (!(newLayer->isDead)) {
fNumberOfActiveLayers += 1;
TString lname(newLayer->GetName());
if ( IsITSLayer(lname) ) fNumberOfActiveITSLayers += 1;
}
} else {
printf("Layer with the name %s does already exist\n",name);
}
}
void DetectorK::KillLayer(char *name) {
//
// Marks layer as dead. Contribution only by Material Budget
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot mark as dead\n",name);
else {
tmp->phiRes = 999999;
tmp->zRes = 999999;
if (!(tmp->isDead)) {
tmp->isDead = kTRUE;
fNumberOfActiveLayers -= 1;
TString lname(tmp->GetName());
if ( IsITSLayer(lname) ) fNumberOfActiveITSLayers -= 1;
}
}
}
void DetectorK::SetRadius(char *name, Float_t radius) {
//
// Set layer radius [cm]
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp) {
printf("Layer %s not found - cannot set radius\n",name);
} else {
Float_t tmpRadL = tmp->radL;
Float_t tmpXRho = tmp->xrho;
Float_t tmpPhiRes = tmp->phiRes;
Float_t tmpZRes = tmp->zRes;
RemoveLayer(name); // so that the ordering is correct
AddLayer(name,radius,tmpRadL,tmpXRho,tmpPhiRes,tmpZRes);
}
}
Float_t DetectorK::GetRadius(char *name) {
//
// Return layer radius [cm]
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot get radius\n",name);
else
return tmp->radius;
return 0;
}
void DetectorK::SetRadiationLength(char *name, Float_t radL) {
//
// Set layer material [cm]
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot set layer material\n",name);
else {
tmp->radL = radL;
}
}
Float_t DetectorK::GetRadiationLength(char *name) {
//
// Return layer radius [cm]
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot get layer material\n",name);
else
return tmp->radL;
return 0;
}
void DetectorK::SetResolution(char *name, Float_t phiRes, Float_t zRes) {
//
// Set layer resolution in [cm]
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot set resolution\n",name);
else {
Bool_t wasDead = tmp->isDead;
tmp->phiRes = phiRes;
tmp->zRes = zRes;
TString lname(tmp->GetName());
if (zRes==RIDICULOUS && phiRes==RIDICULOUS) {
tmp->isDead = kTRUE;
if (!wasDead) {
fNumberOfActiveLayers -= 1;
if ( IsITSLayer(lname) ) fNumberOfActiveITSLayers -= 1;
}
} else {
tmp->isDead = kFALSE;
if (wasDead) {
fNumberOfActiveLayers += 1;
if ( IsITSLayer(lname) ) fNumberOfActiveITSLayers += 1;
}
}
}
}
Float_t DetectorK::GetResolution(char *name, Int_t axis) {
//
// Return layer resolution in [cm]
// axis = 0: resolution in rphi
// axis = 1: resolution in z
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot get resolution\n",name);
else {
if (axis==0) return tmp->phiRes;
if (axis==1) return tmp->zRes;
printf("error: axis must be either 0 or 1 (rphi or z axis)\n");
}
return 0;
}
void DetectorK::SetLayerEfficiency(char *name, Float_t eff) {
//
// Set layer efficnecy (prop that his is missed within this layer)
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot set layer efficiency\n",name);
else {
tmp->eff = eff;
}
}
Float_t DetectorK::GetLayerEfficiency(char *name) {
//
// Get layer efficnecy (prop that his is missed within this layer)
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot get layer efficneicy\n",name);
else
return tmp->eff;
return 0;
}
void DetectorK::RemoveLayer(char *name) {
//
// Removes a layer from the list
//
CylLayerK *tmp = (CylLayerK*) fLayers.FindObject(name);
if (!tmp)
printf("Layer %s not found - cannot remove it\n",name);
else {
Bool_t wasDead = tmp->isDead;
fLayers.Remove(tmp);
fNumberOfLayers -= 1;
if (!wasDead) {
fNumberOfActiveLayers -= 1;
TString lname(tmp->GetName());
if ( IsITSLayer(lname) ) fNumberOfActiveITSLayers -= 1;
}
}
}
CylLayerK* DetectorK::FindLayer(char *name) const
{
//
// find layer by name
//
return (CylLayerK*) fLayers.FindObject(name);
}
CylLayerK* DetectorK::FindLayer(double r, int mode) const
{
//
// find layer close to radius r
// mode = 0: closest
// mode > 0: closest above
// mode < 0: closest below
//
double drMin=-9999;
int lrID = -1;
int nLr = fLayers.GetEntries();
for (Int_t i=fLayers.GetEntries(); i--;) {
CylLayerK* tmp = (CylLayerK*)fLayers.At(i);
double dr = tmp->radius - r;
if (TMath::Abs(dr)<TMath::Abs(drMin)) {
drMin = dr;
lrID = i;
}
}
if (lrID<0) return 0;
if (mode>0 && drMin<0) return ++lrID<nLr ? (CylLayerK*)fLayers.At(lrID) : 0;
if (mode<0 && drMin>0) return --lrID>0 ? (CylLayerK*)fLayers.At(lrID) : 0;
return (CylLayerK*)fLayers.At(lrID);
//
}
Int_t DetectorK::FindLayerID(double r, int mode) const
{
//
// find layer ID close to radius r
// mode = 0: closest
// mode > 0: closest above
// mode < 0: closest below
//
double drMin=-9999;
int lrID = -1;
int nLr = fLayers.GetEntries();
for (Int_t i=fLayers.GetEntries(); i--;) {
CylLayerK* tmp = (CylLayerK*)fLayers.At(i);
double dr = tmp->radius - r;
if (TMath::Abs(dr)<TMath::Abs(drMin)) {
drMin = dr;
lrID = i;
}
}
if (lrID<0) return 0;
if (mode>0 && drMin<0) return ++lrID<nLr ? lrID : -1;
if (mode<0 && drMin>0) return --lrID>0 ? lrID : -1;
return lrID;
//
}
void DetectorK::PrintLayout(Bool_t full) {
//
// Prints the detector layout
//
printf("Detector %s: \"%s\"\n",GetName(),GetTitle());
if (fLayers.GetEntries()>0)
printf(" Name \t\t r [cm] \t X0 \t xRho \t phi & z res [um] layerEff \n");
CylLayerK *tmp = 0;
for (Int_t i = 0; i<fLayers.GetEntries(); i++) {
tmp = (CylLayerK*)fLayers.At(i);
// don't print all the tpc layers
TString name(tmp->GetName());
if (!full && !IsITSLayer(name) && !name.Contains("_0")) continue;
printf("%d. %s \t %03.2f \t%1.4f\t%1.4f\t ",i,
tmp->GetName(), tmp->radius, tmp->radL, tmp->xrho);
if (tmp->phiRes==RIDICULOUS)
printf(" - ");
else
printf("%3.0f ",tmp->phiRes*10000);
if (tmp->zRes==RIDICULOUS)
printf(" -");
else
printf("%3.0f",tmp->zRes*10000);
if (tmp->zRes==RIDICULOUS)
printf("\t -\n");
else
printf("\t%0.2f\n",tmp->eff);
}
}
void DetectorK::PlotLayout(Int_t plotDead) {
//
// Plots the detector layout in Front view
//
Double_t x0=0, y0=0;
TGraphErrors *gr = new TGraphErrors();
gr->SetPoint(0,0,0);
CylLayerK *lastLayer = (CylLayerK*)fLayers.At(fLayers.GetEntries()-1); Double_t maxRad = lastLayer->radius;
gr->SetPointError(0,maxRad,maxRad);
gr->Draw("APE");
CylLayerK *tmp = 0;
for (Int_t i = fLayers.GetEntries()-1; i>=0; i--) {
tmp = (CylLayerK*)fLayers.At(i);
Double_t txtpos = tmp->radius;
if ((tmp->isDead)) txtpos*=-1; //
TText *txt = new TText(x0,txtpos,tmp->GetName());
txt->SetTextSizePixels(5); txt->SetTextAlign(21);
if (!tmp->isDead || plotDead) txt->Draw();
TEllipse *layEl = new TEllipse(x0,y0,tmp->radius);
// layEl->SetFillColor(5);
layEl->SetFillStyle(5001);
layEl->SetLineStyle(tmp->isDead+1); // dashed if not active
layEl->SetLineColor(4);
TString name(tmp->GetName());
if (!tmp->isDead) layEl->SetLineWidth(2);
if (name.Contains("tpc") ) layEl->SetLineColor(29);
if (name.Contains("trd") ) layEl->SetLineColor(30);
if (!tmp->isDead || plotDead) layEl->Draw();
}
}
void DetectorK::AddTPC(Float_t phiResMean, Float_t zResMean, Int_t skip) {
//
// Emulates the TPC
//
// skip=1: Use every padrow, skip=2: Signal in every 2nd padrow
AddLayer((char*)"tpcIFC", 77.8, 9.279967e-02, 3.325701e+00); // Inner Field cage
AddLayer((char*)"tpcOFC", 254.0, 9.279967e-02, 3.325701e+00); // Outer Field cage
// % Radiation Lengths ... Average per TPC row (i.e. total/159 )
const int kNPassiveBound = 2;
const Float_t radLBoundary[kNPassiveBound] = {1.692612e-01, 8.711904e-02};
const Float_t xrhoBoundary[kNPassiveBound] = {6.795774e+00, 3.111401e+00};
const Float_t rBoundary[kNPassiveBound] = {50, 70.0}; // cm
Float_t radLPerRow = 0.000036;
Float_t tpcInnerRadialPitch = 0.75 ; // cm
Float_t tpcMiddleRadialPitch = 1.0 ; // cm
Float_t tpcOuterRadialPitch = 1.5 ; // cm
// Float_t tpcInnerPadWidth = 0.4 ; // cm
// Float_t tpcMiddlePadWidth = 0.6 ; // cm
// Float_t tpcOuterPadWidth = 0.6 ; // cm
Float_t innerRows = 63 ;
Float_t middleRows = 64 ;
Float_t outerRows = 32 ;
Float_t tpcRows = (innerRows + middleRows + outerRows) ;
Float_t rowOneRadius = 85.2 ; // cm
Float_t row64Radius = 135.1 ; // cm
Float_t row128Radius = 199.2 ; // cm
// add boundaries between ITS and TPC
for (int i=0;i<kNPassiveBound;i++) {
AddLayer(Form("tpc_boundary%d",i),rBoundary[i],radLBoundary[i], xrhoBoundary[i]); // dummy errors
}
for ( Int_t k = 0 ; k < tpcRows ; k++ ) {
Float_t rowRadius =0;
if (k<innerRows)
rowRadius = rowOneRadius + k*tpcInnerRadialPitch ;
else if ( k>=innerRows && k<(innerRows+middleRows) )
rowRadius = row64Radius + (k-innerRows+1)*tpcMiddleRadialPitch ;
else if (k>=(innerRows+middleRows) && k<tpcRows )
rowRadius = row128Radius + (k-innerRows-middleRows+1)*tpcOuterRadialPitch ;
if ( k%skip == 0 )
AddLayer(Form("tpc_%d",k),rowRadius,radLPerRow, 0, phiResMean,zResMean);
else
AddLayer(Form("tpc_%d",k),rowRadius,radLPerRow, 0); // non "active" row
}
}
void DetectorK::AddTRD(Float_t phiResMean, Float_t zResMean, Float_t lrEff) {
//
// Emulates the TRD
//
const double trdX2X0=3.3e-2;
for (int i=0;i<6;i++) AddLayer((char*)Form("trd_%d",i), 300.0+13*i ,trdX2X0, phiResMean, zResMean,
lrEff<1 ? lrEff : 1.0);
}
void DetectorK::RemoveTPC() {
// flag as dead, although resolution is ok ... makes live easier in the prints ... ;-)
CylLayerK *tmp = 0;
for (Int_t i = 0; i<fLayers.GetEntries(); i++) {
tmp = (CylLayerK*)fLayers.At(i);
TString name(tmp->GetName());
if (name.Contains("tpc")) { RemoveLayer((char*)name.Data()); i--; }
}
}
Double_t DetectorK::ThetaMCS ( Double_t mass, Double_t radLength, Double_t momentum ) const
{
//
// returns the Multiple Couloumb scattering angle (compare PDG boolet, 2010, equ. 27.14)
//
Double_t beta = momentum / TMath::Sqrt(momentum*momentum+mass*mass) ;
Double_t theta = 0.0 ; // Momentum and mass in GeV
// if ( RadLength > 0 ) theta = 0.0136 * TMath::Sqrt(RadLength) / ( beta * momentum );
if ( radLength > 0 ) theta = 0.0136 * TMath::Sqrt(radLength) / ( beta * momentum ) * (1+0.038*TMath::Log(radLength)) ;
return (theta) ;
}
Double_t DetectorK::ProbGoodHit ( Double_t radius, Double_t searchRadiusRPhi, Double_t searchRadiusZ )
{
// Based on work by Howard Wieman: http://rnc.lbl.gov/~wieman/GhostTracks.htm
// and http://rnc.lbl.gov/~wieman/HitFinding2D.htm
// This is the probability of getting a good hit using 2D Gaussian distribution function and infinite search radius
Double_t sx, sy, goodHit ;
sx = 2 * TMath::Pi() * searchRadiusRPhi * searchRadiusRPhi * HitDensity(radius) ;
sy = 2 * TMath::Pi() * searchRadiusZ * searchRadiusZ * HitDensity(radius) ;
goodHit = TMath::Sqrt(1./((1+sx)*(1+sy))) ;
return ( goodHit ) ;
}
Double_t DetectorK::ProbGoodChiSqHit ( Double_t radius, Double_t searchRadiusRPhi, Double_t searchRadiusZ )
{
// Based on work by Victor Perevoztchikov and Howard Wieman: http://rnc.lbl.gov/~wieman/HitFinding2DXsq.htm
// This is the probability of getting a good hit using a Chi**2 search on a 2D Gaussian distribution function
Double_t sx, goodHit ;
sx = 2 * TMath::Pi() * searchRadiusRPhi * searchRadiusZ * HitDensity(radius) ;
goodHit = 1./(1+sx) ;
return ( goodHit ) ;
}
Double_t DetectorK::ProbGoodChiSqPlusConfHit ( Double_t radius, Double_t leff, Double_t searchRadiusRPhi, Double_t searchRadiusZ )
{
// Based on work by Ruben Shahoyen
// This is the probability of getting a good hit using a Chi**2 search on a 2D Gaussian distribution function
// Plus, in addition, taking a "confidence level" and the "layer efficiency" into account
// Following is correct for 2 DOF
Double_t c = -2 *TMath::Log(fConfLevel); // quantile at cut of confidence level
Double_t alpha = (1 + 2 * TMath::Pi() * HitDensity(radius) * searchRadiusRPhi * searchRadiusZ)/2;
Double_t goodHit = leff/(2*alpha) * (1 - TMath::Exp(-alpha*c));
return ( goodHit ) ;
}
Double_t DetectorK::ProbNullChiSqPlusConfHit ( Double_t radius, Double_t leff, Double_t searchRadiusRPhi, Double_t searchRadiusZ )
{
// Based on work by Ruben Shahoyen
// This is the probability to not have any match to the track (see also :ProbGoodChiSqPlusConfHit:)
Double_t c = -2 *TMath::Log(fConfLevel); // quantile at cut of confidence level
Double_t alpha = (1 + 2 * TMath::Pi() * HitDensity(radius) * searchRadiusRPhi * searchRadiusZ)/2;
Double_t nullHit = (1-leff+fConfLevel*leff)*TMath::Exp(-c*(alpha-1./2));
return ( nullHit ) ;
}
Double_t DetectorK::HitDensity ( Double_t radius )
{
// Background (0-1) is included via 'OtherBackground' which multiplies the minBias rate by a scale factor.
// UPC electrons is a temporary kludge that is based on Kai Schweda's summary of Kai Hainken's MC results
// See K. Hencken et al. PRC 69, 054902 (2004) and PPT slides by Kai Schweda.
// Note that this function assumes we are working in CM and CM**2 [not meters].
// Based on work by Yan Lu 12/20/2006, all radii and densities in centimeters or cm**2.
// Double_t MaxRadiusSlowDet = 0.1; //? // Maximum radius for slow detectors. Fast detectors
// and only fast detectors reside outside this radius.
Double_t arealDensity = 0 ;
if ( radius > fMaxRadiusSlowDet )
{
arealDensity = OneEventHitDensity(fdNdEtaCent,radius) ; // Fast detectors see central collision density (only)
arealDensity += OtherBackground*OneEventHitDensity(dNdEtaMinB,radius) ; // Increase density due to background
}
if (radius < fMaxRadiusSlowDet )
{ // Note that IntegratedHitDensity will always be minB one event, or more, even if integration time => zero.
arealDensity = OneEventHitDensity(fdNdEtaCent,radius)
+ IntegratedHitDensity(dNdEtaMinB,radius)
+ UpcHitDensity(radius) ;
arealDensity += OtherBackground*IntegratedHitDensity(dNdEtaMinB,radius) ;
// Increase density due to background
}
return ( arealDensity ) ;
}
double DetectorK::OneEventHitDensity( Double_t multiplicity, Double_t radius ) const
{
// This is for one event at the vertex. No smearing.
double den = multiplicity / (2.*TMath::Pi()*radius*radius) ; // 2 eta ?
double tg = TMath::Tan(2*TMath::ATan(TMath::Exp(-fAvgRapidity)));
den = den/TMath::Sqrt(1 + 1/(tg*tg));
// double den = multiplicity / (2.*TMath::Pi()*radius*radius) ; // 2 eta ?
// note: surface of sphere is '4*pi*r^2'
// surface of cylinder is '2*pi*r* h'
return den ;
}
double DetectorK::IntegratedHitDensity(Double_t multiplicity, Double_t radius)
{
// The integral of minBias events smeared over a gaussian vertex distribution.
// Based on work by Yan Lu 12/20/2006, all radii in centimeters.
Double_t zdcHz = Luminosity * 1.e-24 * CrossSectionMinB ;
Double_t den = zdcHz * fIntegrationTime/1000. * multiplicity * Dist(0., radius) / (2.*TMath::Pi()*radius) ;
// Note that we do not allow the rate*time calculation to fall below one minB event at the vertex.
if ( den < OneEventHitDensity(multiplicity,radius) ) den = OneEventHitDensity(multiplicity,radius) ;
return den ;
}
double DetectorK::UpcHitDensity(Double_t radius)
{
// QED electrons ...
Double_t mUPCelectrons = 0;
return mUPCelectrons ;
// mUPCelectrons = fLhcUPCscale * (1.23 - radius/6.5) ; // Fit to Kai Schweda summary tables at RHIC * 'scale' for LHC
mUPCelectrons = fLhcUPCscale*5456/(radius*radius)/dNdEtaMinB; // Fit to 'Rossegger,Sadovsky'-Alice simulation
if ( mUPCelectrons < 0 ) mUPCelectrons = 0.0 ; // UPC electrons fall off quickly and don't go to large R
mUPCelectrons *= IntegratedHitDensity(dNdEtaMinB,radius) ; // UPCs increase Mulitiplicty ~ proportional to MinBias rate
mUPCelectrons *= UPCBackgroundMultiplier ; // Allow for an external multiplier (eg 0-1) to turn off UPC
return mUPCelectrons ;
}
double DetectorK::Dist(double z, double r)
{
// Convolute dEta/dZ distribution with assumed Gaussian of vertex z distribution
// Based on work by Howard Wieman http://rnc.lbl.gov/~wieman/HitDensityMeasuredLuminosity7.htm
// Based on work by Yan Lu 12/20/2006, all radii and Z location in centimeters.
Int_t index = 1 ; // Start weight at 1 for Simpsons rule integration
Int_t nsteps = 301 ; // NSteps must be odd for Simpson's rule to work
double dist = 0.0 ;
double dz0 = ( 4*SigmaD - (-4)*SigmaD ) / (nsteps-1) ; //cm
double z0 = 0.0 ; //cm
for(int i=0; i<nsteps; i++){
if ( i == nsteps-1 ) index = 1 ;
z0 = -4*SigmaD + i*dz0 ;
dist += index * (dz0/3.) * (1/sqrt(2.*TMath::Pi())/SigmaD) * exp(-z0*z0/2./SigmaD/SigmaD) *
(1/sqrt((z-z0)*(z-z0) + r*r)) ;
if ( index != 4 ) index = 4; else index = 2 ;
}
return dist;
}
#define PZero 0.861 // Momentum of back to back decay particles in the CM frame
#define EPiZero 0.872 // Energy of the pion from a D0 decay at rest
#define EKZero 0.993 // Energy of the Kaon from a D0 decay at rest
void DetectorK::SolveViaBilloir(Double_t selPt, double ptmin) {
//
// Solves the current geometry with the Billoir technique
// ( see P. Billoir, Nucl. Instr. and Meth. 225 (1984), p. 352. )
// ABOVE IS OBSOLETE -> NOW, its uses the Aliroot Kalman technique
//
Int_t print = 1;
const float kTrackingMargin = 0.1;
static AliExternalTrackParam probTr; // track to propagate
probTr.SetUseLogTermMS(kFALSE);
Int_t nPt = kNptBins;
// Clean up ......
for (Int_t j=0; j<nPt; j++) {
for (Int_t i=0; i<kMaxNumberOfDetectors; i++) {
fDetPointRes[i][j] = RIDICULOUS;
fDetPointZRes[i][j] = RIDICULOUS;
}
fTransMomenta[j] =0;
fMomentumRes[j] =0;
fResolutionRPhi[j] =0;
}
// Calculate track parameters using Billoirs method of matrices
Double_t pt,tgl, lambda, deltaPoverP ;
Double_t charge = 1;
Int_t printOnce = 1 ;
Int_t mStart =0;
if ( TMath::Abs(charge)>1.2) fParticleMass = -TMath::Abs(fParticleMass);
// Prepare Probability Kombinations
Int_t nLayer = fNumberOfActiveITSLayers;
Int_t base = 3; // null, fake, correct
printf("N ITS Layers: %d\n",fNumberOfActiveITSLayers);
TMatrixD probLay(base,fNumberOfActiveITSLayers);
TObjArray probKombArr;
probKombArr.Expand(nLayer);
probKombArr.SetOwner(kTRUE);
for (int nl=3;nl<=nLayer;nl++) {
Int_t komb = (Int_t) TMath::Power(base,nl);
TMatrixD *probKombP = new TMatrixD(komb,nl);
TMatrixD &probKomb = *probKombP;
for (Int_t num=0; num<komb; num++) {
for (Int_t l=nl; l--;) {
Int_t pow = ((Int_t)TMath::Power(base,l+1));
probKomb(num,nl-1-l)=(num%pow)/((Int_t)TMath::Power(base,l));
}
}
probKombArr[nl-3] = probKombP;
}
CylLayerK *last = (CylLayerK*) fLayers.At((fLayers.GetEntries()-1));
if (last->radius > fMinRadTrack) {
last = 0;
for (Int_t i=0; i<fLayers.GetEntries();i++) {
CylLayerK *l = (CylLayerK*) fLayers.At(i);
if (!(l->isDead) && (l->radius<fMinRadTrack)) last = l;
}
if (!last) {
printf("No layer with radius < %f is found\n",fMinRadTrack);
return;
}
}
if (ptmin<0) {
Double_t bigRad = last->radius/2 ; // min. pt which the algorithm below could handle
ptmin = ( 0.3*bigRad*TMath::Abs(fBField)*1e-2 ) + 0.005; // safety margin
if (ptmin<kPtMinFix) ptmin = kPtMinFix;
}
double ptmax = kPtMaxFix;
double dlpt = log(ptmax/ptmin)/nPt;
const double SQRT2 = TMath::Sqrt(2.);
printf("Will test %d tracks with %f < pt < %f\n",nPt,ptmin,ptmax);
// PseudoRapidity OK, used as an angle
lambda = TMath::Pi()/2.0 - 2.0*TMath::ATan(TMath::Exp(-1*fAvgRapidity)) ;
// find first "active layer" - start tracking at the first active layer
Int_t firstActiveLayer = 0;
for (Int_t j=0; j<=fLayers.GetEntries(); j++) {
CylLayerK* layer = (CylLayerK*)fLayers.At(j);
if (!(layer->isDead)) { // is alive
firstActiveLayer = j;
break;
}
}
for ( Int_t i = 0 ; i < nPt ; i++ ) { // pt loop
//
// Starting values based on radius of outermost layer ... log10 steps to ~20 GeV
// if (bigRad<61) bigRad=61; // -> min pt around 100 MeV for Bz=0.5T (don't overdo it ... ;-) )
fTransMomenta[i] = ptmin*TMath::Exp(dlpt*i);
//fTransMomenta[i] = ( 0.3*bigRad*TMath::Abs(fBField)*1e-2 ) - 0.08 - (1./fptScale-0.1) + TMath::Power(10,2.3*i/nPt) / fptScale ;
// New from here ................
// Assume track started at (0,0,0) and shoots out on the X axis, and B field is on the Z axis
// These are the EndPoint values for y, z, a, b, and d
double bGauss = fBField*10; // field in kgauss
pt = fTransMomenta[i]; // GeV/c
tgl = TMath::Tan(lambda); // dip
charge = -1; // Assume an electron
enum {kY,kZ,kSnp,kTgl,kPtI}; // track parameter aliases
enum {kY2,kYZ,kZ2,kYSnp,kZSnp,kSnp2,kYTgl,kZTgl,kSnpTgl,kTgl2,kYPtI,kZPtI,kSnpPtI,kTglPtI,kPtI2}; // cov.matrix aliases
//
probTr.Reset();
double *trPars = (double*)probTr.GetParameter();
double *trCov = (double*)probTr.GetCovariance();
trPars[kY] = 0; // start from Y = 0
trPars[kZ] = 0; // Z = 0
trPars[kSnp] = 0; // track along X axis at the vertex
trPars[kTgl] = tgl; // dip
trPars[kPtI] = charge/pt; // q/pt
//
// put tiny errors to propagate to the outer radius
trCov[kY2] = trCov[kZ2] = trCov[kSnp2] = trCov[kTgl2] = trCov[kPtI2] = 1e-9;
//
// find max layer this track can reach
double rmx = (TMath::Abs(fBField)>1e-5) ? TMath::Abs(charge)*pt*100./(0.3*TMath::Abs(fBField)) : 9999;
Int_t lastActiveLayer = -1;
for (Int_t j=fLayers.GetEntries(); j--;) {
CylLayerK *l = (CylLayerK*) fLayers.At(j);
// printf("at lr %d r: %f vs %f, pt:%f\n",j,l->radius, 2*rmx-2.*kTrackingMargin, pt);
if (!(l->isDead) && (l->radius < 2*rmx-5.)) {lastActiveLayer = j; last = l; break;}
}
if (lastActiveLayer<0) {
printf("No active layer with radius < %f is found, pt = %f\n",rmx, pt);
continue; //return;
}
printf("PT=%f 2Rpt=%f Rlr=%f\n",pt,2*rmx,last->radius);
//
float prepLrOK[lastActiveLayer+1];
for (int il=lastActiveLayer+1;il--;) prepLrOK[il] = 0;
int lastReached = 0;
for (int il=1;il<=lastActiveLayer;il++) {
AliExternalTrackParam probTrLast(probTr);
CylLayerK *lr = (CylLayerK*) fLayers.At(il);
if (!PropagateToR(&probTrLast,lr->radius,bGauss,1)) break;
if (!probTrLast.CorrectForMeanMaterial(lr->radL, 0, fParticleMass , kTRUE)) break;
if (lr->xrho>0) { // correct in small steps
bool elossOK = kTRUE;
for (int ise=xrhosteps;ise--;) {
if (!probTrLast.CorrectForMeanMaterial(0, -lr->xrho/xrhosteps, fParticleMass , kTRUE)) {elossOK = kFALSE; break;}
}
if (!elossOK) break;
}
if (lr->radius>1e-3 && !lr->isDead &&
( !probTrLast.Rotate(probTrLast.PhiPos()) || TMath::Abs( probTrLast.GetSnp() )>fMaxSnp) ) {
break;
}
probTr = probTrLast;
lastReached = il;
prepLrOK[il] = 1.; // flag successfully passed layer
}
// if ( ((CylLayerK*)fLayers.At(lastReached))->radius < fMinRadTrack) continue;
if (!PropagateToR(&probTr,probTr.GetX() + kTrackingMargin,bGauss,1)) continue;
// if (probTr.GetX()<fMinRadTrack) continue;
lastActiveLayer = lastReached;
if (lastActiveLayer<fNumberOfActiveITSLayers) {
continue;
}
// if (!PropagateToR(&probTr,last->radius + kTrackingMargin,bGauss,1)) continue;
//if (!probTr.PropagateTo(last->radius,bGauss)) continue;
// reset cov.matrix
const double kLargeErr2Coord = 100*100;
const double kLargeErr2Dir = 1.*1.;
const double kLargeErr2PtI = 30.*30.;
///*
for (int ic=15;ic--;) trCov[ic] = 0.;
trCov[kY2] = trCov[kZ2] = kLargeErr2Coord;
trCov[kSnp2] = trCov[kTgl2] = kLargeErr2Dir;
trCov[kPtI2] = kLargeErr2PtI*trPars[kPtI]*trPars[kPtI];
//*/
//probTr.ResetCovariance(1e10);
probTr.CheckCovariance();
/*
printf(">>> #%2d pt %f RLMax=%.2f, q/pt:%e err2 %e relres %f\n",i,pt,
last->radius,trPars[kPtI],trCov[kPtI2],TMath::Sqrt(trCov[kPtI2])/trPars[kPtI]);
probTr.Print();
*/
//
// Set Detector-Efficiency Storage area to unity
fEfficiency[i] = 1.0 ;
//
// Back-propagate the covariance matrix along the track.
CylLayerK *layer = 0;
// probTr.Print();
Bool_t skipPTBin = kFALSE;
for (Int_t j=lastActiveLayer+1; j--;) { // Layer loop
layer = (CylLayerK*)fLayers.At(j);
if (layer->radius>fMaxSeedRadius) continue; // no seeding beyond this radius
TString name(layer->GetName());
Bool_t isVertex = name.Contains("vertex");
Bool_t isFirstActive = j == firstActiveLayer;
//
if (!PropagateToR(&probTr,layer->radius,bGauss,-1)) {
printf("Failed inward propagation for bin %d pT=%.2f at lr%d of r=%.2f\n",i,pt,j,layer->radius);
probTr.Print();
skipPTBin = kTRUE;
fEfficiency[i] = 0.0 ;
break; //exit(1);
}
// if (!probTr.PropagateTo(last->radius,bGauss)) exit(1); //
// rotate to frame with X axis normal to the surface
if (!isVertex) {
double pos[3];
probTr.GetXYZ(pos); // lab position
double phi = TMath::ATan2(pos[1],pos[0]);
if ( TMath::Abs(TMath::Abs(phi)-TMath::Pi()/2)<1e-3) phi = 0;//TMath::Sign(TMath::Pi()/2 - 1e-3,phi);
if (!probTr.Rotate(phi)) {
printf("Failed to rotate to the frame (phi:%+.3f)of layer at %.2f at XYZ: %+.3f %+.3f %+.3f (pt=%+.3f)\n",
phi,layer->radius,pos[0],pos[1],pos[2],pt);
probTr.Print();
exit(1);
}