Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:12:49

0001 #ifndef __INTTCONVERSION_H_
0002 #define __INTTCONVERSION_H_
0003 
0004 // #include <Eigen/Dense>
0005 // #include <Eigen/Geometry>
0006 // #include <Eigen/LU>
0007 // #include <Eigen/SVD>
0008 // #include <Math/Transform3D.h>
0009 
0010 // #include <intt/InttMapping.h>
0011 // R__LOAD_LIBRARY(libintt.so)
0012 
0013 struct full_ladder_info {
0014     int FC;
0015     TString Port;
0016     int ROC;
0017     int Direction; // note : 0 : south, 1 : north 
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(); // note : constructor
0038         InttConversion(string conversion_mode, double peek); // note : constructor
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         // TTree * survey_tree = new TTree();
0050         // Intt::RawData_s trial_channel; // note : chip seems to be from 0 to 25
0051 
0052         double layer_raduis[4] = {71.844000, 77.284000, 96.764000, 102.58400}; // note : unit : mm
0053         int N_ladder[4] = {12, 12, 16, 16};
0054         double angle_increment[4] = {30,30,22.5,22.5}; // note : ladder rotation
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; // note : unit : mm
0059         // note : It's different from the sPHENIX-INTT official conversion, but it's 
0060         double ideal_z_pos[13] = {
0061             221.75, 201.75, 181.75, 161.75, 141.75, // note : type B, column 1 to column 5
0062             121.55, 105.55, 89.55, 73.55, 57.55, 41.55, 25.55, 9.55 // note : type A, column 6 to column 13
0063 
0064             // 9.55, 25.55, 41.55, 57.55, 73.55, 89.55, 105.55, 121.55, // note : type A
0065             // 141.75, 161.75, 181.75, 201.75, 221.75 // note : type B
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                 // -0.26384,
0144                 // -0.78815,
0145                 // -1.30314,
0146                 // 1.31438,
0147                 // 0.80029,
0148                 // 0.27082,
0149                 // -0.25736,
0150                 // -0.78393,
0151                 // -1.30531,
0152                 // 1.31406,
0153                 // 0.79025,
0154                 // 0.26877
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                 // -0.00218,
0172                 // -0.51881,
0173                 // -1.0441,
0174                 // -1.5659,
0175                 // 1.0518,
0176                 // 0.52987,
0177                 // -0.01209,
0178                 // -0.52199,
0179                 // -1.04294,
0180                 // 1.56356, // note : remove the sign manually
0181                 // 1.05152,
0182                 // 0.52701
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                 // -0.19496,
0200                 // -0.58817,
0201                 // -0.98211,
0202                 // -1.37107,
0203                 // 1.37973,
0204                 // 0.9788,
0205                 // 0.59268,
0206                 // 0.20298,
0207                 // -0.18748,
0208                 // -0.58648,
0209                 // -0.97829,
0210                 // -1.37224,
0211                 // 1.37942,
0212                 // 0.98354,
0213                 // 0.59753,
0214                 // 0.19973
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                 // 0.01453,
0236                 // -0.38568,
0237                 // -0.78268,
0238                 // -1.17174,
0239                 // -1.57008,
0240                 // 1.18513,
0241                 // 0.79233,
0242                 // 0.40179,
0243                 // 0.01651,
0244                 // -0.39829,
0245                 // -0.78889,
0246                 // -1.1741,
0247                 // 1.56883,
0248                 // 1.1828,
0249                 // 0.79526,
0250                 // 0.39805
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"}}, // note : intt 0
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"}},  // note : intt 1
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"}},  // note : intt 2
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"}},  // note : intt 3
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"}},    // note : intt 4
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"}},    // note : intt 5
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"}},    // note : intt 6
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"}},    // note : intt 7
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         // map<TString,ladder_info> ladder_toinfo_map{    
0430         //     {"B1L101S", {0, "D2", 0, 0}}, // note : intt 0
0431         //     {"B0L101S", {1, "C1", 0, 0}},
0432         //     {"B1L001S", {2, "C2", 0, 0}},
0433         //     {"B1L000S", {3, "B3", 0, 0}},
0434         //     {"B1L100S", {4, "A2", 0, 0}},
0435         //     {"B0L000S", {5, "B1", 0, 0}},
0436         //     {"B0L100S", {6, "A1", 0, 0}},
0437 
0438         //     {"B1L103S", {7, "C2", 1, 0}},
0439         //     {"B0L002S", {8, "C1", 1, 0}},
0440         //     {"B0L001S", {9, "A1", 1, 0}},
0441         //     {"B1L002S", {10, "B3", 1, 0}},
0442         //     {"B1L102S", {11, "A2", 1, 0}},
0443         //     {"B0L102S", {12, "B1", 1, 0}},
0444         //     {"B1L003S", {13, "D2", 1, 0}},
0445 
0446 
0447 
0448         //     {"B1L105S", {0, "C2", 2, 0}},  // note : intt 1
0449         //     {"B0L104S", {1, "C1", 2, 0}},  
0450         //     {"B0L103S", {2, "A2", 2, 0}},  
0451         //     {"B1L004S", {3, "B3", 2, 0}},  
0452         //     {"B1L104S", {4, "A1", 2, 0}},  
0453         //     {"B0L003S", {5, "B1", 2, 0}},  
0454         //     {"B1L005S", {6, "D2", 2, 0}},  
0455 
0456         //     {"B1L107S", {7, "C2", 3, 0}},  
0457         //     {"B0L005S", {8, "C1", 3, 0}},  
0458         //     {"B0L004S", {9, "A1", 3, 0}},  
0459         //     {"B1L006S", {10, "B2", 3, 0}},  
0460         //     {"B1L106S", {11, "A2", 3, 0}},  
0461         //     {"B0L105S", {12, "B1", 3, 0}},  
0462         //     {"B1L007S", {13, "D1", 3, 0}},
0463 
0464 
0465 
0466         //     {"B0L106S", {0, "A1", 4, 0}},  // note : intt 2
0467         //     {"B0L006S", {1, "B1", 4, 0}},  
0468         //     {"B0L107S", {2, "C1", 4, 0}},  
0469         //     {"B1L108S", {3, "A2", 4, 0}},  
0470         //     {"B1L008S", {4, "B2", 4, 0}},  
0471         //     {"B1L109S", {5, "C2", 4, 0}},  
0472         //     {"B1L009S", {6, "D1", 4, 0}},  
0473 
0474         //     {"B0L007S", {7, "A1", 5, 0}},  
0475         //     {"B0L108S", {8, "B3", 5, 0}},  
0476         //     {"B0L008S", {9, "C1", 5, 0}},  
0477         //     {"B1L110S", {10, "A2", 5, 0}},  
0478         //     {"B1L010S", {11, "B2", 5, 0}},  
0479         //     {"B1L111S", {12, "C2", 5, 0}},  
0480         //     {"B1L011S", {13, "C3", 5, 0}},
0481 
0482 
0483 
0484         //     {"B0L109S", {0, "A1", 6, 0}},  // note : intt 3
0485         //     {"B0L009S", {1, "B1", 6, 0}},  
0486         //     {"B0L110S", {2, "C1", 6, 0}},  
0487         //     {"B1L112S", {3, "A2", 6, 0}},  
0488         //     {"B1L012S", {4, "B3", 6, 0}},  
0489         //     {"B1L113S", {5, "C2", 6, 0}},  
0490         //     {"B1L013S", {6, "D1", 6, 0}},  
0491 
0492         //     {"B0L010S", {7, "A1", 7, 0}},  
0493         //     {"B0L111S", {8, "B1", 7, 0}},  
0494         //     {"B0L011S", {9, "C1", 7, 0}},  
0495         //     {"B1L114S", {10, "A2", 7, 0}},  
0496         //     {"B1L014S", {11, "B3", 7, 0}},  
0497         //     {"B1L115S", {12, "C3", 7, 0}},  
0498         //     {"B1L015S", {13, "D2", 7, 0}},
0499 
0500 
0501 
0502         //     {"B1L101N", {0,  "B1", 0, 1}},   // note : intt 4
0503         //     {"B0L000N", {1,  "C2", 0, 1}},   
0504         //     {"B0L100N", {2,  "D1", 0, 1}},   
0505         //     {"B1L001N", {3,  "A2", 0, 1}},   
0506         //     {"B0L101N", {4,  "B2", 0, 1}},   
0507         //     {"B1L000N", {5,  "C3", 0, 1}},   
0508         //     {"B1L100N", {6,  "D2", 0, 1}},    
0509 
0510         //     {"B0L002N", {7, "B1", 1, 1}},     
0511         //     {"B0L102N", {8, "C2", 1, 1}},    
0512         //     {"B0L001N", {9, "D1", 1, 1}},    
0513         //     {"B1L003N", {10, "A2", 1, 1}},    
0514         //     {"B1L103N", {11, "B2", 1, 1}},   
0515         //     {"B1L002N", {12, "C3", 1, 1}},   
0516         //     {"B1L102N", {13, "B3", 1, 1}},
0517 
0518 
0519 
0520         //     {"B0L003N", {0, "C1", 2, 1}},    // note : intt 5
0521         //     {"B0L104N", {1, "B1", 2, 1}},    
0522         //     {"B0L103N", {2, "D2", 2, 1}},     
0523         //     {"B1L004N", {3, "D1", 2, 1}},    
0524         //     {"B1L005N", {4, "A2", 2, 1}},     
0525         //     {"B1L104N", {5, "C2", 2, 1}},    
0526         //     {"B1L105N", {6, "A1", 2, 1}},    
0527 
0528         //     {"B1L107N", {7, "C3", 3, 1}},    
0529         //     {"B1L007N", {8, "B1", 3, 1}},    
0530         //     {"B1L006N", {9, "C1", 3, 1}},    
0531         //     {"B1L106N", {10, "D2", 3, 1}},   
0532         //     {"B0L005N", {11, "A1", 3, 1}},   
0533         //     {"B0L105N", {12, "C2", 3, 1}},   
0534         //     {"B0L004N", {13, "D1", 3, 1}},
0535 
0536 
0537 
0538         //     {"B0L106N", {0, "A1", 4, 1}},    // note : intt 6
0539         //     {"B0L006N", {1, "C3", 4, 1}},    
0540         //     {"B0L107N", {2, "B2", 4, 1}},    
0541         //     {"B1L108N", {3, "D1", 4, 1}},    
0542         //     {"B1L008N", {4, "C2", 4, 1}},    
0543         //     {"B1L109N", {5, "B3", 4, 1}},    
0544         //     {"B1L009N", {6, "A2", 4, 1}},    
0545 
0546         //     {"B0L007N", {7, "D1", 5, 1}},    
0547         //     {"B0L108N", {8, "C3", 5, 1}},    
0548         //     {"B0L008N", {9, "A2", 5, 1}},    
0549         //     {"B1L110N", {10, "D2", 5, 1}},     
0550         //     {"B1L010N", {11, "C2", 5, 1}},   
0551         //     {"B1L111N", {12, "B3", 5, 1}},   
0552         //     {"B1L011N", {13, "A1", 5, 1}},  
0553 
0554 
0555 
0556         //     {"B0L109N", {0, "B3", 6, 1}},    // note : intt 7
0557         //     {"B0L009N", {1, "C1", 6, 1}},    
0558         //     {"B0L110N", {2, "B1", 6, 1}},    
0559         //     {"B1L112N", {3, "D1", 6, 1}},    
0560         //     {"B1L012N", {4, "C2", 6, 1}},    
0561         //     {"B1L113N", {5, "B2", 6, 1}},    
0562         //     {"B1L013N", {6, "A1", 6, 1}},    
0563 
0564         //     {"B0L010N", {7, "B2", 7, 1}},    
0565         //     {"B0L111N", {8, "C2", 7, 1}},    
0566         //     {"B0L011N", {9, "B1", 7, 1}},      
0567         //     {"B1L114N", {10, "D2", 7, 1}},     
0568         //     {"B1L014N", {11, "C3", 7, 1}},   
0569         //     {"B1L115N", {12, "B3", 7, 1}},   
0570         //     {"B1L015N", {13, "A1", 7, 1}}
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     // todo : check the file you use
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     // pos_3D all_ch_pos[8][14][26][128];
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     // note : chip_id 1 ~ 13 -> 0 
0616     // note : chip_id 14 ~ 26 -> 1
0617     int row_index = (chip_id > 0 && chip_id < 14) ? 0 : 1;
0618     double dummy_X = 0; 
0619     double dummy_Y;
0620     
0621     // note : north
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     // note : south
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     // note : original, only works for north
0635     // // note : chip_id 1 ~ 13, 14 ~ 26
0636     // int row_index = (chip_id > 0 && chip_id < 14) ? 0 : 1;
0637 
0638     // double dummy_X = 0;
0639     // double dummy_Y = (row_index == 0) ? -0.039 - (127 - chan_id) * 0.078 : 0.039 + (127 - chan_id) * 0.078;
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 ladder_name*/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     // string ladder_pos_str = ladder_name;
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     // note : 0, 1, 2, 3 : south, id 0
0672     // note : 4, 5, 6, 7 : north, id 1
0673     int ladder_SN = ( stoi(server.substr(4,1)) < 4 ) ? 0 : 1;
0674     // cout<<"test : ladder_SN : "<<ladder_SN<<endl;
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]) // note : ideal, nominal
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] ) // note : survey_1_XY (based on survey data typeB south)
0697     {
0698         // note : ideal ladder rotation
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         // note : survey data ladder center position
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] ) // note : survey_1_XYAlpha (based on survey data typeB south)
0708     {
0709         // note : here is an attempt, try to import the survey data, but only the center position of ladders
0710 
0711         // note : 
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         // note : survey data ladder center position
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] ) // note : survey_1_XYAlpha_Peek
0721     {
0722         // note : 
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         // cout<<" test : "<<sqrt(pow(peek_correction_x,2)+pow(peek_correction_y,2))<<endl;
0729         // if (chip_id == 1)
0730         // { 
0731         //     if (chan_id == 0)
0732         //     {
0733         //         cout<<"test : "<<ladder_pos_str<<" "<<survey_ladder_rotate[layer_index][ladder_index] + 180.<<" "<<peek_correction_x<<" "<<peek_correction_y<<endl;
0734         //     }
0735         // }
0736         
0737 
0738         // note : survey data ladder center position
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]) // note : full survey data with the 3.32 mm correction inward. 2023_10_11
0744     {
0745         // trial_channel.felix_server = server[4] - '0'; // note : from 0 to 7
0746         // trial_channel.felix_channel = module;
0747         // trial_channel.chip = chip_id - 1; // note : from 0 to 25
0748         // trial_channel.channel = chan_id;   // note : chan should be from 0 to 127
0749 
0750         // Eigen::Affine3d sensor_trans = Intt::GetTransform(survey_tree, ToOffline(trial_channel));
0751         // Eigen::Vector4d local_trans = Intt::GetLocalPos(ToOffline(trial_channel));
0752         // final_pos_X = (sensor_trans * local_trans)[0];
0753         // final_pos_Y = (sensor_trans * local_trans)[1];
0754         // final_pos_Z = (sensor_trans * local_trans)[2];
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 // class InttClutering
0790 // {
0791 //     public:
0792 //         InttClutering();
0793 //         pair<double,double> Get_XY_all(string ladder_name,/*string server, int module,*/ int chip_id, int chan_id);
0794     
0795 //     private: 
0796 //         double layer_raduis[4] = {71.844000, 77.284000, 96.764000, 102.58400}; // note : unit : mm
0797 //         int N_ladder[4] = {12, 12, 16, 16};
0798 //         double angle_increment[4] = {30,30,22.5,22.5}; // note : ladder rotation
0799 //         double ladder_location_angle_ini_correction[4] = {255,270,258.75,270};
0800 //         double ladder_self_angle_ini_correction[4] = {345,360,348.75,360};
0801 //         double pos_ini_correction[4];
0802 //         double channel_width = 0.078; // note : unit : mm
0803 //         string ladder_index_string[16] = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15"};
0804 
0805 //         map<TString,full_ladder_info> serverFC_toinfo_map{    
0806 //             {"intt0_0", {0, "D2", 0, 0, "B1L101S"}}, // note : intt 0
0807 //             {"intt0_1", {1, "C1", 0, 0, "B0L101S"}},
0808 //             {"intt0_2", {2, "C2", 0, 0, "B1L001S"}},
0809 //             {"intt0_3", {3, "B3", 0, 0, "B1L000S"}},
0810 //             {"intt0_4", {4, "A2", 0, 0, "B1L100S"}},
0811 //             {"intt0_5", {5, "B1", 0, 0, "B0L000S"}},
0812 //             {"intt0_6", {6, "A1", 0, 0, "B0L100S"}},
0813 
0814 //             {"intt0_7", {7, "C2", 1, 0, "B1L103S"}},
0815 //             {"intt0_8", {8, "C1", 1, 0, "B0L002S"}},
0816 //             {"intt0_9", {9, "A1", 1, 0, "B0L001S"}},
0817 //             {"intt0_10", {10, "B3", 1, 0, "B1L002S"}},
0818 //             {"intt0_11", {11, "A2", 1, 0, "B1L102S"}},
0819 //             {"intt0_12", {12, "B1", 1, 0, "B0L102S"}},
0820 //             {"intt0_13", {13, "D2", 1, 0, "B1L003S"}},
0821 
0822 
0823 
0824 //             {"intt1_0", {0, "C2", 2, 0, "B1L105S"}},  // note : intt 1
0825 //             {"intt1_1", {1, "C1", 2, 0, "B0L104S"}},  
0826 //             {"intt1_2", {2, "A2", 2, 0, "B0L103S"}},  
0827 //             {"intt1_3", {3, "B3", 2, 0, "B1L004S"}},  
0828 //             {"intt1_4", {4, "A1", 2, 0, "B1L104S"}},  
0829 //             {"intt1_5", {5, "B1", 2, 0, "B0L003S"}},  
0830 //             {"intt1_6", {6, "D2", 2, 0, "B1L005S"}},  
0831 
0832 //             {"intt1_7", {7, "C2", 3, 0, "B1L107S"}},  
0833 //             {"intt1_8", {8, "C1", 3, 0, "B0L005S"}},  
0834 //             {"intt1_9", {9, "A1", 3, 0, "B0L004S"}},  
0835 //             {"intt1_10", {10, "B2", 3, 0, "B1L006S"}},  
0836 //             {"intt1_11", {11, "A2", 3, 0, "B1L106S"}},  
0837 //             {"intt1_12", {12, "B1", 3, 0, "B0L105S"}},  
0838 //             {"intt1_13", {13, "D1", 3, 0, "B1L007S"}},
0839 
0840 
0841 
0842 //             {"intt2_0", {0, "A1", 4, 0, "B0L106S"}},  // note : intt 2
0843 //             {"intt2_1", {1, "B1", 4, 0, "B0L006S"}},  
0844 //             {"intt2_2", {2, "C1", 4, 0, "B0L107S"}},  
0845 //             {"intt2_3", {3, "A2", 4, 0, "B1L108S"}},  
0846 //             {"intt2_4", {4, "B2", 4, 0, "B1L008S"}},  
0847 //             {"intt2_5", {5, "C2", 4, 0, "B1L109S"}},  
0848 //             {"intt2_6", {6, "D1", 4, 0, "B1L009S"}},  
0849 
0850 //             {"intt2_7", {7, "A1", 5, 0, "B0L007S"}},  
0851 //             {"intt2_8", {8, "B3", 5, 0, "B0L108S"}},  
0852 //             {"intt2_9", {9, "C1", 5, 0, "B0L008S"}},  
0853 //             {"intt2_10", {10, "A2", 5, 0, "B1L110S"}},  
0854 //             {"intt2_11", {11, "B2", 5, 0, "B1L010S"}},  
0855 //             {"intt2_12", {12, "C2", 5, 0, "B1L111S"}},  
0856 //             {"intt2_13", {13, "C3", 5, 0, "B1L011S"}},
0857 
0858 
0859 
0860 //             {"intt3_0", {0, "A1", 6, 0, "B0L109S"}},  // note : intt 3
0861 //             {"intt3_1", {1, "B1", 6, 0, "B0L009S"}},  
0862 //             {"intt3_2", {2, "C1", 6, 0, "B0L110S"}},  
0863 //             {"intt3_3", {3, "A2", 6, 0, "B1L112S"}},  
0864 //             {"intt3_4", {4, "B3", 6, 0, "B1L012S"}},  
0865 //             {"intt3_5", {5, "C2", 6, 0, "B1L113S"}},  
0866 //             {"intt3_6", {6, "D1", 6, 0, "B1L013S"}},  
0867 
0868 //             {"intt3_7", {7, "A1", 7, 0, "B0L010S"}},  
0869 //             {"intt3_8", {8, "B1", 7, 0, "B0L111S"}},  
0870 //             {"intt3_9", {9, "C1", 7, 0, "B0L011S"}},  
0871 //             {"intt3_10", {10, "A2", 7, 0, "B1L114S"}},  
0872 //             {"intt3_11", {11, "B3", 7, 0, "B1L014S"}},  
0873 //             {"intt3_12", {12, "C3", 7, 0, "B1L115S"}},  
0874 //             {"intt3_13", {13, "D2", 7, 0, "B1L015S"}},
0875 
0876 
0877 
0878 //             {"intt4_0", {0,  "B1", 0, 1, "B1L101N"}},    // note : intt 4
0879 //             {"intt4_1", {1,  "C2", 0, 1, "B0L000N"}},    
0880 //             {"intt4_2", {2,  "D1", 0, 1, "B0L100N"}},    
0881 //             {"intt4_3", {3,  "A2", 0, 1, "B1L001N"}},    
0882 //             {"intt4_4", {4,  "B2", 0, 1, "B0L101N"}},    
0883 //             {"intt4_5", {5,  "C3", 0, 1, "B1L000N"}},    
0884 //             {"intt4_6", {6,  "D2", 0, 1, "B1L100N"}},     
0885 
0886 //             {"intt4_7", {7, "B1", 1, 1, "B0L002N"}},  
0887 //             {"intt4_8", {8, "C2", 1, 1, "B0L102N"}}, 
0888 //             {"intt4_9", {9, "D1", 1, 1, "B0L001N"}}, 
0889 //             {"intt4_10", {10, "A2", 1, 1, "B1L003N"}},    
0890 //             {"intt4_11", {11, "B2", 1, 1, "B1L103N"}},   
0891 //             {"intt4_12", {12, "C3", 1, 1, "B1L002N"}},   
0892 //             {"intt4_13", {13, "B3", 1, 1, "B1L102N"}},
0893 
0894 
0895 
0896 //             {"intt5_0", {0, "C1", 2, 1, "B0L003N"}}, // note : intt 5
0897 //             {"intt5_1", {1, "B1", 2, 1, "B0L104N"}}, 
0898 //             {"intt5_2", {2, "D2", 2, 1, "B0L103N"}},  
0899 //             {"intt5_3", {3, "D1", 2, 1, "B1L004N"}}, 
0900 //             {"intt5_4", {4, "A2", 2, 1, "B1L005N"}},  
0901 //             {"intt5_5", {5, "C2", 2, 1, "B1L104N"}}, 
0902 //             {"intt5_6", {6, "A1", 2, 1, "B1L105N"}}, 
0903 
0904 //             {"intt5_7", {7, "C3", 3, 1, "B1L107N"}}, 
0905 //             {"intt5_8", {8, "B1", 3, 1, "B1L007N"}}, 
0906 //             {"intt5_9", {9, "C1", 3, 1, "B1L006N"}}, 
0907 //             {"intt5_10", {10, "D2", 3, 1, "B1L106N"}},   
0908 //             {"intt5_11", {11, "A1", 3, 1, "B0L005N"}},   
0909 //             {"intt5_12", {12, "C2", 3, 1, "B0L105N"}},   
0910 //             {"intt5_13", {13, "D1", 3, 1, "B0L004N"}},
0911 
0912 
0913 
0914 //             {"intt6_0", {0, "A1", 4, 1, "B0L106N"}}, // note : intt 6
0915 //             {"intt6_1", {1, "C3", 4, 1, "B0L006N"}}, 
0916 //             {"intt6_2", {2, "B2", 4, 1, "B0L107N"}}, 
0917 //             {"intt6_3", {3, "D1", 4, 1, "B1L108N"}}, 
0918 //             {"intt6_4", {4, "C2", 4, 1, "B1L008N"}}, 
0919 //             {"intt6_5", {5, "B3", 4, 1, "B1L109N"}}, 
0920 //             {"intt6_6", {6, "A2", 4, 1, "B1L009N"}}, 
0921 
0922 //             {"intt6_7", {7, "D1", 5, 1, "B0L007N"}}, 
0923 //             {"intt6_8", {8, "C3", 5, 1, "B0L108N"}}, 
0924 //             {"intt6_9", {9, "A2", 5, 1, "B0L008N"}}, 
0925 //             {"intt6_10", {10, "D2", 5, 1, "B1L110N"}},     
0926 //             {"intt6_11", {11, "C2", 5, 1, "B1L010N"}},   
0927 //             {"intt6_12", {12, "B3", 5, 1, "B1L111N"}},   
0928 //             {"intt6_13", {13, "A1", 5, 1, "B1L011N"}},  
0929 
0930 
0931 
0932 //             {"intt7_0", {0, "B3", 6, 1, "B0L109N"}}, // note : intt 7
0933 //             {"intt7_1", {1, "C1", 6, 1, "B0L009N"}}, 
0934 //             {"intt7_2", {2, "B1", 6, 1, "B0L110N"}}, 
0935 //             {"intt7_3", {3, "D1", 6, 1, "B1L112N"}}, 
0936 //             {"intt7_4", {4, "C2", 6, 1, "B1L012N"}}, 
0937 //             {"intt7_5", {5, "B2", 6, 1, "B1L113N"}}, 
0938 //             {"intt7_6", {6, "A1", 6, 1, "B1L013N"}}, 
0939 
0940 //             {"intt7_7", {7, "B2", 7, 1, "B0L010N"}}, 
0941 //             {"intt7_8", {8, "C2", 7, 1, "B0L111N"}}, 
0942 //             {"intt7_9", {9, "B1", 7, 1, "B0L011N"}},   
0943 //             {"intt7_10", {10, "D2", 7, 1, "B1L114N"}},     
0944 //             {"intt7_11", {11, "C3", 7, 1, "B1L014N"}},   
0945 //             {"intt7_12", {12, "B3", 7, 1, "B1L115N"}},   
0946 //             {"intt7_13", {13, "A1", 7, 1, "B1L015N"}}
0947 //         };
0948 
0949 //         pair<double,double> Get_dummy_ladder_XY(int chip_id, int chan_id);
0950 //         pair<double,double> Get_self_rotation( pair<double,double> chan_pos, double angle );
0951         
0952 // };
0953 
0954 // InttClutering::InttClutering()
0955 // {
0956 
0957 // }
0958 
0959 // pair<double,double> InttClutering::Get_XY_all(string ladder_name,/*string server, int module,*/ int chip_id, int chan_id)
0960 // {
0961 //     string ladder_pos_str = ladder_name;
0962 //     // string ladder_pos_str = string(serverFC_toinfo_map[Form("%s_%i",server.c_str(),module)].Ladder);
0963     
0964 //     int layer_index; 
0965 //     if      (ladder_pos_str.substr(0,4) == "B0L0") layer_index = 0;
0966 //     else if (ladder_pos_str.substr(0,4) == "B0L1") layer_index = 1;
0967 //     else if (ladder_pos_str.substr(0,4) == "B1L0") layer_index = 2;
0968 //     else if (ladder_pos_str.substr(0,4) == "B1L1") layer_index = 3;
0969 
0970 //     int ladder_index = stoi(ladder_pos_str.substr(4,2));
0971     
0972     
0973 //     double ladder_location_angle = ladder_location_angle_ini_correction[layer_index] -  (angle_increment[layer_index] * ladder_index);
0974 
0975 //     double ring_pos_x = layer_raduis[layer_index] * cos(ladder_location_angle / (180/TMath::Pi()));
0976 //     double ring_pos_y = layer_raduis[layer_index] * sin(ladder_location_angle / (180/TMath::Pi()));
0977 
0978 //     double ladder_self_pos_X = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id),( 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_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).first;
0979 //     double ladder_self_pos_Y = ( fabs(Get_self_rotation(Get_dummy_ladder_XY(chip_id,chan_id),( 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_self_angle_ini_correction[layer_index] - (angle_increment[layer_index] * ladder_index) )).second;
0980 
0981 //     return {ring_pos_x +  ladder_self_pos_X, ring_pos_y + ladder_self_pos_Y};
0982 // }
0983 
0984 // pair<double,double> InttClutering::Get_dummy_ladder_XY(int chip_id, int chan_id)
0985 // {
0986 //     // note : chip_id 1 ~ 13, 14 ~ 26
0987 //     int row_index = (chip_id > 0 && chip_id < 14) ? 0 : 1;
0988 
0989 //     double dummy_X = 0;
0990 //     double dummy_Y = (row_index == 0) ? -0.039 - (127 - chan_id) * 0.078 : 0.039 + (127 - chan_id) * 0.078;
0991 
0992 //     return {dummy_X,dummy_Y};
0993 // }
0994 
0995 // pair<double,double> InttClutering::Get_self_rotation( pair<double,double> chan_pos, double angle )
0996 // {
0997 //     return {chan_pos.second * cos(angle / (180/TMath::Pi())), chan_pos.second * sin(angle / (180/TMath::Pi()))};
0998 // }