Belle II Software development
TRGGRLMatchModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// include
10#include <trg/grl/modules/trggrl/TRGGRLMatchModule.h>
11#include <trg/grl/dataobjects/TRGGRLMATCH.h>
12#include <trg/grl/dataobjects/TRGGRLMATCHKLM.h>
13#include <trg/grl/dataobjects/TRGGRLPHOTON.h>
14#include <trg/cdc/dataobjects/CDCTriggerTrack.h>
15#include <trg/ecl/dataobjects/TRGECLCluster.h>
16#include <trg/klm/dataobjects/KLMTrgSummary.h>
17#include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
18#include <trg/grl/dataobjects/TRGGRLInfo.h>
19#include <trg/grl/dataobjects/TRGGRLShortTrack.h>
20#include <trg/grl/dataobjects/TRGGRLInnerTrack.h>
21
22// framework - DataStore
23#include <framework/datastore/StoreArray.h>
24#include <framework/datastore/StoreObjPtr.h>
25
26//framework aux
27#include <framework/logging/Logger.h>
28#include <framework/core/ModuleParamList.templateDetails.h>
29
30#include <stdlib.h>
31
32
33using namespace Belle2;
34//-----------------------------------------------------------------
35// Register the Module
36//-----------------------------------------------------------------
38
39//-----------------------------------------------------------------
40// Implementation
41//-----------------------------------------------------------------
42
44{
45 // Set module properties
46 setDescription("match CDC trigger tracks and ECL trigger clusters");
48 addParam("SimulationMode", m_simulationMode, "TRGGRL simulation switch", 1);
49 addParam("FastSimulationMode", m_fastSimulationMode, "TRGGRL fast simulation mode", m_fastSimulationMode);
50 addParam("FirmwareSimulationMode", m_firmwareSimulationMode, "TRGGRL firmware simulation mode", m_firmwareSimulationMode);
51
52 addParam("DrMatch", m_dr_threshold, "the threshold of dr between track and cluster if they are matched successfully", 25.);
53 addParam("DzMatch", m_dz_threshold, "the threshold of dz between track and cluster if they are matched successfully", 30.);
54 addParam("DphidMatch", m_dphi_d_threshold, "the threshold of dphi_d between track and cluster if they are matched successfully", 2);
55 addParam("Ephoton", m_e_threshold, "the threshold of cluster energy as a photon", 1.0);
57 "the threshold of dphi (in degree) between track and KLM sector if they are matched successfully", 32.5);
58 addParam("2DtrackCollection", m_2d_tracklist, "the 2d track list used in the match", std::string("TRGCDC2DFinderTracks"));
59 addParam("3DtrackCollection", m_3d_tracklist, "the 3d track list used in the match", std::string("TRGCDCNeuroTracks"));
60 addParam("TRGECLClusterCollection", m_clusterlist, "the cluster list used in the match", std::string("TRGECLClusters"));
61 addParam("KLMTrgrSummary", m_klmtrgsummarylist, "the KLM track list used in the match", std::string("KLMTrgSummary"));
62 addParam("2DmatchCollection", m_2dmatch_tracklist, "the 2d tracklist with associated cluster", std::string("TRG2DMatchTracks"));
63 addParam("PhimatchCollection", m_phimatch_tracklist, "the 2d tracklist with associated cluster", std::string("TRGPhiMatchTracks"));
64 addParam("3DmatchCollection", m_3dmatch_tracklist, "the 3d NN tracklist with associated cluster", std::string("TRG3DMatchTracks"));
65 addParam("KLMmatchCollection", m_klmmatch_tracklist, "the 2d tracklist with associated KLM track",
66 std::string("TRGKLMMatchTracks"));
67 addParam("GRLphotonCollection", m_grlphotonlist, "the isolated cluster list", std::string("TRGGRLPhotons"));
68 addParam("hitCollectionName", m_hitCollectionName, "Name of the input StoreArray of CDCTriggerSegmentHits.", std::string(""));
69 addParam("TrgGrlInformation", m_TrgGrlInformationName,
70 "Name of the StoreArray holding the information of tracks and clusters from cdc ecl klm.",
71 std::string("TRGGRLObjects"));
72 addParam("grlstCollectionName", m_grlstCollectionName, "Name of the output StoreArray of TRGGRLShortTrack.",
73 std::string("TRGGRLShortTracks"));
74 addParam("grlitCollectionName", m_grlitCollectionName, "Name of the output StoreArray of TRGGRLInnerTrack.",
75 std::string("TRGGRLInnerTracks"));
76
77
78}
79
81{
82}
83
85{
86 B2DEBUG(100, "TRGGRLMatchModule processing");
89 track2Dlist.isRequired();
90 track3Dlist.isRequired();
92 clusterslist.isRequired();
93 clusterslist.registerRelationTo(track2Dlist);
94 clusterslist.registerRelationTo(track3Dlist);
96 klmtrgsummary.isRequired();
97
99 tslist.isRequired();
100
101 StoreArray<TRGGRLMATCH> track2Dmatch;
103 track2Dmatch.registerRelationTo(track2Dlist);
104 track2Dmatch.registerRelationTo(clusterslist);
105
106 StoreArray<TRGGRLMATCH> trackphimatch;
108 trackphimatch.registerRelationTo(track2Dlist);
109 trackphimatch.registerRelationTo(clusterslist);
110
111 StoreArray<TRGGRLMATCH> track3Dmatch;
113 track3Dmatch.registerRelationTo(clusterslist);
114 track3Dmatch.registerRelationTo(track3Dlist);
115
116 StoreArray<TRGGRLMATCHKLM> trackKLMmatch;
118 trackKLMmatch.registerRelationTo(track2Dlist);
119
120 StoreArray<TRGGRLPHOTON> grlphoton;
122 grlphoton.registerRelationTo(clusterslist);
123
126
129
130 m_TRGGRLInfo.registerInDataStore(m_TrgGrlInformationName);
131
132//-- Fill the patterns for short tracking
133
135
136 for (int p = 0; p < 137; p++) {
137 int x0 = patterns_base2[p][0];
138 int x1 = patterns_base2[p][1];
139 int x2 = 0;
140 int x3 = patterns_base2[p][2];
141 int x4 = patterns_base2[p][3];
142 int d = x2 - x0;
143 x1 += d;
144 x2 += d;
145 x3 += d;
146 x4 += d;
147 patterns_base0.push_back({x1, x2, x3, x4});
148 }
149
150
151}
152
154{
155}
156
158{
159
173 trgInfo.create();
174
175//initialize the phi map
176
177 track_phimap.clear();
178 track_phimap_i.clear();
179 eecl_phimap.clear();
180 eecl_phimap_fwd.clear();
181 eecl_phimap_bwd.clear();
182 eecl_sectormap_fwd.clear();
183 eecl_sectormap_bwd.clear();
184 eklm_sectormap.clear();
185 eklm_sectormap_fwd.clear();
186 eklm_sectormap_bwd.clear();
187
188 for (int i = 0; i < 36; i++) {
189 track_phimap.push_back(false);
190 track_phimap_i.push_back(false);
191 eecl_phimap.push_back(false);
192 eecl_phimap_fwd.push_back(false);
193 eecl_phimap_bwd.push_back(false);
194 }
195 for (int i = 0; i < 4; i++) {
196 eecl_sectormap_fwd.push_back(false);
197 eecl_sectormap_bwd.push_back(false);
198 eklm_sectormap.push_back(false);
199 eklm_sectormap_fwd.push_back(false);
200 eklm_sectormap_bwd.push_back(false);
201 }
202
203//do 2d track match with ECL and KLM cluster
204 int klmtrack_ind_phi_map[8] = {};
205 for (int i = 0; i < track2Dlist.getEntries(); i++) {
206
207 double dr_tmp = 99999.;
208 int dphi_d_tmp = 100;
209 double dphi_klm_tmp = 100;
210 int cluster_ind = -1;
211 int cluster_ind_phi = -1;
212 int klmtrack_ind_phi = -1;
213
214// do 2d track match with KLMTrgSummary
215 sectormatching_klm(track2Dlist[i], klmtrgsummary, dphi_klm_tmp, klmtrack_ind_phi);
216
217 for (int j = 0; j < clusterlist.getEntries(); j++) {
218 // skip the end-cap cluster
219 double _cluster_x = clusterlist[j]->getPositionX();
220 double _cluster_y = clusterlist[j]->getPositionY();
221 double _cluster_z = clusterlist[j]->getPositionZ();
222 double _cluster_theta = atan(_cluster_z / (sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y)));
223 _cluster_theta = 0.5 * M_PI - _cluster_theta;
224 if (_cluster_theta < M_PI * 35.0 / 180.0 || _cluster_theta > M_PI * 126.0 / 180.0) continue;
225
226 double ds_ct[2] = {99999., 99999.};
227 calculationdistance(track2Dlist[i], clusterlist[j], ds_ct, 0);
228 int dphi_d = 0;
229 calculationphiangle(track2Dlist[i], clusterlist[j], dphi_d, track_phimap, track_phimap_i);
230
231 if (dr_tmp > ds_ct[0]) {
232 dr_tmp = ds_ct[0];
233 cluster_ind = j;
234 }
235 if (dphi_d_tmp > dphi_d) {
236 dphi_d_tmp = dphi_d;
237 cluster_ind_phi = j;
238 }
239
240 }
241
242 if (dr_tmp < m_dr_threshold && cluster_ind != -1) {
243 TRGGRLMATCH* mat2d = track2Dmatch.appendNew();
244 mat2d->setDeltaR(dr_tmp);
245 mat2d->addRelationTo(track2Dlist[i]);
246 mat2d->addRelationTo(clusterlist[cluster_ind]);
247 // track2Dlist[i]->addRelationTo(clusterlist[cluster_ind]);
248 clusterlist[cluster_ind]->addRelationTo(track2Dlist[i]);
249 }
250 if (dphi_d_tmp < m_dphi_d_threshold && cluster_ind_phi != -1) {
251 TRGGRLMATCH* matphi = trackphimatch.appendNew();
252 matphi->set_dphi_d(dphi_d_tmp);
253 matphi->addRelationTo(track2Dlist[i]);
254 matphi->addRelationTo(clusterlist[cluster_ind_phi]);
255 matphi->set_e(clusterlist[cluster_ind_phi]->getEnergyDep());
256 // track2Dlist[i]->addRelationTo(clusterlist[cluster_ind]);
257 clusterlist[cluster_ind_phi]->addRelationTo(track2Dlist[i]);
258 }
259
260 if (dphi_klm_tmp < m_dphi_klm_threshold * M_PI / 180.0 && klmtrack_ind_phi > -1 && klmtrack_ind_phi < 8) {
261 if (klmtrack_ind_phi_map[klmtrack_ind_phi] == 0) {
262 TRGGRLMATCHKLM* matklm = trackKLMmatch.appendNew();
263 matklm->set_dphi(dphi_klm_tmp);
264 matklm->set_sector(klmtrack_ind_phi);
265 matklm->addRelationTo(track2Dlist[i]);
266 klmtrack_ind_phi_map[klmtrack_ind_phi] = 1;
267 }
268 }
269
270 }
271
272
273//do 3d track match with cluster
274 for (int i = 0; i < track3Dlist.getEntries(); i++) {
275
276 double dr_tmp = 99999.;
277 double dz_tmp = 99999.;
278 int cluster_ind = -1;
279 for (int j = 0; j < clusterlist.getEntries(); j++) {
280 // skip the end-cap cluster
281 double _cluster_x = clusterlist[j]->getPositionX();
282 double _cluster_y = clusterlist[j]->getPositionY();
283 double _cluster_z = clusterlist[j]->getPositionZ();
284 double _cluster_theta = atan(_cluster_z / (sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y)));
285 _cluster_theta = 0.5 * M_PI - _cluster_theta;
286 if (_cluster_theta < M_PI * 35.0 / 180.0 || _cluster_theta > M_PI * 126.0 / 180.0) continue;
287
288 double ds_ct[2] = {99999., 99999.};
289 calculationdistance(track3Dlist[i], clusterlist[j], ds_ct, 1);
290 if (dr_tmp > ds_ct[0]) {
291 dr_tmp = ds_ct[0];
292 dz_tmp = ds_ct[1];
293 cluster_ind = j;
294 }
295 }
296 if (dr_tmp < m_dr_threshold && dz_tmp < m_dz_threshold && cluster_ind != -1) {
297 TRGGRLMATCH* mat3d = track3Dmatch.appendNew();
298 mat3d->setDeltaR(dr_tmp);
299 mat3d->setDeltaZ(dz_tmp);
300 mat3d->addRelationTo(track3Dlist[i]);
301 mat3d->addRelationTo(clusterlist[cluster_ind]);
302 clusterlist[cluster_ind]->addRelationTo(track3Dlist[i]);
303 }
304 }
305
306//pick up isolated clusters as photons with energy thrshold
307 for (int j = 0; j < clusterlist.getEntries(); j++) {
308 if (photon_cluster(clusterlist[j], track_phimap, m_e_threshold)) {
309 TRGGRLPHOTON* photon = grlphoton.appendNew();
310 photon->set_e(clusterlist[j]->getEnergyDep());
311 photon->addRelationTo(clusterlist[j]);
312 }
313 }
314
315//endcap cluster map
318
319// Short tracking
320 std::vector<bool> map_veto(64, 0);
321 make_veto_map(track2Dlist, map_veto);
323 patterns_base0, patterns_base2, grlst, trgInfo);
324
325// Inner tracking
326 inner_tracking(tslist, track_phimap_i, eecl_phimap, eklm_sectormap, grlit, trgInfo);
327
328// EECL-EKLM matching
330
331}
332
334{
335}
336
338{
339}
340
341void TRGGRLMatchModule::calculationdistance(CDCTriggerTrack* _track, TRGECLCluster* _cluster, double* ds, int _match3D)
342{
343
344//double _pt = _track->getTransverseMomentum(1.5);
345 double _r = 1.0 / _track->getOmega() ;
346 double _phi = _track->getPhi0() ;
347
348 //-- cluster/TRGECL information
349 double _cluster_x = _cluster->getPositionX();
350 double _cluster_y = _cluster->getPositionY();
351 double _cluster_z = _cluster->getPositionZ();
352 double _R = sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y);
353//double _D = sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y + _cluster_z * _cluster_z);
354//double _re_scaled_p = _pt * _D / _R;
355
356 //-- calculation
357 if (_R > abs(2 * _r)) {
358 ds[0] = 99999.;
359 } else {
360 double theta0 = _phi - asin(_R / (2 * _r));
361
362 double ex_x0 = _R * cos(theta0), ex_y0 = _R * sin(theta0);
363 ds[0] = sqrt((ex_x0 - _cluster_x) * (ex_x0 - _cluster_x) + (ex_y0 - _cluster_y) * (ex_y0 - _cluster_y));
364 }
365 //z information
366 if (_match3D == 1) {
367 double _z0 = _track->getZ0();
368 double _slope = _track->getCotTheta();
369 double _ex_z = _z0 + _slope * 2 * _r * asin(_R / (2 * _r));
370 ds[1] = fabs(_cluster_z - _ex_z);
371
372 }
373
374}
375
377 std::vector<bool>& phimap, std::vector<bool>& phimap_i)
378{
379
380 //-- 2D track information
381 double _r = 1.0 / _track->getOmega() ;
382 double _phi = _track->getPhi0() ;
383
384 //-- 2D phi angle calculation
385 double phi_p = acos(126.0 / (2 * fabs(_r))); // adjustment angle between 0 to 0.5*M_PI
386 int charge = 0;
387 if (_r > 0) {charge = 1;}
388 else if (_r < 0) {charge = -1;}
389 else {charge = 0;}
390
391 double phi_CDC = 0.0;
392 if (charge == 1) {
393 phi_CDC = _phi + phi_p - 0.5 * M_PI;
394 } else if (charge == -1) {
395 phi_CDC = _phi - phi_p + 0.5 * M_PI;
396 } else {
397 phi_CDC = _phi;
398 }
399
400 if (phi_CDC > 2 * M_PI) {phi_CDC = phi_CDC - 2 * M_PI;}
401 else if (phi_CDC < 0) {phi_CDC = phi_CDC + 2 * M_PI;}
402 if (_phi > 2 * M_PI) {_phi = _phi - 2 * M_PI;}
403 else if (_phi < 0) {_phi = _phi + 2 * M_PI;}
404
405 //-- cluster/TRGECL information
406 double _cluster_x = _cluster->getPositionX();
407 double _cluster_y = _cluster->getPositionY();
408
409 // -- ECL phi angle
410 double phi_ECL = 0.0;
411 if (_cluster_x >= 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x);}
412 else if (_cluster_x < 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
413 else if (_cluster_x < 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
414 else if (_cluster_x >= 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + 2 * M_PI;}
415
416 int phi_ECL_d = 0, phi_CDC_d = 0, phi_i_d = 0;
417 // digitization on both angle
418 for (int i = 0; i < 36; i++) {
419 if (phi_ECL > i * M_PI / 18 && phi_ECL < (i + 1)*M_PI / 18) {phi_ECL_d = i;}
420 if (_phi > i * M_PI / 18 && _phi < (i + 1)*M_PI / 18) {phi_i_d = i;}
421 if (phi_CDC > i * M_PI / 18 && phi_CDC < (i + 1)*M_PI / 18) {phi_CDC_d = i;}
422 }
423
424 phimap[phi_CDC_d] = true;
425 phimap_i[phi_i_d] = true;
426
427 if (abs(phi_ECL_d - phi_CDC_d) == 0 || abs(phi_ECL_d - phi_CDC_d) == 36) {dphi_d = 0;}
428 else if (abs(phi_ECL_d - phi_CDC_d) == 1 || abs(phi_ECL_d - phi_CDC_d) == 35) {dphi_d = 1;}
429 else if (abs(phi_ECL_d - phi_CDC_d) == 2 || abs(phi_ECL_d - phi_CDC_d) == 34) {dphi_d = 2;}
430 else if (abs(phi_ECL_d - phi_CDC_d) == 3 || abs(phi_ECL_d - phi_CDC_d) == 33) {dphi_d = 3;}
431 else if (abs(phi_ECL_d - phi_CDC_d) == 4 || abs(phi_ECL_d - phi_CDC_d) == 32) {dphi_d = 4;}
432 else if (abs(phi_ECL_d - phi_CDC_d) == 5 || abs(phi_ECL_d - phi_CDC_d) == 31) {dphi_d = 5;}
433 else if (abs(phi_ECL_d - phi_CDC_d) == 6 || abs(phi_ECL_d - phi_CDC_d) == 30) {dphi_d = 6;}
434 else if (abs(phi_ECL_d - phi_CDC_d) == 7 || abs(phi_ECL_d - phi_CDC_d) == 29) {dphi_d = 7;}
435 else if (abs(phi_ECL_d - phi_CDC_d) == 8 || abs(phi_ECL_d - phi_CDC_d) == 28) {dphi_d = 8;}
436 else if (abs(phi_ECL_d - phi_CDC_d) == 9 || abs(phi_ECL_d - phi_CDC_d) == 27) {dphi_d = 9;}
437 else if (abs(phi_ECL_d - phi_CDC_d) == 10 || abs(phi_ECL_d - phi_CDC_d) == 26) {dphi_d = 10;}
438 else if (abs(phi_ECL_d - phi_CDC_d) == 11 || abs(phi_ECL_d - phi_CDC_d) == 25) {dphi_d = 11;}
439 else if (abs(phi_ECL_d - phi_CDC_d) == 12 || abs(phi_ECL_d - phi_CDC_d) == 24) {dphi_d = 12;}
440 else if (abs(phi_ECL_d - phi_CDC_d) == 13 || abs(phi_ECL_d - phi_CDC_d) == 23) {dphi_d = 13;}
441 else if (abs(phi_ECL_d - phi_CDC_d) == 14 || abs(phi_ECL_d - phi_CDC_d) == 22) {dphi_d = 14;}
442 else if (abs(phi_ECL_d - phi_CDC_d) == 15 || abs(phi_ECL_d - phi_CDC_d) == 21) {dphi_d = 15;}
443 else if (abs(phi_ECL_d - phi_CDC_d) == 16 || abs(phi_ECL_d - phi_CDC_d) == 20) {dphi_d = 16;}
444 else if (abs(phi_ECL_d - phi_CDC_d) == 17 || abs(phi_ECL_d - phi_CDC_d) == 19) {dphi_d = 17;}
445 else if (abs(phi_ECL_d - phi_CDC_d) == 18) {dphi_d = 18;}
446
447}
448
450 int& phiid_klm)
451{
452
453 //-- 2D track information
454 double _r = 1.0 / _track->getOmega() ;
455 double _phi = _track->getPhi0() ;
456
457 //-- 2D phi angle calculation (extrapolating up to superconducting coil)
458 double phi_p = acos(176.0 / (2 * fabs(_r))); // adjustment angle between 0 to 0.5*M_PI
459 int charge = 0;
460 if (_r > 0) {charge = 1;}
461 else if (_r < 0) {charge = -1;}
462 else {charge = 0;}
463
464 double phi_CDC = 0.0;
465 if (charge == 1) {
466 phi_CDC = _phi + phi_p - 0.5 * M_PI;
467 } else if (charge == -1) {
468 phi_CDC = _phi - phi_p + 0.5 * M_PI;
469 } else {
470 phi_CDC = _phi;
471 }
472
473 if (phi_CDC > 2 * M_PI) {phi_CDC = phi_CDC - 2 * M_PI;}
474 else if (phi_CDC < 0) {phi_CDC = phi_CDC + 2 * M_PI;}
475
476 // KLM track's sector central phi
477 int _sector_mask_fw = _klmtrgsummary->getSector_mask_Forward_Barrel();
478 int _sector_mask_bw = _klmtrgsummary->getSector_mask_Backward_Barrel();
479 int _sector_mask = _sector_mask_fw | _sector_mask_bw;
480 for (int _sector = 0; _sector < 8; _sector++) {
481 if (_sector_mask & (1 << _sector)) {
482 double _sector_central = 0.25 * M_PI * _sector;
483 double dphi_temp;
484 if (fabs(phi_CDC - _sector_central) < M_PI) { dphi_temp = fabs(phi_CDC - _sector_central); }
485 else { dphi_temp = 2 * M_PI - fabs(phi_CDC - _sector_central); }
486 if (dphi_temp < dphi) {
487 dphi = dphi_temp;
488 phiid_klm = _sector;
489 }
490 }
491 }
492
493}
494
495bool TRGGRLMatchModule::photon_cluster(TRGECLCluster* _cluster, std::vector<bool> phimap, double e_threshold)
496{
497
498 //-- cluster/TRGECL information
499 double _cluster_x = _cluster->getPositionX();
500 double _cluster_y = _cluster->getPositionY();
501 double _cluster_z = _cluster->getPositionZ();
502 double _cluster_theta = atan(_cluster_z / (sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y)));
503 _cluster_theta = 0.5 * M_PI - _cluster_theta;
504 bool barrel = true;
505 if (_cluster_theta < M_PI * 35.0 / 180.0 || _cluster_theta > M_PI * 126.0 / 180.0) {barrel = false;}
506 double _cluster_e = _cluster->getEnergyDep();
507
508 // -- ECL phi angle
509 double phi_ECL = 0.0;
510 if (_cluster_x >= 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x);}
511 else if (_cluster_x < 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
512 else if (_cluster_x < 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
513 else if (_cluster_x >= 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + 2 * M_PI;}
514
515 int phi_ECL_d = 0;
516 // digitization on both angle
517 for (int i = 0; i < 36; i++) {
518 if (phi_ECL > i * M_PI / 18 && phi_ECL < (i + 1)*M_PI / 18) {phi_ECL_d = i;}
519 }
520
521 int index = phi_ECL_d, index_p = phi_ECL_d + 1, index_m = phi_ECL_d - 1;
522 if (index_p > 35) {index_p = index_p - 36;}
523 if (index_m < 0) {index_m = index_m + 36;}
524
525 if (!phimap[index] && !phimap[index_p] && !phimap[index_m] && _cluster_e >= e_threshold && barrel) {return true;}
526 else if (!barrel) {return true;}
527 else {return false;}
528
529}
530
532{
533 if (x > 63) x -= 64;
534 if (x < 0) x += 64;
535 return x;
536}
537
539{
540 if (x > 35) x -= 36;
541 if (x < 0) x += 36;
542 return x;
543}
544
545void TRGGRLMatchModule::fill_pattern_base2(std::vector< std::vector<int> >& patt)
546{
547 patt.push_back({ 0, 0, 0, 0});
548 patt.push_back({ 0, -1, 0, 0});
549 patt.push_back({ 0, -1, 1, 0});
550 patt.push_back({ 0, -1, -1, 0});
551 patt.push_back({ 0, -2, 0, 0});
552 patt.push_back({ 0, -2, 1, 0});
553 patt.push_back({ 0, -2, 2, 0});
554 patt.push_back({ 0, -2, 3, 0});
555 patt.push_back({ 0, -3, 1, 0});
556 patt.push_back({ 0, -3, 2, 0});
557 patt.push_back({ 0, -3, 3, 0});
558 patt.push_back({ 0, -4, 2, 0});
559 patt.push_back({ 0, -4, 3, 0});
560 patt.push_back({ 0, 0, 0, 1});
561 patt.push_back({ 0, 0, 1, 1});
562 patt.push_back({ 0, -1, 0, 1});
563 patt.push_back({ 0, -1, 1, 1});
564 patt.push_back({ 0, -1, 2, 1});
565 patt.push_back({ 0, -2, 2, 1});
566 patt.push_back({ 0, -2, 3, 1});
567 patt.push_back({ 0, -3, 2, 1});
568 patt.push_back({ 0, -3, 3, 1});
569 patt.push_back({ 0, 0, 0, -1});
570 patt.push_back({ 0, 0, -1, -1});
571 patt.push_back({ 0, -1, 0, -1});
572 patt.push_back({ 0, -1, -1, -1});
573 patt.push_back({ 0, -2, 0, -1});
574 patt.push_back({ 0, -2, 1, -1});
575 patt.push_back({ 0, -3, 1, -1});
576 patt.push_back({ 0, -3, 2, -1});
577 patt.push_back({ -1, -1, 0, 0});
578 patt.push_back({ -1, -1, 1, 0});
579 patt.push_back({ -1, -2, 0, 0});
580 patt.push_back({ -1, -2, 1, 0});
581 patt.push_back({ -1, -3, 1, 0});
582 patt.push_back({ -1, -3, 2, 0});
583 patt.push_back({ -1, -3, 3, 0});
584 patt.push_back({ -1, -4, 2, 0});
585 patt.push_back({ -1, -4, 3, 0});
586 patt.push_back({ 1, 0, 1, 0});
587 patt.push_back({ 1, 0, 0, 0});
588 patt.push_back({ 1, 0, -1, 0});
589 patt.push_back({ 1, -1, 0, 0});
590 patt.push_back({ 1, -1, 1, 0});
591 patt.push_back({ 1, -2, 2, 0});
592 patt.push_back({ 1, -2, 3, 0});
593 patt.push_back({ 1, -3, 2, 0});
594 patt.push_back({ 1, -3, 3, 0});
595 patt.push_back({ -1, -1, 0, 1});
596 patt.push_back({ -1, -1, 1, 1});
597 patt.push_back({ -1, -2, 0, 1});
598 patt.push_back({ -1, -2, 1, 1});
599 patt.push_back({ -1, -2, 2, 1});
600 patt.push_back({ -1, -3, 1, 1});
601 patt.push_back({ -1, -3, 2, 1});
602 patt.push_back({ -1, -3, 3, 1});
603 patt.push_back({ -1, -4, 2, 1});
604 patt.push_back({ -1, -4, 3, 1});
605 patt.push_back({ 1, 0, -1, -1});
606 patt.push_back({ 1, 0, 0, -1});
607 patt.push_back({ 1, -1, -1, -1});
608 patt.push_back({ 1, -1, 0, -1});
609 patt.push_back({ 1, -1, 1, -1});
610 patt.push_back({ 1, -2, 1, -1});
611 patt.push_back({ 1, -2, 2, -1});
612 patt.push_back({ 1, -3, 1, -1});
613 patt.push_back({ 1, -3, 2, -1});
614 patt.push_back({ -1, -1, 1, 2});
615 patt.push_back({ -1, -1, 2, 2});
616 patt.push_back({ -1, -2, 1, 2});
617 patt.push_back({ -1, -2, 2, 2});
618 patt.push_back({ -1, -2, 3, 2});
619 patt.push_back({ -1, -3, 2, 2});
620 patt.push_back({ -1, -3, 3, 2});
621 patt.push_back({ -1, -3, 4, 2});
622 patt.push_back({ 1, 0, -1, -2});
623 patt.push_back({ 1, 0, 0, -2});
624 patt.push_back({ 1, -1, 1, -2});
625 patt.push_back({ 1, -1, 0, -2});
626 patt.push_back({ 1, -1, -1, -2});
627 patt.push_back({ 1, -2, 0, -2});
628 patt.push_back({ 1, -2, 1, -2});
629 patt.push_back({ -2, -2, 0, 1});
630 patt.push_back({ -2, -2, 1, 1});
631 patt.push_back({ -2, -3, 1, 1});
632 patt.push_back({ -2, -3, 2, 1});
633 patt.push_back({ -2, -4, 2, 1});
634 patt.push_back({ -2, -4, 3, 1});
635 patt.push_back({ -2, -5, 3, 1});
636 patt.push_back({ 2, 1, 0, -1});
637 patt.push_back({ 2, 0, 1, -1});
638 patt.push_back({ 2, 0, 0, -1});
639 patt.push_back({ 2, 0, -1, -1});
640 patt.push_back({ 2, -1, 1, -1});
641 patt.push_back({ 2, -1, 0, -1});
642 patt.push_back({ 2, -2, 2, -1});
643 patt.push_back({ 2, -2, 1, -1});
644 patt.push_back({ -2, -2, 1, 2});
645 patt.push_back({ -2, -2, 2, 2});
646 patt.push_back({ -2, -3, 1, 2});
647 patt.push_back({ -2, -3, 2, 2});
648 patt.push_back({ -2, -3, 3, 2});
649 patt.push_back({ -2, -4, 2, 2});
650 patt.push_back({ -2, -4, 3, 2});
651 patt.push_back({ -2, -4, 4, 2});
652 patt.push_back({ 2, 1, 0, -2});
653 patt.push_back({ 2, 1, -1, -2});
654 patt.push_back({ 2, 0, 1, -2});
655 patt.push_back({ 2, 0, 0, -2});
656 patt.push_back({ 2, 0, -1, -2});
657 patt.push_back({ 2, 0, -2, -2});
658 patt.push_back({ 2, -1, 2, -2});
659 patt.push_back({ 2, -1, 1, -2});
660 patt.push_back({ 2, -1, 0, -2});
661 patt.push_back({ 2, -1, -1, -2});
662 patt.push_back({ 2, -2, 0, -2});
663 patt.push_back({ 2, -2, 1, -2});
664 patt.push_back({ -2, -2, 1, 3});
665 patt.push_back({ -2, -2, 2, 3});
666 patt.push_back({ -2, -3, 2, 3});
667 patt.push_back({ -2, -3, 3, 3});
668 patt.push_back({ -2, -3, 4, 3});
669 patt.push_back({ -2, -4, 3, 3});
670 patt.push_back({ -2, -4, 4, 3});
671 patt.push_back({ 2, 1, -1, -3});
672 patt.push_back({ 2, 0, -1, -3});
673 patt.push_back({ 2, 0, -2, -3});
674 patt.push_back({ 2, -1, 0, -3});
675 patt.push_back({ 2, -2, 0, -3});
676 patt.push_back({ 2, -2, 1, -3});
677 patt.push_back({ -2, -2, 2, 4});
678 patt.push_back({ -2, -3, 3, 4});
679 patt.push_back({ -2, -3, 4, 4});
680 patt.push_back({ -2, -4, 4, 4});
681 patt.push_back({ 2, -1, 0, 4});
682 patt.push_back({ 2, -1, -1, 4});
683 patt.push_back({ 2, -2, 0, 4});
684
685}
686
687void TRGGRLMatchModule::make_veto_map(StoreArray<CDCTriggerTrack> track2Dlist, std::vector<bool>& map_veto)
688{
689 for (int i = 0; i < track2Dlist.getEntries(); i++) {
690 int _w = (int)(2271.7 * track2Dlist[i]->getOmega()) ; // omega from -33 to 33
691 if (_w >= 33) { _w = 33;}
692 else if (_w <= -33) { _w = -33;}
693 int _phi = (int)((track2Dlist[i]->getPhi0() + 2 * M_PI) / (M_PI / 32.0)); // phi_i digitized to 0 ~ 63
694
695 int charge = 0;
696 if (_w > 0) {charge = 1;}
697 else if (_w < 0) {charge = -1;}
698 else {charge = 0;}
699
700 _w = abs(_w);
701
702 int L;
703 // cppcheck-suppress knownConditionTrueFalse
704 if (_w >= 0 && _w <= 8) { L = _phi; }
705 else if (_w >= 9 && _w <= 15) {
706 if (charge < 0) { L = _phi + 1; }
707 else { L = _phi; }
708 } else if (_w >= 16 && _w <= 24) {
709 if (charge < 0) { L = _phi + 2; }
710 else { L = _phi; }
711 } else if (_w >= 25 && _w <= 27) {
712 if (charge < 0) { L = _phi + 3; }
713 else { L = _phi; }
714 } else if (_w >= 28 && _w <= 30) {
715 if (charge < 0) { L = _phi + 3; }
716 else { L = _phi + 1; }
717 } else if (_w >= 31 && _w <= 32) {
718 if (charge < 0) { L = _phi + 4; }
719 else { L = _phi + 1; }
720 } else {
721 if (charge < 0) { L = _phi + 5; }
722 else { L = _phi + 1; }
723 }
724
725 int R;
726 // cppcheck-suppress knownConditionTrueFalse
727 if (_w >= 0 && _w <= 8) { R = _phi; }
728 else if (_w >= 9 && _w <= 15) {
729 if (charge < 0) { R = _phi; }
730 else { R = _phi - 1; }
731 } else if (_w >= 16 && _w <= 24) {
732 if (charge < 0) { R = _phi; }
733 else { R = _phi - 2; }
734 } else if (_w >= 25 && _w <= 27) {
735 if (charge < 0) { R = _phi; }
736 else { R = _phi - 3; }
737 } else if (_w >= 28 && _w <= 30) {
738 if (charge < 0) { R = _phi + 1; }
739 else { R = _phi - 3; }
740 } else if (_w >= 21 && _w <= 32) {
741 if (charge < 0) { R = _phi + 1; }
742 else { R = _phi - 4; }
743 } else {
744 if (charge < 0) { R = _phi + 1; }
745 else { R = _phi - 5; }
746 }
747
748 // L should be > R
749 for (int j = R - 1; j < L + 2; j++) {
750 map_veto[N64(j)] = true;
751 }
752 }
753
754}
755
757 std::vector<bool>& ecl_phimap, std::vector<bool>& ecl_phimap_fwd, std::vector<bool>& ecl_phimap_bwd,
758 std::vector<bool>& ecl_sectormap_fwd, std::vector<bool>& ecl_sectormap_bwd)
759{
760 bool ecl_phimap_loose_fwd[36];
761 bool ecl_phimap_loose_bwd[36];
762 for (int i = 0; i < 36; i++) {
763 ecl_phimap_loose_fwd[i] = false;
764 ecl_phimap_loose_bwd[i] = false;
765 }
766
767 for (int iclst = 0; iclst < clusterlist.getEntries(); iclst++) {
768 //-- cluster/TRGECL information
769 double _cluster_x = clusterlist[iclst]->getPositionX();
770 double _cluster_y = clusterlist[iclst]->getPositionY();
771
772 // -- ECL phi angle
773 double phi_ECL = 0.0;
774 if (_cluster_x >= 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x);}
775 else if (_cluster_x < 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
776 else if (_cluster_x < 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
777 else if (_cluster_x >= 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + 2 * M_PI;}
778
779 int phi_ECL_d = 0;
780 // digitization on both angle
781 for (int i = 0; i < 36; i++) {
782 if (phi_ECL > i * M_PI / 18 && phi_ECL < (i + 1)*M_PI / 18) {phi_ECL_d = i;}
783 }
784
785 //fill endcap only
786 int _cluster_thetaid = clusterlist[iclst]->getMaxThetaId();
787 if (_cluster_thetaid < 4 || _cluster_thetaid > 15) ecl_phimap[phi_ECL_d] = true;
788 if (_cluster_thetaid < 4) ecl_phimap_fwd[phi_ECL_d] = true;
789 if (_cluster_thetaid > 15) ecl_phimap_bwd[phi_ECL_d] = true;
790 if (_cluster_thetaid < 5) ecl_phimap_loose_fwd[phi_ECL_d] = true;
791 if (_cluster_thetaid > 14) ecl_phimap_loose_bwd[phi_ECL_d] = true;
792 }
793
794 //-- 36b into 4b
795 ecl_sectormap_fwd[0] = ecl_phimap_loose_fwd[35] or ecl_phimap_loose_fwd[0] or ecl_phimap_loose_fwd[1] or ecl_phimap_loose_fwd[2] or
796 ecl_phimap_loose_fwd[3] or ecl_phimap_loose_fwd[4] or ecl_phimap_loose_fwd[5] or ecl_phimap_loose_fwd[6] or
797 ecl_phimap_loose_fwd[7] or ecl_phimap_loose_fwd[8] or ecl_phimap_loose_fwd[9];
798 ecl_sectormap_fwd[1] = ecl_phimap_loose_fwd[8] or ecl_phimap_loose_fwd[9] or ecl_phimap_loose_fwd[10] or ecl_phimap_loose_fwd[11]
799 or
800 ecl_phimap_loose_fwd[12] or ecl_phimap_loose_fwd[13] or ecl_phimap_loose_fwd[14] or ecl_phimap_loose_fwd[15] or
801 ecl_phimap_loose_fwd[16] or ecl_phimap_loose_fwd[17] or ecl_phimap_loose_fwd[18] or ecl_phimap_loose_fwd[19];
802 ecl_sectormap_fwd[2] = ecl_phimap_loose_fwd[18] or ecl_phimap_loose_fwd[19] or ecl_phimap_loose_fwd[20]
803 or ecl_phimap_loose_fwd[21] or
804 ecl_phimap_loose_fwd[22] or ecl_phimap_loose_fwd[23] or ecl_phimap_loose_fwd[24] or ecl_phimap_loose_fwd[25] or
805 ecl_phimap_loose_fwd[26] or ecl_phimap_loose_fwd[27] or ecl_phimap_loose_fwd[28];
806 ecl_sectormap_fwd[3] = ecl_phimap_loose_fwd[26] or ecl_phimap_loose_fwd[27] or ecl_phimap_loose_fwd[28]
807 or ecl_phimap_loose_fwd[29] or
808 ecl_phimap_loose_fwd[30] or ecl_phimap_loose_fwd[31] or ecl_phimap_loose_fwd[32] or ecl_phimap_loose_fwd[33] or
809 ecl_phimap_loose_fwd[34] or ecl_phimap_loose_fwd[35] or ecl_phimap_loose_fwd[0];
810 //-- 36b into 4b
811 ecl_sectormap_bwd[0] = ecl_phimap_loose_bwd[35] or ecl_phimap_loose_bwd[0] or ecl_phimap_loose_bwd[1] or ecl_phimap_loose_bwd[2] or
812 ecl_phimap_loose_bwd[3] or ecl_phimap_loose_bwd[4] or ecl_phimap_loose_bwd[5] or ecl_phimap_loose_bwd[6] or
813 ecl_phimap_loose_bwd[7] or ecl_phimap_loose_bwd[8] or ecl_phimap_loose_bwd[9];
814 ecl_sectormap_bwd[1] = ecl_phimap_loose_bwd[8] or ecl_phimap_loose_bwd[9] or ecl_phimap_loose_bwd[10] or ecl_phimap_loose_bwd[11]
815 or
816 ecl_phimap_loose_bwd[12] or ecl_phimap_loose_bwd[13] or ecl_phimap_loose_bwd[14] or ecl_phimap_loose_bwd[15] or
817 ecl_phimap_loose_bwd[16] or ecl_phimap_loose_bwd[17] or ecl_phimap_loose_bwd[18] or ecl_phimap_loose_bwd[19];
818 ecl_sectormap_bwd[2] = ecl_phimap_loose_bwd[18] or ecl_phimap_loose_bwd[19] or ecl_phimap_loose_bwd[20]
819 or ecl_phimap_loose_bwd[21] or
820 ecl_phimap_loose_bwd[22] or ecl_phimap_loose_bwd[23] or ecl_phimap_loose_bwd[24] or ecl_phimap_loose_bwd[25] or
821 ecl_phimap_loose_bwd[26] or ecl_phimap_loose_bwd[27] or ecl_phimap_loose_bwd[28];
822 ecl_sectormap_bwd[3] = ecl_phimap_loose_bwd[26] or ecl_phimap_loose_bwd[27] or ecl_phimap_loose_bwd[28]
823 or ecl_phimap_loose_bwd[29] or
824 ecl_phimap_loose_bwd[30] or ecl_phimap_loose_bwd[31] or ecl_phimap_loose_bwd[32] or ecl_phimap_loose_bwd[33] or
825 ecl_phimap_loose_bwd[34] or ecl_phimap_loose_bwd[35] or ecl_phimap_loose_bwd[0];
826
827}
828
830 std::vector<bool>& _eklm_sectormap, std::vector<bool>& _eklm_sectormap_fwd, std::vector<bool>& _eklm_sectormap_bwd)
831{
832
833 int _sector_mask_fw = _klmtrgsummary->getSector_mask_Forward_Endcap();
834 int _sector_mask_bw = _klmtrgsummary->getSector_mask_Backward_Endcap();
835
836 for (int _sector = 0; _sector < 4; _sector++) {
837 //if(_sector_mask_fw & (1<<_sector) ) _eklm_sectormap_fwd[_sector]=true;
838 if (_sector_mask_bw & (1 << _sector)) _eklm_sectormap_bwd[_sector] = true;
839 //if(_sector_mask & (1<<_sector) ) _eklm_sectormap[_sector]=true;
840 }
841 if (_sector_mask_fw & (1 << 0)) _eklm_sectormap_fwd[1] = true;
842 if (_sector_mask_fw & (1 << 1)) _eklm_sectormap_fwd[0] = true;
843 if (_sector_mask_fw & (1 << 2)) _eklm_sectormap_fwd[3] = true;
844 if (_sector_mask_fw & (1 << 3)) _eklm_sectormap_fwd[2] = true;
845
846 for (int _sector = 0; _sector < 4; _sector++) {
847 _eklm_sectormap[_sector] = (_eklm_sectormap_fwd[_sector] || _eklm_sectormap_bwd[_sector]);
848 }
849}
850
851
853 std::vector<bool> phimap_i,
854 std::vector<bool> ecl_phimap_fwd,
855 std::vector<bool> ecl_phimap_bwd,
856 std::vector<bool> klm_sectormap_fwd,
857 std::vector<bool> klm_sectormap_bwd,
858 std::vector< std::vector<int> >& pattern_base0, std::vector< std::vector<int> >& pattern_base2,
861{
862 std::vector<bool> SL0(64, 0);
863 std::vector<bool> SL1(64, 0);
864 std::vector<bool> SL2(64, 0);
865 std::vector<bool> SL3(64, 0);
866 std::vector<bool> SL4(64, 0);
867 std::vector<bool> ST0(64, 0);
868 std::vector<bool> ST0_36b(36, 0);
869 std::vector<bool> ST2(64, 0);
870 std::vector<int> patt_ID(64, -1);
871
872 std::vector<bool> st_ec1(64, 0);
873 std::vector<bool> st_ec1_36b(36, 0);
874 std::vector<bool> st_ec1_4b(4, 0);
875 std::vector<bool> st_ec2(64, 0);
876 std::vector<bool> st_ec2_36b(36, 0);
877 std::vector<bool> st_ec2_4b(4, 0);
878
879//-- collecting TSF info in SL0~4
880 for (int i = 0; i < tslist.getEntries(); i++) {
881 int id = tslist[i]->getSegmentID();
882 int sl = 0;
883 if (id >= 0 * 32 && id < 5 * 32) {sl = 0; id -= 0;}
884 else if (id >= 5 * 32 && id < 10 * 32) {sl = 1; id -= 5 * 32;}
885 else if (id >= 10 * 32 && id < 16 * 32) {sl = 2; id -= 10 * 32;}
886 else if (id >= 16 * 32 && id < 23 * 32) {sl = 3; id -= 16 * 32;}
887 else if (id >= 23 * 32 && id < 31 * 32) {sl = 4; id -= 23 * 32;}
888 else continue;
889
890 if (sl == 0) {
891 int X = (int)(id / 5), Y = id % 5;
892 if (Y == 0 || Y == 1) { SL0[2 * X] = true; }
893 else if (Y == 3 || Y == 4) { SL0[2 * X + 1] = true; }
894 else { SL0[2 * X] = true; SL0[2 * X + 1] = true; }
895 } else if (sl == 1) {
896 int X = (int)(id / 5), Y = id % 5;
897 if (Y == 0 || Y == 1) { SL1[2 * X] = true; }
898 else if (Y == 3 || Y == 4) { SL1[2 * X + 1] = true; }
899 else { SL1[2 * X] = true; SL1[2 * X + 1] = true; }
900 } else if (sl == 2) {
901 int X = (int)(id / 3);
902 SL2[X] = true;
903 } else if (sl == 3) {
904 int X = (int)(id / 7), Y = id % 7;
905 if (Y == 0 || Y == 1 || Y == 2) { SL3[2 * X] = true; }
906 else if (Y == 4 || Y == 5 || Y == 6) { SL3[2 * X + 1] = true; }
907 else { SL3[2 * X] = true; SL3[2 * X + 1] = true; }
908 } else if (sl == 4) {
909 int X = (int)(id / 4);
910 SL4[X] = true;
911 }
912
913 }
914
915//-- making veto
916 for (int i = 0; i < 64; i++) {
917 if (map_veto[i]) {SL0[i] = false; SL1[i] = false; SL2[i] = false;}
918 }
919 /*
920 for (int i = 0; i < 64; i++) { std::cout<<map_veto[63-i]; if((64-i)%10==1) std::cout<<" ";}
921 std::cout<<std::endl;
922 for (int i = 0; i < 64; i++) { std::cout<<SL4[63-i]; if((64-i)%10==1) std::cout<<" ";}
923 std::cout<<std::endl;
924 for (int i = 0; i < 64; i++) { std::cout<<SL3[63-i]; if((64-i)%10==1) std::cout<<" ";}
925 std::cout<<std::endl;
926 for (int i = 0; i < 64; i++) { std::cout<<SL2[63-i]; if((64-i)%10==1) std::cout<<" ";}
927 std::cout<<std::endl;
928 for (int i = 0; i < 64; i++) { std::cout<<SL1[63-i]; if((64-i)%10==1) std::cout<<" ";}
929 std::cout<<std::endl;
930 for (int i = 0; i < 64; i++) { std::cout<<SL0[63-i]; if((64-i)%10==1) std::cout<<" ";}
931 std::cout<<std::endl;
932 */
933//-- doing short tracking
934
935 std::vector< std::vector<int> > stlist_buf(0);
936
937 // -- ST finding with SL2
938 for (int i = 0; i < 64; i++) {
939
940 int ID0 = 0;
941 int ID1 = 0;
942 int ID2 = 0;
943 int ID3 = 0;
944 int ID4 = 0;
945 stlist_buf.push_back({0, 0, 0, 0, 0, 0});
946
947 if (!SL2[i]) continue;
948 bool SL2_already_found = false;
949
950 for (int p = 0; p < 137; p++) {
951
952 // following patterns will not be used.
953 if (p == 4) continue;
954 if (p == 5) continue;
955 if (p == 17) continue;
956 if (p == 26) continue;
957 if (p == 38) continue;
958 if (p == 41) continue;
959 if (p == 42) continue;
960 if (p == 47) continue;
961 if (p == 50) continue;
962 if (p == 60) continue;
963 if (p == 63) continue;
964 if (p == 64) continue;
965 if (p == 74) continue;
966 if (p == 93) continue;
967 if (p == 94) continue;
968 if (p == 95) continue;
969 if (p == 96) continue;
970 if (p == 104) continue;
971 if (p == 113) continue;
972 if (p == 114) continue;
973 if (p == 115) continue;
974 if (p == 123) continue;
975 if (p == 134) continue;
976 if (p == 135) continue;
977 if (p == 136) continue;
978
979 int x0 = pattern_base2[p][0];
980 int x1 = pattern_base2[p][1];
981 int x3 = pattern_base2[p][2];
982 int x4 = pattern_base2[p][3];
983
984
985 if (SL2[i] && SL0[N64(i + x0)] && SL1[N64(i + x1)] && SL3[N64(i + x3)] && SL4[N64(i + x4)] && !SL2_already_found) {
986 ST2[i] = true;
987 ID0 = N64(i + x0);
988 ID1 = N64(i + x1);
989 ID2 = i;
990 ID3 = N64(i + x3);
991 ID4 = N64(i + x4);
992 SL2_already_found = true; // if it has been found in previous pattern, no need to do it again.
993 }
994
995 // if a pattern is found, no need to look for other pattern
996 if (SL2_already_found) break;
997
998 }
999
1000 if (SL2_already_found) {
1001 stlist_buf[i][0] = 1;
1002 stlist_buf[i][1] = ID0;
1003 stlist_buf[i][2] = ID1;
1004 stlist_buf[i][3] = ID2;
1005 stlist_buf[i][4] = ID3;
1006 stlist_buf[i][5] = ID4;
1007 }
1008 }
1010//-- ST finding with SL0
1011 for (int i = 0; i < 64; i++) {
1012
1013 if (!SL0[i]) continue;
1014 bool SL0_already_found = false;
1015
1016 for (int p = 0; p < 137; p++) {
1017
1018 // following patterns will not be used.
1019 if (p == 4) continue;
1020 if (p == 5) continue;
1021 if (p == 17) continue;
1022 if (p == 26) continue;
1023 if (p == 38) continue;
1024 if (p == 41) continue;
1025 if (p == 42) continue;
1026 if (p == 47) continue;
1027 if (p == 50) continue;
1028 if (p == 60) continue;
1029 if (p == 63) continue;
1030 if (p == 64) continue;
1031 if (p == 74) continue;
1032 if (p == 93) continue;
1033 if (p == 94) continue;
1034 if (p == 95) continue;
1035 if (p == 96) continue;
1036 if (p == 104) continue;
1037 if (p == 113) continue;
1038 if (p == 114) continue;
1039 if (p == 115) continue;
1040 if (p == 123) continue;
1041 if (p == 134) continue;
1042 if (p == 135) continue;
1043 if (p == 136) continue;
1044
1045 int y1 = pattern_base0[p][0];
1046 int y2 = pattern_base0[p][1];
1047 int y3 = pattern_base0[p][2];
1048 int y4 = pattern_base0[p][3];
1049
1050 if (SL0[i] && SL1[N64(i + y1)] && SL2[N64(i + y2)] && SL3[N64(i + y3)] && SL4[N64(i + y4)] && !SL0_already_found) {
1051 ST0[i] = true;
1052 if (patt_ID[i] < 0) { patt_ID[i] = p; }
1053 SL0_already_found = true; // if it has been found in previous pattern, no need to do it again.
1054 }
1055
1056 // if a pattern is found, no need to look for other pattern
1057 if (SL0_already_found) break;
1058
1059 }
1060
1061 }
1063//-- extrapolation
1064 for (int i = 0; i < 64; i++) {
1065 if (patt_ID[i] == -1) continue;
1066
1067 int ec = 0, l = 0, r = 0;
1068 extrapolation(patt_ID[i], l, r, ec);
1069 if (ec == 1) {
1070 for (int e = l; e <= r; e++) { st_ec1[N64(i + e)] = true; }
1071 }
1072 if (ec == 2) {
1073 for (int e = l; e <= r; e++) { st_ec2[N64(i + e)] = true; }
1074 }
1075
1076 }
1077//-- 64b into 36b
1078 for (int i = 0; i < 4; i++) {
1079 ST0_36b[0 + 9 * i] = ST0[0 + 16 * i] or ST0[1 + 16 * i];
1080 ST0_36b[1 + 9 * i] = ST0[1 + 16 * i] or ST0[2 + 16 * i] or ST0[3 + 16 * i];
1081 ST0_36b[2 + 9 * i] = ST0[3 + 16 * i] or ST0[4 + 16 * i] or ST0[5 + 16 * i];
1082 ST0_36b[3 + 9 * i] = ST0[5 + 16 * i] or ST0[6 + 16 * i] or ST0[7 + 16 * i];
1083 ST0_36b[4 + 9 * i] = ST0[7 + 16 * i] or ST0[8 + 16 * i];
1084 ST0_36b[5 + 9 * i] = ST0[8 + 16 * i] or ST0[9 + 16 * i] or ST0[10 + 16 * i];
1085 ST0_36b[6 + 9 * i] = ST0[10 + 16 * i] or ST0[11 + 16 * i] or ST0[12 + 16 * i];
1086 ST0_36b[7 + 9 * i] = ST0[12 + 16 * i] or ST0[13 + 16 * i] or ST0[14 + 16 * i];
1087 ST0_36b[8 + 9 * i] = ST0[14 + 16 * i] or ST0[15 + 16 * i];
1088 st_ec1_36b[0 + 9 * i] = st_ec1[0 + 16 * i] or st_ec1[1 + 16 * i];
1089 st_ec1_36b[1 + 9 * i] = st_ec1[1 + 16 * i] or st_ec1[2 + 16 * i] or st_ec1[3 + 16 * i];
1090 st_ec1_36b[2 + 9 * i] = st_ec1[3 + 16 * i] or st_ec1[4 + 16 * i] or st_ec1[5 + 16 * i];
1091 st_ec1_36b[3 + 9 * i] = st_ec1[5 + 16 * i] or st_ec1[6 + 16 * i] or st_ec1[7 + 16 * i];
1092 st_ec1_36b[4 + 9 * i] = st_ec1[7 + 16 * i] or st_ec1[8 + 16 * i];
1093 st_ec1_36b[5 + 9 * i] = st_ec1[8 + 16 * i] or st_ec1[9 + 16 * i] or st_ec1[10 + 16 * i];
1094 st_ec1_36b[6 + 9 * i] = st_ec1[10 + 16 * i] or st_ec1[11 + 16 * i] or st_ec1[12 + 16 * i];
1095 st_ec1_36b[7 + 9 * i] = st_ec1[12 + 16 * i] or st_ec1[13 + 16 * i] or st_ec1[14 + 16 * i];
1096 st_ec1_36b[8 + 9 * i] = st_ec1[14 + 16 * i] or st_ec1[15 + 16 * i];
1097
1098 st_ec2_36b[0 + 9 * i] = st_ec2[0 + 16 * i] or st_ec2[1 + 16 * i];
1099 st_ec2_36b[1 + 9 * i] = st_ec2[1 + 16 * i] or st_ec2[2 + 16 * i] or st_ec2[3 + 16 * i];
1100 st_ec2_36b[2 + 9 * i] = st_ec2[3 + 16 * i] or st_ec2[4 + 16 * i] or st_ec2[5 + 16 * i];
1101 st_ec2_36b[3 + 9 * i] = st_ec2[5 + 16 * i] or st_ec2[6 + 16 * i] or st_ec2[7 + 16 * i];
1102 st_ec2_36b[4 + 9 * i] = st_ec2[7 + 16 * i] or st_ec2[8 + 16 * i];
1103 st_ec2_36b[5 + 9 * i] = st_ec2[8 + 16 * i] or st_ec2[9 + 16 * i] or st_ec2[10 + 16 * i];
1104 st_ec2_36b[6 + 9 * i] = st_ec2[10 + 16 * i] or st_ec2[11 + 16 * i] or st_ec2[12 + 16 * i];
1105 st_ec2_36b[7 + 9 * i] = st_ec2[12 + 16 * i] or st_ec2[13 + 16 * i] or st_ec2[14 + 16 * i];
1106 st_ec2_36b[8 + 9 * i] = st_ec2[14 + 16 * i] or st_ec2[15 + 16 * i];
1107 }
1108//-- 36b into 4b
1109 st_ec1_4b[0] = st_ec1_36b[35] or st_ec1_36b[0] or st_ec1_36b[1] or st_ec1_36b[2] or st_ec1_36b[3] or st_ec1_36b[4] or st_ec1_36b[5]
1110 or st_ec1_36b[6] or st_ec1_36b[7] or st_ec1_36b[8] or st_ec1_36b[9];
1111 st_ec1_4b[1] = st_ec1_36b[8] or st_ec1_36b[9] or st_ec1_36b[10] or st_ec1_36b[11] or st_ec1_36b[12] or st_ec1_36b[13]
1112 or st_ec1_36b[14] or st_ec1_36b[15] or st_ec1_36b[16] or st_ec1_36b[17] or st_ec1_36b[18] or st_ec1_36b[19];
1113 st_ec1_4b[2] = st_ec1_36b[18] or st_ec1_36b[19] or st_ec1_36b[20] or st_ec1_36b[21] or st_ec1_36b[22] or st_ec1_36b[23]
1114 or st_ec1_36b[24] or st_ec1_36b[25] or st_ec1_36b[26] or st_ec1_36b[27] or st_ec1_36b[28];
1115 st_ec1_4b[3] = st_ec1_36b[26] or st_ec1_36b[27] or st_ec1_36b[28] or st_ec1_36b[29] or st_ec1_36b[30] or st_ec1_36b[31]
1116 or st_ec1_36b[32] or st_ec1_36b[33] or st_ec1_36b[34] or st_ec1_36b[35] or st_ec1_36b[0];
1117 st_ec2_4b[0] = st_ec2_36b[35] or st_ec2_36b[0] or st_ec2_36b[1] or st_ec2_36b[2] or st_ec2_36b[3] or st_ec2_36b[4] or st_ec2_36b[5]
1118 or st_ec2_36b[6] or st_ec2_36b[7] or st_ec2_36b[8] or st_ec2_36b[9];
1119 st_ec2_4b[1] = st_ec2_36b[8] or st_ec2_36b[9] or st_ec2_36b[10] or st_ec2_36b[11] or st_ec2_36b[12] or st_ec2_36b[13]
1120 or st_ec2_36b[14] or st_ec2_36b[15] or st_ec2_36b[16] or st_ec2_36b[17] or st_ec2_36b[18] or st_ec2_36b[19];
1121 st_ec2_4b[2] = st_ec2_36b[18] or st_ec2_36b[19] or st_ec2_36b[20] or st_ec2_36b[21] or st_ec2_36b[22] or st_ec2_36b[23]
1122 or st_ec2_36b[24] or st_ec2_36b[25] or st_ec2_36b[26] or st_ec2_36b[27] or st_ec2_36b[28];
1123 st_ec2_4b[3] = st_ec2_36b[26] or st_ec2_36b[27] or st_ec2_36b[28] or st_ec2_36b[29] or st_ec2_36b[30] or st_ec2_36b[31]
1124 or st_ec2_36b[32] or st_ec2_36b[33] or st_ec2_36b[34] or st_ec2_36b[35] or st_ec2_36b[0];
1125
1126
1127
1128
1129//-- Summary info
1130
1131 int N_ST = 0;
1132 int N_ST_fwd = 0;
1133 int N_ST_bwd = 0;
1134 bool s2s3 = false;
1135 bool s2s5 = false;
1136 bool s2so = false;
1137 bool s2s30 = false;
1138 bool s2f3 = false;
1139 bool s2f5 = false;
1140 bool s2fo = false;
1141 bool s2f30 = false;
1142 int secl = 0;
1143 int secl_fwd = 0;
1144 int secl_bwd = 0;
1145 int sklm = 0;
1146 int sklm_fwd = 0;
1147 int sklm_bwd = 0;
1148
1149//-- short track counting on ST2
1150 for (int i = 0; i < 64; i++) {
1151 if (ST2[i]) {
1152 N_ST++;
1153 ST2[i] = false;
1154 int L = i - 1, R = i + 1;
1155 while (ST2[N64(L)]) {
1156 ST2[N64(L)] = false;
1157 L--;
1158 }
1159 while (ST2[N64(R)]) {
1160 ST2[N64(R)] = false;
1161 R++;
1162 }
1163
1164 //-- Fill the store array
1165 L++; R--;
1166 int index = N64((L + R) / 2); // fill the middle one when multiple ST is found continuously in the map
1167 TRGGRLShortTrack* st = grlst.appendNew();
1168 st->set_TS_ID(0, stlist_buf[index][1]);
1169 st->set_TS_ID(1, stlist_buf[index][2]);
1170 st->set_TS_ID(2, stlist_buf[index][3]);
1171 st->set_TS_ID(3, stlist_buf[index][4]);
1172 st->set_TS_ID(4, stlist_buf[index][5]);
1173 }
1174 }
1175 for (int i = 0; i < 64; i++) {
1176 if (st_ec1[i]) N_ST_fwd++;
1177 }
1178 for (int i = 0; i < 64; i++) {
1179 if (st_ec2[i]) N_ST_bwd++;
1180 }
1181
1182//-- b2b info with ST0 and phi_i map
1183 for (int i = 0; i < 36; i++) {
1184 s2s3 = (ST0_36b[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)])) or s2s3;
1185 s2s5 = (ST0_36b[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)]
1186 or ST0_36b[N36(i + 16)] or ST0_36b[N36(i + 20)])) or s2s5;
1187 s2so = (ST0_36b[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)]
1188 or ST0_36b[N36(i + 16)] or ST0_36b[N36(i + 20)]
1189 or ST0_36b[N36(i + 15)] or ST0_36b[N36(i + 21)]
1190 or ST0_36b[N36(i + 14)] or ST0_36b[N36(i + 22)]
1191 or ST0_36b[N36(i + 13)] or ST0_36b[N36(i + 23)]
1192 or ST0_36b[N36(i + 12)] or ST0_36b[N36(i + 24)]
1193 or ST0_36b[N36(i + 11)] or ST0_36b[N36(i + 25)]
1194 or ST0_36b[N36(i + 10)] or ST0_36b[N36(i + 26)]
1195 or ST0_36b[N36(i + 9)] or ST0_36b[N36(i + 27)])) or s2so ;
1196 s2s30 = (ST0_36b[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)]
1197 or ST0_36b[N36(i + 16)] or ST0_36b[N36(i + 20)]
1198 or ST0_36b[N36(i + 15)] or ST0_36b[N36(i + 21)]
1199 or ST0_36b[N36(i + 14)] or ST0_36b[N36(i + 22)]
1200 or ST0_36b[N36(i + 13)] or ST0_36b[N36(i + 23)]
1201 or ST0_36b[N36(i + 12)] or ST0_36b[N36(i + 24)]
1202 or ST0_36b[N36(i + 11)] or ST0_36b[N36(i + 25)]
1203 or ST0_36b[N36(i + 10)] or ST0_36b[N36(i + 26)]
1204 or ST0_36b[N36(i + 9)] or ST0_36b[N36(i + 27)]
1205 or ST0_36b[N36(i + 8)] or ST0_36b[N36(i + 28)]
1206 or ST0_36b[N36(i + 7)] or ST0_36b[N36(i + 29)]
1207 or ST0_36b[N36(i + 6)] or ST0_36b[N36(i + 30)]
1208 or ST0_36b[N36(i + 5)] or ST0_36b[N36(i + 31)]
1209 or ST0_36b[N36(i + 4)] or ST0_36b[N36(i + 32)]
1210 or ST0_36b[N36(i + 3)] or ST0_36b[N36(i + 33)])) or s2s30 ;
1211
1212
1213 s2f3 = (phimap_i[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)])) or s2f3;
1214 s2f5 = (phimap_i[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)]
1215 or ST0_36b[N36(i + 16)] or ST0_36b[N36(i + 20)])) or s2f5;
1216 s2fo = (phimap_i[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)]
1217 or ST0_36b[N36(i + 16)] or ST0_36b[N36(i + 20)]
1218 or ST0_36b[N36(i + 15)] or ST0_36b[N36(i + 21)]
1219 or ST0_36b[N36(i + 14)] or ST0_36b[N36(i + 22)]
1220 or ST0_36b[N36(i + 13)] or ST0_36b[N36(i + 23)]
1221 or ST0_36b[N36(i + 12)] or ST0_36b[N36(i + 24)]
1222 or ST0_36b[N36(i + 11)] or ST0_36b[N36(i + 25)]
1223 or ST0_36b[N36(i + 10)] or ST0_36b[N36(i + 26)]
1224 or ST0_36b[N36(i + 9)] or ST0_36b[N36(i + 27)])) or s2fo ;
1225 s2f30 = (phimap_i[i] and (ST0_36b[N36(i + 18)] or ST0_36b[N36(i + 17)] or ST0_36b[N36(i + 19)]
1226 or ST0_36b[N36(i + 16)] or ST0_36b[N36(i + 20)]
1227 or ST0_36b[N36(i + 15)] or ST0_36b[N36(i + 21)]
1228 or ST0_36b[N36(i + 14)] or ST0_36b[N36(i + 22)]
1229 or ST0_36b[N36(i + 13)] or ST0_36b[N36(i + 23)]
1230 or ST0_36b[N36(i + 12)] or ST0_36b[N36(i + 24)]
1231 or ST0_36b[N36(i + 11)] or ST0_36b[N36(i + 25)]
1232 or ST0_36b[N36(i + 10)] or ST0_36b[N36(i + 26)]
1233 or ST0_36b[N36(i + 9)] or ST0_36b[N36(i + 27)]
1234 or ST0_36b[N36(i + 8)] or ST0_36b[N36(i + 28)]
1235 or ST0_36b[N36(i + 7)] or ST0_36b[N36(i + 29)]
1236 or ST0_36b[N36(i + 6)] or ST0_36b[N36(i + 30)]
1237 or ST0_36b[N36(i + 5)] or ST0_36b[N36(i + 31)]
1238 or ST0_36b[N36(i + 4)] or ST0_36b[N36(i + 32)]
1239 or ST0_36b[N36(i + 3)] or ST0_36b[N36(i + 33)])) or s2f30 ;
1240
1241 }
1242
1243//short-ecl matching at endcap
1244 for (int i = 0; i < 36; i++) {
1245 if (ecl_phimap_fwd[i] and st_ec1_36b[i])secl_fwd++;
1246 }
1247 for (int i = 0; i < 36; i++) {
1248 if (ecl_phimap_bwd[i] and st_ec2_36b[i])secl_bwd++;
1249 }
1250 secl = secl_fwd + secl_bwd;
1251
1252//short-klm matching at endcap
1253 for (int i = 0; i < 4; i++) {
1254 if (klm_sectormap_fwd[i] and st_ec1_4b[i])sklm_fwd++;
1255 }
1256 for (int i = 0; i < 4; i++) {
1257 if (klm_sectormap_bwd[i] and st_ec2_4b[i])sklm_bwd++;
1258 }
1259 sklm = sklm_fwd + sklm_bwd;
1260
1261//-- set results
1262 trgInfo->setNshorttrk(N_ST);
1263 trgInfo->setNshorttrk_fwd(N_ST_fwd);
1264 trgInfo->setNshorttrk_bwd(N_ST_bwd);
1265 trgInfo->sets2s3(s2s3);
1266 trgInfo->sets2s5(s2s5);
1267 trgInfo->sets2so(s2so);
1268 trgInfo->sets2s30(s2s30);
1269 trgInfo->sets2f3(s2f3);
1270 trgInfo->sets2f5(s2f5);
1271 trgInfo->sets2fo(s2fo);
1272 trgInfo->sets2f30(s2f30);
1273 trgInfo->setbwdsb(0);
1274 trgInfo->setbwdnb(0);
1275 trgInfo->setfwdsb(0);
1276 trgInfo->setfwdnb(0);
1277 trgInfo->setbrlfb(0);
1278 trgInfo->setbrlnb(0);
1279 trgInfo->setNsecl(secl);
1280 trgInfo->setNsecl_fwd(secl_fwd);
1281 trgInfo->setNsecl_bwd(secl_bwd);
1282 trgInfo->setNsklm(sklm);
1283 trgInfo->setNsklm_fwd(sklm_fwd);
1284 trgInfo->setNsklm_bwd(sklm_bwd);
1285
1286 //for (int i = 0; i < 64; i++) {
1287 // std::cout << st_ec1[i] << " ";
1288 //}
1289 //std::cout << std::endl;
1290 //for (int i = 0; i < 64; i++) {
1291 // std::cout << st_ec2[i] << " ";
1292 //}
1293 //std::cout << std::endl;
1294 //for (int i = 0; i < 36; i++) {
1295 // std::cout << st_ec1_36b[i] << " ";
1296 //}
1297 //std::cout << std::endl;
1298 //for (int i = 0; i < 36; i++) {
1299 // std::cout << st_ec2_36b[i] << " ";
1300 //}
1301 //std::cout << std::endl;
1302 //for (int i = 0; i < 36; i++) {
1303 // std::cout << ecl_phimap_fwd[i] << " ";
1304 //}
1305 //std::cout << std::endl;
1306 //for (int i = 0; i < 36; i++) {
1307 // std::cout << ecl_phimap_bwd[i] << " ";
1308 //}
1309 //std::cout << std::endl;
1310 //std::cout << secl << " " << secl_fwd << " " << secl_bwd << std::endl;
1311
1312}
1313
1314
1315void TRGGRLMatchModule::inner_tracking(StoreArray<CDCTriggerSegmentHit> tslist,
1316 std::vector<bool> phimap_i,
1317 std::vector<bool> ecl_phimap,
1318 std::vector<bool> klm_sectormap,
1321{
1322 std::vector<bool> SL0(64, 0);
1323 std::vector<bool> SL1(64, 0);
1324 std::vector<bool> SL2(64, 0);
1325 std::vector<bool> IT0(64, 0);
1326 std::vector<bool> IT0_36b(36, 0);
1327 std::vector<bool> IT0_4b(4, 0);
1328
1329 //-- collecting TSF info in SL0~2
1330 for (int i = 0; i < tslist.getEntries(); i++) {
1331 int id = tslist[i]->getSegmentID();
1332 int sl = 0;
1333 if (id >= 0 * 32 && id < 5 * 32) {sl = 0; id -= 0;}
1334 else if (id >= 5 * 32 && id < 10 * 32) {sl = 1; id -= 5 * 32;}
1335 else if (id >= 10 * 32 && id < 16 * 32) {sl = 2; id -= 10 * 32;}
1336 else continue;
1337
1338 if (sl == 0) {
1339 int X = (int)(id / 5), Y = id % 5;
1340 if (Y == 0 || Y == 1) { SL0[2 * X] = true; }
1341 else if (Y == 3 || Y == 4) { SL0[2 * X + 1] = true; }
1342 else { SL0[2 * X] = true; SL0[2 * X + 1] = true; }
1343 } else if (sl == 1) {
1344 int X = (int)(id / 5), Y = id % 5;
1345 if (Y == 0 || Y == 1) { SL1[2 * X] = true; }
1346 else if (Y == 3 || Y == 4) { SL1[2 * X + 1] = true; }
1347 else { SL1[2 * X] = true; SL1[2 * X + 1] = true; }
1348 } else if (sl == 2) {
1349 int X = (int)(id / 3);
1350 SL2[X] = true;
1351 }
1352 }
1353
1354
1355 // -- Inner Track finding with SL0
1356 for (int i = 0; i < 64; i++) {
1357 int j1 = i - 4;
1358 if (j1 < 0) j1 = j1 + 64;
1359 int j2 = i - 3;
1360 if (j2 < 0) j2 = j2 + 64;
1361 int j3 = i - 2;
1362 if (j3 < 0) j3 = j3 + 64;
1363 int j4 = i - 1;
1364 if (j4 < 0) j4 = j4 + 64;
1365 int j5 = i;
1366 int j6 = i + 1;
1367 if (j6 > 63)j6 = j6 - 64;
1368 int j7 = i + 2;
1369 if (j7 > 63)j7 = j7 - 64;
1370 if (
1371 SL0[i] &&
1372 (SL1[j1] || SL1[j2] || SL1[j3] || SL1[j4] || SL1[j5]) &&
1373 (SL2[j3] || SL2[j4] || SL2[j5] || SL2[j6] || SL2[j7])
1374 ) {
1375 IT0[i] = true;
1376 } else {
1377 IT0[i] = false;
1378 }
1379 }
1380
1381 //-- 64b into 36b
1382 for (int i = 0; i < 4; i++) {
1383 IT0_36b[0 + 9 * i] = IT0[0 + 16 * i] or IT0[1 + 16 * i];
1384 IT0_36b[1 + 9 * i] = IT0[1 + 16 * i] or IT0[2 + 16 * i] or IT0[3 + 16 * i];
1385 IT0_36b[2 + 9 * i] = IT0[3 + 16 * i] or IT0[4 + 16 * i] or IT0[5 + 16 * i];
1386 IT0_36b[3 + 9 * i] = IT0[5 + 16 * i] or IT0[6 + 16 * i] or IT0[7 + 16 * i];
1387 IT0_36b[4 + 9 * i] = IT0[7 + 16 * i] or IT0[8 + 16 * i];
1388 IT0_36b[5 + 9 * i] = IT0[8 + 16 * i] or IT0[9 + 16 * i] or IT0[10 + 16 * i];
1389 IT0_36b[6 + 9 * i] = IT0[10 + 16 * i] or IT0[11 + 16 * i] or IT0[12 + 16 * i];
1390 IT0_36b[7 + 9 * i] = IT0[12 + 16 * i] or IT0[13 + 16 * i] or IT0[14 + 16 * i];
1391 IT0_36b[8 + 9 * i] = IT0[14 + 16 * i] or IT0[15 + 16 * i];
1392 }
1393
1394 //-- 36b into 4b
1395 IT0_4b[0] = IT0_36b[35] or IT0_36b[0] or IT0_36b[1] or IT0_36b[2] or IT0_36b[3] or IT0_36b[4] or IT0_36b[5] or IT0_36b[6]
1396 or IT0_36b[7] or IT0_36b[8] or IT0_36b[9];
1397 IT0_4b[1] = IT0_36b[8] or IT0_36b[9] or IT0_36b[10] or IT0_36b[11] or IT0_36b[12] or IT0_36b[13] or IT0_36b[14] or IT0_36b[15]
1398 or IT0_36b[16] or IT0_36b[17] or IT0_36b[18] or IT0_36b[19];
1399 IT0_4b[2] = IT0_36b[18] or IT0_36b[19] or IT0_36b[20] or IT0_36b[21] or IT0_36b[22] or IT0_36b[23] or IT0_36b[24] or IT0_36b[25]
1400 or IT0_36b[26] or IT0_36b[27] or IT0_36b[28];
1401 IT0_4b[3] = IT0_36b[26] or IT0_36b[27] or IT0_36b[28] or IT0_36b[29] or IT0_36b[30] or IT0_36b[31] or IT0_36b[32] or IT0_36b[33]
1402 or IT0_36b[34] or IT0_36b[36] or IT0_36b[0];
1403
1404 //-- Summary info
1405 int N_IT = 0;
1406 bool i2fo = false;
1407 bool i2io = false;
1408 int iecl = 0;
1409 int iklm = 0;
1410
1411 //-- inner track counting
1412 for (int i = 0; i < 64; i++) {
1413 if (IT0[i]) N_IT++;
1414 TRGGRLInnerTrack* it = grlit.appendNew();
1415 it->set_TS_ID(0, i);
1416 }
1417
1418 //-- b2b info with IT0 and phi_i map
1419 for (int i = 0; i < 36; i++) {
1420 i2fo = (phimap_i[i] and (IT0_36b[N36(i + 18)] or IT0_36b[N36(i + 17)] or IT0_36b[N36(i + 19)]
1421 or IT0_36b[N36(i + 16)] or IT0_36b[N36(i + 20)]
1422 or IT0_36b[N36(i + 15)] or IT0_36b[N36(i + 21)]
1423 or IT0_36b[N36(i + 14)] or IT0_36b[N36(i + 22)]
1424 or IT0_36b[N36(i + 13)] or IT0_36b[N36(i + 23)]
1425 or IT0_36b[N36(i + 12)] or IT0_36b[N36(i + 24)]
1426 or IT0_36b[N36(i + 11)] or IT0_36b[N36(i + 25)]
1427 or IT0_36b[N36(i + 10)] or IT0_36b[N36(i + 26)]
1428 or IT0_36b[N36(i + 9)] or IT0_36b[N36(i + 27)])) or i2fo ;
1429 }
1430 //-- b2b info with IT0
1431 for (int i = 0; i < 36; i++) {
1432 i2io = (IT0_36b[i] and (IT0_36b[N36(i + 18)] or IT0_36b[N36(i + 17)] or IT0_36b[N36(i + 19)]
1433 or IT0_36b[N36(i + 16)] or IT0_36b[N36(i + 20)]
1434 or IT0_36b[N36(i + 15)] or IT0_36b[N36(i + 21)]
1435 or IT0_36b[N36(i + 14)] or IT0_36b[N36(i + 22)]
1436 or IT0_36b[N36(i + 13)] or IT0_36b[N36(i + 23)]
1437 or IT0_36b[N36(i + 12)] or IT0_36b[N36(i + 24)]
1438 or IT0_36b[N36(i + 11)] or IT0_36b[N36(i + 25)]
1439 or IT0_36b[N36(i + 10)] or IT0_36b[N36(i + 26)]
1440 or IT0_36b[N36(i + 9)] or IT0_36b[N36(i + 27)])) or i2io ;
1441 }
1442 //inner-ecl matching at endcap
1443
1444 bool IT0_36b_temp[44] = {false};
1445 for (int i = 4; i < 40; i++) {
1446 IT0_36b_temp[i] = IT0_36b[i - 4];
1447 }
1448 IT0_36b_temp[0] = IT0_36b[32];
1449 IT0_36b_temp[1] = IT0_36b[33];
1450 IT0_36b_temp[2] = IT0_36b[34];
1451 IT0_36b_temp[3] = IT0_36b[35];
1452 IT0_36b_temp[40] = IT0_36b[0];
1453 IT0_36b_temp[41] = IT0_36b[1];
1454 IT0_36b_temp[42] = IT0_36b[2];
1455 IT0_36b_temp[43] = IT0_36b[3];
1456
1457 for (int i = 4; i < 40; i++) {
1458 if (ecl_phimap[i - 4] and (IT0_36b_temp[i - 4] or IT0_36b_temp[i - 3] or IT0_36b_temp[i - 2] or IT0_36b_temp[i - 1]
1459 or IT0_36b_temp[i] or IT0_36b_temp[i + 1] or IT0_36b_temp[i + 2] or IT0_36b_temp[i + 3] or IT0_36b_temp[i + 4])) {
1460 iecl++;
1461 }
1462 }
1463
1464
1465 //std::cout << "sector map " ;
1466 //for (int i = 0; i < 4; i++) {
1467 // std::cout << " " << i << " " << IT0_4b[i] << " " << klm_sectormap[i];
1468 //}
1469 //std::cout << std::endl;
1470
1471 //inner-klm matching at endcap
1472 for (int i = 0; i < 4; i++) {
1473 if (klm_sectormap[i] and IT0_4b[i])iklm++;
1474 }
1475 //-- set results
1476 trgInfo->setNinnertrk(N_IT);
1477 trgInfo->seti2fo(i2fo);
1478 trgInfo->seti2io(i2io);
1479 trgInfo->setNiecl(iecl);
1480 trgInfo->setNiklm(iklm);
1481
1482 //for (int i = 0; i < 64; i++) {
1483 // std::cout << SL0[i] << " ";
1484 //}
1485 //std::cout << std::endl;
1486 //for (int i = 0; i < 64; i++) {
1487 // std::cout << SL1[i] << " ";
1488 //}
1489 //std::cout << std::endl;
1490 //for (int i = 0; i < 64; i++) {
1491 // std::cout << SL2[i] << " ";
1492 //}
1493 //std::cout << std::endl;
1494 //for (int i = 0; i < 64; i++) {
1495 // std::cout << IT0[i] << " ";
1496 //}
1497 //std::cout << std::endl;
1498 //for (int i = 0; i < 36; i++) {
1499 // std::cout << IT0_36b[i] << " ";
1500 //}
1501 //std::cout << std::endl;
1502 //for (int i = 0; i < 36; i++) {
1503 // std::cout << phimap_i[i] << " ";
1504 //}
1505 //std::cout << std::endl;
1506 //for (int i = 0; i < 36; i++) {
1507 // std::cout << ecl_phimap[i] << " ";
1508 //}
1509 //std::cout << std::endl;
1510 //std::cout << i2fo << " " << iecl << std::endl;
1511
1512}
1513
1514void TRGGRLMatchModule::matching_eecl_eklm(std::vector<bool> _eecl_sectormap_fw,
1515 std::vector<bool> _eecl_sectormap_bw,
1516 std::vector<bool> _eklm_sectormap_fw,
1517 std::vector<bool> _eklm_sectormap_bw,
1519{
1520 int ieclklm = 0;
1521 for (int i = 0; i < 4; i++) {
1522 if (_eklm_sectormap_fw[i] && _eecl_sectormap_fw[i])ieclklm++;
1523 if (_eklm_sectormap_bw[i] && _eecl_sectormap_bw[i])ieclklm++;
1524 }
1525
1526 trgInfo->setNeecleklm(ieclklm);
1527
1528}
1529
1530void
1531TRGGRLMatchModule::extrapolation(int pattern, int& l, int& r, int& ec)
1532{
1533 if (pattern == 6) {ec = 1; l = 0; r = 1;}
1534 if (pattern == 7) {ec = 1; l = 0; r = 1;}
1535 if (pattern == 8) {ec = 1; l = 0; r = 1;}
1536 if (pattern == 9) {ec = 1; l = 0; r = 2;}
1537 if (pattern == 10) {ec = 1; l = 0; r = 2;}
1538 if (pattern == 11) {ec = 1; l = 0; r = 1;}
1539 if (pattern == 12) {ec = 1; l = 0; r = 2;}
1540 if (pattern == 18) {ec = 1; l = 0; r = 2;}
1541 if (pattern == 19) {ec = 1; l = 0; r = 2;}
1542 if (pattern == 20) {ec = 1; l = 0; r = 4;}
1543 if (pattern == 21) {ec = 1; l = 0; r = 4;}
1544 if (pattern == 28) {ec = 1; l = -4; r = 0;}
1545 if (pattern == 29) {ec = 1; l = -3; r = 0;}
1546 if (pattern == 34) {ec = 1; l = 0; r = 1;}
1547 if (pattern == 35) {ec = 1; l = 0; r = 3;}
1548 if (pattern == 36) {ec = 1; l = 1; r = 3;}
1549 if (pattern == 37) {ec = 1; l = 0; r = 3;}
1550 if (pattern == 44) {ec = 1; l = -4; r = 0;}
1551 if (pattern == 45) {ec = 1; l = -2; r = 0;}
1552 if (pattern == 46) {ec = 1; l = -3; r = 0;}
1553 if (pattern == 54) {ec = 1; l = 1; r = 7;}
1554 if (pattern == 55) {ec = 1; l = 1; r = 6;}
1555 if (pattern == 56) {ec = 1; l = 1; r = 5;}
1556 if (pattern == 57) {ec = 1; l = 1; r = 5;}
1557 if (pattern == 64) {ec = 1; l = -6; r = -1;}
1558 if (pattern == 73) {ec = 1; l = 3; r = 13;}
1559 if (pattern == 81) {ec = 1; l = -10; r = -3;}
1560 if (pattern == 86) {ec = 1; l = 3; r = 12;}
1561 if (pattern == 87) {ec = 1; l = 3; r = 6;}
1562 if (pattern == 100) {ec = 1; l = 7; r = 20;}
1563 if (pattern == 101) {ec = 1; l = 5; r = 20;}
1564 if (pattern == 102) {ec = 1; l = 5; r = 20;}
1565 if (pattern == 103) {ec = 1; l = 4; r = 14;}
1566 if (pattern == 111) {ec = 1; l = -12; r = -5;}
1567 if (pattern == 112) {ec = 1; l = -18; r = -5;}
1568 if (pattern == 116) {ec = 1; l = -11; r = -6;}
1569 if (pattern == 120) {ec = 1; l = 7; r = 21;}
1570 if (pattern == 121) {ec = 1; l = 7; r = 14;}
1571 if (pattern == 122) {ec = 1; l = 7; r = 21;}
1572 if (pattern == 127) {ec = 1; l = -21; r = -8;}
1573 if (pattern == 128) {ec = 1; l = -15; r = -7;}
1574 if (pattern == 129) {ec = 1; l = -12; r = -7;}
1575 if (pattern == 132) {ec = 1; l = 10; r = 18;}
1576 if (pattern == 133) {ec = 1; l = 8; r = 18;}
1577
1578 if (pattern == 0) {ec = 2; l = -3; r = 1;}
1579 if (pattern == 1) {ec = 2; l = -3; r = 1;}
1580 if (pattern == 3) {ec = 2; l = -3; r = 0;}
1581 if (pattern == 13) {ec = 2; l = 0; r = 3;}
1582 if (pattern == 14) {ec = 2; l = 0; r = 4;}
1583 if (pattern == 15) {ec = 2; l = 0; r = 5;}
1584 if (pattern == 22) {ec = 2; l = -4; r = -1;}
1585 if (pattern == 23) {ec = 2; l = -5; r = -1;}
1586 if (pattern == 24) {ec = 2; l = -3; r = 0;}
1587 if (pattern == 25) {ec = 2; l = -4; r = 0;}
1588 if (pattern == 30) {ec = 2; l = 1; r = 5;}
1589 if (pattern == 39) {ec = 2; l = -2; r = 0;}
1590 if (pattern == 40) {ec = 2; l = -2; r = 0;}
1591 if (pattern == 48) {ec = 2; l = 2; r = 6;}
1592 if (pattern == 49) {ec = 2; l = 3; r = 8;}
1593 if (pattern == 58) {ec = 2; l = -9; r = -3;}
1594 if (pattern == 59) {ec = 2; l = -9; r = -3;}
1595 if (pattern == 67) {ec = 2; l = 5; r = 11;}
1596 if (pattern == 75) {ec = 2; l = -13; r = -6;}
1597 if (pattern == 82) {ec = 2; l = 5; r = 9;}
1598 if (pattern == 83) {ec = 2; l = 5; r = 9;}
1599 if (pattern == 89) {ec = 2; l = -10; r = -4;}
1600 if (pattern == 92) {ec = 2; l = -10; r = -4;}
1601 if (pattern == 97) {ec = 2; l = 7; r = 19;}
1602 if (pattern == 105) {ec = 2; l = -16; r = -10;}
1603 if (pattern == 106) {ec = 2; l = -17; r = -7;}
1604 if (pattern == 109) {ec = 2; l = -17; r = -6;}
1605 if (pattern == 111) {ec = 2; l = -16; r = -7;}
1606 if (pattern == 117) {ec = 2; l = 9; r = 19;}
1607 if (pattern == 118) {ec = 2; l = 9; r = 19;}
1608 if (pattern == 124) {ec = 2; l = -17; r = -8;}
1609 if (pattern == 125) {ec = 2; l = -17; r = -8;}
1610 if (pattern == 126) {ec = 2; l = -17; r = -8;}
1611
1612}
1613
1614
double R
typedef autogenerated by FFTW
Track created by the CDC trigger.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Example Detector.
Definition: TRGECLCluster.h:24
double getPositionZ() const
Get Energy weighted position Z.
double getEnergyDep() const
The method to get deposited energy.
double getPositionX() const
The method to get hit average time Get Energy weighted position X.
double getPositionY() const
Get Energy weighted position Y.
a class for neutral ECL cluster in TRGGRL
void set_TS_ID(int i, int id)
set TS ID of SL i
a class for CDC2D-KLM Matching in TRGGRL
void set_sector(int sector)
set the klm sector id
void set_dphi(double dphi)
set the dphi
a class for CDC2D-ECL Matching in TRGGRL
Definition: TRGGRLMATCH.h:21
void set_dphi_d(double dphi_d)
set the dphi_d
Definition: TRGGRLMATCH.h:49
void setDeltaZ(double deltaz)
set the Delta Z
Definition: TRGGRLMATCH.h:46
void set_e(double e)
set the cluster energy
Definition: TRGGRLMATCH.h:52
void setDeltaR(double deltar)
set the Delta R
Definition: TRGGRLMATCH.h:43
std::string m_klmtrgsummarylist
the KLM track list
std::vector< bool > eklm_sectormap
8 bits phi map of KLM clusters at endcap
StoreObjPtr< TRGGRLInfo > m_TRGGRLInfo
output for TRGGRLInfo
std::string m_2dmatch_tracklist
the distance in phi direction between track and cluster
int m_fastSimulationMode
Switch for the fast simulation.
int N36(int x)
Force an int to be witnin 0 to 35.
int m_simulationMode
Mode for TRGGRL simulation.
std::string m_grlitCollectionName
GRL inner track list.
int m_firmwareSimulationMode
Switch for the firmware simulation. 0:do nothing, 1:do everything.
double m_dr_threshold
max value of dr to be identified as match
int m_dphi_d_threshold
max value of dphi_d to be identified as match, 1 digit = 10 degrees
std::vector< std::vector< int > > patterns_base2
Short tracking patterns based on SL2.
virtual void initialize() override
Initialize the parameters.
std::string m_phimatch_tracklist
the matched 2d track list by phi matching
std::vector< std::vector< int > > patterns_base0
Short tracking patterns based on SL0.
std::vector< bool > track_phimap_i
36 bits phi map of all 2D tracks
bool photon_cluster(TRGECLCluster *cluster, std::vector< bool > track_phimap, double e_threshold)
determine photon from isolated cluster
std::vector< bool > eecl_phimap
36 bits phi map of ECL clusters at endcap
virtual void event() override
Event processor.
void make_veto_map(StoreArray< CDCTriggerTrack > track2Dlist, std::vector< bool > &map_veto)
Make the full track phi veto map for short tracking.
std::vector< bool > eklm_sectormap_fwd
8 bits sector map of KLM clusters at forward endcap
virtual void endRun() override
End-of-run action.
void calculationdistance(CDCTriggerTrack *track, TRGECLCluster *cluster, double *ds, int _match3D)
calculate dr and dz between track and cluster
void calculationphiangle(CDCTriggerTrack *track, TRGECLCluster *cluster, int &dphi_d, std::vector< bool > &track_phimap, std::vector< bool > &track_phimap_i)
calculate dphi_d between track and cluster
virtual void terminate() override
Termination action.
virtual ~TRGGRLMatchModule()
Destructor.
double m_dz_threshold
max value of dz to be identified as match
void short_tracking(StoreArray< CDCTriggerSegmentHit > tslist, std::vector< bool > map_veto, std::vector< bool > phimap_i, std::vector< bool > ecl_phimap_fwd, std::vector< bool > ecl_phimap_bwd, std::vector< bool > klm_sectormap_fwd, std::vector< bool > klm_sectormap_bwd, std::vector< std::vector< int > > &pattern_base0, std::vector< std::vector< int > > &pattern_base2, StoreArray< TRGGRLShortTrack > grlst, StoreObjPtr< TRGGRLInfo > trgInfo)
Short tracking logic.
std::vector< bool > eecl_sectormap_fwd
8 bits sector map of ECL clusters at forward endcap
std::string m_2d_tracklist
the 2D finder track list
virtual void beginRun() override
Called when entering a new run.
void extrapolation(int pattern, int &l, int &r, int &ec)
Short track extrapolation (to endcap) function.
std::string m_grlstCollectionName
GRL short track list.
std::string m_klmmatch_tracklist
the matched 2d track list by KLM matching
double m_dphi_klm_threshold
max value of dphi (CDC track to KLM sector) to be identified as match (in degrees)
std::string m_TrgGrlInformationName
Name of the StoreArray holding projects information from grl.
int N64(int x)
Force an int to be witnin 0 to 63.
TRGGRLMatchModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::vector< bool > track_phimap
36 bits phi map of all 2D tracks
void make_eecl_map(StoreArray< TRGECLCluster > clusterlist, std::vector< bool > &ecl_phimap, std::vector< bool > &ecl_phimap_fwd, std::vector< bool > &ecl_phimap_bwd, std::vector< bool > &ecl_sectormap_fwd, std::vector< bool > &ecl_sectormap_bwd)
Make the ecl endcap phi map for inner/short track matching.
void sectormatching_klm(CDCTriggerTrack *track, StoreObjPtr< KLMTrgSummary > klmtrgsummary, double &dphi, int &klmtrack_ind_phi)
calculate dphi between 2D track and KLM track
std::string m_grlphotonlist
Non-matched cluster list at GRL.
std::vector< bool > eecl_phimap_bwd
36 bits phi map of ECL clusters at backward endcap
std::vector< bool > eecl_phimap_fwd
36 bits phi map of ECL clusters at forward endcap
void fill_pattern_base2(std::vector< std::vector< int > > &patt)
Fill the patterns in short tracking logic.
std::string m_3d_tracklist
the 3D NN track list
double m_e_threshold
min value of isolated cluster energy
std::vector< bool > eklm_sectormap_bwd
8 bits sector map of KLM clusters at backward endcap
std::string m_clusterlist
the ecl cluster list
std::string m_hitCollectionName
Track Segment list.
std::vector< bool > eecl_sectormap_bwd
8 bits sector map of ECL clusters at backward endcap
void make_eklm_map(StoreObjPtr< KLMTrgSummary > klmtrgsummary, std::vector< bool > &eklm_sectormap, std::vector< bool > &eklm_sectormap_fwd, std::vector< bool > &eklm_sectormap_bwd)
Make the klm endcap phi map for inner/short track matching.
std::string m_3dmatch_tracklist
the matched 3d track list
A class to represent a matching candidate in TRGGRL A matching candidate consists of a TRGCDCTrack an...
Definition: TRGGRLMatch.h:24
a class for neutral ECL cluster in TRGGRL
Definition: TRGGRLPHOTON.h:21
void set_e(double e)
set energy
Definition: TRGGRLPHOTON.h:39
a class for neutral ECL cluster in TRGGRL
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
double atan(double a)
atan for double
Definition: beamHelpers.h:34
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.