-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNewAD2016Aug_Marvin_3.C
4865 lines (4465 loc) · 233 KB
/
NewAD2016Aug_Marvin_3.C
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
// Includes for compilation of this macro
#if !defined (__CINT__) || defined (__MAKECINT__)
#include "TMCProcess.h"
#include "TClassTable.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TGeoManager.h"
#include "TCanvas.h"
#include "TPaveStats.h"
#include "TArrow.h"
// For drawing of tracks
// #include "TGLClipSet.h"
#include "TGLClip.h"
#include "TGLAnnotation.h"
#include "TGLSAViewer.h"
#include "TGFrame.h" // for TGMainFrame.h
#include "TPolyLine3D.h"
#include "TPolyMarker3D.h"
#include "TView.h"
#include "TView3D.h"
#include "TGLViewer.h"
#include "TVirtualGeoTrack.h"
#include "TGeoTrack.h"
#include "TObjArray.h"
#include "TMacro.h"
#include "TNamed.h"
// For geometry
// defined in TGeoVolume: #include "TGeoVolumeAssembly.h"
#include "TGeoVolume.h"
#include "TGeoMedium.h"
#include "TGeoCompositeShape.h"
#include "TGeoVolume.h"
#include "TGeoXtru.h"
#include "TGeoShape.h"
#include "TGeoBBox.h"
#include "TGeoPara.h"
#include "TGeoTrd1.h"
#include "TGeoTube.h"
#include "TGeoCone.h"
#include "TGeoArb8.h"
#include "TGeoPcon.h"
#include "TGeoTorus.h"
#include "TGeoEltu.h"
//
/*#include "AliRunLoader.h"
#include "AliStack.h"
#include "AliFMD.h"
#include "AliFMDHit.h"
//#include "FMD/FMDsim/AliFMD.h"
//#include "FMD/FMDsim/AliFMDHit.h"
#include "AliVZERO.h"
#include "AliVZEROLoader.h"
#include "AliVZEROhit.h"
#include "AliITSgeom.h"
#include "AliITSInitGeometry.h"
#include "AliITS.h"
#include "AliITShit.h"
#include "AliITSLoader.h"
#include "AliITSmodule.h"
#include "AliZDCHit.h"
#include "AliZDC.h"
#include "AliLoader.h"
#include "AliADhit.h"
#include "AliAD.h"
#include "AliADLoader.h"*/
#include "TH2I.h"
#include "TH2F.h"
#include "TH1F.h"
#include "TTree.h"
#include "TClonesArray.h"
#include "TDatabasePDG.h"
#include "TParticle.h"
#include "TFile.h"
#include "TKey.h"
#include "TParticlePDG.h"
/*#include "AliHeader.h"
#include "STEER/STEER/AliRun.h"
#include "STEER/STEERBase/AliGenEventHeader.h"
#include "STEER/STEERBase/AliGenPythiaEventHeader.h"
#include "STEER/STEERBase/AliGenDPMjetEventHeader.h"
#include "STEER/STEERBase/AliGenHijingEventHeader.h"*/
#include "TRandom.h"
#include "TMath.h"
#include "TArrayF.h"
/* #include "AliTrackReference.h"*/
//
#elif defined (__CINT__)
#include <TInterpreter.h>
#endif
TGeoRotation * Rx180, * Rz180, * Ry180, * Rx90, * Rx90m, * Ry90m, *Ry90, * Rz90;
enum {kCoordX=0, kCoordY=1, kCoordZ=2};
// void PrintNodeAt(Double_t x, Double_t y, Double_t z);
// void FindNodes(const Double_t x, const Double_t y, const Double_t z, const Double_t tf, const Int_t Coord=2) ;
// TGeoVolumeAssembly * CreateWarmModule_VMAOI();
void CreateCurvedBundles();
TGeoVolume * CreateWarmModule();
TGeoVolumeAssembly * CreateBLM();
TGeoVolumeAssembly * CreatePipeOvalyzed(const TGeoMedium * mat);
TGeoVolumeAssembly * CreateADAShielding();
TGeoVolumeAssembly * CreateVacuumChamberSupport();
TGeoVolumeAssembly * CreatePmtBoxC() ;
TGeoVolumeAssembly * CreateAD();
TGeoVolume * MakeVolIBeam(const char * volname, const TGeoMedium * mat, const Double_t x, const Double_t y, const Double_t dx, const Double_t dy, const Double_t dz);
Bool_t GetADATwoInstalled() { return kTRUE;}
Bool_t GetADCTwoInstalled() { return kTRUE;}
//_________________________________________________________
TGeoVolume * Make_UProfile(const char * volname, const Double_t L,
const TGeoMedium * medium, const Double_t W, const Double_t H,
const Double_t dw, const Double_t dh)
{
const Int_t nvertices = 8;
const Double_t W2 = W*0.5;
Double_t X[nvertices] = {-W2 , -W2 , -W2 + dw , -W2 +dw , W2 -dw , W2 - dw , W2 , W2 };
Double_t Y[nvertices] = { 0 , H , H , dh , dh , H , H , 0 };
TGeoXtru * shAD_UProfileV = new TGeoXtru(2);
// shADsuppIBeam->SetNameTitle("shAD_UProfile","shAD_UProfile");
shAD_UProfileV->DefinePolygon(nvertices, X, Y);
shAD_UProfileV->DefineSection(0, -0.5*L, 0., 0., 1.0); // index, Z position, offset (x,y) and scale for first section
shAD_UProfileV->DefineSection(1, 0.5*L, 0., 0., 1.0); // idem, second section
TGeoVolume * vol = new TGeoVolume(volname, shAD_UProfileV, medium);
vol->SetLineColor(kAzure-3);
return vol;
}
//_________________________________________________________
TGeoVolume * Make_UProfileH(const char * volname, TGeoMedium * medium)
{
const Float_t dw = 0.85;
const Float_t dh = 0.60;
TGeoVolumeAssembly * voprofile = new TGeoVolumeAssembly(volname);
TGeoVolume * volH = Make_UProfile(Form("%s_H", volname), 90.-2*dw-0.01, medium, 10, 5, dw, dh);
TGeoVolume * volL = gGeoManager->MakeBox(Form("%s_L", volname), medium, 5, 2.5, dw/2.);
volH->SetLineColor(kAzure-3);
volL->SetLineColor(kAzure-3);
voprofile->AddNode(volH, 1);
voprofile->AddNode(volL, 1, new TGeoTranslation(0, 2.5, -90./2. + dw/2.));
voprofile->AddNode(volL, 2, new TGeoTranslation(0, 2.5, +90./2. - dw/2.));
return voprofile;
}
//_________________________________________________________
//
enum ADCPosition_t { kADCInTunnel, kADCInCavern, kADCInBoth};
ADCPosition_t fADCPosition = kADCInTunnel;
Bool_t fADCstruct = kTRUE;
Bool_t fADAstruct = kTRUE;
//
TGeoMaterial *matVacuum;
TGeoMaterial *matAl;
// define some media
TGeoMedium * kMedVacuum;
TGeoMedium * kMedAlu;
TGeoMedium * kMedSteelSh;
TGeoMedium * kMedCopper; // = gGeoManager->GetMedium("AD_Cu_C0"); // Stainless Steel
TGeoMedium * kMedPVC ; // = gGeoManager->GetMedium("AD_PVC" ); // Stainless Steel
TGeoVolume * alice = 0;
Float_t as[11];
Float_t zs[11];
Float_t fs[11];
Double_t radLength, absLength, a_ad, z_ad;
Int_t id;
// Taken from ./MWE_EvDisplayAD.C
TGeoManager * fCustomGeo = 0; //!
TGeoManager * fFileGeo = 0; //!
class CurvedBundle
{
// TODO:
// 1) Curved bundle should know:
// 1.a) about its total length. [DONE]
// 1.b) If a given a (x,y,z) belong the her.
// 1.C) The fiber length from a point inside her to both ends of the fiber [DONE]
private:
TString fVolName;
TGeoVolumeAssembly * fFiberBundle;
// Rotations and translations:
TGeoTranslation * fGlobalTranslation;
TGeoRotation * fRotationYphi ; //!
TGeoRotation * fRotationX90m ; //!
TGeoRotation * fRotationZtheta ; //!
Bool_t fReflected; //!
// Medium and materials
TGeoMaterial * fMatVacuum; //!
TGeoMedium * fMedium; //!
Double_t fBundleRadius; //! radius of the fiber bundle in cm!!
Double_t fX1; Double_t fY1; Double_t fZ1; //! First point coordinates
Double_t fX2; Double_t fY2; Double_t fZ2; //! Second point coordinates
Double_t fPhiAngle; //! Phi angle in degrees
Double_t fThetaAngle; //! Angle between plane of Arc0 and horizontal plane (XZ)
Double_t fLocalW; //!
Double_t fMaxAllowedX; //! Maximun x in local coordinate system:
Double_t fLocalC0X, fLocalC0Y, fLocalArc0StartAngle, fLocalArc0EndAngle, fLocalArc0Radius; //! Center of first arc in local plane
Double_t fLocalC1X, fLocalC1Y, fLocalArc1StartAngle, fLocalArc1EndAngle, fLocalArc1Radius; //! Center of first arc in local plane
Double_t fLocalC2X, fLocalC2Y, fLocalArc2StartAngle, fLocalArc2EndAngle, fLocalArc2Radius; //! Center of first arc in local plane
Double_t fLocalC3X, fLocalC3Y, fLocalArc3StartAngle, fLocalArc3EndAngle, fLocalArc3Radius; //! Center of first arc in local plane
Double_t fStartPointRadius; //!
Double_t fArc1Beta; //!
Double_t fLengthTotal; //!
Double_t fLengthArc[4]; //!
// To compute the early-time
Double_t fLowerLimitMasterZ_Arc[4]; //!
Double_t fUpperLimitMasterZ_Arc[4]; //!
TGeoHMatrix * fLocalMatrixArc[4]; //!
public:
CurvedBundle(const char * name, Double_t x1, Double_t y1, Double_t z1, Double_t x2, Double_t y2, Double_t z2, Double_t r1, Double_t r2, Double_t max_allowed_x, Bool_t reflex) :
fVolName(name),
fGlobalTranslation(0),
fRotationYphi(0),
fRotationX90m(0),
fRotationZtheta(0),
fReflected(reflex),
fBundleRadius((1.6/2.)/TMath::Sqrt(2.)), //! radius (r) of the half fiber bundle (in cm). 2(r^2)=R^2, With R the radius of the full fiber bundle !!
fLengthTotal(-1),
fFiberBundle(new TGeoVolumeAssembly(fVolName))
{
SetFirstPoint ( x1 , y1 , z1 - r1 );
SetLastPoint ( x2 , y2 , z2 );
SetFirstPointRadius(r1);
SetLastPointRadius (r2);
FindPhiAngle();
SetMaxAllowedX(max_allowed_x);
FindLocalPlaneW();
// First compute parameters in 3->2->1 order !
ComputeArc3Parameters();
ComputeArc2Parameters();
ComputeArc1Parameters();
ComputeArc0Parameters();
// You can optionaly make a reflection on zx plane:
if (fReflected) MakeReflectionXZ();
// After parameters are computed, we create the matrices !
CreateMatrices();
CreateMediums();
// Finally, we create the volumes
CreateArc3();
CreateArc2();
CreateArc1();
CreateArc0();
ComputeTotalLength();
// fCombiTrans = new TGeoCombiTrans(fX1, fY1, fZ1, fRotation123);
Print();
}
const char * GetName() { return fVolName; }
TGeoVolumeAssembly * GetVolume() { return fFiberBundle; }
// TGeoCombiTrans * GetCombiTrans() { return fCombiTrans; }
void SetFirstPoint(Double_t x, Double_t y, Double_t z) { fX1 = x, fY1 = y, fZ1 = z; }
void SetLastPoint(Double_t x, Double_t y, Double_t z) { fX2 = x, fY2 = y, fZ2 = z; }
void SetFirstPointRadius(Double_t r) { fStartPointRadius=r; }
void SetLastPointRadius(Double_t r) { fLocalArc3Radius=r; }
Double_t GetFirstPointRadius() { return fStartPointRadius; }
Double_t GetLastPointRadius() { return fLocalArc3Radius; }
void SetMaxAllowedX(Double_t x) {
if (x>fX2 || x<fX1) {
printf("max_allowed_x (%f) out of valid range [%f;%f]\n", x, fX1, fX2);
exit(1);
}
Double_t cos = TMath::Cos(DegToRad(fPhiAngle));
if (cos==0) { printf("%s:%d: Error, angle is 90 degrees\n", __FUNCTION__, __LINE__); exit(1); }
fMaxAllowedX = (x-fX1) / cos;
}
void FindPhiAngle() { /* result = atan2 (y,x) * 180 / PI; */ fPhiAngle = - RadToDeg(TMath::ATan2(fZ2-fZ1, fX2-fX1)); }
void FindLocalPlaneW() { fLocalW = TMath::Sqrt((fX2-fX1)*(fX2-fX1) + (fZ2-fZ1)*(fZ2-fZ1)); }
Double_t RadToDeg(Double_t rad) { return rad * (180./TMath::Pi()); }
Double_t DegToRad(Double_t deg) { return deg * (TMath::Pi()/180.); }
//
void NegateSwapAngles(Double_t & angle1, Double_t & angle2)
{
Double_t aux = angle1;
angle1 = -angle2;
angle2 = -aux;
}
void MakeReflectionXZ(){
// Make Y-Centers negative
fLocalC3Y = -fLocalC3Y;
fLocalC2Y = -fLocalC2Y;
fLocalC1Y = -fLocalC1Y;
//
NegateSwapAngles(fLocalArc3StartAngle, fLocalArc3EndAngle);
NegateSwapAngles(fLocalArc2StartAngle, fLocalArc2EndAngle);
NegateSwapAngles(fLocalArc1StartAngle, fLocalArc1EndAngle);
//
fThetaAngle = - fThetaAngle;
fY1 = -fY1;
}
void CreateMatrices()
{
// TObjArray * GetListOfMatrices () const
fRotationX90m = new TGeoRotation("Rx90m", 0., -90., 0.);
fRotationYphi = new TGeoRotation(Form("fRotationYphi_%s" , fVolName. Data()), 90, fPhiAngle, -90);
fRotationZtheta = new TGeoRotation(Form("fRotationZtheta_%s", fVolName. Data()), fThetaAngle, 0, 0 );
fGlobalTranslation = new TGeoTranslation(fX1, fY1, fZ1);
}
void CreateMediums()
{
// fMatVacuum = new TGeoMaterial("Vacuum", 0,0,0);
// fMedium = new TGeoMedium("Vacuum10",10, fMatVacuum);
fMedium = gGeoManager->GetMedium("AD_BC404"); // AD Scin.
}
void ComputeArc3Parameters()
{
fLocalC3X = fLocalW - GetLastPointRadius();
fLocalC3Y = fY2-fY1;
fLocalArc3StartAngle = 0.;
fLocalArc3EndAngle = 90.;
///////////////////////////////
// Ry90m = new TGeoRotation("Ry90m", 90., -90., -90.) ;
// Ry90 = new TGeoRotation("Ry90" , 90., 90., -90.) ;
}
void ComputeArc2Parameters()
{
Double_t r = GetLastPointRadius();
Double_t l = fLocalW - r - fMaxAllowedX;
fLocalArc2Radius = (l*l + r*r) / (2*r);
Double_t alpha = RadToDeg(TMath::ATan2(r,l)); // half arc2!
fLocalC2X = fLocalW - r;
fLocalC2Y = fY2-fY1 + r - fLocalArc2Radius;
fLocalArc2StartAngle = 90.;
fLocalArc2EndAngle = 90. + 2.*alpha;
}
void ComputeArc1Parameters()
{
// local variables for angles named by greek letters are in radians
// private class level members for variables are in degrees !
// Some alias in the local plane
Double_t alpha = DegToRad(TMath::Abs(180. - fLocalArc2EndAngle));
Double_t b = fStartPointRadius;
Double_t h = fY2 - fY1;
Double_t w = fMaxAllowedX;
Double_t a = (0.5 * ( w*w + h*h - b*b )) / ( b + w * TMath::Sin(alpha) + h * TMath::Cos(alpha) );
Double_t beta = TMath::ASin(( h - a * TMath::Cos(alpha) ) / ( a + b ));
Double_t delta = 0.5 * (TMath::PiOver2() - (alpha + beta));
Double_t R = a / TMath::Tan(delta) ;
// Center coordinates:
// fLocalC1X = fX1 - R * TMath::Sin(beta) + b * TMath::Cos(beta);
// fLocalC1Y = fY1 + R * TMath::Cos(beta) + b * TMath::Sin(beta);
fLocalC1X = w - (R * TMath::Cos(alpha));
fLocalC1Y = h + (R * TMath::Sin(alpha));
// Arc1 angles:
fLocalArc1EndAngle = 360. - RadToDeg(alpha);
fLocalArc1StartAngle = 360. - RadToDeg(alpha + 2*delta);
fLocalArc1Radius = R;
// Needed for ComputeArc0Parameters:
fArc1Beta = RadToDeg(beta);
// printf("****************************************************************\n");
// printf("****************************************************************\n");
// printf("//////////////////////// %s ////////////////////////\n", __FUNCTION__);
// printf(" h: %f | a: %f | b: %f | w: %f\n", h, a, b, w);
// printf(" alpha: %f | beta: %f | delta: %f\n", RadToDeg(alpha), RadToDeg(beta), RadToDeg(delta));
// printf(" h-acos(alpha): %f\n", h - a * TMath::Cos(alpha));
// printf(" w-asin(alpha): %f\n", w - a * TMath::Sin(alpha));
// printf(" a + b: %f\n", a + b);
// printf(" R: %f\n", R);
// printf(" fLocalC1X: %f\n", fLocalC1X);
// printf(" fLocalC1Y: %f\n", fLocalC1Y);
// printf("****************************************************************\n");
// printf("****************************************************************\n");
}
void ComputeArc0Parameters()
{
// local variables for angles named by greek letters are in radians
// private class level members for variables are in degrees !
// I need beta from ComputeArc1Parameters
Double_t beta = DegToRad(fArc1Beta);
Double_t phi = TMath::Abs(DegToRad(fPhiAngle));
Double_t b = TMath::Abs(fStartPointRadius); // This is not a curvature radius!
Double_t h2 = ( TMath::Power(b,2) * TMath::Power(TMath::Sin(beta),2) ) + TMath::Power((b+b*TMath::Cos(beta)*TMath::Sin(phi)),2);
Double_t c2 = TMath::Power(b*TMath::Cos(beta)*TMath::Cos(phi),2);
Double_t l = TMath::Sqrt(h2+c2);
Double_t sigma = TMath::ACos(l/(2*b));
Double_t theta = TMath::ASin(TMath::Sin(beta)/TMath::Sin(2*sigma));
Double_t R = b / TMath::Tan(sigma);
// Coordinates of Arc0 center:
fLocalC0X = R;
fLocalC0Y = - b;
fLocalArc0StartAngle = 180. - 2 * RadToDeg(sigma);
fLocalArc0EndAngle = 180.;
fLocalArc0Radius = R;
fThetaAngle = RadToDeg(theta);
// printf("****************************************************************\n");
// printf("****************************************************************\n");
// printf(" phi: %f\n", RadToDeg(phi));
// printf(" sigma: %f\n", RadToDeg(sigma));
// printf(" theta: %f\n", RadToDeg(theta));
// printf(" l: %f\n", l);
// printf(" b: %f\n", b);
// printf(" R: %f\n", R);
// printf(" fLocalC0X: %f\n", fLocalC0X);
// printf(" fLocalC0Y: %f\n", fLocalC0Y);
// printf("****************************************************************\n");
// printf("****************************************************************\n");
}
void CreateArc0()
{
// TGeoTorus(Double_t R,Double_t Rmin,Double_t Rmax,Double_t Phi1,Double_t Dphi);
printf("============ A ==========\n");
TString volname = "CurvedBundle_Arc0";
TGeoTorus * fArc0Shape = new TGeoTorus(fLocalArc0Radius, 0., fBundleRadius, fLocalArc0StartAngle, fLocalArc0EndAngle - fLocalArc0StartAngle);
TGeoVolume * fArc0Vol = new TGeoVolume(volname, fArc0Shape, fMedium);
fArc0Vol->SetLineColor(kPink-8);
printf("============ B ==========\n");
if (!fFiberBundle) exit(1);
fArc0Vol -> Print();
printf("============ C ==========\n");
// fFiberBundle -> AddNode( fArc0Vol, 1, new TGeoTranslation(fLocalC0X, fLocalC0Y, 0));
//
// Combined transformations: Represent a rotation followed by a translation.
//
// For Arc0 the order is different:
// 1) Translation in the local plane: E.g. (fLocalC3X,fLocalC3Y)
// 2) Rotation of the local plane (fPhiAngle) or (Rx90 * RzTheta)
// 3) Translation in global coordinates to P1 (x,y,z) position
//
TGeoTranslation * fLocalArc0Tr = new TGeoTranslation(fLocalC0X, fLocalC0Y, 0);
// TGeoTranslation * fLocalArc0Tr = new TGeoTranslation(0, 0, 0);
/// - after=TRUE (default): THIS*ROT
/// - after=FALSE : ROT*THIS
fRotationZtheta->MultiplyBy(fRotationX90m, 1);
TGeoCombiTrans * fLocalArc0Cb = new TGeoCombiTrans (*fGlobalTranslation, *fRotationZtheta);
// TGeoCombiTrans * fLocalArc0Cb = new TGeoCombiTrans (*fGlobalTranslation, *fRotationX90m);
TGeoHMatrix * fLocalMatrix = new TGeoHMatrix((*fLocalArc0Cb)*(*fLocalArc0Tr));
//
fFiberBundle -> AddNode( fArc0Vol, 1, fLocalMatrix);
// Compute global z-limits for the arc 0
Double_t localStart[3] = {0.};
Double_t localEnd [3] = {0.};
localStart[0] = fLocalArc0Radius * TMath::Cos( DegToRad(fLocalArc0StartAngle));
localStart[1] = fLocalArc0Radius * TMath::Sin( DegToRad(fLocalArc0StartAngle));
localEnd [0] = fLocalArc0Radius * TMath::Cos( DegToRad(fLocalArc0EndAngle));
localEnd [1] = fLocalArc0Radius * TMath::Sin( DegToRad(fLocalArc0EndAngle));
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
// printf("%s:%d Angles: Start= %f End= %f\n", __FUNCTION__, __LINE__, fLocalArc0StartAngle, fLocalArc0EndAngle);
// printf("%s:%d localStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localStart[0], localStart[1], localStart[2]);
// printf("%s:%d localEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localEnd [0], localEnd [1], localEnd [2]);
Double_t masterStart[3] = {0.};
Double_t masterEnd [3] = {0.};
fLocalMatrix->LocalToMaster(localStart, masterStart);
fLocalMatrix->LocalToMaster(localEnd , masterEnd );
// printf("%s:%d masterStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterStart[0], masterStart[1], masterStart[2]);
// printf("%s:%d masterEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterEnd [0], masterEnd [1], masterEnd [2]);
// Array indexes below should match Arc number
const Int_t arc=0;
fLowerLimitMasterZ_Arc[arc]= TMath::Min(masterStart[2], masterEnd[2]);
fUpperLimitMasterZ_Arc[arc]= TMath::Max(masterStart[2], masterEnd[2]);
fLocalMatrixArc[arc]=fLocalMatrix;
// printf("%s:%d fLowerLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fLowerLimitMasterZ_Arc[arc]);
// printf("%s:%d fUpperLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fUpperLimitMasterZ_Arc[arc]);
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
}
void CreateArc3()
{
// TGeoTorus(Double_t R,Double_t Rmin,Double_t Rmax,Double_t Phi1,Double_t Dphi);
TString volname = "CurvedBundle_Arc3";
TGeoTorus * fArc3Shape = new TGeoTorus(GetLastPointRadius(), 0., fBundleRadius, fLocalArc3StartAngle, fLocalArc3EndAngle - fLocalArc3StartAngle);
TGeoVolume * fArc3Vol = new TGeoVolume(volname, fArc3Shape, fMedium);
fArc3Vol->SetLineColor(kCyan);
if (!fFiberBundle) exit(1);
fArc3Vol -> Print();
// fFiberBundle -> AddNode( fArc3Vol, 1, new TGeoTranslation(fLocalC3X, fLocalC3Y, 0));
//
// Combined transformations: Represent a rotation followed by a translation.
//
// This is the roder:
// 1) Translation in the local plane: E.g. (fLocalC3X,fLocalC3Y)
// 2) Rotation of the local plane (fPhiAngle) or (Rx90 * RzTheta)
// 3) Translation in global coordinates to P1 (x,y,z) position
//
TGeoTranslation * fLocalArc3Tr = new TGeoTranslation(fLocalC3X, fLocalC3Y, 0);
TGeoCombiTrans * fLocalArc3Cb = new TGeoCombiTrans (*fGlobalTranslation, *fRotationYphi);
TGeoHMatrix * fLocalMatrix = new TGeoHMatrix((*fLocalArc3Cb)*(*fLocalArc3Tr));
//
fFiberBundle -> AddNode( fArc3Vol, 1, fLocalMatrix);
// Compute global z-limits for the arc 3
Double_t localStart[3] = {0.};
Double_t localEnd [3] = {0.};
localStart[0] = GetLastPointRadius() * TMath::Cos( DegToRad(fLocalArc3StartAngle));
localStart[1] = GetLastPointRadius() * TMath::Sin( DegToRad(fLocalArc3StartAngle));
localEnd [0] = GetLastPointRadius() * TMath::Cos( DegToRad(fLocalArc3EndAngle));
localEnd [1] = GetLastPointRadius() * TMath::Sin( DegToRad(fLocalArc3EndAngle));
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
// printf("%s:%d Angles: Start= %f End= %f\n", __FUNCTION__, __LINE__, fLocalArc3StartAngle, fLocalArc3EndAngle);
// printf("%s:%d localStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localStart[0], localStart[1], localStart[2]);
// printf("%s:%d localEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localEnd [0], localEnd [1], localEnd [2]);
Double_t masterStart[3] = {0.};
Double_t masterEnd [3] = {0.};
fLocalMatrix->LocalToMaster(localStart, masterStart);
fLocalMatrix->LocalToMaster(localEnd , masterEnd );
// printf("%s:%d masterStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterStart[0], masterStart[1], masterStart[2]);
// printf("%s:%d masterEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterEnd [0], masterEnd [1], masterEnd [2]);
// Array indexes below should match Arc number
const Int_t arc=3;
fLowerLimitMasterZ_Arc[arc]= TMath::Min(masterStart[2], masterEnd[2]);
fUpperLimitMasterZ_Arc[arc]= TMath::Max(masterStart[2], masterEnd[2]);
fLocalMatrixArc[arc]=fLocalMatrix;
// printf("%s:%d fLowerLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fLowerLimitMasterZ_Arc[arc]);
// printf("%s:%d fUpperLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fUpperLimitMasterZ_Arc[arc]);
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
}
void CreateArc2()
{
// TGeoTorus(Double_t R,Double_t Rmin,Double_t Rmax,Double_t Phi1,Double_t Dphi);
TString volname = "CurvedBundle_Arc2";
TGeoTorus * fArc2Shape = new TGeoTorus(fLocalArc2Radius, 0., fBundleRadius, fLocalArc2StartAngle, fLocalArc2EndAngle - fLocalArc2StartAngle);
TGeoVolume * fArc2Vol = new TGeoVolume(volname, fArc2Shape, fMedium);
fArc2Vol->SetLineColor(kViolet+10);
if (!fFiberBundle) exit(1);
fArc2Vol -> Print();
// fFiberBundle -> AddNode( fArc2Vol, 1, new TGeoTranslation(fLocalC2X, fLocalC2Y, 0));
//
// Combined transformations: Represent a rotation followed by a translation.
//
// This is the order:
// 1) Translation in the local plane: E.g. (fLocalC3X,fLocalC3Y)
// 2) Rotation of the local plane (fPhiAngle) or (Rx90 * RzTheta)
// 3) Translation in global coordinates to P1 (x,y,z) position
//
TGeoTranslation * fLocalArc2Tr = new TGeoTranslation(fLocalC2X, fLocalC2Y, 0);
TGeoCombiTrans * fLocalArc2Cb = new TGeoCombiTrans (*fGlobalTranslation, *fRotationYphi);
TGeoHMatrix * fLocalMatrix = new TGeoHMatrix((*fLocalArc2Cb)*(*fLocalArc2Tr));
//
fFiberBundle -> AddNode( fArc2Vol, 1, fLocalMatrix);
// Compute global z-limits for the arc 2
Double_t localStart[3] = {0.};
Double_t localEnd [3] = {0.};
localStart[0] = fLocalArc2Radius * TMath::Cos( DegToRad(fLocalArc2StartAngle));
localStart[1] = fLocalArc2Radius * TMath::Sin( DegToRad(fLocalArc2StartAngle));
localEnd [0] = fLocalArc2Radius * TMath::Cos( DegToRad(fLocalArc2EndAngle));
localEnd [1] = fLocalArc2Radius * TMath::Sin( DegToRad(fLocalArc2EndAngle));
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
// printf("%s:%d Angles: Start= %f End= %f\n", __FUNCTION__, __LINE__, fLocalArc2StartAngle, fLocalArc2EndAngle);
// printf("%s:%d localStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localStart[0], localStart[1], localStart[2]);
// printf("%s:%d localEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localEnd [0], localEnd [1], localEnd [2]);
Double_t masterStart[3] = {0.};
Double_t masterEnd [3] = {0.};
fLocalMatrix->LocalToMaster(localStart, masterStart);
fLocalMatrix->LocalToMaster(localEnd , masterEnd );
// printf("%s:%d masterStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterStart[0], masterStart[1], masterStart[2]);
// printf("%s:%d masterEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterEnd [0], masterEnd [1], masterEnd [2]);
// Array indexes below should match Arc number
const Int_t arc=2;
fLowerLimitMasterZ_Arc[arc]= TMath::Min(masterStart[2], masterEnd[2]);
fUpperLimitMasterZ_Arc[arc]= TMath::Max(masterStart[2], masterEnd[2]);
fLocalMatrixArc[arc]=fLocalMatrix;
// printf("%s:%d fLowerLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fLowerLimitMasterZ_Arc[arc]);
// printf("%s:%d fUpperLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fUpperLimitMasterZ_Arc[arc]);
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
}
void CreateArc1()
{
// TGeoTorus(Double_t R,Double_t Rmin,Double_t Rmax,Double_t Phi1,Double_t Dphi);
TString volname = "CurvedBundle_Arc1";
TGeoTorus * fArc1Shape = new TGeoTorus(fLocalArc1Radius, 0., fBundleRadius, fLocalArc1StartAngle, fLocalArc1EndAngle - fLocalArc1StartAngle);
TGeoVolume * fArc1Vol = new TGeoVolume(volname, fArc1Shape, fMedium);
fArc1Vol->SetLineColor(kOrange);
if (!fFiberBundle) exit(1);
fArc1Vol -> Print();
// fFiberBundle -> AddNode( fArc1Vol, 1, new TGeoTranslation(fLocalC1X, fLocalC1Y, 0));
//
// Combined transformations: Represent a rotation followed by a translation.
//
// This is the order:
// 1) Translation in the local plane: E.g. (fLocalC3X,fLocalC3Y)
// 2) Rotation of the local plane (fPhiAngle) or (Rx90 * RzTheta)
// 3) Translation in global coordinates to P1 (x,y,z) position
//
TGeoTranslation * fLocalArc1Tr = new TGeoTranslation(fLocalC1X, fLocalC1Y, 0);
TGeoCombiTrans * fLocalArc1Cb = new TGeoCombiTrans (*fGlobalTranslation, *fRotationYphi);
TGeoHMatrix * fLocalMatrix = new TGeoHMatrix((*fLocalArc1Cb)*(*fLocalArc1Tr));
//
fFiberBundle -> AddNode( fArc1Vol, 1, fLocalMatrix);
// Compute global z-limits for the arc 1
Double_t localStart[3] = {0.};
Double_t localEnd [3] = {0.};
localStart[0] = fLocalArc1Radius * TMath::Cos( DegToRad(fLocalArc1StartAngle));
localStart[1] = fLocalArc1Radius * TMath::Sin( DegToRad(fLocalArc1StartAngle));
localEnd [0] = fLocalArc1Radius * TMath::Cos( DegToRad(fLocalArc1EndAngle));
localEnd [1] = fLocalArc1Radius * TMath::Sin( DegToRad(fLocalArc1EndAngle));
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
// printf("%s:%d Angles: Start= %f End= %f\n", __FUNCTION__, __LINE__, fLocalArc1StartAngle, fLocalArc1EndAngle);
// printf("%s:%d localStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localStart[0], localStart[1], localStart[2]);
// printf("%s:%d localEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, localEnd [0], localEnd [1], localEnd [2]);
Double_t masterStart[3] = {0.};
Double_t masterEnd [3] = {0.};
fLocalMatrix->LocalToMaster(localStart, masterStart);
fLocalMatrix->LocalToMaster(localEnd , masterEnd );
// printf("%s:%d masterStart[]=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterStart[0], masterStart[1], masterStart[2]);
// printf("%s:%d masterEnd []=(%f,%f,%f)\n", __FUNCTION__, __LINE__, masterEnd [0], masterEnd [1], masterEnd [2]);
// Array indexes below should match Arc number
const Int_t arc=1;
fLowerLimitMasterZ_Arc[arc]= TMath::Min(masterStart[2], masterEnd[2]);
fUpperLimitMasterZ_Arc[arc]= TMath::Max(masterStart[2], masterEnd[2]);
fLocalMatrixArc[arc]=fLocalMatrix;
// printf("%s:%d fLowerLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fLowerLimitMasterZ_Arc[arc]);
// printf("%s:%d fUpperLimitMasterZ_Arc[%d]=%f\n", __FUNCTION__, __LINE__, arc, fUpperLimitMasterZ_Arc[arc]);
// printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
}
Double_t ComputeTotalLength()
{
fLengthArc[0] = fLocalArc0Radius * DegToRad(TMath::Abs(fLocalArc0EndAngle - fLocalArc0StartAngle));
fLengthArc[1] = fLocalArc1Radius * DegToRad(TMath::Abs(fLocalArc1EndAngle - fLocalArc1StartAngle));
fLengthArc[2] = fLocalArc2Radius * DegToRad(TMath::Abs(fLocalArc2EndAngle - fLocalArc2StartAngle));
fLengthArc[3] = fLocalArc3Radius * DegToRad(TMath::Abs(fLocalArc3EndAngle - fLocalArc3StartAngle));
return fLengthTotal = fLengthArc[0] + fLengthArc[1] + fLengthArc[2] + fLengthArc[3];
}
Double_t GetTotalLength() { return (fLengthTotal>0)?fLengthTotal:ComputeTotalLength();}
Int_t GetArcIndexFromZ(Double_t & z)
{
// static Bool_t init_array = 0;
// static Double_t array[5] = {0};
// if (!init_array) {
// array[0] = fLowerLimitMasterZ_Arc[0];
// array[4] = fLowerLimitMasterZ_Arc[3];
// for (Int_t i=0; i<4; i++)
// {
// Double_t z1=fUpperLimitMasterZ_Arc[i ];
// Double_t z2=fLowerLimitMasterZ_Arc[i+1];
// array[i+1]=(z1+z2)/2.;
// printf("@@@ z1: %8.2f z2: %8.2f array: %8.2f\n", z1, z2, array[i+1]);
// }
// init_array=1;
// }
// // remenber we are in the negative z-axis
// if (z>array[0]) { printf("@@@ %s:%d TOO-LOW | %f > %f\n", __FUNCTION__, __LINE__, z, array[0]); return -1; }
// if (z<array[4]) { printf("@@@ %s:%d TOO-HIGH | %f < %f\n", __FUNCTION__, __LINE__, z, array[4]); return -1; }
// for (Int_t i=0; i<4; i++)
// {
// if ((z>=array[i]) && (z<array[i+1])) return i;
//
// }
// return -1;
for (Int_t i=0; i<4; i++)
{
if ((z>=fLowerLimitMasterZ_Arc[i]) && (z<fUpperLimitMasterZ_Arc[i])) return i;
}
// If still here, print debugging info and try to find the closest arc
for (Int_t i=0; i<4; i++)
{
// printf("@@@ %s:%d CHECKING | [ %+8.2f ? %+8.2f ? %+8.2f ] \n", __FUNCTION__, __LINE__, fLowerLimitMasterZ_Arc[i], z, fUpperLimitMasterZ_Arc[i] );
if ((z>=fLowerLimitMasterZ_Arc[i]) && (z<fUpperLimitMasterZ_Arc[i])) return i;
}
if (TMath::Abs(z-fLowerLimitMasterZ_Arc[3])<fBundleRadius+0.1) { z=fLowerLimitMasterZ_Arc[3]; return 3; }
if (TMath::Abs(z-fLowerLimitMasterZ_Arc[0])<fBundleRadius+0.1) { z=fLowerLimitMasterZ_Arc[0]; return 0; }
return -1;
}
Double_t GetHitLengthInArc(Int_t arc, Double_t x, Double_t y, Double_t z)
{
// Transform (x,y,z) to local Arc plane
Double_t master[3] = {x,y,z};
Double_t local [3] = {0.};
fLocalMatrixArc[arc]->MasterToLocal(master, local);
Double_t R, startangle, endangle, CX, CY;
switch (arc)
{
case 0: R = fLocalArc0Radius; startangle = fLocalArc0StartAngle; endangle = fLocalArc0EndAngle; CX = fLocalC0X; CY = fLocalC0Y; break;
case 1: R = fLocalArc1Radius; startangle = fLocalArc1StartAngle; endangle = fLocalArc1EndAngle; CX = fLocalC1X; CY = fLocalC1Y; break;
case 2: R = fLocalArc2Radius; startangle = fLocalArc2StartAngle; endangle = fLocalArc2EndAngle; CX = fLocalC2X; CY = fLocalC2Y; break;
case 3: R = fLocalArc3Radius; startangle = fLocalArc3StartAngle; endangle = fLocalArc3EndAngle; CX = fLocalC3X; CY = fLocalC3Y; break;
}
Double_t dx = local[0]; // - CX;
Double_t dy = local[1]; // - CY;
Double_t phi = TMath::ATan2(dy, dx);
phi=RadToDeg(phi);
Int_t n = 0;
while (phi<startangle && n++<10) phi+=180.;
n=0;
while (phi>endangle && n++<10) phi-=180;
// for Arc1 start angle is closer to IP (lower absolute value of z)
Double_t dangle = (arc==1)?startangle-phi:endangle-phi;
dangle=TMath::Abs(dangle);
// printf("###########################################################\n");
// printf("%s:%d: Arc: %d passed-x: %f passed-y: %f passed-z: %f\n", __FUNCTION__, __LINE__, arc, x, y, z);
// printf("%s:%d: Arc: %d local-x: %f local-y: %f local-z: %f\n", __FUNCTION__, __LINE__, arc, local[0], local[1], local[2]);
// printf("%s:%d: Arc: %d Star: %f Hit: %f End: %f\n", __FUNCTION__, __LINE__, arc, startangle, phi, endangle);
// printf("###########################################################\n");
dangle=DegToRad(dangle);
return R*dangle;
}
Double_t ComputeLengthToWLSBar(Double_t x, Double_t y, Double_t z)
{
// This finds the length from the WLS bar end to the hit.
// Find out which arc
Int_t arc = GetArcIndexFromZ(z);
Double_t lengthPmt2Hit = 0;
// Transform global (x,y,z) coordinate to local coordinates of the arc.
// With x-local and y-local and the center (x-c,y-c) of the arc calculate the angle.
// Withe the angle, local-radius, local-start and local-end angles of the arc, calculate the length
lengthPmt2Hit += fLengthArc[arc] - GetHitLengthInArc(arc,x,y,z);
// Add the lenght of the other arcs
for (Int_t i=3; i>arc; i--)
{
lengthPmt2Hit+=fLengthArc[i];
// printf("%s:%d length: %f\n", __FUNCTION__, __LINE__, lengthPmt2Hit); //dbg-ecv
}
//
return lengthPmt2Hit;
}
Double_t ComputeLength(Double_t x, Double_t y, Double_t z)
{
// This finds the length from the position of hit to the end oposite to the WLS bar.
// Compare to: ComputeLengthToWLSBar()
// Find out which arc
Int_t arc = GetArcIndexFromZ(z);
Double_t lengthPmt2Hit = 0;
// Transform global (x,y,z) coordinate to local coordinates of the arc.
// With x-local and y-local and the center (x-c,y-c) of the arc calculate the angle.
// Withe the angle, local-radius, local-start and local-end angles of the arc, calculate the length
lengthPmt2Hit += GetHitLengthInArc(arc,x,y,z);
// Add the lenght of the other arcs
for (Int_t i=0; i<arc; i++)
{
lengthPmt2Hit+=fLengthArc[i];
}
//
return lengthPmt2Hit;
}
void TestArc(Int_t arc)
{
Double_t R, startangle, endangle, CX, CY;
switch (arc)
{
case 0: R = fLocalArc0Radius; startangle = fLocalArc0StartAngle; endangle = fLocalArc0EndAngle; CX = fLocalC0X; CY = fLocalC0Y; break;
case 1: R = fLocalArc1Radius; startangle = fLocalArc1StartAngle; endangle = fLocalArc1EndAngle; CX = fLocalC1X; CY = fLocalC1Y; break;
case 2: R = fLocalArc2Radius; startangle = fLocalArc2StartAngle; endangle = fLocalArc2EndAngle; CX = fLocalC2X; CY = fLocalC2Y; break;
case 3: R = fLocalArc3Radius; startangle = fLocalArc3StartAngle; endangle = fLocalArc3EndAngle; CX = fLocalC3X; CY = fLocalC3Y; break;
}
Double_t radangle = DegToRad(gRandom->Uniform(startangle, endangle));
Double_t x = R * TMath::Cos(radangle);
Double_t y = R * TMath::Sin(radangle);
Double_t local[3] = {x,y,0};
Double_t master[3] = {0};
fLocalMatrixArc[arc]->LocalToMaster(local, master);
printf("###########################################################\n");
printf("%s:%d: Arc: %d Star: %f Hiti(Rnd): %f End: %f\n", __FUNCTION__, __LINE__, arc, startangle, RadToDeg(radangle), endangle);
printf("%s:%d: Arc: %d mx: %f my: %f mz: %f\n", __FUNCTION__, __LINE__, arc, master[0], master[1], master[2]);
printf("###########################################################\n");
// Test!!
ComputeLength(master[0], master[1], master[2]);
}
void Print() {
printf("****************************************************************\n");
printf("****************************************************************\n");
printf(" First Point: %f %f %f | R1: %f\n", fX1, fY1, fZ1, GetFirstPointRadius());
printf(" Second Point: %f %f %f | R2: %f\n", fX2, fY2, fZ2, GetLastPointRadius());
printf(" Phi Angle is: %f (degrees)\n", fPhiAngle);
printf(" fMaxAllowedX (in local frame) is: %f\n", fMaxAllowedX);
printf(" fLocalW (in local frame) is: %f\n", fLocalW);
printf(" Arc3 parameters: %f %f %f %f R: %f\n", fLocalC3X, fLocalC3Y, fLocalArc3StartAngle, fLocalArc3EndAngle, fLocalArc3Radius);
printf(" Arc2 parameters: %f %f %f %f R: %f\n", fLocalC2X, fLocalC2Y, fLocalArc2StartAngle, fLocalArc2EndAngle, fLocalArc2Radius);
printf(" Arc1 parameters: %f %f %f %f R: %f\n", fLocalC1X, fLocalC1Y, fLocalArc1StartAngle, fLocalArc1EndAngle, fLocalArc1Radius);
printf(" Arc0 parameters: %f %f %f %f R: %f\n", fLocalC0X, fLocalC0Y, fLocalArc0StartAngle, fLocalArc0EndAngle, fLocalArc0Radius);
printf(" Total Length: %f\n", fLengthTotal);
for (Int_t i=0; i<4; i++)
{
printf(" Length Arc%d: %f\n", i, fLengthArc[i]);
}
printf("****************************************************************\n");
printf("****************************************************************\n");
}
};
void PrintVolumes()
{
gGeoManager = fFileGeo;
TGeoVolume *vol;
TGeoVolume * topvol = gGeoManager->GetVolume("ALIC");
Int_t nd = topvol->GetNdaughters();
for (Int_t i=0; i<nd; i++) {
gGeoManager->RestoreMasterVolume();
TGeoNode * node;
node = topvol->GetNode(i);
vol = node->GetVolume();
TString title = node->GetName();
printf("node: %s\n", node->GetName());
}
gGeoManager = fCustomGeo;
}
void AddVolumeToCustomGeo(const char * path)
{
TGeoManager * aux = NULL;
aux = gGeoManager;
gGeoManager = fFileGeo;
printf("========== AddVolumeFromManager: %s ==========\n", path);
if (!gGeoManager) exit(1);
gGeoManager->cd(path);
TGeoHMatrix * matrix = (TGeoHMatrix *) gGeoManager->GetCurrentMatrix()->MakeClone();
TGeoNode * node = gGeoManager->GetCurrentNode();
TGeoVolume * vol = gGeoManager->GetCurrentNode()->GetVolume()->CloneVolume();
gGeoManager = fCustomGeo;
alice->AddNode(vol , 1, matrix );
}
void ImportGeoFromFile()
{
TGeoManager * aux = NULL;
if (!fFileGeo) {
aux = gGeoManager;
gGeoManager = 0;
TGeoManager::Import(Form("./geometry.root"));
fFileGeo = gGeoManager;
}
gGeoManager = aux;
}
//
// NewAD2016Aug_Marvin_2.C
//
void NewAD2016Aug_Marvin_3()
{
// gStyle->SetCanvasPreferGL(kTRUE);
gSystem->Load("libGeom");
// if (gGeoManager) gGeoManager = 0;
fCustomGeo = new TGeoManager("NewAD", "Test for New AD geometry");
//
// Make the top container volume
//
alice = gGeoManager -> MakeBox("TOP", kMedVacuum, 400., 400., 2000.);
// fCustomTop = alice;
gGeoManager -> SetTopVolume(alice);
matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
matAl = new TGeoMaterial("Al", 26.98,13,2.7);
kMedVacuum = new TGeoMedium("Vacuum",1, matVacuum);
kMedAlu = new TGeoMedium("Aluminium",2, matAl);
kMedSteelSh = kMedAlu; // TODO: Change this!!
kMedCopper = kMedAlu; // TODO: Change this!! // = gGeoManager->GetMedium("AD_Cu_C0"); // Stainless Steel
kMedPVC = kMedAlu; // TODO: Change this!! // = gGeoManager->GetMedium("AD_PVC" ); // Stainless Steel
TGeoMedium * medADASci = gGeoManager->GetMedium("AD_NE102"); // AD Scin.
if (1) {
Rx90m = new TGeoRotation("Rx90m", 0., -90., 0.) ;
Rx90 = new TGeoRotation("Rx90" , 0., 90., 0.) ;
Rx180 = new TGeoRotation("Rx180", 0., 180., 0.) ; // 4 | 1
Rz180 = new TGeoRotation("Rz180", 180., 0., 0.) ; // ---------------> x
Rz90 = new TGeoRotation("Rz90" , 90., 0., 0.) ;
Ry180 = new TGeoRotation("Ry180", 180., 180., 0.) ; // 3 | 2
Ry90m = new TGeoRotation("Ry90m", 90., -90., -90.) ;
Ry90 = new TGeoRotation("Ry90" , 90., 90., -90.) ;
TGeoVolume * voTest = CreateWarmModule();
// TGeoVolume * voTest = CreateOldADA();
// TGeoVolume * voTest = CreatePump();
voTest -> SetTransparency(0);
// voTest->SetLineColor(kGray);
alice->AddNode(voTest , 1, new TGeoTranslation(0., 0., 0.));
// gGeoManager->DefaultColors();
gGeoManager->CloseGeometry();
gGeoManager->SetVisLevel(50);
gGeoManager->SetVisOption(0);
alice->Draw("ogl");
return;
}
// // CreateCurvedBundles();
CreateAD();
ImportGeoFromFile();
// PrintVolumes();
// AddVolumeToCustomGeo("/ALIC_1/ZEM_1" );
// AddVolumeToCustomGeo("/ALIC_1/ZEM_2" );
// AddVolumeToCustomGeo("/ALIC_1/RB24_1" );
// AddVolumeToCustomGeo("/ALIC_1/DCM0_1" );
//
gGeoManager->CloseGeometry();
gGeoManager->SetVisLevel(20);
gGeoManager->SetVisOption(0);
alice->Draw("ogl");
return;
// for (Int_t i=0; i<10; i++)
// {
// printf("=========== test %3d ============\n", i);
// fBottomBundles[2]->TestArc(1);
// }
// for (Int_t i=2; i<fNBundles; i++)
// {
// Double_t L = fTopBundles[i]->GetTotalLength();
// printf("fTopBundles[%d]: L: %6.3f | 250-L: %6.3f\n", i, L, 250. - L);
// }
// for (Int_t i=2; i<fNBundles; i++)
// {
// Double_t L = fBottomBundles[i]->GetTotalLength();
// printf("fBottomBundles[%d]: L: %6.3f | 250-L: %6.3f\n", i, L, 250. - L);
// }
//
// CurvedBundle bundle1("Bundle1", -95,0,-1920, 20,25,-1955, 20, 20, -60);
// CurvedBundle bundle2("Bundle2", -95,0,-1920, 2,25,-1955, 20, 20, -60);
// CurvedBundle bundle3("Bundle3", -100,0,-1920, -2,25,-1955, 20, 20, -60);
// CurvedBundle bundle4("Bundle4", -100,0,-1920,-20,25,-1955, 20, 20, -60);
// CurvedBundle bundle1r("Bundle1r", -95,0,-1920, 20,25,-1955, 20, 20, -60, kTRUE );
// alice -> AddNode( bundle1. GetVolume(), 1);
// alice -> AddNode( bundle2. GetVolume(), 2);
// alice -> AddNode( bundle3. GetVolume(), 3);
// alice -> AddNode( bundle4. GetVolume(), 4);
// alice -> AddNode( bundle1. GetVolume(), 1, bundle1. GetCombiTrans());
// Add volumes from geometry file:
ImportGeoFromFile();
PrintVolumes();
gGeoManager->SetVisOption(0);
AddVolumeToCustomGeo("/ALIC_1/DCM0_1" );
AddVolumeToCustomGeo("/ALIC_1/YSAA_1" );
AddVolumeToCustomGeo("/ALIC_1/RB26Pipe_1" );
AddVolumeToCustomGeo("/ALIC_1/RB24_1" );
AddVolumeToCustomGeo("/ALIC_1/HALL_1" );
AddVolumeToCustomGeo("/ALIC_1/VZERO_1" );
// alice -> Draw("ogl");
// return;
//
// Define some materials
//
matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
matAl = new TGeoMaterial("Al", 26.98,13,2.7);
// ****************************************************************
// Defines tracking media parameters.
// Les valeurs sont commentees pour laisser le defaut
// a GEANT (version 3-21, page CONS200), f.m.
Float_t epsil, stmin, tmaxfd, deemax, stemax;
epsil = .001 ; // Tracking precision,
stemax = -1. ; // Maximum displacement for multiple scat
tmaxfd = -20. ; // Maximum angle due to field deflection
deemax = -.3 ; // Maximum fractional energy loss, DLS
stmin = -.8 ;
// ****************************************************************
//
// Parameters for AD scintillator: NE-102 (BC400)
//
// NE-102, has the following properties : (from internet, need better reference)
// Density : ca. 1.03 g/cm3
// Electrons/cm3: 3.39 x 10^23
// H atoms/cm3: 5.28 x 10^22
// C atoms/cm3: 4.78 x 10^22
// Ratio of H to C : 1.104 .
// wavelength of emission : ~4.23 nm.
// Decay time : ~2.4 ns.
// Luminescent efficiency : typically 18% of NaI(Tl)
// Photons/MeV: 2.5 x 10^4
//
// H // C
as[0] = 1.00794; as[1] = 12.011;
zs[0] = 1.; zs[1] = 6.;
fs[0] = 5.23; fs[1] = 4.74;
Double_t density = 1.032;
id = 1;
// AliMixture( id, "NE102", as, zs, density, -2, fs );
// AliMedium( id, "NE102", id, 1, fieldType, maxField, maxBending, maxStepSize,
// maxEnergyLoss, precision, minStepSize );
//
// Parameters for lightGuide:
// TODO check material
// Should be Poly(methyl methacrylate) (PMMA) acrylic
// (C5O2H8)n
// Density 1.18 g/cm3