10 using std::stringstream;
12 #define FREE(_x_) { free(_x_); _x_ = nullptr; }
32 vector < t2list >
out;
58 for (
int j = 0; j < nt2; j++)
59 if ((input[j].time > msec - 100) && (input[j].time < msec + 100))
68 for (
int j = 0; j < nt2; j++)
69 if ((input[j].
time > msec - 100) && (input[j].
time < msec + 100)) {
80 int total = nbt2inbin[0] + nbt2inbin[1] + nbt2inbin[2] + nbt2inbin[3] + nbt2inbin[4];
81 static struct t2 *liste[100];
86 if (total >= minstat && nbt2inbin[j] > 0) {
89 if (total >= MAXSTATINONEBIN) {
93 for (k = 0; k < nbt2inbin[j]; k++) {
96 for (l = -2; l < 3; l++)
97 for (m = 0; m < nbt2inbin[j + l]; m++)
98 cour[(
int)
neighbour[listt2inbin[j][k]->ID *
ROW + (int) listt2inbin[j + l][m]->
ID]]++;
104 for (l = -2; l < 3; l++)
105 for (m = 0; m < nbt2inbin[j + l]; m++)
106 liste[index++] = listt2inbin[j + l][m];
108 for (l = 0; l < total; l++) {
119 for (i = 0; i < total; i++) {
120 for (l = i + 1; l < total; l++) {
121 if (liste[i]->
ID == liste[l]->
ID) {
133 for (l = 0; l < total; l++) {
147 total += nbt2inbin[j + 3] - nbt2inbin[j - 2];
148 nbt2inbin[j - 2] = 0;
154 static struct t2 min;
155 int nt2cm = 0, ntot = 0;
158 int mink, supp, tcm, tdn, tmr, nbstat;
159 static struct t2list t2mergedclusters[1000];
183 s <<
"Too many extra triggers: " <<
nextra;
187 for (j = 0; j <
nextra; j++) {
215 for (j = 0; j < nt2; j++) {
216 if (input[j].time > 1000000) {
218 s <<
"Time too big: " << input[j].
time <<
" from LS " << input[j].
ID;
221 if (input[j].ID<100)
continue;
222 if (input[j].time > 1000000)
continue;
225 if (input[j].time > 1000000 - 5*
binsize) {
229 s <<
"Too many new extra triggers: " << nextra <<
", removing 100";
235 compteurt2[k][l] = &input[j];
243 compteurtot[k][l] = &input[j];
249 s <<
"TOT triggers: " << ntot;
265 t2mergedclusters[j].
point = (
struct t2 *) malloc(t2mergedclusters[j].nelem *
sizeof(
struct t2));
275 *(t2mergedclusters[j].
point + k) = min;
286 if ((t2mergedclusters[i].nelem>0 && t2mergedclusters[j].nelem>0) && (
abs((*(t2mergedclusters[j].point)).
time - (*(t2mergedclusters[i].point)).
time) < 100)) {
288 for (k = 0; k < t2mergedclusters[j].
nelem; k++) {
289 for (m = 0; m < t2mergedclusters[i].
nelem; m++) {
290 if (((*(t2mergedclusters[j].point + k)).
ID == (*(t2mergedclusters[i].point + m)).
ID)
291 && ((*(t2mergedclusters[j].point + k)).time == (*(t2mergedclusters[i].point + m)).time)) {
299 s <<
"supperposition of " << i <<
" and " << j;
304 if (strstr(t2mergedclusters[i].algo,
"TOT")) t2mergedclusters[j].algo=t2mergedclusters[i].algo;
305 for (m = 0; m < t2mergedclusters[i].
nelem; m++) {
307 for (k = 0; k < t2mergedclusters[j].
nelem; k++) {
308 if (((*(t2mergedclusters[j].point + k)).
ID == (*(t2mergedclusters[i].point + m)).
ID)
309 && ((*(t2mergedclusters[j].
point + k)).time == (*(t2mergedclusters[i].
point +
m)).time)) {
315 t2mergedclusters[j].
nelem++;
316 t2mergedclusters[j].
point = (
struct t2 *) realloc(t2mergedclusters[j].point, t2mergedclusters[j].nelem *
sizeof(
struct t2));
317 *(t2mergedclusters[j].
point + t2mergedclusters[j].
nelem - 1) = *(t2mergedclusters[i].point + m);
321 t2mergedclusters[i].
nelem = 0;
322 FREE(t2mergedclusters[i].point);
331 for (k = 0; k < t2mergedclusters[j].
nelem; k++)
332 s << (*(t2mergedclusters[j].point + k)).time <<
" " << (*(t2mergedclusters[j].
point + k)).ID <<
", ";
333 if (t2mergedclusters[j].nelem > 0)
340 for (k = 0; k < t2mergedclusters[j].
nelem; k++) {
341 if ((*(t2mergedclusters[j].point + k)).ID ==
CARMEN) tcm++;
342 if ((*(t2mergedclusters[j].point + k)).ID ==
MIRANDA) tcm++;
343 if ((*(t2mergedclusters[j].point + k)).ID ==
DIA) tdn++;
344 if ((*(t2mergedclusters[j].point + k)).ID ==
NOCHE) tdn++;
345 if ((*(t2mergedclusters[j].point + k)).ID ==
MOULIN) tmr++;
346 if ((*(t2mergedclusters[j].point + k)).ID ==
ROUGE) tmr++;
348 nbstat = t2mergedclusters[j].
nelem;
349 if (tcm == 2) nbstat--;
350 if (tdn == 2) nbstat--;
351 if (tmr == 2) nbstat--;
352 if (t2mergedclusters[j].nelem > 0 && nbstat >= 3)
353 out.push_back(t2mergedclusters[j]);
362 static struct t2list event;
364 int chosen = (int) (1.0 * nt2 * rand() / (RAND_MAX + 1.0));
365 event.point = (
struct t2 *) malloc(
sizeof(
struct t2));
366 event.algo = (
char *)
"RANDOM";
367 event.point[0] = input[chosen];
369 out.push_back(event);
373 for (j = 0; j < nt2; j++)
375 static struct t2list event;
377 event.point = (
struct t2 *) malloc(
sizeof(
struct t2));
378 event.algo = (
char *)
"OBSERVER";
379 event.point[0] = input[j];
380 out.push_back(event);
388 for (i = 0; i < nt2cm; i++)
389 for (j = 0; j < nt2cm; j++)
395 static struct t2list event;
397 event.
algo = (
char *)
"CARMEN_MIRANDA";
401 event.algo = (
char *)
"DIA_NOCHE";
405 event.algo = (
char *)
"MOULIN_ROUGE";
409 event.point = (
struct t2 *) malloc(2 *
sizeof(
struct t2));
412 out.push_back(event);
417 s <<
"Cluster Rate for second " <<
second_ <<
" is " <<
out.size();
422 s <<
"binsize (" <<
binsize <<
") and binnumber (" <<
binnumber <<
") used";
442 for (
unsigned int i = 0; i < in.
nelem; i++)
445 for (
unsigned int i = 0; i < in.
nelem; i++) {
449 ret.
point.push_back(tmp);
454 if (! (strcmp(in.
algo,
"MOULIN_ROUGE") == 0
455 || strcmp(in.
algo,
"DIA_NOCHE") == 0
456 || strcmp(in.
algo,
"OBSERVER") == 0
457 || strcmp(in.
algo,
"CARMEN_MIRANDA") == 0))
458 for (
int i = 0; i <
nstat; i++) {
468 if (j == in.
nelem && mindist<6) {
471 ret.
point.push_back(tmp);
static struct t2 extrat2old[1024]
static struct t2 extrat2[1024]
t2 at the end of the second that will be used in both seconds
static struct t2list t2cluster[1000]
t2 clusters
int XbAlgoT3FullArray()
Full Array current trigger: 2C1 & 3C2 & 4C4.
information for one station in a t3: id, offset, window
static struct t2 * compteurt2[110000][30]
histogram of these t2 per time bin, poiting to the precise t2
std::vector< t3stat > point
vector< t2list > out
output of the algorithm: a list of clusters
void XbAlgoFindCluster(int minstat, struct t2 *input, int nt2, unsigned short *nbt2inbin, struct t2 *listt2inbin[110000][30], int(*T3func)(), const char *algo)
Function called to find clusters.
#define InternalLog(A, B)
static unsigned short ncompteurt2[110000]
number of t2 per time bin
double abs(const SVector< n, T > &v)
void XbAlgoT2Init()
initialisation of XbAlgoT2 algorithm, building fake station and resetting histograms ...
static int nbt2cluster
number of t2 cluster
a t3: algo, second, usecond and a vector of <t3stat>
vector< t2list > XbAlgoT2Process(struct t2 *input, int nt2)
Main function, processing T2 and returning clusters of T2.
static unsigned short ncompteurtot[110000]
int XbAlgoT3ToT()
ToT current trigger: 2C1 & 3C2.
t3 XbAlgoT3Build(struct t2list in)
builds t3 from a list of t2
static struct t2 * compteurtot[110000][30]
void XbAlgoFree(t2list in)
frees the malloced part of the list of t2
void HugeShower(struct t2 *input, int nt2, int msec)
Function called when more than MAXSTATINONEBIN are in 5 consecutive bins of the time histogram...
static struct t2 fake
the fake trigger, not in cluster with any trigger, to be used when one removes a trigger from a clust...
static struct t2 carmenmiranda[1024]
t2 from one of the doublets to be used in the doublet special trigger