FdDoubleBumpFinder.cc
Go to the documentation of this file.
1 #include <det/Detector.h>
2 
3 #include <evt/Event.h>
4 #include <evt/GaisserHillas4Parameter.h>
5 #include <evt/ShowerFRecData.h>
6 #include <evt/ShowerRecData.h>
7 #include <evt/VGaisserHillasParameter.h>
8 #include <evt/GaisserHillas4Parameter.h>
9 #include <evt/MultipleGaisserHillasParameters.h>
10 
11 
12 #include <fdet/Camera.h>
13 #include <fdet/Eye.h>
14 #include <fdet/FDetector.h>
15 #include <fdet/Pixel.h>
16 #include <fdet/Telescope.h>
17 
18 #include <fevt/Eye.h>
19 #include <fevt/EyeHeader.h>
20 #include <fevt/EyeRecData.h>
21 #include <fevt/FEvent.h>
22 #include <fevt/Header.h>
23 #include <fevt/Pixel.h>
24 #include <fevt/PixelRecData.h>
25 #include <fevt/Telescope.h>
26 #include <fevt/TelescopeRecData.h>
27 
28 #include <fwk/CentralConfig.h>
29 #include <fwk/LocalCoordinateSystem.h>
30 #include <fwk/RandomEngineRegistry.h>
31 #include <fwk/VModule.h>
32 
33 #include <sdet/SDetector.h>
34 #include <sdet/Station.h>
35 
36 #include <sevt/Header.h>
37 #include <sevt/SEvent.h>
38 #include <sevt/Station.h>
39 #include <sevt/StationRecData.h>
40 
41 #include <utl/AugerUnits.h>
42 #include <utl/CoordinateSystemPtr.h>
43 #include <utl/ErrorLogger.h>
44 #include <utl/MathConstants.h>
45 #include <utl/PhysicalConstants.h>
46 #include <utl/RandomEngine.h>
47 #include <utl/Reader.h>
48 #include <utl/TabulatedFunctionErrors.h>
49 #include <utl/TimeInterval.h>
50 #include <utl/TimeStamp.h>
51 #include <utl/Transformation.h>
52 
53 #include "FdDoubleBumpFinder.h"
54 
55 #include "ProfileFitter.h"
56 
57 #include <sstream>
58 #include <iostream>
59 #include <vector>
60 
61 //do not use namespace evt, det
62 using namespace std;
63 using namespace fwk;
64 using namespace utl;
65 using namespace atm;
66 using namespace fevt;
67 using namespace sevt;
68 using namespace evt::gh;
69 using namespace fdDoubleBumpFinder;
70 
71 
72 FdDoubleBumpFinder::FdDoubleBumpFinder() : fProfileFitter()
73 { }
74 
75 
78 {
79  CentralConfig* const cc = CentralConfig::GetInstance();
80  Branch topB = cc->GetTopBranch("FdDoubleBumpFinder");
81 
82  if (!topB) {
83  ERROR("Could not find branch FdDoubleBumpFinder");
84  return eFailure;
85  }
86 
87  Branch preSelectEventsB = topB.GetChild("preSelectEvents");
88  if (!preSelectEventsB) {
89  ERROR("Could not find branch preSelectEvents");
90  return eFailure;
91  }
92  preSelectEventsB.GetData(fPreSelectEvents);
93 
94  Branch maxZenithB = topB.GetChild("maxZenith");
95  if (!maxZenithB) {
96  ERROR("Could not find branch maxZenith");
97  return eFailure;
98  }
99  maxZenithB.GetData(fMaxZenith);
100 
101  Branch minAxisPixelsB = topB.GetChild("minAxisPixels");
102  if (!minAxisPixelsB) {
103  ERROR("Could not find branch minAxisPixels");
104  return eFailure;
105  }
106  minAxisPixelsB.GetData(fMinAxisPixels);
107 
108  Branch maxCoreTankDistB = topB.GetChild("maxCoreTankDist");
109  if (!maxCoreTankDistB) {
110  ERROR("Could not find branch maxCoreTankDist");
111  return eFailure;
112  }
113  maxCoreTankDistB.GetData(fMaxCoreTankDist);
114 
115  Branch cutValueB = topB.GetChild("cutValue");
116  if (!cutValueB) {
117  ERROR("Could not find branch cutValue");
118  return eFailure;
119  }
120  cutValueB.GetData(fCutValue);
121 
122  Branch constraintXFirstB = topB.GetChild("constraintXFirst");
123  if (!constraintXFirstB) {
124  ERROR("Could not find branch constraintXFirst");
125  return eFailure;
126  }
127  constraintXFirstB.GetData (fConstraintXFirst);
128 
129  Branch constraintLambdaB = topB.GetChild("constraintLambda");
130  if (!constraintLambdaB) {
131  ERROR("Could not find branch constraintLambda");
132  return eFailure;
133  }
134  constraintLambdaB.GetData(fConstraintLambda);
135 
136  Branch constraintXFirstMinusXMaxB = topB.GetChild("constraintXFirstMinusXMax");
137  if (!constraintXFirstMinusXMaxB) {
138  ERROR("Could not find branch constraintXFirstMinusXMax");
139  return eFailure;
140  }
141  constraintXFirstMinusXMaxB.GetData(fConstraintXFirstMinusXMax);
142 
143  Branch verbosityB = topB.GetChild("verbosity");
144  if (!verbosityB) {
145  ERROR("Could not find branch verbosity");
146  return eFailure;
147  }
148  verbosityB.GetData(fVerbosity);
149 
150  const string version = GetVersionInfo(VModule::eRevisionNumber);
151 
152  std::ostringstream info;
153  info << " Version: " << version
154  << "\n\t Parameters:"
155  << endl
156  << "\n\t Preselection of events = " << fPreSelectEvents
157  << endl
158  << "\n\t Cut value = " << fCutValue
159  << "\n\t Max core tank dis = " << fMaxCoreTankDist / m << " m"
160  << "\n\t Min axis pixels = " << fMinAxisPixels
161  << "\n\t Max zenith angle = " << fMaxZenith / degree << "°"
162  << endl
163  << "\n\t Constraint XFirst = " << fConstraintXFirst / g * cm * cm << " g/cm²"
164  << "\n\t Constraint Lambda = " << fConstraintLambda / g * cm * cm << " g/cm²"
165  << "\n\t Constraint XFirst-XMax = " << fConstraintXFirstMinusXMax / g * cm * cm << " g/cm²"
166  << endl;
167 
168  if (fVerbosity >- 1) {
169  INFO(info);
170  }
171 
172  return eSuccess;
173 }
174 
175 
178 {
179  if (fVerbosity > -1)
180  INFO("---Starting FdDoubleBumpFinder");
181 
182  if (!event.HasFEvent()) {
183  if (fVerbosity > -1)
184  WARNING("---No FD Event");
185  return eContinueLoop;
186  }
187 
188  FEvent& fdEvent = event.GetFEvent();
189  for (FEvent::EyeIterator eyeIter = fdEvent.EyesBegin(ComponentSelector::eHasData);
190  eyeIter != fdEvent.EyesEnd(ComponentSelector::eHasData); ++eyeIter) {
191 
192  if (fVerbosity > -1) {
193  ostringstream ostr;
194  ostr << "---Processing eye " << eyeIter->GetId();
195  INFO(ostr);
196  }
197 
198  if (fPreSelectEvents) {
199  if (!IsPreselected(event, *eyeIter)) {
200  if (fVerbosity > -1)
201  INFO("---Not Preselected");
202  continue;
203  }
204  }
205 
206  if (!Fit(*eyeIter)) {
207  if (fVerbosity > -1)
208  INFO("---Not Fitted");
209  continue;
210  }
211 
212  if (!FillRecData(event, *eyeIter)) {
213  if (fVerbosity > -1)
214  WARNING("!!!Error writing to event");
215  continue;
216  }
217  }
218 
219  return eSuccess;
220 }
221 
222 
223 bool
224 FdDoubleBumpFinder::Scan(const vector<double>& depth,
225  const vector<double>& dEdX, const vector<double>& dEdXError,
226  double& xMax1, double& xMax2, double& dEdXMax1, double& dEdXMax2)
227 {
228  double trackMax, trackMin;
229  if (depth.size() > 1) {
230  trackMax = depth.back();
231  trackMin = depth.front();
232  } else {
233  if (fVerbosity > 0)
234  WARNING("Depth.size() < 2; aborting scan");
235  return false;
236  }
237 
238  vector<double>::const_iterator ite = dEdX.begin();
239  double energyMax = *ite;
240  while (ite < dEdX.end()) {
241  if (*ite > energyMax)
242  energyMax = *ite;
243  ite++;
244  }
245 
246  const double energyMin = energyMax/10.;
247 
248  double chi2Min = 1e99;
249 
250  vector<double>::const_iterator itd;
251  vector<double>::const_iterator itee;
252  double xfirst1 = fConstraintXFirst / g * cm * cm;
253  double lambda = fConstraintLambda / g * cm * cm;
254  double xfirstminusxmax = fConstraintXFirstMinusXMax / g * cm * cm;
255 
256  for (double ixMax1 = trackMin; ixMax1 <= trackMax; ixMax1 += trackMax/10) {
257  for (double ixMax2 = ixMax1; ixMax2 <= trackMax; ixMax2 += trackMax/10) {
258  for (double idEdXMax1 = energyMin; idEdXMax1 < energyMax; idEdXMax1 += energyMax/10) {
259  for (double idEdXMax2 = energyMin; idEdXMax2 < energyMax; idEdXMax2 += energyMax/10) {
260  double chi2=0;
261  itd = depth.begin();
262  ite = dEdX.begin();
263  itee = dEdXError.begin();
264 
265  while (itd < depth.end()) {
266  if (*itee != 0)
267  chi2 += pow(profileFit::DoubleGHFunction(*itd, xfirst1, lambda, ixMax1, idEdXMax1, ixMax2 + xfirstminusxmax, lambda, ixMax2, idEdXMax2) - *ite,2)/ *itee / *itee;
268  ++itd;
269  ++ite;
270  ++itee;
271  }
272  if (chi2 < chi2Min) {
273  chi2Min = chi2;
274  xMax1 = ixMax1;
275  xMax2 = ixMax2;
276  dEdXMax1 = idEdXMax1;
277  dEdXMax2 = idEdXMax2;
278  }
279  }
280  }
281  }
282  }
283 
284  if (chi2Min == 1e99) {
285  if (fVerbosity > 0)
286  WARNING("No Min Found; aborting scan");
287  return false;
288  }
289 
290  if (fVerbosity > 0) {
291  ostringstream ostr;
292  ostr << "---Scan(): ";
293  ostr << setprecision(2) << "Chi² = " << chi2Min
294  << "\t" << "XMax1 = " << xMax1
295  << "\t" << "XMax2 = " << xMax2
296  << "\t" << "dEdXMax1 = " << dEdXMax1
297  << "\t" << "dEdXMax2 = " << dEdXMax2;
298  INFO(ostr);
299  }
300 
301  return true;
302 }
303 
304 
305 bool
307 {
308  // Check for eye data
309  if (eye.HasRecData()) {
310  const EyeRecData& recData = eye.GetRecData();
311 
312  // Check for shower reconstruction
313  if (recData.HasFRecShower()) {
314  const evt::ShowerFRecData& showerData = recData.GetFRecShower();
315 
316  // Check for dE/dX profile
317  if (showerData.HasEnergyDeposit()) {
318  const TabulatedFunctionErrors& profile = showerData.GetEnergyDeposit();
319 
320  if (profile.GetNPoints() < 2) {
321  if (fVerbosity > 0)
322  WARNING("Need >= 2 points for profile fit; aborting fit");
323  return false;
324  }
325 
326  vector<double> depth;
327  transform(profile.XBegin(), profile.XEnd(), back_inserter(depth),
328  [](const auto& elem) { return elem / (g/cm2); });
329 
330  vector<double> dEdX;
331  transform(profile.YBegin(), profile.YEnd(), back_inserter(dEdX),
332  [](const auto& elem) { return elem / (PeV / (g/cm2)); });
333 
334  vector<double> dEdXError;
335  transform(profile.YErrBegin(), profile.YErrEnd(), back_inserter(dEdXError),
336  [](const auto& elem) { return elem / (PeV / (g/cm2)); });
337 
342 
343  vector<double> fitParameters;
344  vector<double> fitSteps;
345  vector<double> fitLimitsDown;
346  vector<double> fitLimitsUp;
347 
348  double xMax1start;
349  double xMax2start;
350  double dEdXMax1start;
351  double dEdXMax2start;
352 
353  // Search for a local minimum in GH function
354  if (Scan(depth, dEdX, dEdXError,
355  xMax1start, xMax2start, dEdXMax1start, dEdXMax2start))
356  {
357  //Set starting values for double GH fit
358  fitParameters.resize(profileFit::eNDGHpars);
359  fitSteps.resize(profileFit::eNDGHpars);
360  fitLimitsDown.resize(profileFit::eNDGHpars);
361  fitLimitsUp.resize(profileFit::eNDGHpars);
362 
363  fitParameters[profileFit::eDGHXmax1] = xMax1start;
364  fitSteps[profileFit::eDGHXmax1] = 10.;
365  fitParameters[profileFit::eDGHnMax1] = dEdXMax1start;
366  fitSteps[profileFit::eDGHnMax1] = dEdXMax1start*0.05;
367  fitParameters[profileFit::eDGHLambda1 ]= fConstraintLambda / g * cm * cm;
368  fitSteps[profileFit::eDGHLambda1] = 5.;
369  fitParameters[profileFit::eDGHX01] = fConstraintXFirst / g * cm * cm;
370  fitSteps[profileFit::eDGHX01] = 10;
371 
372  fitParameters[profileFit::eDGHXmax2] = xMax2start;
373  fitSteps[profileFit::eDGHXmax2] = 10;
374  fitParameters[profileFit::eDGHnMax2] = dEdXMax2start;
375  fitSteps[profileFit::eDGHnMax2] = dEdXMax2start*0.05;
376  fitParameters[profileFit::eDGHLambda2] = fConstraintLambda / g * cm * cm;
377  fitSteps[profileFit::eDGHLambda2] = 5.;
378  fitParameters[profileFit::eDGHX02] = xMax2start + fConstraintXFirstMinusXMax / g * cm * cm;
379  fitSteps[profileFit::eDGHX02] = 10;
380 
381  fitLimitsDown[profileFit::eDGHXmax1] = 0;
382  fitLimitsUp[profileFit::eDGHXmax1] = 2000;
383  fitLimitsDown[profileFit::eDGHnMax1] = 0;
384  fitLimitsUp[profileFit::eDGHnMax1] = 0;
385  fitLimitsDown[profileFit::eDGHLambda1] = 10;
386  fitLimitsUp[profileFit::eDGHLambda1] = 150;
387  fitLimitsDown[profileFit::eDGHX01] = -1000;
388  fitLimitsUp[profileFit::eDGHX01] = 500;
389 
390  fitLimitsDown[profileFit::eDGHXmax2] = 0;
391  fitLimitsUp[profileFit::eDGHXmax2] = 2000;
392  fitLimitsDown[profileFit::eDGHnMax2] = 0;
393  fitLimitsUp[profileFit::eDGHnMax2] = 0;
394  fitLimitsDown[profileFit::eDGHLambda2] = 10;
395  fitLimitsUp[profileFit::eDGHLambda2] = 150;
396  fitLimitsDown[profileFit::eDGHX02] = -1000;
397  fitLimitsUp[profileFit::eDGHX02] = 1000;
398  }
399  fProfileFitter.SetStartParameters(fitParameters, fitSteps, fitLimitsDown, fitLimitsUp);
400  fProfileFitter.SetData(depth.size(), &depth[0], &dEdX[0], &dEdXError[0]);
401 
402  // Double GH fit
403  if (fProfileFitter.Fit() && fProfileFitter.GetStatus() > 0) {
406  const vector<double>& fitPar = fProfileFitter.GetFitParameters();
407  fXMax1 = fitPar[profileFit::eDGHXmax1] * (g / cm2);
408  fXMax2 = fitPar[profileFit::eDGHXmax2] * (g / cm2);
409  fLambda1 = fitPar[profileFit::eDGHLambda1] * (g / cm2);
410  fLambda2 = fitPar[profileFit::eDGHLambda2] * (g / cm2);
411  fXFirst1 = fitPar[profileFit::eDGHX01] * (g / cm2);
412  fXFirst2 = fitPar[profileFit::eDGHX02] * (g / cm2);
413  fdEdXMax1 = fitPar[profileFit::eDGHnMax1] * PeV / (g / cm2);
414  fdEdXMax2 = fitPar[profileFit::eDGHnMax2] * PeV / (g / cm2);
415 
416  if (!showerData.HasGHParameters()) {
417  if (fVerbosity > 0)
418  WARNING("No GH Paramaters; aborting fit");
419  return false;
420  }
421 
422  const evt::GaisserHillas4Parameter* gh4Pars =
423  dynamic_cast<evt::GaisserHillas4Parameter*>(
425  );
426 
427  if (!gh4Pars) {
428  if (fVerbosity > 0)
429  WARNING("Casting of GH Parameters failed; aborting fit");
430  return false;
431  }
432 
433  //Set starting values for single GH fit
434  theType = profileFit::eGaisserHillas;
436  fitParameters.resize(profileFit::eNGHpars);
437  fitSteps.resize(profileFit::eNGHpars);
438  fitLimitsDown.resize(profileFit::eNGHpars);
439  fitLimitsUp.resize(profileFit::eNGHpars);
440 
441  fitParameters[profileFit::eGHXmax] = gh4Pars->GetXMax() / g * cm2;
442  fitSteps[profileFit::eGHXmax] = 10.;
443  fitParameters[profileFit::eGHnMax] = gh4Pars->GetNMax() / PeV * g / cm2;
444  fitSteps[profileFit::eGHnMax] = 0.05*gh4Pars->GetNMax() / PeV * g / cm2;
445  fitParameters[profileFit::eGHLambda] = gh4Pars->GetShapeParameter(eLambda) / g*cm2;
446  fitSteps[profileFit::eGHLambda] = 5.;
447  fitParameters[profileFit::eGHX0] = gh4Pars->GetShapeParameter(eX0) / g * cm2;
448  fitSteps[profileFit::eGHX0] = 10;
449  fitLimitsDown[profileFit::eGHXmax] = 0;
450  fitLimitsUp[profileFit::eGHXmax] = 0;
451  fitLimitsDown[profileFit::eGHnMax] = 0;
452  fitLimitsUp[profileFit::eGHnMax] = 0;
453  fitLimitsDown[profileFit::eGHLambda] = 10;
454  fitLimitsUp[profileFit::eGHLambda] = 150;
455  fitLimitsDown[profileFit::eGHX0] = -1000;
456  fitLimitsUp[profileFit::eGHX0] = 500;
457 
458  fProfileFitter.SetStartParameters(fitParameters, fitSteps, fitLimitsDown, fitLimitsUp);
459  fProfileFitter.SetData(depth.size(), &depth[0], &dEdX[0], &dEdXError[0]);
460 
461  //Single GH fit (done with Chi² to be comparable to double GH fit)
462  if (fProfileFitter.Fit() && fProfileFitter.GetStatus() > 0) {
464  return true;
465  }
466  else {
467  return false;
468  }
469  }
470  }
471  else {
472  if (fVerbosity > 0)
473  WARNING("No dE/dX profile available: aborting fit");
474  }
475  }
476  else {
477  if (fVerbosity > 0)
478  WARNING("No shower rec data available; aborting fit");
479  }
480  }
481  else {
482  if (fVerbosity > 0)
483  WARNING("No rec data available; aborting fit");
484  }
485 
486  return false;
487 }
488 
489 
490 bool
492  const
493 {
494  if (!eye.HasRecData() || !eye.GetRecData().HasFRecShower()) {
495  if (fVerbosity > 0)
496  INFO ("No FRecShower; rejecting event");
497  return false;
498  }
499 
500  const fevt::EyeRecData& eyeData = eye.GetRecData();
501  const evt::ShowerFRecData& frecShower = eyeData.GetFRecShower();
502 
503  // Can be shot by lidar (zenith <= 60°)
504  const Point& core = frecShower.GetCorePosition();
505  const CoordinateSystemPtr localCS = LocalCoordinateSystem::Create(core);
506  const Vector& showerAxis = frecShower.GetAxis();
507 
508  if (showerAxis.GetTheta(localCS) > fMaxZenith) {
509  if (fVerbosity > 0) {
510  ostringstream ostr;
511  ostr << "Zenith angle = " << showerAxis.GetTheta(localCS) / degree
512  << "°; rejecting event";
513  INFO (ostr);
514  }
515  return false;
516  }
517 
518  //Minumum Pixel (ADST FDSelection.cc:323)
519  if (eyeData.GetTimeFitNDof() - frecShower.GetStationIds().size() + 3 <= fMinAxisPixels) {
520  if (fVerbosity > 0) {
521  ostringstream ostr;
522  ostr << "N Axis Pixel = " << eyeData.GetNTimeFitPixels()
523  << "; rejecting event";
524  INFO(ostr);
525  }
526  return false;
527  }
528 
529 
530  //Has Energy Reconstruction
531  if (!frecShower.HasGHParameters()) {
532  if (fVerbosity > 0)
533  INFO("No GH Parameters; rejecting event");
534  return false;
535  }
536 
537 
538  //No (HighGain)Saturated Pixels (ADST FDSelection.cc:187)
539  for (Eye::ConstTelescopeIterator telIter =
540  eye.TelescopesBegin(ComponentSelector::eHasData);
541  telIter != eye.TelescopesEnd(ComponentSelector::eHasData);
542  ++telIter)
543  {
544  for (Telescope::ConstPixelIterator pixelIter =
545  telIter->PixelsBegin(ComponentSelector::eHasData);
546  pixelIter != telIter->PixelsEnd(ComponentSelector::eHasData);
547  ++pixelIter)
548  {
549  if (pixelIter->IsHighGainSaturation()) {
550  if (fVerbosity > 0)
551  INFO("Saturated; rejecting event");
552  return false;
553  }
554  }
555  }
556 
557  //Distance to axis (from RecDataProvider.cc CheckHybridStations())
558  if (!event.HasSEvent()) {
559  if (fVerbosity > 0)
560  INFO("No SEvent; rejecting event");
561  return false;
562  }
563  const SEvent& sevent = event.GetSEvent();
564 
565  det::Detector& Det = det::Detector::GetInstance();
566  const sdet::SDetector& theSDetector = Det.GetSDetector();
568  Det.GetFDetector().GetEye(eye.GetId()).GetLocalCoordinateSystem();
569 
570  Vector vertical(0,0,1,CS,Vector::kCartesian);
571  Vector SDP = eyeData.GetSDP();
572  AxialVector horizontal = cross(SDP, vertical);
573  horizontal.Normalize();
574 
575  double Chi0 = eyeData.GetChiZero();
576  double Rp = eyeData.GetRp();
577 
578  Vector eyeCoreVec = Rp / sin(kPi - Chi0) * horizontal;
579  eyeCoreVec.TransformTo(CS) ;
580 
581  Transformation rot(Transformation::Rotation(-Chi0, SDP, CS));
582 
583  Vector axis(rot*horizontal); // apply rotation
584  if (axis.GetTheta(CS) > (kPi/2))
585  axis *= -1; // reflect if necessary
586  axis.Normalize();
587 
588  bool first = true;
589  double hottestRho = 0;
590  double hottestSignal = 0;
591  unsigned int hottestId = 0;
592  for (SEvent::ConstStationIterator sditer = sevent.StationsBegin();
593  sditer != sevent.StationsEnd(); ++sditer)
594  {
595  if (!sditer->HasRecData())
596  continue;
597 
598  const StationRecData& recdata = sditer->GetRecData();
599 
600  if (sditer->IsSilent())
601  continue;
602 
603  if (!sditer->IsCandidate())
604  continue;
605 
606  unsigned int thisStationId = (unsigned int)sditer->GetId();
607  double signal = recdata.GetTotalSignal();
608 
609  const sdet::Station& currentSt = theSDetector.GetStation(*sditer);
610  const Point& SdPos = currentSt.GetPosition();
611  Vector eyeTankVec(SdPos.GetX(CS), SdPos.GetY(CS), SdPos.GetZ(CS), CS,
612  Vector::kCartesian);
613  Vector coreTankVec = eyeTankVec - eyeCoreVec ;
614 
615  double tankProj = (coreTankVec * axis);
616  Vector tankInAxisVec = eyeCoreVec + tankProj * axis;
617  Vector tankAxisVec = coreTankVec - (tankProj * axis);
618  double rho = tankAxisVec.GetMag(); // perp. distance to axis
619 
620  const vector<unsigned short int>& hybridStations =
621  frecShower.GetStationIds();
622 
623  for (unsigned int k = 0; k < hybridStations.size(); k++) {
624  if (hybridStations[k] == thisStationId) {
625  if (first) {
626  first = false;
627  hottestRho = rho;
628  hottestSignal = signal;
629  hottestId = thisStationId;
630  }
631  else if (signal > hottestSignal) { //find hottest hybrid station
632  hottestSignal = signal;
633  hottestRho = rho;
634  hottestId = thisStationId;
635  }
636  break; //after station with right ID exit loop
637  }
638  }
639  }
640  const double fdStationAxisDistance = hottestRho;
641 
642  //things from coreTankDistCut (ADST/Analysis/src/FDSelection.cc:696)
643  if (hottestId < 1) { //hybrid stations != SD stations
644  if (fVerbosity > 0)
645  INFO("No hottest station; rejecting event");
646  return false;
647  }
648 
649  // hasfdevent, hastriggeredpixels, hasreconstructedpixels, hasfdtimefit,
650  // hasfdsdpfit
651  if (!(eyeData.GetSDPFitNDof() > 0) || !(eyeData.GetTimeFitNDof() > 0)) {
652  if (fVerbosity > 0)
653  INFO("No time fit pixels; rejecting event");
654  return false;
655  }
656 
657  if (fdStationAxisDistance >= fMaxCoreTankDist) {
658  if (fVerbosity > 0) {
659  ostringstream ostr;
660  ostr << "CoreTankDist: " << fdStationAxisDistance
661  << "; rejecting event";
662  INFO(ostr);
663  }
664  return false;
665  }
666 
667  return true;
668 }
669 
670 
671 bool
673  const
674 {
675  if (!eye.HasRecData() || !eye.GetRecData().HasFRecShower()) {
676  if (fVerbosity > 0)
677  INFO("No FRecShower; rejecting event");
678  return false;
679  }
680 
681  // Chi²-Cut
682  if ((fDGHChi2 + 2) - fGHChi2 > fCutValue) {
683  if (fVerbosity > 0) {
684  ostringstream ostr;
685  ostr << "Cut Not Fulfilled: (dghChi2 + 2) - chi2 = " << (fDGHChi2 + 2) - fGHChi2
686  << "; rejecting event";
687  INFO(ostr);
688  }
689  return false;
690  }
691 
692  // Both XMax in FOV
693  const TabulatedFunctionErrors& profile =
695 
696  const unsigned int size = profile.GetNPoints();
697  if (size <= 0) {
698  if (fVerbosity > 0)
699  INFO("Size of depth = 0; rejecting event");
700  return false;
701  }
702 
703  const double trackMax = *(--profile.XEnd());
704  const double trackMin = *profile.XBegin();
705 
706  if (fXMax1 < trackMin || fXMax1 > trackMax ||
707  fXMax2 < trackMin || fXMax2 > trackMax) {
708  if (fVerbosity > 0) {
709  ostringstream ostr;
710  ostr << "XMax not in FoV; rejecting event: not between "
711  << trackMin / (g/cm2)
712  << "<>" << trackMax / (g/cm2);
713  INFO(ostr);
714  }
715  return false;
716  }
717  return true;
718 }
719 
720 
721 bool
723 {
724  using namespace evt;
729  GaisserHillas4Parameter ghPar1(fdEdXMax1, fXMax1, x01, lambda1);
730  GaisserHillas4Parameter ghPar2(fdEdXMax2, fXMax2, x02, lambda2);
731 
732  ghPar1.SetChiSquare(fDGHChi2, fDGHNdf);
733  ghPar2.SetChiSquare(fDGHChi2, fDGHNdf);
734 
735  ShowerFRecData& shower = eye.GetRecData().GetFRecShower();
736  MultipleGaisserHillasParameters& mghPars = shower.GetMultipleGHParameters();
737 
738  mghPars.Add(ghPar1);
739  mghPars.Add(ghPar2);
740  mghPars.SetChi2Improvement(fDGHChi2 - fGHChi2 - 2);
741 
742  if (mghPars.GetVirtualParameters().size() != 2) {
743  if (fVerbosity > 0)
744  WARNING("Error in writing to event; rejecting event");
745  return false;
746  }
747 
748  ostringstream ostr;
749  ostr << "Data needed for Cut" << endl
750  << "chi2improvement= " << mghPars. GetChi2Improvement()
751  << " XMax1= " << (*(mghPars.GetVirtualParameters()[0])).GetXMax()/(g/cm2)
752  << " XMax2= " << (*(mghPars.GetVirtualParameters()[1])).GetXMax()/(g/cm2)
753  << endl;
754  INFO(ostr); //always print
755 
756 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
757 // ++++ if you want event IDs written to file, pls uncomment this +++++
758 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
759 
760 // if (IsSelected(eye)) {
761 // if (fVerbosity > -1)
762 // INFO("---Double bump found");
763 // ofstream pFile;
764 // pFile.open("events.txt",ios::app);
765 // if (!pFile.is_open()) {
766 // if (fVerbosity > 0)
767 // WARNING("Error in writing to file; rejecting event");
768 // return false;
769 // }
770 // if (!event.HasSEvent()) {
771 // if (fVerbosity > 0)
772 // WARNING("Error in writing to file; rejecting event");
773 // return false;
774 // }
775 // ostringstream id;
776 // id << event.GetSEvent().GetHeader().GetId();
777 // pFile << id.str() <<"\n";
778 // pFile.close();
779 // }
780 
781  return true;
782 }
783 
784 
787 {
788  if (fVerbosity > -1)
789  INFO("---Closing FdDoubleBumpFinder");
790  return eSuccess;
791 }
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
Definition: OperationsAV.h:32
Class to access station level reconstructed data.
double GetShapeParameter(const gh::EShapeParameter par) const
access to all variants of shape parameters (see GaisserHillasTypes.h)
unsigned int GetId() const
Definition: FEvent/Eye.h:54
const std::vector< double > & GetFitParameters() const
void SetData(const int n, const T *depth, const T *size, const T *sizeError=0)
unsigned int GetNPoints() const
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
void Normalize()
Definition: Vector.h:64
const double degree
Point object.
Definition: Point.h:32
const double PeV
Detector description interface for Station-related data.
Report success to RunController.
Definition: VModule.h:62
bool HasRecData() const
Definition: FEvent/Eye.h:116
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
void Add(const VGaisserHillasParameter &val)
bool HasFEvent() const
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
double GetChiZero() const
Definition: EyeRecData.h:85
ArrayIterator XEnd()
end of array of X
Skip remaining modules in the current loop and continue with next iteration of the loop...
Definition: VModule.h:68
Class to access parameters that were fitted by more than one Gaisser-Hillas function.
std::vector< unsigned short int > & GetStationIds()
retrieve vector of station IDs used in hybrid fit
unsigned int GetSDPFitNDof() const
Definition: EyeRecData.h:81
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
bool IsSelected(fevt::Eye &eye) const
unsigned int GetTimeFitNDof() const
Definition: EyeRecData.h:93
std::pair< gh::EShapeParameter, double > ShapeParameter
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Definition: FEvent.h:55
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
double pow(const double x, const unsigned int i)
std::string GetVersionInfo(const VersionInfoType v) const
Retrieve different sorts of module version info.
Definition: VModule.cc:26
double GetMag() const
Definition: Vector.h:58
utl::Point GetPosition() const
Tank position.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
void SetFunctionType(EFitFunctionType type)
Class representing a document branch.
Definition: Branch.h:107
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:230
constexpr double kPi
Definition: MathConstants.h:24
double GetTotalSignal() const
Total integrated signal in VEM unit, averaged over pmts.
Active transformations of geometrical objects.
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
bool HasFRecShower() const
Check if reconstructed shower info has been allocated.
Definition: EyeRecData.h:330
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
Definition: EyeRecData.h:323
const sdet::SDetector & GetSDetector() const
Definition: Detector.cc:119
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
boost::filter_iterator< ComponentSelector, ConstAllPixelIterator > ConstPixelIterator
const fdet::FDetector & GetFDetector() const
Definition: Detector.cc:131
constexpr double g
Definition: AugerUnits.h:200
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
void SetChiSquare(const double chi, const unsigned int ndof)
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Eye-specific shower reconstruction data.
Definition: EyeRecData.h:65
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
const utl::AxialVector & GetSDP() const
Definition: EyeRecData.h:75
ArrayIterator YBegin()
begin of array of Y
unsigned int GetNTimeFitPixels() const
Get number of Time Fit pixels.
Definition: EyeRecData.h:184
bool Scan(const std::vector< double > &depth, const std::vector< double > &dEdX, const std::vector< double > &dEdXError, double &xMax1, double &xMax2, double &dEdXMax1, double &dEdXMax2)
bool HasGHParameters() const
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
profileFit::ProfileFitter fProfileFitter
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
ArrayIterator YErrBegin()
begin of array of errors Y
utl::TabulatedFunctionErrors & GetLongitudinalProfile()
retrieve longitudinal profile information (size vs depth)
void SetStartParameters(const std::vector< double > &start, const std::vector< double > &step)
double GetRp() const
Definition: EyeRecData.h:87
ArrayIterator XBegin()
begin of array of X
StationIterator StationsBegin()
Beginning of all stations.
Definition: SEvent.h:57
constexpr double cm
Definition: AugerUnits.h:117
Vector object.
Definition: Vector.h:30
Interface class to access to Fluorescence reconstruction of a Shower.
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
bool IsPreselected(evt::Event &event, fevt::Eye &eye) const
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
bool FillRecData(evt::Event &event, fevt::Eye &eye)
Main configuration utility.
Definition: CentralConfig.h:51
AxialVector object.
Definition: AxialVector.h:30
double DoubleGHFunction(const double X, const double x01, const double lambda1, const double xMax1, const double nMax1, const double x02, const double lambda2, const double xMax2, const double nMax2)
ArrayIterator YEnd()
end of array of Y
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
Gaisser Hillas with 4 parameters.
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
Definition: SEvent.h:54
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
constexpr double m
Definition: AugerUnits.h:121
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
bool HasSEvent() const
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
Definition: FEvent/Eye.h:73
bool HasEnergyDeposit() const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
ArrayIterator YErrEnd()
end of array of errors Y
utl::TabulatedFunctionErrors & GetEnergyDeposit()
retrieve dE/dX
constexpr double cm2
Definition: AugerUnits.h:118
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.

, generated on Tue Sep 26 2023.