File indexing completed on 2025-08-06 08:12:49
0001 #ifndef __INTTCONVERSION_H_
0002 #define __INTTCONVERSION_H_
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 struct full_ladder_info {
0014 int FC;
0015 TString Port;
0016 int ROC;
0017 int Direction;
0018 TString Ladder;
0019 };
0020 struct pos_str{
0021
0022 double x;
0023 double y;
0024 double z;
0025 int layer;
0026 double phi;
0027 };
0028
0029 struct pos_3D{
0030 float x;
0031 float y;
0032 float z;
0033 };
0034
0035 class InttConversion {
0036 public :
0037 InttConversion();
0038 InttConversion(string conversion_mode, double peek);
0039 pos_str Get_XY_all(string server, int module, int chip_id, int chan_id);
0040 string GetGeoMode();
0041 string GetLadderName(string server_module);
0042
0043 private :
0044
0045 string conversion_mode;
0046 double peek;
0047 pos_3D all_ch_pos[8][14][26][128];
0048
0049
0050
0051
0052 double layer_raduis[4] = {71.844000, 77.284000, 96.764000, 102.58400};
0053 int N_ladder[4] = {12, 12, 16, 16};
0054 double angle_increment[4] = {30,30,22.5,22.5};
0055 double ladder_location_angle_ini_correction[4] = {255,270,258.75,270};
0056 double ladder_self_angle_ini_correction[4] = {345,360,348.75,360};
0057 double pos_ini_correction[4];
0058 double channel_width = 0.078;
0059
0060 double ideal_z_pos[13] = {
0061 221.75, 201.75, 181.75, 161.75, 141.75,
0062 121.55, 105.55, 89.55, 73.55, 57.55, 41.55, 25.55, 9.55
0063
0064
0065
0066 };
0067 string ladder_index_string[16] = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15"};
0068
0069 vector<vector<pair<double,double>>> survey_ring_pos{
0070 {
0071 {-21.46096,-75.90736},
0072 {-55.11142,-56.18837},
0073 {-74.28391,-22.54561},
0074 {-74.27526,16.63011},
0075 {-55.28476,50.09862},
0076 {-21.29183,69.67282},
0077 {21.88624,70.05464},
0078 {55.62919,50.6206},
0079 {74.91651,16.92973},
0080 {75.05231,-21.87484},
0081 {55.65433,-55.67402},
0082 {22.03765,-75.04037}
0083 },
0084
0085
0086 {
0087 {-1.95208,-84.45033},
0088 {-42.53011,-73.45485},
0089 {-72.16084,-43.72407},
0090 {-82.95509,-3.14924},
0091 {-72.23989,37.60837},
0092 {-42.44876,67.26436},
0093 {2.51679,78.71859},
0094 {42.93029,67.67477},
0095 {72.5979,37.94146},
0096 {83.584,-2.404},
0097 {72.79182,-43.00581},
0098 {43.10364,-72.82611}
0099 },
0100
0101
0102 {
0103 {-21.31346,-101.64604},
0104 {-57.58322,-86.34445},
0105 {-85.04187,-58.59704},
0106 {-99.84728,-22.61833},
0107 {-99.77396,16.49293},
0108 {-84.90474,52.57002},
0109 {-57.61532,80.21115},
0110 {-21.37688,95.16837},
0111 {22.02317,95.28014},
0112 {58.19153,80.27542},
0113 {85.65315,52.7357},
0114 {100.52747,16.68818},
0115 {100.46573,-21.98187},
0116 {85.62499,-58.16364},
0117 {58.02216,-85.95094},
0118 {21.76647,-100.8559}
0119 },
0120
0121 {
0122 {-1.73438,-109.56383},
0123 {-42.59149,-101.4651},
0124 {-77.22727,-78.31667},
0125 {-100.13177,-43.74884},
0126 {-108.23473,-3.11344},
0127 {-99.90249,37.60892},
0128 {-77.06972,72.28864},
0129 {-42.4645,95.04719},
0130 {2.69826,103.51905},
0131 {43.41251,95.69813},
0132 {77.88536,72.49284},
0133 {100.8459,38.06807},
0134 {108.91711,-2.60334},
0135 {100.82318,-43.04702},
0136 {78.07134,-77.57372},
0137 {43.22038,-100.8719}
0138 }
0139 };
0140
0141 vector<vector<double>> survey_ladder_rotate{
0142 {
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 254.88308,
0157 224.84233,
0158 195.33558,
0159 165.30843,
0160 135.85324,
0161 105.51684,
0162 75.25436,
0163 45.08412,
0164 15.21125,
0165 -14.70991,
0166 -44.72201,
0167 -74.60061
0168 },
0169
0170 {
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184 269.87510,
0185 240.27438,
0186 210.17748,
0187 180.28054,
0188 150.26370,
0189 120.35931,
0190 89.30729,
0191 60.09218,
0192 30.24394,
0193 -0.41461,
0194 -29.75234,
0195 -59.80455
0196 },
0197
0198 {
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 258.82961,
0217 236.30034,
0218 213.72924,
0219 191.44348,
0220 169.05271,
0221 146.08111,
0222 123.95806,
0223 101.62990,
0224 79.25819,
0225 56.39717,
0226 33.94811,
0227 11.37644,
0228 -10.96506,
0229 -33.64731,
0230 -55.76405,
0231 -78.55631
0232 },
0233
0234 {
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 270.83251,
0253 247.90216,
0254 225.15574,
0255 202.86424,
0256 180.04104,
0257 157.90295,
0258 135.39716,
0259 113.02087,
0260 90.94595,
0261 67.17966,
0262 44.79993,
0263 22.72903,
0264 -0.11266,
0265 -22.23055,
0266 -44.43496,
0267 -67.19341
0268 }
0269 };
0270
0271 map<TString,full_ladder_info> serverFC_toinfo_map{
0272 {"intt0_0", {0, "D2", 0, 0, "B1L101S"}},
0273 {"intt0_1", {1, "C1", 0, 0, "B0L101S"}},
0274 {"intt0_2", {2, "C2", 0, 0, "B1L001S"}},
0275 {"intt0_3", {3, "B3", 0, 0, "B1L000S"}},
0276 {"intt0_4", {4, "A2", 0, 0, "B1L100S"}},
0277 {"intt0_5", {5, "B1", 0, 0, "B0L000S"}},
0278 {"intt0_6", {6, "A1", 0, 0, "B0L100S"}},
0279
0280 {"intt0_7", {7, "C2", 1, 0, "B1L103S"}},
0281 {"intt0_8", {8, "C1", 1, 0, "B0L002S"}},
0282 {"intt0_9", {9, "A1", 1, 0, "B0L001S"}},
0283 {"intt0_10", {10, "B3", 1, 0, "B1L002S"}},
0284 {"intt0_11", {11, "A2", 1, 0, "B1L102S"}},
0285 {"intt0_12", {12, "B1", 1, 0, "B0L102S"}},
0286 {"intt0_13", {13, "D2", 1, 0, "B1L003S"}},
0287
0288
0289
0290 {"intt1_0", {0, "C2", 2, 0, "B1L105S"}},
0291 {"intt1_1", {1, "C1", 2, 0, "B0L104S"}},
0292 {"intt1_2", {2, "A2", 2, 0, "B0L103S"}},
0293 {"intt1_3", {3, "B3", 2, 0, "B1L004S"}},
0294 {"intt1_4", {4, "A1", 2, 0, "B1L104S"}},
0295 {"intt1_5", {5, "B1", 2, 0, "B0L003S"}},
0296 {"intt1_6", {6, "D2", 2, 0, "B1L005S"}},
0297
0298 {"intt1_7", {7, "C2", 3, 0, "B1L107S"}},
0299 {"intt1_8", {8, "C1", 3, 0, "B0L005S"}},
0300 {"intt1_9", {9, "A1", 3, 0, "B0L004S"}},
0301 {"intt1_10", {10, "B2", 3, 0, "B1L006S"}},
0302 {"intt1_11", {11, "A2", 3, 0, "B1L106S"}},
0303 {"intt1_12", {12, "B1", 3, 0, "B0L105S"}},
0304 {"intt1_13", {13, "D1", 3, 0, "B1L007S"}},
0305
0306
0307
0308 {"intt2_0", {0, "A1", 4, 0, "B0L106S"}},
0309 {"intt2_1", {1, "B1", 4, 0, "B0L006S"}},
0310 {"intt2_2", {2, "C1", 4, 0, "B0L107S"}},
0311 {"intt2_3", {3, "A2", 4, 0, "B1L108S"}},
0312 {"intt2_4", {4, "B2", 4, 0, "B1L008S"}},
0313 {"intt2_5", {5, "C2", 4, 0, "B1L109S"}},
0314 {"intt2_6", {6, "D1", 4, 0, "B1L009S"}},
0315
0316 {"intt2_7", {7, "A1", 5, 0, "B0L007S"}},
0317 {"intt2_8", {8, "B3", 5, 0, "B0L108S"}},
0318 {"intt2_9", {9, "C1", 5, 0, "B0L008S"}},
0319 {"intt2_10", {10, "A2", 5, 0, "B1L110S"}},
0320 {"intt2_11", {11, "B2", 5, 0, "B1L010S"}},
0321 {"intt2_12", {12, "C2", 5, 0, "B1L111S"}},
0322 {"intt2_13", {13, "C3", 5, 0, "B1L011S"}},
0323
0324
0325
0326 {"intt3_0", {0, "A1", 6, 0, "B0L109S"}},
0327 {"intt3_1", {1, "B1", 6, 0, "B0L009S"}},
0328 {"intt3_2", {2, "C1", 6, 0, "B0L110S"}},
0329 {"intt3_3", {3, "A2", 6, 0, "B1L112S"}},
0330 {"intt3_4", {4, "B3", 6, 0, "B1L012S"}},
0331 {"intt3_5", {5, "C2", 6, 0, "B1L113S"}},
0332 {"intt3_6", {6, "D1", 6, 0, "B1L013S"}},
0333
0334 {"intt3_7", {7, "A1", 7, 0, "B0L010S"}},
0335 {"intt3_8", {8, "B1", 7, 0, "B0L111S"}},
0336 {"intt3_9", {9, "C1", 7, 0, "B0L011S"}},
0337 {"intt3_10", {10, "A2", 7, 0, "B1L114S"}},
0338 {"intt3_11", {11, "B3", 7, 0, "B1L014S"}},
0339 {"intt3_12", {12, "C3", 7, 0, "B1L115S"}},
0340 {"intt3_13", {13, "D2", 7, 0, "B1L015S"}},
0341
0342
0343
0344 {"intt4_0", {0, "B1", 0, 1, "B1L101N"}},
0345 {"intt4_1", {1, "C2", 0, 1, "B0L000N"}},
0346 {"intt4_2", {2, "D1", 0, 1, "B0L100N"}},
0347 {"intt4_3", {3, "A2", 0, 1, "B1L001N"}},
0348 {"intt4_4", {4, "B2", 0, 1, "B0L101N"}},
0349 {"intt4_5", {5, "C3", 0, 1, "B1L000N"}},
0350 {"intt4_6", {6, "D2", 0, 1, "B1L100N"}},
0351
0352 {"intt4_7", {7, "B1", 1, 1, "B0L002N"}},
0353 {"intt4_8", {8, "C2", 1, 1, "B0L102N"}},
0354 {"intt4_9", {9, "D1", 1, 1, "B0L001N"}},
0355 {"intt4_10", {10, "A2", 1, 1, "B1L003N"}},
0356 {"intt4_11", {11, "B2", 1, 1, "B1L103N"}},
0357 {"intt4_12", {12, "C3", 1, 1, "B1L002N"}},
0358 {"intt4_13", {13, "B3", 1, 1, "B1L102N"}},
0359
0360
0361
0362 {"intt5_0", {0, "C1", 2, 1, "B0L003N"}},
0363 {"intt5_1", {1, "B1", 2, 1, "B0L104N"}},
0364 {"intt5_2", {2, "D2", 2, 1, "B0L103N"}},
0365 {"intt5_3", {3, "D1", 2, 1, "B1L004N"}},
0366 {"intt5_4", {4, "A2", 2, 1, "B1L005N"}},
0367 {"intt5_5", {5, "C2", 2, 1, "B1L104N"}},
0368 {"intt5_6", {6, "A1", 2, 1, "B1L105N"}},
0369
0370 {"intt5_7", {7, "C3", 3, 1, "B1L107N"}},
0371 {"intt5_8", {8, "B1", 3, 1, "B1L007N"}},
0372 {"intt5_9", {9, "C1", 3, 1, "B1L006N"}},
0373 {"intt5_10", {10, "D2", 3, 1, "B1L106N"}},
0374 {"intt5_11", {11, "A1", 3, 1, "B0L005N"}},
0375 {"intt5_12", {12, "C2", 3, 1, "B0L105N"}},
0376 {"intt5_13", {13, "D1", 3, 1, "B0L004N"}},
0377
0378
0379
0380 {"intt6_0", {0, "A1", 4, 1, "B0L106N"}},
0381 {"intt6_1", {1, "C3", 4, 1, "B0L006N"}},
0382 {"intt6_2", {2, "B2", 4, 1, "B0L107N"}},
0383 {"intt6_3", {3, "D1", 4, 1, "B1L108N"}},
0384 {"intt6_4", {4, "C2", 4, 1, "B1L008N"}},
0385 {"intt6_5", {5, "B3", 4, 1, "B1L109N"}},
0386 {"intt6_6", {6, "A2", 4, 1, "B1L009N"}},
0387
0388 {"intt6_7", {7, "D1", 5, 1, "B0L007N"}},
0389 {"intt6_8", {8, "C3", 5, 1, "B0L108N"}},
0390 {"intt6_9", {9, "A2", 5, 1, "B0L008N"}},
0391 {"intt6_10", {10, "D2", 5, 1, "B1L110N"}},
0392 {"intt6_11", {11, "C2", 5, 1, "B1L010N"}},
0393 {"intt6_12", {12, "B3", 5, 1, "B1L111N"}},
0394 {"intt6_13", {13, "A1", 5, 1, "B1L011N"}},
0395
0396
0397
0398 {"intt7_0", {0, "B3", 6, 1, "B0L109N"}},
0399 {"intt7_1", {1, "C1", 6, 1, "B0L009N"}},
0400 {"intt7_2", {2, "B1", 6, 1, "B0L110N"}},
0401 {"intt7_3", {3, "D1", 6, 1, "B1L112N"}},
0402 {"intt7_4", {4, "C2", 6, 1, "B1L012N"}},
0403 {"intt7_5", {5, "B2", 6, 1, "B1L113N"}},
0404 {"intt7_6", {6, "A1", 6, 1, "B1L013N"}},
0405
0406 {"intt7_7", {7, "B2", 7, 1, "B0L010N"}},
0407 {"intt7_8", {8, "C2", 7, 1, "B0L111N"}},
0408 {"intt7_9", {9, "B1", 7, 1, "B0L011N"}},
0409 {"intt7_10", {10, "D2", 7, 1, "B1L114N"}},
0410 {"intt7_11", {11, "C3", 7, 1, "B1L014N"}},
0411 {"intt7_12", {12, "B3", 7, 1, "B1L115N"}},
0412 {"intt7_13", {13, "A1", 7, 1, "B1L015N"}}
0413 };
0414
0415 map<int,string>pid_to_server{
0416 {3001,"intt0"},
0417 {3002,"intt1"},
0418 {3003,"intt2"},
0419 {3004,"intt3"},
0420 {3005,"intt4"},
0421 {3006,"intt5"},
0422 {3007,"intt6"},
0423 {3008,"intt7"}
0424 };
0425
0426 pair<double,double> Get_dummy_ladder_XY(int chip_id, int chan_id, int ladder_SN);
0427 pair<double,double> Get_self_rotation( pair<double,double> chan_pos, double angle);
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573 };
0574
0575 InttConversion::InttConversion()
0576 {}
0577
0578 InttConversion::InttConversion(string conversion_mode, double peek)
0579 :conversion_mode(conversion_mode), peek(peek)
0580 {
0581
0582 TFile * file_in = TFile::Open(Form("/sphenix/user/ChengWei/INTT/INTT_commissioning/INTT_CW/INTT_commissioning/DAC_Scan/geo_folder/survey_data_all_3.32.root"));
0583 TTree * tree = (TTree *)file_in->Get("t_ch_pos");
0584 int pid;
0585 int module;
0586 int chip;
0587 int chan;
0588 double ch_x;
0589 double ch_y;
0590 double ch_z;
0591 double ch_phi;
0592
0593 tree -> SetBranchAddress("pid",&pid);
0594 tree -> SetBranchAddress("module",&module);
0595 tree -> SetBranchAddress("chip",&chip);
0596 tree -> SetBranchAddress("chan",&chan);
0597 tree -> SetBranchAddress("x",&ch_x);
0598 tree -> SetBranchAddress("y",&ch_y);
0599 tree -> SetBranchAddress("z",&ch_z);
0600 tree -> SetBranchAddress("phi",&ch_phi);
0601
0602
0603
0604 for (int i = 0; i < tree -> GetEntries(); i++){
0605 tree -> GetEntry(i);
0606 all_ch_pos[pid][module][chip-1][chan] = {float(ch_x),float(ch_y),float(ch_z)};
0607 }
0608
0609 file_in -> Close();
0610 }
0611
0612
0613 pair<double,double> InttConversion::Get_dummy_ladder_XY(int chip_id, int chan_id, int ladder_SN)
0614 {
0615
0616
0617 int row_index = (chip_id > 0 && chip_id < 14) ? 0 : 1;
0618 double dummy_X = 0;
0619 double dummy_Y;
0620
0621
0622 if (ladder_SN == 1) {
0623 dummy_Y = (row_index == 0) ? -0.039 - (127 - chan_id) * 0.078 : 0.039 + (127 - chan_id) * 0.078;
0624 }
0625
0626 else if (ladder_SN == 0){
0627 dummy_Y = (row_index == 1) ? -0.039 - (127 - chan_id) * 0.078 : 0.039 + (127 - chan_id) * 0.078;
0628 }
0629 else{
0630 cout<<" wrong ladder_SN ID "<<endl;
0631 exit(1);
0632 }
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642 return {dummy_X,dummy_Y};
0643 }
0644
0645 pair<double,double> InttConversion::Get_self_rotation( pair<double,double> chan_pos, double angle)
0646 {
0647 return {chan_pos.second * cos(angle / (180/TMath::Pi())), chan_pos.second * sin(angle / (180/TMath::Pi()))};
0648 }
0649
0650 pos_str InttConversion::Get_XY_all(string server, int module, int chip_id, int chan_id)
0651 {
0652
0653 vector<string> conversion_mode_DB = {"ideal","nominal","survey_1_XY","survey_1_XYAlpha","survey_1_XYAlpha_Peek","full_survey_3.32"};
0654
0655
0656 string ladder_pos_str = string(serverFC_toinfo_map[Form("%s_%i",server.c_str(),module)].Ladder);
0657
0658 int layer_index;
0659 if (ladder_pos_str.substr(0,4) == "B0L0") layer_index = 0;
0660 else if (ladder_pos_str.substr(0,4) == "B0L1") layer_index = 1;
0661 else if (ladder_pos_str.substr(0,4) == "B1L0") layer_index = 2;
0662 else if (ladder_pos_str.substr(0,4) == "B1L1") layer_index = 3;
0663 else
0664 {
0665 cout<<"error happens, wrong name"<<endl;
0666 exit(1);
0667 }
0668
0669 int ladder_index = stoi(ladder_pos_str.substr(4,2));
0670
0671
0672
0673 int ladder_SN = ( stoi(server.substr(4,1)) < 4 ) ? 0 : 1;
0674
0675
0676
0677 double ladder_location_angle = ladder_location_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index);
0678
0679 double ring_pos_x = layer_raduis[layer_index] * cos(ladder_location_angle / (180/TMath::Pi()));
0680 double ring_pos_y = layer_raduis[layer_index] * sin(ladder_location_angle / (180/TMath::Pi()));
0681
0682 double ladder_self_pos_X;
0683 double ladder_self_pos_Y;
0684 double final_pos_X;
0685 double final_pos_Y;
0686 double final_pos_Z;
0687
0688 if (conversion_mode == conversion_mode_DB[0] || conversion_mode == conversion_mode_DB[1])
0689 {
0690 ladder_self_pos_X = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).first) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).first;
0691 ladder_self_pos_Y = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).second) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).second;
0692 final_pos_X = ring_pos_x + ladder_self_pos_X;
0693 final_pos_Y = ring_pos_y + ladder_self_pos_Y;
0694 final_pos_Z = ideal_z_pos[(chip_id - 1) % 13] * pow(-1, 1 - ladder_SN);
0695 }
0696 else if ( conversion_mode == conversion_mode_DB[2] )
0697 {
0698
0699 ladder_self_pos_X = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).first) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).first;
0700 ladder_self_pos_Y = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).second) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( ladder_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).second;
0701
0702
0703 final_pos_X = survey_ring_pos[layer_index][ladder_index].first + ladder_self_pos_X;
0704 final_pos_Y = survey_ring_pos[layer_index][ladder_index].second + ladder_self_pos_Y;
0705 final_pos_Z = ideal_z_pos[(chip_id - 1) % 13] * pow(-1, 1 - ladder_SN);
0706 }
0707 else if ( conversion_mode == conversion_mode_DB[3] )
0708 {
0709
0710
0711
0712 ladder_self_pos_X = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).first) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).first;
0713 ladder_self_pos_Y = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).second) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).second;
0714
0715
0716 final_pos_X = survey_ring_pos[layer_index][ladder_index].first + ladder_self_pos_X;
0717 final_pos_Y = survey_ring_pos[layer_index][ladder_index].second + ladder_self_pos_Y;
0718 final_pos_Z = ideal_z_pos[(chip_id - 1) % 13] * pow(-1, 1 - ladder_SN);
0719 }
0720 else if ( conversion_mode == conversion_mode_DB[4] )
0721 {
0722
0723 ladder_self_pos_X = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).first) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).first;
0724 ladder_self_pos_Y = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).second) < 0.0000001) ? 0 : Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id,ladder_SN),( survey_ladder_rotate[layer_index][ladder_index] + 90. )).second;
0725
0726 double peek_correction_x = peek * cos( ( survey_ladder_rotate[layer_index][ladder_index] + 90. + 90.) / (180./M_PI) );
0727 double peek_correction_y = peek * sin( ( survey_ladder_rotate[layer_index][ladder_index] + 90. + 90.) / (180./M_PI) );
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739 final_pos_X = survey_ring_pos[layer_index][ladder_index].first + ladder_self_pos_X + peek_correction_x;
0740 final_pos_Y = survey_ring_pos[layer_index][ladder_index].second + ladder_self_pos_Y + peek_correction_y;
0741 final_pos_Z = ideal_z_pos[(chip_id - 1) % 13] * pow(-1, 1 - ladder_SN);
0742 }
0743 else if (conversion_mode == conversion_mode_DB[5])
0744 {
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756 pos_3D single_ch_pos = all_ch_pos[(server[4] - '0')][module][chip_id - 1][chan_id];
0757
0758 final_pos_X = single_ch_pos.x;
0759 final_pos_Y = single_ch_pos.y;
0760 final_pos_Z = single_ch_pos.z;
0761 }
0762 else
0763 {
0764 cout<<"InttConversion_new.h wrong mode input"<<endl;
0765 cout<<"you have filled : "<<conversion_mode<<endl;
0766 exit(1);
0767 }
0768
0769 int final_pos_layer = (layer_index == 0 || layer_index == 1) ? 0 : 1;
0770 double final_pos_phi = (final_pos_Y < 0) ? atan2(final_pos_Y,final_pos_X) * (180./TMath::Pi()) + 360 : atan2(final_pos_Y,final_pos_X) * (180./TMath::Pi());
0771
0772 return {final_pos_X,final_pos_Y,final_pos_Z,final_pos_layer,final_pos_phi};
0773 }
0774
0775 string InttConversion::GetGeoMode()
0776 {
0777 return conversion_mode;
0778 }
0779
0780 string InttConversion::GetLadderName(string server_module)
0781 {
0782 return (serverFC_toinfo_map[server_module].Ladder).Data();
0783 }
0784
0785 #endif
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998