Changeset 486 for trunk/MagicSoft
- Timestamp:
- 01/12/01 19:00:08 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx
r459 r486 53 53 fwhm_resp = RESPONSE_FWHM ; 54 54 ampl_resp = RESPONSE_AMPLITUDE ; 55 55 56 overlaping_time = TRIGGER_OVERLAPING; 57 56 58 threshold = CHANNEL_THRESHOLD ; 57 59 … … 90 92 sscanf (datac, "%s %f", dummy, &l_resp ) ; 91 93 } 94 else if ( strncmp (datac, "overlaping", 10 ) == 0 ) { 95 sscanf (datac, "%s %f", dummy, &overlaping_time ) ; 96 } 92 97 else if ( strncmp (datac, "multiplicity", 12 ) == 0 ) { 93 98 sscanf (datac, "%s %f", dummy, &trigger_multi ) ; … … 126 131 } 127 132 cout << "[MTrigger] Gate Length: " << gate_leng << " ns" 133 << endl ; 134 cout << "[MTrigger] Overlaping time: " << overlaping_time << " ns" 128 135 << endl ; 129 136 cout << "[MTrigger] Response FWHM: " << fwhm_resp << " ns" … … 262 269 263 270 // 271 // Read in the lookup table for trigger cells 272 // 273 274 i = 0 ; 275 276 if ( (unit = fopen("../include-MTrigger/TABLE_PIXELS_IN_CELLS", "r" )) == 0 ) { 277 cout << "ERROR: not able to read ../include-MTrigger/TABLE_PIXELS_IN_CELLS" 278 << endl ; 279 exit(123) ; 280 } 281 else { 282 while ( i < TRIGGER_PIXELS ) 283 { 284 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 285 TC[k][i]=FALSE; 286 } 287 i++ ; 288 } 289 while ( feof(unit) == 0 ) { 290 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 291 fscanf ( unit, "%d ", &i ) ; 292 if ((i-1)<TRIGGER_PIXELS) 293 TC[k][i-1]=TRUE; 294 } 295 } 296 fclose (unit) ; 297 } 298 299 300 // 264 301 // 265 302 // set all the booleans used to FALSE, indicating that the pixel is not … … 301 338 } 302 339 303 MTrigger::MTrigger(float gate, float ampl, float fwhm) {340 MTrigger::MTrigger(float gate, float overt, float ampl, float fwhm) { 304 341 // ============================================================ 305 342 // … … 333 370 fwhm_resp = fwhm ; 334 371 ampl_resp = ampl ; 372 373 overlaping_time = overt; 374 335 375 336 376 threshold = CHANNEL_THRESHOLD ; … … 344 384 << "[MTrigger] Setting up the MTrigger with this values "<< endl ; 345 385 cout << "[MTrigger] Gate Length: " << gate_leng << " ns" 386 << endl ; 387 cout << "[MTrigger] Overlaping time: " << overlaping_time << " ns" 346 388 << endl ; 347 389 cout << "[MTrigger] Response FWHM: " << fwhm_resp << " ns" … … 453 495 454 496 // 497 // Read in the lookup table for trigger cells 498 // 499 500 i = 0 ; 501 502 if ( (unit = fopen("../include-MTrigger/TABLE_PIXELS_IN_CELLS", "r" )) == 0 ) { 503 cout << "ERROR: not able to read ../include-MTrigger/TABLE_PIXELS_IN_CELLS" 504 << endl ; 505 exit(123) ; 506 } 507 else { 508 while ( i < TRIGGER_PIXELS ) 509 { 510 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 511 TC[k][i]=FALSE; 512 } 513 i++ ; 514 } 515 while ( feof(unit) == 0 ) { 516 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 517 fscanf ( unit, "%d ", &i ) ; 518 if((i-1)<TRIGGER_PIXELS) 519 TC[k][i-1]=TRUE; 520 } 521 } 522 fclose (unit) ; 523 } 524 525 526 // 455 527 // 456 528 // set all the booleans used to FALSE, indicating that the pixel is not … … 496 568 // destructor 497 569 // 498 // cout << "destructor of MTrigger" << endl ;499 570 int i; 571 500 572 delete histPmt ; 501 573 502 for( Int_ti=0;i<TRIGGER_PIXELS;i++){503 // 504 // 505 } 506 574 for(i=0;i<TRIGGER_PIXELS;i++){ 575 //delete [] a_sig[i]; 576 //delete [] d_sig[i]; 577 } 578 507 579 delete GenElec; 508 509 580 } 510 581 … … 1104 1175 if (SlicesZero[iSli]){ 1105 1176 // 1106 // then look in all pixel if the diskriminated signal is 1 1177 // Loop over trigger cells. It is topology analisy, 1178 // therefore it is keep here after multiplicity and 1179 // threshold checks. 1107 1180 // 1181 1182 for(Int_t iCell=0; iCell<TRIGGER_CELLS; iCell++){ 1183 // 1184 // then look in all pixel of that cell if the 1185 // diskriminated signal is 1 1186 // 1187 for ( Int_t iPix = 0 ; iPix < TRIGGER_PIXELS; iPix++ ) { 1188 Muster[iPix] = kFALSE ; 1189 Neighb[iPix] = kFALSE ; 1190 // Select pixels which are used and it the current cell 1191 if ( used [iPix] == TRUE && TC[iCell][iPix]==TRUE) { 1192 // 1193 // now check the diskriminated signal 1194 // 1195 if ( d_sig [iPix][iSli] > 0. ) { 1196 Muster[iPix] = kTRUE ; 1197 } 1198 } 1199 } // end of loop over the pixels 1200 1201 // 1202 // Here we check which of the "muster" pixels will be fired for 1203 // the minimum required overlaping time 1204 // 1205 1206 OverlapingTime(Muster, &Muster[0],iSli); 1207 1208 // 1209 // here we have to look for the topologies 1210 // 1108 1211 1109 for ( Int_t iPix = 0 ; iPix < TRIGGER_PIXELS; iPix++ ) { 1110 Muster[iPix] = kFALSE ; 1111 Neighb[iPix] = kFALSE ; 1112 if ( used [iPix] == TRUE ) { 1113 // 1114 // now check the diskriminated signal 1115 // 1116 if ( d_sig [iPix][iSli] > 0. ) { 1117 Muster[iPix] = kTRUE ; 1118 } 1119 } 1120 } // end of loop over the pixels 1121 1122 // 1123 // here we have to look for the topologies 1124 // 1125 1126 switch(trigger_geometry){ 1127 case 0:{ 1212 switch(trigger_geometry){ 1213 case 0:{ 1128 1214 1129 // It looks for a pixel above threshold which has 1130 // trigger_multi-1 neighbour pixels above threshold 1131 1132 Bool_t Dummy[TRIGGER_PIXELS] ; 1133 1134 // Loop over all pixels 1135 for (int j=0;j<TRIGGER_PIXELS;j++){ 1136 1137 // 1138 // I commented out this line here 1139 // Dummy=Muster; 1140 1141 for (int k=0; k<TRIGGER_PIXELS; k++){ 1142 Neighb[k]=kFALSE; 1143 1144 Dummy[k] = Muster[k] ; 1145 } 1146 if(Muster[j]){ 1147 // If pixel is fired, it checks how many fired neighbours it has 1148 for (iMulti=1;iMulti<trigger_multi; iMulti++) { 1149 Neighb[j] = kTRUE ; 1150 Dummy[j] = kTRUE ; 1151 if (!PassNextNeighbour(Dummy, &Neighb[0])){ 1152 break; 1153 } 1154 for (int k=0; k<TRIGGER_PIXELS; k++){ 1155 if (Neighb[k]){ 1156 Dummy[k]=kFALSE; 1157 Neighb[k]=kFALSE; 1215 // It looks for a pixel above threshold which has 1216 // trigger_multi-1 neighbour pixels above threshold 1217 1218 Bool_t Dummy[TRIGGER_PIXELS] ; 1219 1220 // Loop over all pixels 1221 for (int j=0;j<TRIGGER_PIXELS;j++){ 1222 1223 for (int k=0; k<TRIGGER_PIXELS; k++){ 1224 Neighb[k]=kFALSE; 1225 1226 Dummy[k] = Muster[k] ; 1227 } 1228 if(Muster[j]){ 1229 // If pixel is fired, it checks how many fired neighbours it has 1230 for (iMulti=1;iMulti<trigger_multi; iMulti++) { 1231 Neighb[j] = kTRUE ; 1232 Dummy[j] = kTRUE ; 1233 if (!PassNextNeighbour(Dummy, &Neighb[0])){ 1234 break; 1235 } 1236 for (int k=0; k<TRIGGER_PIXELS; k++){ 1237 if (Neighb[k]){ 1238 Dummy[k]=kFALSE; 1239 Neighb[k]=kFALSE; 1240 } 1158 1241 } 1159 1242 } 1243 if (iMulti==trigger_multi ) { 1244 // 1245 // A NN-Trigger is detected at time Slice 1246 // 1247 PixelsFirst[nFirst] = j; // We save pixel that triggers 1248 SlicesFirst[nFirst++] = iSli ; // We save time when it triggers 1249 iReturn++ ; 1250 iSli+=(50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1251 iCell=TRIGGER_CELLS; // We skip the remaining trigger cells 1252 break ; 1253 } 1160 1254 } 1161 if (iMulti==trigger_multi ) {1162 //1163 // A NN-Trigger is detected at time Slice1164 //1165 PixelsFirst[nFirst] = j; // We save pixel that triggers1166 SlicesFirst[nFirst++] = iSli ; // We save time when it triggers1167 iReturn++ ;1168 iSli+=(50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time)1169 break ;1170 }1171 1255 } 1172 } 1173 break; 1174 }; 1256 break; 1257 }; 1175 1258 1176 case 1:{ 1177 1178 // It looks for trigger_multi neighbour pixels above the 1179 // threshold. 1180 1181 for (int j=0;j<TRIGGER_PIXELS;j++){ 1182 if(Muster[j]){ 1183 // It checks if you can find 1184 // trigger_multi fired neighbour pixels 1185 Neighb[j] = kTRUE ; 1186 for (iMulti=1;iMulti<trigger_multi; iMulti++) { 1187 if (!PassNextNeighbour(Muster, &Neighb[0])) 1188 break; 1189 } 1190 if (iMulti==trigger_multi ) { 1191 // 1192 // A NN-Trigger is detected at time Slice 1193 // 1194 PixelsFirst[nFirst] = j; // We save pixel that triggers 1195 SlicesFirst[nFirst++] = iSli ; // We save when it triggers 1196 iReturn++ ; 1197 iSli+=(50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1198 break ; 1199 } 1200 else { 1201 // We put Neighb to kFALSE to check an other pixel 1202 for (int k=0; k<TRIGGER_PIXELS; k++){ 1203 if (Neighb[k]){ 1204 Neighb[k]=kFALSE; 1259 case 1:{ 1260 1261 // It looks for trigger_multi neighbour pixels above the 1262 // threshold. 1263 1264 for (int j=0;j<TRIGGER_PIXELS;j++){ 1265 if(Muster[j]){ 1266 // It checks if you can find 1267 // trigger_multi fired neighbour pixels 1268 Neighb[j] = kTRUE ; 1269 for (iMulti=1;iMulti<trigger_multi; iMulti++) { 1270 if (!PassNextNeighbour(Muster, &Neighb[0])) 1271 break; 1272 } 1273 if (iMulti==trigger_multi ) { 1274 // 1275 // A NN-Trigger is detected at time Slice 1276 // 1277 PixelsFirst[nFirst] = j; // We save pixel that triggers 1278 SlicesFirst[nFirst++] = iSli ; // We save when it triggers 1279 iReturn++ ; 1280 iSli+=(50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1281 iCell=TRIGGER_CELLS; // We skip the remaining trigger cells 1282 break ; 1283 } 1284 else { 1285 // We put Neighb to kFALSE to check an other pixel 1286 for (int k=0; k<TRIGGER_PIXELS; k++){ 1287 if (Neighb[k]){ 1288 Neighb[k]=kFALSE; 1289 } 1205 1290 } 1206 1291 } 1207 1292 } 1208 1293 } 1294 break; 1295 }; 1296 case 2:{ 1297 1298 // It looks for trigger_multi closed pack neighbours 1299 // above threshold 1300 // Closed pack means that you can take out any pixel 1301 // and you will still get a trigger for trigger_multi -1 1302 // The algorithm is not perfect, there still somes cases 1303 // that are not really well treated 1304 1305 Int_t closed_pack = 1; 1306 1307 for (int j=0;j<TRIGGER_PIXELS;j++){ 1308 if(Muster[j]){ 1309 // It checks if there are trigger_multi 1310 // neighbours above threshold 1311 1312 Neighb[j] = kTRUE ; 1313 iMulti=1; 1314 1315 //while(PassNextNeighbour(Muster, &Neighb[0])) iMulti++; 1316 for (iMulti=1;iMulti<trigger_multi;iMulti++){ 1317 if (!PassNextNeighbour(Muster, &Neighb[0])) 1318 break; 1319 } 1320 1321 if (iMulti==trigger_multi ) { 1322 // 1323 // A NN-Trigger is detected at time Slice 1324 // 1325 1326 // Check if there is closed pack topology 1327 1328 Bool_t Aux1[TRIGGER_PIXELS]; 1329 Bool_t Aux2[TRIGGER_PIXELS]; 1330 for (int jj=0;jj<TRIGGER_PIXELS;jj++) 1331 Aux2[jj]=kFALSE; 1332 1333 for (int i=0;i<TRIGGER_PIXELS;i++){ 1334 if (Neighb[i]) { 1335 // Loop over pixels that achive neighbouring condition 1336 1337 for (int jj=0;jj<TRIGGER_PIXELS;jj++) { 1338 1339 Aux1[jj] = Neighb[jj] ; // huschel 1340 Aux2[jj]=kFALSE; 1341 } 1342 1343 // It checks if taking out any of the pixels we lose 1344 // neighbouring condition for trigger_multi -1 1345 1346 Aux1[i]=kFALSE; 1347 closed_pack=0; 1348 for (int jj=0;jj<TRIGGER_PIXELS;jj++) { 1349 if (Aux1[jj]==kTRUE){ 1350 Aux2[jj]=kTRUE; 1351 for (iMulti=1;iMulti<(trigger_multi-1);iMulti++){ 1352 if (!PassNextNeighbour(Aux1, &Aux2[0])) 1353 break; 1354 } 1355 if (iMulti==(trigger_multi-1)){ 1356 // We found a NN trigger for trigger_multi -1 1357 // taking out pixel jj 1358 closed_pack=1; 1359 break; 1360 } 1361 Aux2[jj]=kFALSE; 1362 } 1363 } 1364 if (!closed_pack) break; 1365 // For some pixell we did not found NN condition 1366 // for trigger_multi -1 1367 } 1368 } 1369 if (closed_pack){ 1370 PixelsFirst[nFirst] = j; // We save pixel that triggers 1371 SlicesFirst[nFirst++] = iSli ; // We save time when it triggers 1372 iReturn++ ; 1373 iSli+=(50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1374 iCell=TRIGGER_CELLS; // We skip the remaining trigger cells 1375 break ; 1376 } 1377 else { 1378 for (int k=0; k<TRIGGER_PIXELS; k++){ 1379 if (Neighb[k]){ 1380 Neighb[k]=kFALSE; 1381 } 1382 } 1383 } 1384 } // end if trigger multiplicity achived 1385 else{ 1386 for (int k=0; k<TRIGGER_PIXELS; k++) 1387 Neighb[k]=kFALSE; 1388 } 1389 } // end if pixel fired 1390 } // end loop trigger pixels 1391 break; 1392 }; // end case 2: 1393 default:{ 1394 cout << "This topology is not implemented yet"<<endl; 1395 break; 1209 1396 } 1210 break;1211 };1212 case 2:{1213 1214 // It looks for trigger_multi closed pack neighbours1215 // above threshold1216 // Closed pack means that you can take out any pixel1217 // and you will still get a trigger for trigger_multi -11218 1219 Int_t closed_pack = 1;1220 1221 for (int j=0;j<TRIGGER_PIXELS;j++){1222 if(Muster[j]){1223 // It checks if there are trigger_multi1224 // neighbours above threshold1225 Neighb[j] = kTRUE ;1226 for (iMulti=1;iMulti<trigger_multi; iMulti++){1227 if (!PassNextNeighbour(Muster, &Neighb[0]))1228 break;1229 }1230 if (iMulti==trigger_multi ) {1231 //1232 // A NN-Trigger is detected at time Slice1233 //1234 1235 // Check if there is closed pack topology1236 Bool_t Aux1[TRIGGER_PIXELS];1237 Bool_t Aux2[TRIGGER_PIXELS];1238 for (int jj=0;jj<TRIGGER_PIXELS;jj++)1239 Aux2[jj]=kFALSE;1240 1241 for (int i=0;i<TRIGGER_PIXELS;i++){1242 if (Neighb[i]) {1243 // Loop over pixels that achive neighbouring condition1244 1245 // huschel1246 // here also some corrections were neccessary1247 //1248 //Aux1=Neighb;1249 1250 for (int jj=0;jj<TRIGGER_PIXELS;jj++) {1251 Aux1[jj] = Neighb[jj] ; // huschel1252 1253 Aux2[jj]=kFALSE;1254 }1255 1256 Aux1[i]=kFALSE;1257 Aux2[j]=kTRUE;1258 // It checks if taking any of the pixels we lose1259 // neighbouring condition for trigger -11260 for (iMulti=1;iMulti<(trigger_multi-1);iMulti++){1261 if (!PassNextNeighbour(Aux1, &Aux2[0]))1262 break;1263 }1264 if (iMulti<(trigger_multi-1)){1265 closed_pack=0;1266 break;1267 }1268 1269 }1270 }1271 if (closed_pack){1272 PixelsFirst[nFirst] = j; // We save pixel that triggers1273 SlicesFirst[nFirst++] = iSli ; // We save time when it triggers1274 iReturn++ ;1275 iSli+=(50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time)1276 break ;1277 }1278 else {1279 for (int k=0; k<TRIGGER_PIXELS; k++){1280 if (Neighb[k]){1281 Neighb[k]=kFALSE;1282 }1283 }1284 }1285 }1286 else1287 for (int k=0; k<TRIGGER_PIXELS; k++)1288 Neighb[k]=kFALSE;1289 }1290 1397 } 1291 break; 1292 }; 1293 default:{ 1294 cout << "This topology is not implemented yet"<<endl; 1295 break; 1296 } 1297 } 1398 } //end loop over trigger cells. 1298 1399 } 1299 1400 } // end of loop over the slices … … 1352 1453 } 1353 1454 } 1354 1455 else break; 1355 1456 } 1356 1457 } … … 1375 1476 return(PixelsFirst[il]); 1376 1477 } 1478 1479 void MTrigger::OverlapingTime ( Bool_t m[], Bool_t *n, Int_t ifSli){ 1480 1481 //============================================================ 1482 // 1483 // It returns in n the pixels of m that are fired during the 1484 // required overlaping time for trigger after ifSli 1485 1486 int i,j; 1487 int iNumSli; 1488 1489 // Translation from ns to slices 1490 iNumSli=(int) (overlaping_time*SLICES_PER_NSEC); 1491 if (iNumSli<1) iNumSli=1; 1492 1493 // Put pixels that fulfill the requirement in n 1494 for (i=0;i<TRIGGER_PIXELS;i++){ 1495 if (m[i]==kTRUE){ 1496 for(j=ifSli;j<ifSli+iNumSli;j++){ 1497 if(!d_sig[i][j]){ 1498 n[i]=kFALSE; 1499 break; 1500 } 1501 } 1502 } 1503 } 1504 1505 } 1506 1507 1508
Note:
See TracChangeset
for help on using the changeset viewer.