BmnRoot
Loading...
Searching...
No Matches
CreateMapTof400_BMN_12_2016.c
Go to the documentation of this file.
1
2#include <TMath.h>
3#include "TString.h"
4#include <iostream>
5#include "Riostream.h"
6#include <string>
7#include <fstream>
8#include <sstream>
9
10void CreateMapTof400_BMN_12_2016(std::string placementMapFile, std::string mapFile)
11{
12
13 Int_t MapR[24] = {3, 0, 9, 6, 4, 1, 10, 7, 5, 2, 11, 8, 18, 21, 12, 15, 19, 22, 13, 16, 20, 23, 14, 17};
14 Int_t MapL[24] = {20, 23, 14, 17, 19, 22, 13, 16, 18, 21, 12, 15, 5, 2, 11, 8, 4, 1, 10, 7, 3, 0, 9, 6};
15 //Int_t MapL[24] = {4, 1, 10, 7, 5, 2, 11, 8, 6, 3, 12, 9, 19, 22, 13, 16, 20, 23, 14, 17, 21, 0, 15, 18};
16 //Int_t MapR[24] = {21, 0, 15, 18, 20, 23, 14, 17, 19, 22, 13, 16, 6, 3, 12, 9, 5, 2, 11, 8, 4, 1, 10, 7};
17
18 //UInt_t crate = 0x01690454;
19 UInt_t crate = 0x06ea9711;
20 static const Int_t kNSlot = 23;
21 UInt_t slot[kNSlot] = {0.};
22 slot[1] = 0x06e9da86;
23 slot[2] = 0x06e9da91;
24 slot[3] = 0x076caef6;
25 slot[4] = 0x076cae7b;
26 slot[5] = 0x046f332f;
27 slot[6] = 0x06e9404b;
28 slot[7] = 0x06e9e4b0;
29 slot[14] = 0x046f408c;
30 slot[15] = 0x06e94033;
31 slot[16] = 0x076cae7a;
32 slot[17] = 0x07a8deb2;
33 slot[18] = 0x076cad52;
34 slot[19] = 0x076ccf62;
35 slot[20] = 0x06e940be;
36
37 fstream ff;
38
39 //1.Placement map
40 ff.open(placementMapFile.c_str(), std::fstream::out);
41 if (ff.fail())
42 {
43 cerr << "Cannot open the file " << placementMapFile << endl;
44 return;
45 }
46 for (Int_t i = 0; i < kNSlot; i++)
47 if (slot[i] != 0)
48 {
49 ff << std::hex << std::setfill('0') << std::setw(8) << crate << '\t';
50 ff << std::dec << i << '\t';
51 ff << std::hex << std::setfill('0') << std::setw(8) << slot[i] << endl;
52 }
53 ff.close();
54
55
56 Int_t Num = 14516;
57 cout << "Num = " << Num << endl;
58 cout << "GetSlot(Num) = " << GetSlot(Num) << " GetCon(Num) = " << GetCon(Num) << endl;
59 cout << "GetDet(Num) = " << GetDet(Num) << " GetSide(Num) = " << GetSide(Num) << endl;
60
61
62 //create Map for Cosmic Test Setup
63 ff.open(mapFile.c_str(), std::fstream::out);
64 if (ff.fail())
65 {
66 cerr << "Cannot open the file " << mapFile << endl;
67 return;
68 }
69
70 static const Int_t kNIt = 4;
71 static const Int_t kNDet = 10+1;
72 Int_t MapDet[kNDet][kNIt] = {
73 {1002, 1101, 1204, 2003},
74 {2112, 2211, 3014, 3113},
75 {3222, 4021, 4124, 4223},
76 {5032, 5131, 5234, 6033},
77 {6142, 6241, 7044, 7143},
78 {14052, 14151, 14254, 15053},
79 {15162, 15261, 16064, 16163},
80 {16272, 17071, 17174, 17273},
81 {18082, 18181, 18284, 19083},
82 {19192, 19291, 20094, 20193},
83 {7205, 20205, 7205, 20205}
84 };
85
86 //first number - slot 1-22, second number - connector (0 - 0..23, 1 - 24..47, 2 - 48..71
87 //third - detector , fourth - side (1,2 - L, 3,4 - R)
88
89
90 for (Int_t det = 0; det < kNDet; det++)
91 {
92 for (Int_t i = 0; i < kNIt; i++)
93 {
94 for (Int_t j = 0; j < 24; j++)
95 {
96 /*
97 cout << std::dec << "MapDet = " << MapDet[det][i] << "; Det = " << det << "; i = " << i << "; j = " << j << "; slot = " << slot[GetSlot(MapDet[det][i])]
98 << "; chTDC = " << j + 24 * GetCon(MapDet[det][i]) << "; GetDet = " << GetDet(MapDet[det][i])
99 << "; GetSide = " << GetSide(MapDet[det][i]) << endl;
100 getchar();
101 */
102
103 ff << std::hex << std::setfill('0') << std::setw(8) << slot[GetSlot(MapDet[det][i])] << std::setfill(' ') << '\t';
104 ff << std::dec << j + 24 * GetCon(MapDet[det][i]) << '\t';
105 ff << GetDet(MapDet[det][i]) << '\t';
106 if (GetSide(MapDet[det][i]) == 1 || GetSide(MapDet[det][i]) == 2)
107 {
108 if (det < 5) ff << 47 - (MapL[j] + (GetSide(MapDet[det][i]) - 1)*24) << '\t';
109 else ff << MapL[j] + (GetSide(MapDet[det][i]) - 1)*24 << '\t';
110 //ff << MapL[j] + (GetSide(MapDet[det][i]) - 1)*24 << '\t';
111 ff << 'L';
112 ff << endl;
113 }
114 else if (GetSide(MapDet[det][i]) == 3 || GetSide(MapDet[det][i]) == 4)
115 {
116 if (det < 5) ff << 47 - (MapR[j] + (GetSide(MapDet[det][i]) - 3)*24) << '\t';
117 else ff << MapR[j] + (GetSide(MapDet[det][i]) - 3)*24 << '\t';
118 //ff << MapR[j] + (GetSide(MapDet[det][i]) - 3)*24 << '\t';
119 ff << 'R';
120 ff << endl;
121 }
122 else
123 {
124 ff << -1 << '\t';
125 ff << 'L';
126 ff << endl;
127 }
128 }
129 }
130 }
131
132}
133
134Int_t GetSlot(Int_t number)
135{
136 Int_t temp = static_cast<int> number / 1000.;
137 return temp;
138}
139
140Int_t GetCon(Int_t number)
141{
142 Int_t temp = static_cast<int>(number - GetSlot(number)*1000.) / 100.;
143 return temp;
144}
145
146Int_t GetDet(Int_t number)
147{
148 Int_t temp = static_cast<int>(number - GetSlot(number)*1000. - GetCon(number)*100.) / 10.;
149 return temp;
150}
151
152Int_t GetSide(Int_t number)
153{
154 Int_t temp = static_cast<int>(number - GetSlot(number)*1000. - GetCon(number)*100. - GetDet(number)*10.);
155 return temp;
156}
void CreateMapTof400_BMN_12_2016(std::string placementMapFile, std::string mapFile)
Int_t GetSide(Int_t number)
Int_t GetSlot(Int_t number)
Int_t GetCon(Int_t number)
Int_t GetDet(Int_t number)
int i
Definition P4_F32vec4.h:22