TopDownSelector.cc
Go to the documentation of this file.
1 #include "TopDownSelector.h"
2 #include <utl/ErrorLogger.h>
3 
4 #include <evt/Event.h>
5 #include <evt/ShowerSRecData.h>
6 #include <evt/ShowerRecData.h>
7 #include <sevt/EventTrigger.h>
8 #include <sevt/SEvent.h>
9 #include <sevt/Station.h>
10 #include <sevt/StationConstants.h>
11 #include <sevt/SortCriteria.h>
12 
13 #include <fwk/CentralConfig.h>
14 #include <det/Detector.h>
15 #include <sdet/Station.h>
16 #include <sdet/SDetector.h>
17 #include <utl/CoordinateSystemPtr.h>
18 #include <utl/Branch.h>
19 
20 #include <TCdasUtil.h>
21 
22 using namespace sdet;
23 using namespace std;
24 using namespace sevt;
25 using namespace evt;
26 using namespace fwk;
27 using namespace utl;
28 using namespace TopDownSelectorNS;
29 
30 
31 static bool bFirstIteration;
32 
33 
34 TopDownSelector::TopDownSelector() :
35  fSEvent(0),
36  fVerbose(0),
37  fRejectNonT4Events(false),
38  fU(0),
39  fV(0),
40  fXCore(0),
41  fYCore(0),
42  fZCore(0),
43  fTCore(0),
44  fNMinStations(3),
45  fNMaxRemovedStations(4)
46 { }
47 
48 
51 {
52  INFO("TopDownSelector::Init()");
53 
54  Branch tb = CentralConfig::GetInstance()->GetTopBranch("TopDownSelector");
55  tb.GetChild("RejectNonT4Events").GetData(fRejectNonT4Events);
56 
57  tb.GetChild("MinNumberStations").GetData(fNMinStations);
58  tb.GetChild("MaxRejectedStations").GetData(fNMaxRemovedStations);
59 
60  tb.GetChild("Verbose").GetData(fVerbose);
61  tb.GetChild("BaryPower").GetData(kBaryPower);
62  tb.GetChild("TimeResidualTolerance").GetData(kTolRes);
63  tb.GetChild("MTimeResidualTolerance").GetData(kTolResM);
64  tb.GetChild("IsolatedDistance1").GetData(kIsoDist1);
65  tb.GetChild("IsolatedDistance2").GetData(kIsoDist2);
66  tb.GetChild("Curv0").GetData(kCurv0);
67  tb.GetChild("AreaMin").GetData(kAreaMin);
68  tb.GetChild("AreaMax").GetData(kAreaMax);
69  tb.GetChild("Ana3RatMin").GetData(kAna3RatMin);
70  tb.GetChild("DistMax").GetData(kDistMax);
71  tb.GetChild("IsoTime1").GetData(kIsoTime1);
72  tb.GetChild("IsoTime2").GetData(kIsoTime2);
73 
74  return eSuccess;
75 }
76 
77 
80 {
81  INFO("TopDownSelector::Run()");
82 
83  if (!event.HasSEvent()) {
84  INFO("TopDownSelector::Run() => Event has not SEvent");
85  return eContinueLoop;
86  }
87 
88  fSEvent = &event.GetSEvent();
89 
90  const bool isFD = fSEvent->GetTrigger().IsFD();
91  const bool isSdT4 = Select();
92 
93  if (!event.HasRecShower())
94  event.MakeRecShower();
95  if (!event.GetRecShower().HasSRecShower())
96  event.GetRecShower().MakeSRecShower();
97 
98  ShowerSRecData& shSRec = event.GetRecShower().GetSRecShower();
99  shSRec.SetT4Trigger((isFD * ShowerSRecData::eT4_FD) |
100  (isSdT4 * ShowerSRecData::eT4_4C1));
101 
102  if (fRejectNonT4Events && !isSdT4) {
103  INFO("Event was not selected.");
104  return eContinueLoop;
105  }
106  return eSuccess;
107 }
108 
109 
112 {
113  INFO("TopDownSelector::Finish()");
114  return eSuccess;
115 }
116 
117 
118 // ==============================================
119 // driving function
120 // ==============================================
121 
122 bool
124 {
125  InitializeEvent();
126 
127  const unsigned int ns = fStations.size();
128  const unsigned int k = ((ns - fNMinStations) < fNMaxRemovedStations) ? ns - fNMinStations : fNMaxRemovedStations;
129 
130  // trivial selection
131  if (ns < fNMinStations)
132  return false;
133 
134  if (PatternRecovering()) {
135  if (fVerbose > 0)
136  cout << " Event Accepted with all stations. Theta ~ "
137  << EstimatedZenith("deg") << " deg." << endl;
138  return true;
139  }
140 
141  // "top down" selection
142  bFirstIteration = true;
143  for (unsigned int i = 1; i <= k; ++i) {
144  fIndexes.clear();
145  fIndexes.resize(i);
146  fIndexes[i-1] = ns;
147  if (fVerbose > 1) {
148  cout << " Select: Trying with " << i << " less stations over "<< ns << endl;
149  for (unsigned int ik = 0; ik < i; ++ik)
150  cout << " Select: fIndexes[" << ik << "] = "<< fIndexes[ik] << endl;
151  }
152  if (TryRemovingStations(i)) {
153  for (unsigned int j = 0; j < fStations.size(); ++j) {
154  if (!fStations[j].candidate)
155  fStations[j].event->SetRejected(sevt::StationConstants::eOutOfTime);
156  }
157  if (fVerbose > 0) {
158  cout << " Event accepted with " << i << " rejected. Theta ~ "
159  << EstimatedZenith("deg") << " deg." << endl;
160  }
161  return true;
162  }
163  }
164 
165  bFirstIteration = false;
166  for (unsigned int i = 1; i <= k; ++i) {
167  fIndexes.clear();
168  fIndexes.resize(i);
169  fIndexes[i-1] = ns;
170  if (fVerbose > 1) {
171  cout << " Select: Trying with " << i << " less stations over "<< ns << endl;
172  for (unsigned int ik = 0; ik < i; ++ik)
173  cout << " Select: fIndexes[" << ik << "] = "<< fIndexes[ik] << endl;
174  }
175  if (TryRemovingStations(i)) {
176  for (unsigned int j = 0; j < fStations.size(); ++j) {
177  if (!fStations[j].candidate)
178  fStations[j].event->SetRejected(sevt::StationConstants::eOutOfTime);
179  }
180  if (fVerbose > 0) {
181  cout << " Event accepted with " << i << " rejected. Theta ~ "
182  << EstimatedZenith("deg") << " deg." << endl;
183  }
184  return true;
185  }
186  }
187 
188  return false;
189 }
190 
191 
192 void
194 {
195  RemoveEA();
196  RemoveDoublets();
198 
199  fStations.clear();
200  const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
203  sIt != fSEvent->CandidateStationsEnd(); ++sIt) {
204  StationPairStatus stationPair;
205  stationPair.detector = &sdetector.GetStation(*sIt);
206  stationPair.event = &(*sIt);
207  stationPair.candidate = true;
208  fStations.push_back(stationPair);
209  }
210 }
211 
212 
213 void
215 {
217  sIt != fSEvent->CandidateStationsEnd(); ++sIt) {
218  if (sIt->GetId() < 100) {
220  }
221  }
222 }
223 
224 
225 // This one actually removes all off-grid stations (in-fill, triplets, doublets),
226 // not only doublets. If we want to remove only doublets we need to change IsInFill
227 // by the corresponding one
228 void
230 {
231  const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
232 
234  sIt != fSEvent->CandidateStationsEnd(); ++sIt) {
235  const sdet::Station& station = sdetector.GetStation(*sIt);
236  if (!station.IsInGrid()) {
237  sIt->SetRejected(sevt::StationConstants::eOffGrid);
238  }
239  }
240 }
241 
242 
243 void
245 {
246  const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
247 
249  sIt_1 != fSEvent->CandidateStationsEnd(); ++sIt_1) {
250  utl::Point fStPoint1 = sdetector.GetStation(*sIt_1).GetPosition();
251  int n1 = 0;
252  int n2 = 0;
253  TimeStamp t1 = sIt_1->GetRecData().GetSignalStartTime();
254 
256  sIt_2 != fSEvent->CandidateStationsEnd(); ++sIt_2) {
257  if (sIt_1->GetId() == sIt_2->GetId())
258  continue;
259 
260  const utl::Point fStPoint2 = sdetector.GetStation(*sIt_2).GetPosition();
261  const double d = ( fStPoint1 - fStPoint2 ).GetMag();
262  const TimeStamp t2 = sIt_2->GetRecData().GetSignalStartTime();
263  const double dt = fabs((t1-t2).GetInterval());
264 
265  if (d < kIsoDist1 && dt < kIsoTime1)
266  ++n1;
267  if (d < kIsoDist2 && dt < kIsoTime2)
268  ++n2;
269  }
270 
271  if (n1 == 0)
272  sIt_1->SetRejected(sevt::StationConstants::eLonely);
273 
274  if (n1 && n2 < 2)
275  sIt_1->SetRejected(sevt::StationConstants::eLonely);
276  }
277 }
278 
279 
280 /*void
281 TopDownSelector::RemoveIsolatedStations()
282 {
283  const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
284  // discarding very isolated stations
285  unsigned int size = fStations.size();
286  if (size>=40) kIsoDist1=3400.; // => gain time in case of huge events...
287  for (sevt::SEvent::CandidateStationIterator sIt_1 = fSEvent->CandidateStationsBegin(); sIt_1 != fSEvent->CandidateStationsEnd(); ++sIt_1) {
288  int n1 = 0;
289  int n2 = 0;
290  for (sevt::SEvent::CandidateStationIterator sIt_2 = fSEvent->CandidateStationsBegin(); sIt_2 != fSEvent->CandidateStationsEnd(); ++sIt_2) {
291  const double d = (sdetector.GetStation(*sIt_1).GetPosition() - sdetector.GetStation(*sIt_2).GetPosition()).GetMag();
292  if ( d<kIsoDist1 ) n1++;
293  if ( d<kIsoDist2 ) n2++;
294  }
295  if (n1==0) sIt_1->SetRejected(sevt::StationConstants::eLonely);
296  if (n1 && n2<2) sIt_1->SetRejected(sevt::StationConstants::eLonely);
297  }
298 }
299 */
300 
301 
302 // ==============================================
303 // selection algorithm
304 // ==============================================
305 
306 bool
308 {
309  unsigned int ns = 0;
310  for (unsigned int is = 0; is < fStations.size(); ++is)
311  if (fStations[is].candidate)
312  ++ns;
313 
314  if (ns == 3) {
315  if (fNMinStations == 3)
316  return Recover3Stations();
317  else
318  return false;
319  }
320  if (!EstimateCore())
321  return false;
322  fIsLastTimingIteration = false;
323  if (!IsGoodTimeConfig(eNone))
324  return false;
325  if (!IsGoodSpaceConfig())
326  return false;
327  fIsLastTimingIteration = true;
329  return false;
330  if (IsAligned())
331  return false;
332  return true;
333 }
334 
335 
336 bool
338 {
339  if (n < 2) {
340  for (unsigned int is = 0; is < fIndexes[0]; ++is) {
341  fStations[is].candidate = false;
342  if (PatternRecovering())
343  return true;
344  fStations[is].candidate = true;
345  }
346  } else {
347  for (unsigned int is = n-1; is < fIndexes[n-1]; ++is) {
348  fStations[is].candidate = false;
349  fIndexes[n-2] = is;
350  if (TryRemovingStations(n-1))
351  return true;
352  fStations[is].candidate = true;
353  }
354  }
355  return false;
356 }
357 
358 
359 bool
361 {
362  const CoordinateSystemPtr siteCS =
363  det::Detector::GetInstance().GetSiteCoordinateSystem();
364  const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
365 
366  fBarycenter = Vector(0,0,0, siteCS);
367  fBaryTime = 0;
368 
369  // the absolute points in time and space
370  const Point siteOrigin(0,0,0, siteCS);
371  const TimeStamp& eventTime = fSEvent->GetTrigger().GetTime();
372 
373  if (fVerbose > 2)
374  cout << " Estimating core..." << endl;
375 
376  unsigned int size = fStations.size();
377  double sumw = 0;
378  for (unsigned int is = 0; is < size; ++is) {
379  if (!fStations[is].candidate)
380  continue;
381  sevt::Station& station = *fStations[is].event;
382 
383  const double weight = exp(kBaryPower*log(station.GetRecData().GetTotalSignal()));
384  fBarycenter += weight * (sdetector.GetStation(station).GetPosition() - siteOrigin);
385  fBaryTime += weight *
386  (eventTime - station.GetRecData().GetSignalStartTime()).GetInterval();
387 
388  sumw += weight;
389  }
390  if (sumw == 0) {
391  if (fVerbose > 2)
392  cout << " ...FAILED." << endl;
393  return false;
394  }
395  fBarycenter /= sumw;
396  fBaryTime /= sumw;
397  fTCore = fBaryTime;
398  fXCore = fBarycenter.GetX(siteCS);
399  fYCore = fBarycenter.GetY(siteCS);
400  fZCore = fBarycenter.GetZ(siteCS);
401 
402  if (fVerbose > 2)
403  cout << " ... Core(X,Y,Z,t): ("
404  << fXCore << " , "
405  << fYCore << " , "
406  << fZCore << " , "
407  << fTCore << ")" << endl;
408 
409  return true;
410 }
411 
412 
413 double
415 {
416  const CoordinateSystemPtr siteCS =
417  det::Detector::GetInstance().GetSiteCoordinateSystem();
418  const double costh = sqrt(max(0., 1 - fU*fU - fV*fV));
419  return costh * (fStations[is].detector->GetPosition().GetZ(siteCS) - fZCore) / kSpeedOfLight;
420 }
421 
422 
423 double
425 {
426  // this is not used right now and probably shouldn't be used (HD)
427  const CoordinateSystemPtr siteCS =
428  det::Detector::GetInstance().GetSiteCoordinateSystem();
429  const double costh = sqrt(max(0., 1 - fU*fU - fV*fV));
430  const double dx = fStations[is].detector->GetPosition().GetX(siteCS);
431  const double dy = fStations[is].detector->GetPosition().GetY(siteCS);
432  const double d2 = dx*dx + dy*dy - pow(fU*dx + fV*dy, 2);
433  // WARNING: model of the curvature seems too simple (HD)
434  const double curv = kCurv0 * costh;
435  return (costh * (fStations[is].detector->GetPosition().GetZ(siteCS) - fZCore) - 0.5*curv*d2) / kSpeedOfLight;
436 }
437 
438 
439 bool
441 {
442  const CoordinateSystemPtr siteCS =
443  det::Detector::GetInstance().GetSiteCoordinateSystem();
444  unsigned int is, ns = 0;
445  double wgt, dx, dy, dt, sumw, sumx, sumy, sumx2, sumy2, sumxy, sumt, sumxt, sumyt;
446  double rxx, ryy, rxy, rx, ry, rr, deter;
447 
448  if (fVerbose > 2)
449  cout << " Checking for Good Time Configuration. Correction Type: " << correctionType << " ..." << endl;
450 
451  const TimeStamp& eventTime = fSEvent->GetTrigger().GetTime();
452  unsigned int size = fStations.size();
453  sumw = sumx = sumy = sumx2 = sumy2 = sumxy = sumt = sumxt = sumyt = 0;
454  for (is = 0; is < size; ++is) {
455  if (!fStations[is].candidate)
456  continue;
457 
458  dx = fStations[is].detector->GetPosition().GetX(siteCS) - fXCore;
459  dy = fStations[is].detector->GetPosition().GetY(siteCS) - fYCore;
460 
461  if (correctionType == TopDownSelector::eAltitude)
462  dt = CorrectTimeAltitude(is);
463  else if (correctionType == TopDownSelector::eAltitudeCurved)
464  dt = CorrectTimeAltitudeCurv(is);
465  else if (correctionType == TopDownSelector::eNone)
466  dt = 0;
467  else {
468  dt = 0;
469  INFO("Timing Correction Type not recognized. No correction done.");
470  }
471  dt +=
472  (eventTime-fStations[is].event->GetRecData().GetSignalStartTime()).GetInterval() -
473  fBaryTime;
474  wgt = 1;
475  sumw += wgt;
476  sumx += wgt * dx;
477  sumy += wgt * dy;
478  sumx2 += wgt * dx*dx;
479  sumy2 += wgt * dy*dy;
480  sumxy += wgt * dx * dy;
481  sumt += wgt * dt;
482  sumxt += wgt * dt * dx;
483  sumyt += wgt * dt * dy;
484  ++ns;
485  }
486 
487  rxx = sumw * sumy2 - sumy*sumy;
488  ryy = sumw * sumx2 - sumx*sumx;
489  rxy = sumx * sumy - sumw * sumxy;
490  rx = sumxy * sumy - sumx * sumy2;
491  ry = sumxy * sumx - sumy * sumx2;
492  rr = sumx2 * sumy2 - sumxy*sumxy;
493  deter = sumx2 * rxx + sumxy * rxy + sumx * rx;
494 
495  if (deter == 0 || std::isnan(deter))
496  return false;
497  fU = (rxx * sumxt + rxy * sumyt + rx * sumt) / deter;
498  fV = (rxy * sumxt + ryy * sumyt + ry * sumt) / deter;
499  fT0 = (rx * sumxt + ry * sumyt + rr * sumt) / deter;
500  fU *= -kSpeedOfLight;
501  fV *= -kSpeedOfLight;
502 
504  return true;
505  if (fU*fU + fV*fV > 1)
506  return false;
507 
508  if (ns == 3)
509  return true;
510 
511  double sumdt2 = 0;
512  double costh = sqrt(max(0., 1 - fU*fU - fV*fV));
513 
514  if (fVerbose > 3)
515  cout << " Weight sum: " << sumw
516  << "\t Residual Max: " << (ns-2)*kTolResM*max(costh, 0.2) << endl;
517 
518  fResiduals.clear();
519  for (is = 0; is < size; ++is) {
520  if (!fStations[is].candidate || !fStations[is].event->HasRecData())
521  continue; // trying patterns...
522  const double dx = fStations[is].detector->GetPosition().GetX(siteCS) - fXCore;
523  const double dy = fStations[is].detector->GetPosition().GetY(siteCS) - fYCore;
524  const double dt =
525  (eventTime-fStations[is].event->GetRecData().GetSignalStartTime()).GetInterval() -
526  fBaryTime - (fT0 -fU*dx/kCdasUtil::CSPEED - fV*dy/kCdasUtil::CSPEED);
527  sumdt2 += dt*dt;
528 
529  if (fVerbose > 3)
530  cout << " St: " << fStations[is].event->GetId()
531  << "\tResidual: " << dt << " --> ";
532 
533  if (fabs(dt) > (ns - 2)*kTolResM*max(costh, 0.2)){
534  if (fVerbose > 3)
535  cout << " Pattern REJECTED." << endl;
536  return false;
537  }
538 
539  if (fVerbose > 3)
540  cout << " St. ACCEPTED." << endl;
541  fResiduals.push_back(dt);
542  }
543 
544  if (sqrt(sumdt2 / (ns - 3)) > (ns - 2)*kTolRes*max(costh, 0.2)) {
545  if (fVerbose > 3)
546  cout << " REJECTED by tolerance on mean RMS of residuals" << endl;
547  return false;
548  }
549 
550  double sin2th = fU*fU + fV*fV;
551  if (sin2th >= 1 && bFirstIteration) {
552  if (fVerbose > 3)
553  cout << " REJECTED (firstIt && sin2th > 1)" << endl;
554  return false;
555  }
556  if (sin2th >= 1) {
557  fU /= sqrt(sin2th);
558  fV /= sqrt(sin2th);
559  }
560 
561  return true;
562 }
563 
564 
565 bool
567 {
568  const CoordinateSystemPtr siteCS =
569  det::Detector::GetInstance().GetSiteCoordinateSystem();
570  unsigned int ns = fStations.size();
571  double dist2_max_proj = pow(1300., 2.) * (ns - 2);
572 
573  if (fVerbose > 2)
574  cout << " Checking Space Configuration..." << endl;
575 
576  if (fVerbose > 3)
577  cout << " Maximum Proj. Dist squared: " << dist2_max_proj << endl;
578 
579  for (int i = ns-1; i >= 0; --i) {
580  if (!fStations[i].candidate)
581  continue;
582  const double dx = fStations[i].detector->GetPosition().GetX(siteCS) - fXCore;
583  const double dy = fStations[i].detector->GetPosition().GetY(siteCS) - fYCore;
584  const double dist2 = pow(dx, 2.) + pow(dy, 2.) - pow(fU*dx + fV*dy, 2.);
585  if (fVerbose > 3)
586  cout << " St: " << fStations[i].event->GetId()
587  << "\tDist square: " << dist2 << " --> ";
588 
589  if (dist2 > dist2_max_proj) {
590  if (fVerbose > 3)
591  cout << " Pattern REJECTED." << endl;
592  return false;
593  }
594  if (fVerbose > 3)
595  cout << " St. ACCEPTED." << endl;
596  }
597  return true;
598 }
599 
600 
601 bool
603 {
604  const CoordinateSystemPtr siteCS =
605  det::Detector::GetInstance().GetSiteCoordinateSystem();
606  unsigned int ns = fStations.size();
607  double xmean = 0, ymean = 0;
608  for (unsigned int is = 0; is < ns; ++is) {
609  if (!fStations[is].candidate)
610  continue;
611  xmean += fStations[is].detector->GetPosition().GetX(siteCS) / double(ns);
612  ymean += fStations[is].detector->GetPosition().GetY(siteCS) / double(ns);
613  }
614  vector<double> dx(ns);
615  vector<double> dy(ns);
616  for (unsigned int is = 0; is < ns; ++is) {
617  if (!fStations[is].candidate)
618  continue;
619  dx[is] = fStations[is].detector->GetPosition().GetX(siteCS) - xmean;
620  dy[is] = fStations[is].detector->GetPosition().GetY(siteCS) - ymean;
621  }
622  double ixx = 0, ixy = 0, iyy = 0;
623  for (unsigned int is = 0; is < ns; ++is) {
624  if (!fStations[is].candidate)
625  continue;
626  ixx += dx[is]*dx[is];
627  iyy += dy[is]*dy[is];
628  ixy += dx[is]*dy[is];
629  }
630  const double zeta = 0.5*atan2(2*ixy, ixx - iyy);
631  vector<double> lg(ns);
632  vector<double> tr(ns);
633  for (unsigned int is = 0; is < ns; ++is) {
634  if (!fStations[is].candidate)
635  continue;
636  lg[is] = dx[is]*cos(zeta) + dy[is]*sin(zeta);
637  tr[is] = dx[is]*sin(zeta) - dy[is]*cos(zeta);
638  }
639  double longi = 0, trans = 0;
640  for (unsigned int is = 0; is < ns; ++is) {
641  if (!fStations[is].candidate)
642  continue;
643  longi += lg[is]*lg[is];
644  trans += tr[is]*tr[is];
645  }
646  longi = sqrt(longi);
647  trans = sqrt(trans);
648  if (longi < 300)
649  return true;
650 
651  if (trans < 300)
652  return true;
653 
654  return false;
655 }
656 
657 
658 double
660 {
661  if (s == "deg")
662  return asin(sqrt(fU*fU + fV*fV)) / degree;
663  return asin(sqrt(fU*fU + fV*fV));
664 }
665 
666 
667 double
669 {
670  if (s == "deg")
671  return atan2(fV, fU) / degree;
672  return atan2(fV, fU);
673 }
674 
675 
676 bool
678 {
679  const CoordinateSystemPtr siteCS =
680  det::Detector::GetInstance().GetSiteCoordinateSystem();
681  const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
682 
683  int index[3];
684  unsigned int ns = fStations.size();
685  for (unsigned int i = 0, j = 0; i < ns; ++i) {
686  if (!fStations[i].candidate)
687  continue;
688 
689  index[j] = i;
690  ++j;
691  }
692 
693  // area and maximal distance
694  const double st1X = sdetector.GetStation(*fStations[index[0]].event).GetPosition().GetX(siteCS);
695  const double st1Y = sdetector.GetStation(*fStations[index[0]].event).GetPosition().GetY(siteCS);
696  const double st2X = sdetector.GetStation(*fStations[index[1]].event).GetPosition().GetX(siteCS);
697  const double st2Y = sdetector.GetStation(*fStations[index[1]].event).GetPosition().GetY(siteCS);
698  const double st3X = sdetector.GetStation(*fStations[index[2]].event).GetPosition().GetX(siteCS);
699  const double st3Y = sdetector.GetStation(*fStations[index[2]].event).GetPosition().GetY(siteCS);
700  const double deter =
701  st1X * st2Y - st1Y * st2X +
702  st2X * st3Y - st2Y * st3X +
703  st3X * st1Y - st3Y * st1X;
704  double dist2 = pow(st1X - st2X, 2.) + pow(st1Y - st2Y, 2.);
705  dist2 = max(dist2, pow(st2X - st3X, 2.) + pow(st2Y - st3Y, 2.));
706  dist2 = max(dist2, pow(st3X - st1X, 2.) + pow(st3Y - st1Y, 2.));
707 
708  // geometrical extension : cut on area of the triangle
709  if (fabs(0.5*deter) > kAreaMax || fabs(0.5*deter) < kAreaMin) {
710  return false;
711  }
712  // cut on distance between stations
713  if (dist2 > pow(kDistMax, 2.)) {
714  return false;
715  }
716  //--- computation of direction
717 
718  double dt1 = (fStations[index[1]].event->GetRecData().GetSignalStartTime() -
719  fStations[index[0]].event->GetRecData().GetSignalStartTime()).GetInterval();
720  double dt2 = (fStations[index[2]].event->GetRecData().GetSignalStartTime() -
721  fStations[index[0]].event->GetRecData().GetSignalStartTime()).GetInterval();
722 
723  fU = kSpeedOfLight * ((st1Y - st3Y)*dt1 - (st1Y - st2Y)*dt2) / deter;
724  fV = kSpeedOfLight * ((st3X - st1X)*dt1 - (st2X - st1X)*dt2) / deter;
725 
726  EstimateCore();
727 
728  fIsLastTimingIteration = false;
729  if (!IsGoodTimeConfig(eAltitude)) {
730  return false;
731  }
732 
733  // fIsLastTimingIteration=true; if (!TopDownIsGoodTimeConfig(2)) return false;
734  double sin2th = fU*fU + fV*fV;
735  if (sin2th > 1) {
736  return false; // no SINTHMAX condition...
737  }
738  return true;
739 }
Branch GetTopBranch() const
Definition: Branch.cc:63
const double degree
Point object.
Definition: Point.h:32
Detector description interface for Station-related data.
Report success to RunController.
Definition: VModule.h:62
Interface class to access to the SD Reconstruction of a Shower.
std::vector< unsigned int > fIndexes
bool HasRecShower() const
Skip remaining modules in the current loop and continue with next iteration of the loop...
Definition: VModule.h:68
ShowerRecData & GetRecShower()
bool is(const double a, const double b)
Definition: testlib.cc:113
EventTrigger & GetTrigger()
Get the object with central trigger data, throw if n.a.
Definition: SEvent.h:148
sevt::StationRecData & GetRecData()
Get station level reconstructed data.
double EstimatedAzimuth(const std::string &s)
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
bool IsInGrid(const SDetectorConstants::GridIndex index=SDetectorConstants::eStandard) const
Tells whether the station is in the regular triangular grid.
boost::filter_iterator< CandidateStationFilter, StationIterator > CandidateStationIterator
Iterator over candidate stations.
Definition: SEvent.h:68
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
double pow(const double x, const unsigned int i)
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
void SortStations(const OrderingCriterion ord) const
Sort the list of stations by the criterion specified in an OrderingCriterion object.
Definition: SEvent.h:172
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
double EstimatedZenith(const std::string &s)
utl::Point GetPosition() const
Tank position.
Criterion to sort stations by increasing signal.
Definition: SortCriteria.h:25
CandidateStationIterator CandidateStationsBegin()
Definition: SEvent.h:72
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
#define max(a, b)
Class representing a document branch.
Definition: Branch.h:107
class to hold data at Station level
constexpr double s
Definition: AugerUnits.h:163
utl::TimeStamp GetSignalStartTime() const
Start time of the signal.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
const double ns
bool IsGoodTimeConfig(TimeCorrectionType correctionType)
double GetTotalSignal() const
Total integrated signal in VEM unit, averaged over pmts.
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
std::vector< double > fResiduals
a second level trigger
Definition: XbT2.h:8
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
constexpr double kSpeedOfLight
static bool bFirstIteration
utl::TimeStamp GetTime() const
Get time of the trigger.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Vector object.
Definition: Vector.h:30
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
std::vector< StationPairStatus > fStations
CandidateStationIterator CandidateStationsEnd()
Definition: SEvent.h:74
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
void SetT4Trigger(const int t4)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
bool HasSRecShower() const
bool HasSEvent() const

, generated on Tue Sep 26 2023.