24 {
25 char line[255];
26 std::string filename = std::string(getenv( "TRIGGERROOT" ));
27 filename += std::string("/data/tm/TM_BARREL.pat");
28 std::ifstream infile( filename.c_str() );
29 if(infile) {
30 while(infile) {
31 infile.getline(line,255);
32 if(line[0] == '#') continue;
33 std::string mdcId, tofId_l, tofId_h, emcId_l, emcId_h;
34 char* token = strtok( line, " " );
35 if ( token ) { mdcId = token; token = strtok(
NULL,
" " );}
else continue;
36 if ( token ) { tofId_l = token; token = strtok(
NULL,
" " );}
else continue;
37 if ( token ) { tofId_h = token; token = strtok(
NULL,
" " );}
else continue;
38 if ( token ) { emcId_l = token; token = strtok(
NULL,
" " );}
else continue;
39 if ( token ) { emcId_h = token; token = strtok(
NULL,
" " );}
else continue;
40 if ( token !=
NULL )
continue;
41
42
43 int i_tofId_l = atoi( tofId_l.c_str() );
44 int i_tofId_h = atoi( tofId_h.c_str() );
45 int i_emcId_l = atoi( emcId_l.c_str() );
46 int i_emcId_h = atoi( emcId_h.c_str() );
47
48 std::vector<int> tof_tmp;
49 std::vector<int> emc_tmp;
50
51 if(i_tofId_l > i_tofId_h) {
52 for(int i = i_tofId_l; i <= (i_tofId_h + 88); i++) {
53 if(i >= 88) tof_tmp.push_back(i - 88);
54 else tof_tmp.push_back(i);
55 }
56 }
57 else {
58 for(int i = i_tofId_l; i <= i_tofId_h; i++) {
59 tof_tmp.push_back(i);
60 }
61 }
62
63 if(i_emcId_l > i_emcId_h) {
64 for(int i = i_emcId_l; i <= (i_emcId_h + 30); i++) {
65 if(i >= 30) emc_tmp.push_back(i - 30);
66 else emc_tmp.push_back(i);
67 }
68 }
69 else {
70 for(int i = i_emcId_l; i <= i_emcId_h; i++) {
71 emc_tmp.push_back(i);
72 }
73 }
74 m_tm_barrel.push_back(tof_tmp);
75 m_tm_barrel.push_back(emc_tmp);
76 }
77 }
78 else {
79 std::cout << "Can not open file: " << filename << " in BesTMTrig. " << std::endl;
80 }
81
82 filename = std::string(getenv( "TRIGGERROOT" ));
83 filename += std::string("/data/tm/TM_EAST_ENDCAP.pat");
84 std::ifstream infile1( filename.c_str() );
85 if(infile1) {
86 while(infile1) {
87 infile1.getline(line,255);
88 if(line[0] == '#') continue;
89 std::string mdcId, tofId_l, tofId_h, emcId_l, emcId_h;
90 char* token = strtok( line, " " );
91 if ( token ) { mdcId = token; token = strtok(
NULL,
" " );}
else continue;
92 if ( token ) { tofId_l = token; token = strtok(
NULL,
" " );}
else continue;
93 if ( token ) { tofId_h = token; token = strtok(
NULL,
" " );}
else continue;
94 if ( token ) { emcId_l = token; token = strtok(
NULL,
" " );}
else continue;
95 if ( token ) { emcId_h = token; token = strtok(
NULL,
" " );}
else continue;
96 if ( token !=
NULL )
continue;
97
98
99 int i_tofId_l = atoi( tofId_l.c_str() );
100 int i_tofId_h = atoi( tofId_h.c_str() );
101 int i_emcId_l = atoi( emcId_l.c_str() );
102 int i_emcId_h = atoi( emcId_h.c_str() );
103
104 std::vector<int> tof_tmp;
105 std::vector<int> emc_tmp;
106
107 if(i_tofId_l > i_tofId_h) {
108 for(int i = i_tofId_l; i <= (i_tofId_h + 24); i++) {
109 if(i >= 24) tof_tmp.push_back(i - 24);
110 else tof_tmp.push_back(i);
111 }
112 }
113 else {
114 for(int i = i_tofId_l; i <= i_tofId_h; i++) {
115 tof_tmp.push_back(i);
116 }
117 }
118
119 if(i_emcId_l > i_emcId_h) {
120 for(int i = i_emcId_l; i <= (i_emcId_h + 16); i++) {
121 if(i >= 16) emc_tmp.push_back(i - 16);
122 else emc_tmp.push_back(i);
123 }
124 }
125 else {
126 for(int i = i_emcId_l; i <= i_emcId_h; i++) {
127 emc_tmp.push_back(i);
128 }
129 }
130 m_tm_ecap.push_back(tof_tmp);
131 m_tm_ecap.push_back(emc_tmp);
132 }
133 }
134 else {
135 std::cout << "Can not open file: " << filename << " in BesTMTrig. " << std::endl;
136 }
137
138
139 filename = std::string(getenv( "TRIGGERROOT" ));
140 filename += std::string("/data/tm/TM_WEST_ENDCAP.pat");
141 std::ifstream infile2( filename.c_str() );
142 if(infile2) {
143 while(infile2) {
144 infile2.getline(line,255);
145 if(line[0] == '#') continue;
146 std::string mdcId, tofId_l, tofId_h, emcId_l, emcId_h;
147 char* token = strtok( line, " " );
148 if ( token ) { mdcId = token; token = strtok(
NULL,
" " );}
else continue;
149 if ( token ) { tofId_l = token; token = strtok(
NULL,
" " );}
else continue;
150 if ( token ) { tofId_h = token; token = strtok(
NULL,
" " );}
else continue;
151 if ( token ) { emcId_l = token; token = strtok(
NULL,
" " );}
else continue;
152 if ( token ) { emcId_h = token; token = strtok(
NULL,
" " );}
else continue;
153 if ( token !=
NULL )
continue;
154
155
156 int i_tofId_l = atoi( tofId_l.c_str() );
157 int i_tofId_h = atoi( tofId_h.c_str() );
158 int i_emcId_l = atoi( emcId_l.c_str() );
159 int i_emcId_h = atoi( emcId_h.c_str() );
160
161 std::vector<int> tof_tmp;
162 std::vector<int> emc_tmp;
163
164 if(i_tofId_l > i_tofId_h) {
165 for(int i = i_tofId_l; i <= (i_tofId_h + 24); i++) {
166 if(i >= 24) tof_tmp.push_back(i - 24);
167 else tof_tmp.push_back(i);
168 }
169 }
170 else {
171 for(int i = i_tofId_l; i <= i_tofId_h; i++) {
172 tof_tmp.push_back(i);
173 }
174 }
175
176 if(i_emcId_l > i_emcId_h) {
177 for(int i = i_emcId_l; i <= (i_emcId_h + 16); i++) {
178 if(i >= 16) emc_tmp.push_back(i - 16);
179 else emc_tmp.push_back(i);
180 }
181 }
182 else {
183 for(int i = i_emcId_l; i <= i_emcId_h; i++) {
184 emc_tmp.push_back(i);
185 }
186 }
187 m_tm_wcap.push_back(tof_tmp);
188 m_tm_wcap.push_back(emc_tmp);
189 }
190 }
191 else {
192 std::cout << "Can not open file: " << filename << " in BesTMTrig. " << std::endl;
193 }
194 infile.close();
195 infile1.close();
196 infile2.close();
197
198}