UseMcGeometry.cc
Go to the documentation of this file.
1 
7 #include "UseMcGeometry.h"
8 
9 #include <fwk/CentralConfig.h>
10 #include <fwk/CoordinateSystemRegistry.h>
11 #include <fwk/LocalCoordinateSystem.h>
12 
13 #include <utl/Reader.h>
14 #include <utl/ErrorLogger.h>
15 #include <utl/MathConstants.h>
16 #include <utl/PhysicalConstants.h>
17 #include <utl/Transformation.h>
18 #include <utl/Vector.h>
19 #include <utl/Point.h>
20 
21 #include <evt/Event.h>
22 
23 #include <sevt/SEvent.h>
24 
25 #include <fevt/Telescope.h>
26 #include <fevt/Eye.h>
27 #include <fevt/EyeHeader.h>
28 #include <fevt/FEvent.h>
29 #include <fevt/Pixel.h>
30 #include <fevt/PixelRecData.h>
31 #include <fevt/EyeRecData.h>
32 #include <fevt/TelescopeRecData.h>
33 
34 #include <evt/ShowerSimData.h>
35 #include <evt/ShowerRecData.h>
36 #include <evt/ShowerFRecData.h>
37 #include <evt/ShowerSRecData.h>
38 
39 #include <det/Detector.h>
40 
41 #include <fdet/FDetector.h>
42 #include <fdet/Telescope.h>
43 #include <fdet/Eye.h>
44 #include <fdet/Channel.h>
45 #include <fdet/Pixel.h>
46 
47 #include <iostream>
48 
49 
50 using namespace std;
51 using namespace fwk;
52 using namespace utl;
53 using namespace fevt;
54 using namespace evt;
55 using namespace UseMcGeometryOG;
56 
57 
58 
59 // --------------------------------------------------------------------------
62 {
63  Branch topB =
64  CentralConfig::GetInstance()->GetTopBranch("UseMcGeometry");
65 
66  topB.GetChild("setSDP").GetData(fSetSDP);
67  topB.GetChild("setTimeFit").GetData(fSetTimeFit);
68  topB.GetChild("setSdGeometry").GetData(fSetSdGeometry);
69 
70  // -------- do some output ------------
71  // info output
72  ostringstream info;
73  info << " Version: "
74  << GetVersionInfo(VModule::eRevisionNumber) << "\n"
75  " Parameters:\n";
76  info << " set SDP: " << fSetSDP << "\n"
77  " set time fit: " << fSetTimeFit << "\n"
78  " set SD geometry: " << fSetSdGeometry << "\n";
79  INFO(info);
80 
81  return eSuccess;
82 }
83 
84 
85 
86 // --------------------------------------------------------------------------
88 UseMcGeometry::Run(evt::Event& event)
89 {
90  if (!event.HasSimShower()) {
91  ERROR("No sim info. Cannot use MC geometry!");
92  return eBreakLoop;
93  }
94  const evt::ShowerSimData& simShower = event.GetSimShower();
95 
96  if (!simShower.HasDirection()) {
97  ERROR("Sim info has no direction");
98  return eBreakLoop;
99  }
100 
101  if (!simShower.HasPosition()) {
102  ERROR("Sim info has no position");
103  return eBreakLoop;
104  }
105 
106  if (fSetSDP)
107  SetSDP(event);
108 
109  if (fSetTimeFit)
110  SetTimeFit(event);
111 
112  if (fSetSdGeometry)
113  SetSdGeometry(event);
114 
115  return eSuccess;
116 }
117 
118 
119 
120 // -------------------------------------------------------------------------
121 void
122 UseMcGeometry::SetSDP(evt::Event& event)
123 {
124  if (!event.HasFEvent())
125  return;
126 
127  const CoordinateSystemPtr& siteCS =
128  det::Detector::GetInstance().GetSiteCoordinateSystem();
129 
130  FEvent& fevent = event.GetFEvent();
131  evt::ShowerSimData& simShower = event.GetSimShower();
132 
133  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
134 
135  const CoordinateSystemPtr showerCS = simShower.GetShowerCoordinateSystem();
136  const utl::Point showerCore(0,0,0,showerCS);
137  utl::Vector showerAxisReal(0,0,-1,showerCS); // REAL SHOWER MOVEMENT
138  if ((showerAxisReal.GetTheta(siteCS)>90.*deg))
139  showerAxisReal *= -1.0; // reco-def (ALWAYS POINTING UPWARDS)
140 
141  ostringstream info;
142  info << " showerAxis theta: " << simShower.GetDirection().GetTheta(siteCS)/deg << " deg (sim) ";
143  INFO(info);
144 
145  for (FEvent::EyeIterator eyeiter = fevent.EyesBegin(ComponentSelector::eHasData);
146  eyeiter != fevent.EyesEnd(ComponentSelector::eHasData);
147  ++eyeiter){
148 
149  fevt::Eye& eye = *eyeiter;
150 
151  if (!eye.HasHeader())
152  continue;
153 
154  const fdet::Eye& eyeDet = detFD.GetEye(eye);
155  const CoordinateSystemPtr eyeCS = eyeDet.GetEyeCoordinateSystem();
156  utl::Point eyePos = eyeDet.GetPosition();
157 
158  utl::Vector showerAxis = showerAxisReal;
159  if (showerAxis.GetTheta(eyeCS)>90.*deg)
160  showerAxis *= -1; // reco-def
161 
162  if (!eye.HasRecData())
163  eye.MakeRecData();
164 
165  const utl::Vector& eyeToCore = showerCore-eyePos;
166  utl::Vector sdp = cross(showerAxis, eyeToCore);
167  sdp.Normalize();
168 
169  EyeRecData& eyerecdata = eye.GetRecData();
170  eyerecdata.SetSDPFitChiSquare(1.,1); // reset
171  eyerecdata.SetSDP(sdp);
172  eyerecdata.SetSDPThetaError(0);
173  eyerecdata.SetSDPPhiError(0);
174 
175  ostringstream info2;
176  info2 << " sdp theta: " << sdp.GetTheta(eyeCS)/deg
177  << " phi: " << sdp.GetPhi(eyeCS)/deg;
178  INFO(info2);
179 
180  //--------------------------------------------
181  // Fill Telescope geometry parameters to deal with compound eyes
182  for (fevt::Eye::TelescopeIterator telIt = eye.TelescopesBegin(ComponentSelector::eHasData);
183  telIt != eye.TelescopesEnd(ComponentSelector::eHasData); ++telIt)
184  {
185  const fdet::Telescope& detTel = detFD.GetTelescope(*telIt);
186  const utl::Point& telPos = detTel.GetPosition();
187  // The localTelCS is at the tel. pos., but unlike the TelescopeCoordinateSystem,
188  // its Z-axis points towards the zenith and not towards the aperture.
189  // This is intended as an equivalent of the eyeCS, but at the telescope.
190  // Unfortunately, a telescope has no backwall angle, so we're using the site's
191  // X/Y directions.
194 
195  if (!telIt->HasRecData())
196  telIt->MakeRecData();
197  fevt::TelescopeRecData& telRecData = telIt->GetRecData();
198 
199  const Vector telToCore = showerCore - telPos;
200  //const double distCoreTel = telToCore.GetMag();
201 
202  utl::Vector showerAxis = showerAxisReal;
203  if (showerAxis.GetTheta(localTelCS) > 90.*deg)
204  showerAxis *= -1; // reco-def
205 
206  utl::Vector sdp = cross(showerAxis, telToCore);
207  sdp.Normalize();
208 
209  telRecData.SetSDPFitChiSquare(1.,1); // reset
210  telRecData.SetSDP(sdp);
211  telRecData.SetSDPThetaError(0);
212  telRecData.SetSDPPhiError(0);
213  }
214 
215  // loop over pixels and fill SDP-fit-pixels
216  int nPix = 0;
217  for (EyeRecData::PixelIterator pixeliter = eyerecdata.PulsedPixelsBegin();
218  pixeliter != eyerecdata.PulsedPixelsEnd();
219  ++pixeliter){
220 
221  const utl::Vector sdp = eye.GetTelescope(pixeliter->GetTelescopeId()).GetRecData().GetSDP();
222 
223  const fdet::Pixel& detpixel =
224  det::Detector::GetInstance().GetFDetector().GetPixel(*pixeliter);
225 
226  const utl::Vector& dir = detpixel.GetDirection();
227  const double angle = fabs(kPi/2 - fabs(Angle(dir, sdp)));
228 
229  if (angle < 2*degree) {
230  eyerecdata.AddSDPPixel(*pixeliter);
231  nPix++;
232  } // for pixel
233  }
234 
235  ostringstream info3;
236  info3 << " sdp pixels: " << nPix;
237  INFO(info3);
238 
239  }// for eyeiter
240 
241 }
242 
243 
244 
245 // ------------------------------------------------------------------------------
246 void
247 UseMcGeometry::SetTimeFit(evt::Event& event)
248 {
249  const CoordinateSystemPtr siteCS = det::Detector::GetInstance().GetSiteCoordinateSystem();
250 
251  if (!event.HasFEvent())
252  return;
253 
254  FEvent& fevent = event.GetFEvent();
255  const evt::ShowerSimData& simShower = event.GetSimShower();
256  const CoordinateSystemPtr showerCS = simShower.GetShowerCoordinateSystem();
257  const utl::Point showerCore(0,0,0,showerCS);
258 
259  const TimeStamp& timeAtCore = simShower.GetTimeStamp();
260  const utl::Vector showerAxisReal(0,0,-1,showerCS);
261 
262  ostringstream info;
263  info << " sim Axis (Theta,Phi) (siteCS) : "
264  << showerAxisReal.GetTheta(siteCS)/deg << ", "
265  << showerAxisReal.GetPhi(siteCS)/deg << " [deg]"
266  << endl;
267 
268  info << " sim Core (x,y,z) (siteCS) : " << showerCore.GetX(siteCS)/m
269  << ", " << showerCore.GetY(siteCS)/m
270  << ", " << showerCore.GetZ(siteCS)/m << " [m]"
271  << endl;
272 
273  const CoordinateSystemPtr localCS = simShower.GetLocalCoordinateSystem();
274  const double zenith = (-simShower.GetDirection()).GetTheta(localCS);
275  const double azimuth = (-simShower.GetDirection()).GetPhi(localCS);
276 
277  info << " simulated theta : " << zenith/deg
278  << " phi : " << azimuth/deg << " [deg]";
279  INFO(info);
280 
281 
282  for (fevt::FEvent::EyeIterator eyeiter= fevent.EyesBegin(ComponentSelector::eHasData);
283  eyeiter != fevent.EyesEnd(ComponentSelector::eHasData);
284  ++eyeiter) {
285 
286  fevt::Eye& eye = *eyeiter;
287 
288  if (!eye.HasHeader() || !eye.HasRecData())
289  continue;
290 
291  fevt::EyeRecData& eyerecdata = eye.GetRecData();
292  const utl::Vector& sdp = eyerecdata.GetSDP();
293 
294  utl::TimeStamp eyeTriggerTime
295  = eye.GetHeader().GetTimeStamp() - utl::TimeInterval(1000.*100.*ns);
296 
297  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
298  const utl::Point& eyePos = detFD.GetEye(eye).GetPosition();
299  const CoordinateSystemPtr& eyeCS = detFD.GetEye(eye).GetEyeCoordinateSystem();
300  const Vector eyeToCore = showerCore-eyePos;
301 
302  utl::Vector showerAxis = showerAxisReal;
303  bool upward = true;
304  if (showerAxis.GetTheta(eyeCS)>90.*deg) {
305  showerAxis *= -1; // reco-def
306  upward = false;
307  }
308 
309  if (upward) {
310  INFO(" upward: YES");
311  }
312  else {
313  INFO(" upward: NO");
314  }
315 
316  const Vector vertical(0, 0, 1, eyeCS);
317  Vector horizontalWithinSDP = cross(vertical, sdp); // horizontal
318  horizontalWithinSDP.Normalize();
319  if (horizontalWithinSDP.GetPhi(eyeCS) < 0 ||
320  horizontalWithinSDP.GetPhi(eyeCS) > kPi) {
321  //sdp *= -1;
322  horizontalWithinSDP *= -1;
323  }
324 
325  //VN: deal with back-eye core
326  Vector eyeToCoreInEye = eyeToCore-eyeToCore.GetZ(eyeCS)/showerAxis.GetZ(eyeCS)*showerAxis;
327  if (eyeToCoreInEye.GetPhi(eyeCS) < 0 ||
328  eyeToCoreInEye.GetPhi(eyeCS) > kPi) {
329  horizontalWithinSDP *= -1;
330  }
331 
332  const double chi0 = Angle(horizontalWithinSDP, showerAxis) -
333  (upward ? 180.*deg : 0.*deg);
334 
335  const double Rp = cross(showerAxis, eyeToCore).GetMag() /
336  showerAxis.GetMag() * (upward ? -1 : 1);
337 
338  /*
339  double delta = (showerCore.GetZ(eyeCS) - 0) / showerAxis.GetZ(eyeCS);
340  utl::Point point = showerCore + showerAxis*delta;
341  double distance = (point-eyePos).GetMag ();
342  double Rp = sin(chi0) * distance;
343  */
344  /*
345  utl::TimeInterval deltaT = (cos(chi0) * distance / kSpeedOfLight);
346  utl::TimeStamp time = timeAtCore + deltaT;
347  double T0 = (time-eyeTriggerTime).GetInterval();
348  */
349 
350  const double distCoreEye = eyeToCore.GetMag();
351  const double beta = Angle(-showerAxisReal, eyeToCore);
352  const double T0 = ((timeAtCore + TimeInterval(distCoreEye/kSpeedOfLight * cos(beta)))
353  - eyeTriggerTime).GetInterval();
354 
355  eyerecdata.SetChiZero(chi0, 1.e-5*chi0);
356  eyerecdata.SetTZero(T0, 1.e-5*T0);
357  eyerecdata.SetRp(Rp, 1.e-5*Rp);
358 
359  ostringstream info;
360  info << " chi0: " << chi0/deg << " deg "
361  << " Rp: " << Rp/m << " m"
362  << " T0: " << T0 << " ns";
363  INFO(info);
364 
365  //--------------------------------------------
366  // Fill Telescope geometry parameters to deal with compound eyes
367  for (fevt::Eye::TelescopeIterator telIt = eye.TelescopesBegin(ComponentSelector::eHasData);
368  telIt != eye.TelescopesEnd(ComponentSelector::eHasData); ++telIt)
369  {
370  const fdet::Telescope& detTel = detFD.GetTelescope(*telIt);
371  const utl::Point& telPos = detTel.GetPosition();
372  // localTelCS is at the tel. pos., but unlike the TelescopeCoordinateSystem,
373  // its Z-axis points towards the zenith and not towards the aperture.
374  // This is intended as an equivalent of the eyeCS, but at the telescope.
375  // Unfortunately, a telescope has no backwall angle, so we're using the site's
376  // X/Y directions.
379 
380  if (!telIt->HasRecData())
381  telIt->MakeRecData();
382  fevt::TelescopeRecData& telRecData = telIt->GetRecData();
383 
384  const Vector telToCore = showerCore - telPos;
385  const double distCoreTel = telToCore.GetMag();
386  const double beta = Angle(-showerAxisReal, telToCore);
387  const double T0 = ((timeAtCore + TimeInterval(distCoreTel/kSpeedOfLight * cos(beta)))
388  - eyeTriggerTime).GetInterval();
389 
390  utl::Vector showerAxis = showerAxisReal;
391  bool upward = true;
392  if (showerAxis.GetTheta(localTelCS) > 90.*deg) {
393  showerAxis *= -1; // reco-def
394  upward = false;
395  }
396 
397  utl::Vector sdp = cross(showerAxis, telToCore);
398  sdp.Normalize();
399 
400  const Vector vertical(0, 0, 1, localTelCS);
401  Vector horizontalWithinSDP = cross(vertical, sdp);
402  horizontalWithinSDP.Normalize();
403 
404  // x-axis pointing towards optical axis, z-axis still vertical
405  const CoordinateSystemPtr auxCS =
406  CoordinateSystem::RotationZ(detTel.GetAxis().GetPhi(localTelCS), localTelCS);
407  const utl::Vector horizontalProjOptAxis(1, 0, 0, auxCS);
408 
409  // Make sure that the horiz-in-sdp vector points to the front side of the
410  // telescope. This is what the equivalent code above does for the eye.
411  // Like the original, this is likely to blow up for core-behind-telescope cases?
412  const double angle = Angle(horizontalProjOptAxis, horizontalWithinSDP);
413  if (angle > kPiOnTwo)
414  horizontalWithinSDP *= -1;
415 
416  //VN: deal with back-eye core
417  Vector telToCoreInEye = telToCore-telToCore.GetZ(auxCS)/showerAxis.GetZ(auxCS)*showerAxis;
418  const double angle2 = Angle(horizontalProjOptAxis, telToCoreInEye);
419  if (angle2 > kPiOnTwo)
420  horizontalWithinSDP *= -1;
421 
422  const double chi0 = Angle(horizontalWithinSDP, showerAxis)
423  - (upward ? 180.*deg : 0.*deg);
424 
425  const double Rp = cross(showerAxis, telToCore).GetMag()
426  / showerAxis.GetMag()
427  * (upward ? -1 : 1);
428 
429  telRecData.SetChiZero(chi0, 1.e-5*chi0);
430  telRecData.SetTZero(T0, 1.e-5*T0);
431  telRecData.SetRp(Rp, 1.e-5*Rp);
432 
433  telRecData.SetTimeFitChiSquare(1,1); // FIXME find more elegant solution
434  //telRecData.SetTimeFitCorrelations(rRpT0,rRpChi0,rChi0T0);
435  }
436 
437  if (!eyerecdata.HasFRecShower())
438  eyerecdata.MakeFRecShower();
439  ShowerFRecData& recshower = eyerecdata.GetFRecShower();
440 
441  recshower.SetAxis(showerAxis*(upward?-1:1));
442 
443  // M.U.: FD core: intercept axis-horizontal in eye CS
444  const Vector core_eye_vec = Rp / sin(kPi - chi0) * horizontalWithinSDP;
445  const Point coreInEye = eyePos + core_eye_vec;
446  recshower.SetCorePosition(coreInEye);
447 
448  // V.N.: Correction for timeAtCore
449  const Vector coreToCoreInEye = coreInEye-showerCore;
450  double timeCorrection = -coreToCoreInEye.GetMag()/kSpeedOfLight;
451  if (coreToCoreInEye.GetTheta(eyeCS) > 90*deg)
452  timeCorrection *= -1;
453  if (upward)
454  timeCorrection *= -1;
455  const TimeStamp& timeAtCoreInEye = timeAtCore + timeCorrection;
456  recshower.SetCoreTime(timeAtCoreInEye, 0.);
457 
458  // loop over pixels and fill SDP-fit-pixels to time-fit-pixels
459  unsigned int ndof=0;
460  for (EyeRecData::PixelIterator pixeliter = eyerecdata.SDPPixelsBegin ();
461  pixeliter != eyerecdata.SDPPixelsEnd ();
462  ++pixeliter){
463 
464  const fdet::Pixel& detpixel = detFD.GetPixel(*pixeliter);
465  const fdet::Channel& detChannel = detFD.GetChannel(*pixeliter);
466 
467  // time correction for different eyes
468  const int telid = pixeliter->GetTelescopeId();
469  const unsigned int timeoffset = eye.GetTelescope(telid).GetTimeOffset();
470 
471  const double timebinsize = detChannel.GetFADCBinSize();
472  const double t_i = pixeliter->GetRecData().GetCentroid()
473  * timebinsize // convert to nanosecond
474  + timeoffset; // add offset
475 
476  const double t_i_Err = pixeliter->GetRecData().GetCentroidError()
477  * timebinsize;
478 
479  const Vector& pixeldir = detpixel.GetDirection();
480  //pixeldir.TransformTo(CS);
481  //sdp.TransformTo (CS);
482  //fSDP.Normalize();
483 
484  //Vector vertical (0,0,1,eyeCS,Vector::kCartesian);
485  //Vector horizontalWithinSDP = cross (sdp, vertical);
486  //horizontalWithinSDP.Normalize();
487 
488  // check that it is the one looking outward
489  //if (Angle(horizontalWithinSDP,pixeldir) >kPi/2)
490  // horizontalWithinSDP*=-1;
491 
492  const fdet::Telescope& detTel = detFD.GetEye(eye).GetTelescope(telid);
493  const utl::Point& telPos = detTel.GetPosition();
494  // localTelCS is at the tel. pos., but unlike the TelescopeCoordinateSystem,
495  // its Z-axis points towards the zenith and not towards the aperture.
496  // This is intended as an equivalent of the eyeCS, but at the telescope.
497  // Unfortunately, a telescope has no backwall angle, so we're using the site's
498  // X/Y directions.
500 
501  const Vector telToCore = showerCore - telPos;
502 
503  const utl::Vector sdp = eye.GetTelescope(telid).GetRecData().GetSDP();
504  const Vector vertical(0, 0, 1, localTelCS);
505  Vector horizontalWithinSDP = cross(vertical, sdp);
506  horizontalWithinSDP.Normalize();
507 
508  const CoordinateSystemPtr auxCS =
509  CoordinateSystem::RotationZ(detTel.GetAxis().GetPhi(localTelCS), localTelCS);
510  const utl::Vector horizontalProjOptAxis(1, 0, 0, auxCS);
511 
512  // Make sure that the horiz-in-sdp vector points to the front side of the
513  // telescope. This is what the equivalent code above does for the eye.
514  // Like the original, this is likely to blow up for core-behind-telescope cases?
515  const double angle = Angle(horizontalProjOptAxis, horizontalWithinSDP);
516  if (angle > kPiOnTwo)
517  horizontalWithinSDP *= -1;
518 
519  //VN: deal with back-eye core
520  Vector telToCoreInEye = telToCore-telToCore.GetZ(auxCS)/showerAxis.GetZ(auxCS)*showerAxis;
521  const double angle2 = Angle(horizontalProjOptAxis, telToCoreInEye);
522  if (angle2 > kPiOnTwo)
523  horizontalWithinSDP *= -1;
524 
525  // subtract component parallel to sdp
526  Vector chi_i_vector = pixeldir - (sdp * pixeldir) * sdp;
527  //chi_i_vector.TransformTo(eyeCS);
528  chi_i_vector.Normalize();
529 
530  const double chi_i = Angle(chi_i_vector, horizontalWithinSDP);
531 
532  pixeliter->GetRecData().SetChi_i(chi_i);
533  pixeliter->GetRecData().SetT_i(t_i,t_i_Err);
534 
535  // check residual
536  double chi0 = eye.GetTelescope(telid).GetRecData().GetChiZero();
537  double T0 = eye.GetTelescope(telid).GetRecData().GetTZero();
538  double Rp = eye.GetTelescope(telid).GetRecData().GetRp();
539  const double t_expected =
540  T0 + Rp/kSpeedOfLight * std::tan((chi0 - chi_i) / 2);
541 
542  ostringstream info;
543  info << " chi_i=" << chi_i/deg
544  << " t_i=" << t_i
545  << " chi0=" << chi0
546  << " t0=" << T0
547  << " Rp=" << Rp
548  << " t_exp=" << t_expected;
549  INFO(info);
550 
551 
552  if (fabs(t_i - t_expected) > 400)
553  continue;
554 
555  if (this->IsBadPixel(*pixeliter,eye))
556  continue;
557 
558  // if pixel is distant from SDP, do not take it into account
559  //double distanceToSdp = abs(kPi/2 - std::acos(fSDP * pixeldir)) ;
560  //if (distanceToSdp > fTolerance) continue;
561 
562  eyerecdata.AddTimeFitPixel (*pixeliter);
563  ndof++;
564  }
565 
566  if (ndof)
567  eyerecdata.SetTimeFitChiSquare(ndof, ndof);
568  else
569  eyerecdata.SetTimeFitChiSquare(1, 1);
570 
571  ostringstream info3;
572  info3 << " ndof: " << ndof;
573  INFO(info3);
574 
575  } // for eyeiter
576 }
577 
578 
579 
580 // ------------------------------------------------------------------
581 void
582 UseMcGeometry::SetSdGeometry(evt::Event& event)
583 {
584  if (!event.HasSEvent())
585  return;
586 
587  const CoordinateSystemPtr& siteCS =
588  det::Detector::GetInstance().GetSiteCoordinateSystem();
589 
590  evt::ShowerSimData& simShower = event.GetSimShower();
591  const CoordinateSystemPtr showerCS = simShower.GetShowerCoordinateSystem();
592  const utl::Point showerCore(0,0,0,showerCS);
593  utl::Vector showerAxisReal(0,0,-1,showerCS); // REAL SHOWER MOVEMENT
594  if ((showerAxisReal.GetTheta(siteCS)>90.*deg))
595  showerAxisReal *= -1.0; // reco-def (ALWAYS POINTING UPWARDS)
596  const TimeStamp& timeAtCore = simShower.GetTimeStamp();
597 
598 
599  if (!event.HasRecShower())
600  event.MakeRecShower();
601  if (!event.GetRecShower().HasSRecShower())
602  event.GetRecShower().MakeSRecShower();
603  ShowerSRecData& showersrec = event.GetRecShower().GetSRecShower();
604 
605  showersrec.SetAxis(showerAxisReal);
606 
607  //showersrec.SetAngleErrors(axis.GetCoordinates(fgLocalCS),
608  //Vector::Triple(fit->sigmaU2, fit->sigmaUV, fit->sigmaV2));
609 
610  showersrec.SetCurvature(0, 0);
611  showersrec.SetBarycenter(showerCore);
612  showersrec.SetCorePosition(showerCore);
613  showersrec.SetCoreTime(timeAtCore, TimeInterval(0));
614 
615  /*
616  double timeMean3d;
617  double timeSpread3d;
618  double chi2;
619  CalculateTimeResidual3D(axis, fit->ct0, timeMean3d, timeSpread3d, chi2);
620  showersrec.SetTimeResidualMean(timeMean3d);
621  showersrec.SetTimeResidualSpread(timeSpread3d);
622  */
623 
624  showersrec.SetAngleChi2(0, 0);
625  showersrec.SetLDFRecStage(0);
626 }
627 
628 
630 UseMcGeometry::Finish()
631 {
632  return eSuccess;
633 }
634 
635 
636 
637 // --------------------------------------------------------------------------
638 bool
639 UseMcGeometry::IsBadPixel(const fevt::Pixel& pixel, const fevt::Eye& eye)
640 {
641  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
642  const EyeRecData& recdata = eye.GetRecData();
643 
644  // check S/N limit
645 
646  double signal = pixel.GetRecData().GetTotalCharge ();
647  double rms = pixel.GetRecData().GetRMS();
648  int i1 = pixel.GetRecData().GetPulseStart();
649  int i2 = pixel.GetRecData().GetPulseStop();
650  double nTim = (double) (i2-i1+1);
651  static const double kPhoton2Pe = 0.128; // M.U. same as in FDSim
652  double noise = nTim*rms*rms+signal/kPhoton2Pe;
653  double sigToNoise = signal/sqrt(noise);
654  static double minSigNoise = 1;
655  if(sigToNoise<minSigNoise)
656  return true;
657 
658  // if error is <=0. centroid finding failed
659  const double t_i_Err = pixel.GetRecData().GetCentroidError();
660  if (t_i_Err<=0.)
661  return true;
662 
663  // check time isolation
665  for (iter = recdata.PulsedPixelsBegin();
666  iter != recdata.PulsedPixelsEnd();
667  ++iter){
668 
669  if (*iter==pixel)
670  continue;
671 
672  const double fadcBinSize = detFD.GetChannel(*iter).GetFADCBinSize();
673  const double timediff =
674  std::fabs(pixel.GetRecData().GetCentroid() -
675  iter->GetRecData().GetCentroid()) * fadcBinSize;
676 
677  static double isolationLimit = 10000*ns;
678  if (timediff < isolationLimit )
679  return false;
680 
681  } // for
682 
683  return true;
684 }
685 
686 
687 // Configure (x)emacs for this file ...
688 // Local Variables:
689 // mode:c++
690 // compile-command: "make -C ..
691 // End:
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
Definition: OperationsAV.h:32
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
Definition: FEvent/Eye.cc:57
bool HasDirection() const
Check initialization of shower geometry.
Branch GetTopBranch() const
Definition: Branch.cc:63
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
void SetCurvature(const double curvature, const double error)
gaussian curvature = 1 / Rc
const utl::Vector & GetDirection() const
pointing direction of this pixel
void SetChiZero(const double chiZero, const double error)
Definition: EyeRecData.h:237
void SetSDPFitChiSquare(const double sdpChi2, const unsigned int ndof)
void SetSDPPhiError(const double sdpPhiError)
Definition: EyeRecData.h:223
void Normalize()
Definition: Vector.h:64
int GetPulseStop() const
pulse stop (to be defined)
Definition: PixelRecData.h:72
const double degree
Point object.
Definition: Point.h:32
void SetBarycenter(const utl::Point &bary)
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
const utl::TimeStamp & GetTimeStamp() const
Get the TimeStamp of the absolute shower core-time.
Description of the electronic channel for the 480 channels of the crate.
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
void SetSDPFitChiSquare(const double sdpChi2, const unsigned int ndof)
Definition: EyeRecData.h:229
double GetRMS() const
Get the baseline RMS of the trace.
Definition: PixelRecData.h:76
bool HasHeader() const
Definition: FEvent/Eye.h:104
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Definition: FEvent/Eye.cc:180
unsigned int GetTimeOffset() const
Time offset of this Telescope compared to fevt::Header::GetTime [ns].
bool HasRecData() const
Definition: FEvent/Eye.h:116
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
Interface class to access to the SD Reconstruction of a Shower.
PixelIterator PulsedPixelsEnd()
Definition: EyeRecData.h:121
bool HasRecShower() const
bool HasFEvent() const
const Pixel & GetPixel(const fevt::Pixel &eventPixel) const
Get fdet::Pixel from fevt::Channel.
Definition: FDetector.cc:198
void MakeRecData()
Definition: FEvent/Eye.cc:145
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
int GetPulseStart() const
pulse start (to be defined)
Definition: PixelRecData.h:70
ShowerRecData & GetRecShower()
double GetCentroidError() const
Definition: PixelRecData.h:79
bool HasSimShower() const
void SetCorePosition(const utl::Point &core)
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
double GetMag() const
Definition: AxialVector.h:56
utl::Vector GetAxis() const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void SetAngleChi2(const double chi2, const double ndof)
void SetRp(const double rp, const double error)
Definition: EyeRecData.h:239
void Init()
Initialise the registry.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
Detector description interface for Eye-related data.
Definition: FDetector/Eye.h:45
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
fevt::TelescopeRecData & GetRecData()
Reconstructed data for this telescope.
void AddSDPPixel(fevt::Pixel &pixel)
add a pixel to the list of SDP pixels
Definition: EyeRecData.h:149
PixelIterator PulsedPixelsBegin()
Definition: EyeRecData.h:119
double GetMag() const
Definition: Vector.h:58
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
boost::indirect_iterator< ConstInternalPixelIterator, const Pixel & > ConstPixelIterator
Const iterator over pixels used in reconstruction.
Definition: EyeRecData.h:117
bool HasPosition() const
Check initialization of shower geometry.
constexpr double deg
Definition: AugerUnits.h:140
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
void SetSDP(const utl::AxialVector &vec)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
void MakeFRecShower()
Allocate reconstructed shower info.
Definition: EyeRecData.cc:58
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
PixelIterator SDPPixelsBegin()
Definition: EyeRecData.h:139
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
void SetCoreTime(const utl::TimeStamp &coreTime, const utl::TimeInterval &coreTimeErr)
const double ns
utl::CoordinateSystemPtr GetEyeCoordinateSystem() const
Returns the Eye Coordinate system.
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:230
constexpr double kPi
Definition: MathConstants.h:24
void SetAxis(const utl::Vector &axis)
void SetAxis(const utl::Vector &axis)
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
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
unsigned int GetTelescopeId() const
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
void SetSDPPhiError(const double sdpPhiError)
const Channel & GetChannel(const fevt::Channel &eventChannel) const
Get fdet::Channel from fevt::Channel.
Definition: FDetector.cc:161
void SetChiZero(const double chiZero, const double error)
void SetTimeFitChiSquare(const double tfitChi2, const unsigned int ndof)
Definition: EyeRecData.h:232
constexpr double kPiOnTwo
Definition: MathConstants.h:25
Telescope-specific shower reconstruction data.
void SetSDPThetaError(const double sdpThetaError)
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
Definition: FEvent/Eye.h:72
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
double GetTZero() const
Eye-specific shower reconstruction data.
Definition: EyeRecData.h:65
void SetCoreTime(const utl::TimeStamp &coreTime, const utl::TimeInterval &coreTimeErr)
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
const utl::AxialVector & GetSDP() const
Definition: EyeRecData.h:75
boost::indirect_iterator< InternalPixelIterator, fevt::Pixel & > PixelIterator
Iterator over pixels used in reconstruction.
Definition: EyeRecData.h:113
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
constexpr double kSpeedOfLight
Detector description interface for Telescope-related data.
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
Definition: FDetector.cc:150
double GetFADCBinSize() const
void SetTZero(const double tzero, const double error)
utl::TimeStamp GetTimeStamp() const
Time of the Eye Event as tagged by FD-DAS (== eye trigger time plus pixel trace length) ...
Definition: EyeHeader.h:118
double GetTotalCharge() const
integrated pulse charge
Definition: PixelRecData.h:68
Description of a pixel.
utl::Point GetPosition() const
void SetTimeFitChiSquare(const double tfitChi2, const unsigned int ndof)
Vector object.
Definition: Vector.h:30
Interface class to access to Fluorescence reconstruction of a Shower.
void SetSDPThetaError(const double sdpThetaError)
Definition: EyeRecData.h:220
void SetRp(const double rp, const double error)
void SetCorePosition(const utl::Point &core)
void SetSDP(const utl::AxialVector &vec)
Definition: EyeRecData.h:218
void SetTZero(const double tzero, const double error)
Definition: EyeRecData.h:235
PixelIterator SDPPixelsEnd()
Definition: EyeRecData.h:143
void AddTimeFitPixel(fevt::Pixel &pixel)
add a pixel to the list of Time Fit pixels
Definition: EyeRecData.h:177
void SetLDFRecStage(const double stage)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
double GetChiZero() const
double GetCentroid() const
Definition: PixelRecData.h:78
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
const utl::AxialVector & GetSDP() const
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
constexpr double m
Definition: AugerUnits.h:121
bool HasSRecShower() const
bool HasSEvent() const
utl::Point GetPosition() const
Eye position.
PixelRecData & GetRecData()
Definition: FEvent/Pixel.h:40
utl::CoordinateSystemPtr GetShowerCoordinateSystem() const
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130

, generated on Tue Sep 26 2023.