RdBeamTimeOptimizer.h
Go to the documentation of this file.
1 #ifndef _RdBeamTimeOptimizer_h_
2 #define _RdBeamTimeOptimizer_h_
3 
4 /* #################################################################
5 
6  The class evt/BeamQuantities.h and further support in the framework
7  have been deleted with r34469 (29.10.21).
8 
9 ################################################################# */
10 
11 #include <string>
12 #include <vector>
13 
14 #include <fwk/VModule.h>
15 #include <utl/Vector.h>
16 #include <utl/Trace.h>
17 #include <utl/Triple.h>
18 
19 #include <revt/REvent.h>
20 #include <evt/ShowerRRecData.h>
21 //#include <evt/BeamQuantities.h>
22 #include <revt/Station.h>
23 #include <revt/StationRecData.h>
24 
25 #include <Minuit2/FCNBase.h>
26 
27 #include "RdWaveModel.h"
28 
29 namespace evt {
30  class Event;
31 }
32 
33 namespace revt {
34  class Station;
35 }
36 
37 
38 // you should assign your module to a namespace
39 
40 namespace RdBeamTimeOptimizer {
41 
51  enum gridtype_t { none = 0, polar = 1, carthesian = 2};
52 
54 
55  public:
56  // If you define a constructor, you MUST provide an implementation
57  // for it, otherwise the REGISTER_MODULE macro will not register
58  // your module. (Here, implementation is in RdBeamTimeOptimizer.cc)
60  virtual ~RdBeamTimeOptimizer();
61 
65 
67  utl::TraceD powertrace (revt::REvent& rEvent, evt::ShowerRRecData& rrec, const std::vector<double>& shifts) const;
68  utl::TraceD crosscorr (revt::REvent& rEvent, evt::ShowerRRecData& rrec, const std::vector<double>& shifts) const;
69  utl::TraceD xtrace (utl::TraceD ccTrace, double ccMean, utl::TraceD pwNormal);
70 
71  evt::BeamPeak findPeak (const utl::TraceD& trace);
72 
73  protected:
75  int startbin, stopbin; //< Configured start and stop time in bins.
76  enum gridtype_t gridtype; /*< Configured type of ascii output grid.
77  Meant for debug, but so far the only output method.*/
78  std::string outfile; //< Configured output ascii file name. Prefixed by cc_, pw_ and x_.
79 
80  void delaysToShifts(revt::REvent& rEvent, utl::TimeStamp meanTime, std::vector<double> &times);
81  void shiftsToDelays(revt::REvent& rEvent, utl::TimeStamp meanTime, std::vector<double> &times);
82 
83  std::vector<double> delaysFromRRec(revt::REvent& rEvent, evt::ShowerRRecData& rrec);
84  std::vector<double> shiftsFromRRec(revt::REvent& rEvent, evt::ShowerRRecData& rrec);
85 
86  private:
87 
88  void writeRecData(revt::REvent &rEvent, std::vector<double> &shifts);
90  void WriteASCIISpectrum(const revt::Station &,
91  const std::string &) const;
92 
93  void WriteTrace3D(const utl::TraceD& trace,
94  const std::string& filename,
95  const utl::Triple& coords) const;
96  // /// Writes out a trace in an ASCII file with polar CS
97  // void WriteTracePolar(const utl::TraceD &,
98  // const std::string &,
99  // const utl::Triple &) const;
100  // /// Writes out a trace in an ASCII file with carthesian CS
101  // void WriteTrace_XYZ(const utl::TraceD &,
102  // const std::string &,
103  // const utl::Triple &) const;
104 
106  void WriteASCIIPolar (const utl::TraceD &power,
107  const utl::TraceD &cc,
108  const utl::TraceD &x,
109  const evt::BeamPeak &pwPeak,
110  const evt::BeamPeak &ccPeak,
111  const evt::BeamPeak &xPeak,
112  const utl::Triple &coords) const;
113 
115  void WriteASCII_XYZ (const utl::TraceD &power,
116  const utl::TraceD &cc,
117  const utl::TraceD &x,
118  const evt::BeamPeak &pwPeak,
119  const evt::BeamPeak &ccPeak,
120  const evt::BeamPeak &xPeak,
121  const utl::Triple &coords) const;
122 
124  inline void efieldtopower (const revt::StationTimeSeries& in,
125  utl::TraceD& out,
126  int start, int stop) const;
127 
129  inline void efieldproduct (const revt::StationTimeSeries& in1,
130  const revt::StationTimeSeries& in2,
131  utl::TraceD& out,
132  int start, int stop) const;
133 
134  double peakTime;
135 
136 
137  // The REGISTER_MODULE macro makes the framework aware of your module.
138  // You need to put this macro at the very end of your module class definition.
139  // Give your module a name (first argument) and specify its
140  // class name (second argument). In the ModuleSequenceExample.xml file,
141  // you can see this module being refered to by the name we give it here.
142 
143  REGISTER_MODULE("RdBeamTimeOptimizer", RdBeamTimeOptimizer);
144 
145  };
146 
147  class powerFCN : public ROOT::Minuit2::FCNBase {
148  public:
150  RdBeamTimeOptimizer *beam):rEventP(rEventP),beam(beam){}
151  double operator()(const std::vector<double>& pars) const {
152  utl::TraceD trace = beam->powertrace (*rEventP, *rrecP, pars);
153  evt::BeamPeak peak = beam->findPeak (trace);
154 
155  return - (peak.GetHeight() / peak.GetRMS() );
156  }
157  double Up() const { return 0.5; }
158  protected:
162  };
163 
164 
165  class crossFCN : public ROOT::Minuit2::FCNBase {
166  public:
168  RdBeamTimeOptimizer *beam):rEventP(rEventP),beam(beam){}
169  double operator()(const std::vector<double>& pars) const {
170  utl::TraceD trace = beam->crosscorr (*rEventP, *rrecP, pars);
171  evt::BeamPeak peak = beam->findPeak (trace);
172 
173  return - ( peak.GetHeight() / peak.GetRMS() );
174  }
175  double Up() const { return 0.5; }
176  protected:
180  };
181 }
182 
183 
184 #endif
185 
186 // Configure (x)emacs for this file ...
187 // Local Variables:
188 // mode:c++
189 // compile-command: "make -k"
190 // End:
std::vector< double > delaysFromRRec(revt::REvent &rEvent, evt::ShowerRRecData &rrec)
void writeRecData(revt::REvent &rEvent, std::vector< double > &shifts)
utl::TraceD crosscorr(revt::REvent &rEvent, evt::ShowerRRecData &rrec, const std::vector< double > &shifts) const
void WriteTrace3D(const utl::TraceD &trace, const std::string &filename, const utl::Triple &coords) const
void efieldproduct(const revt::StationTimeSeries &in1, const revt::StationTimeSeries &in2, utl::TraceD &out, int start, int stop) const
Helper for crosscorr.
Module for fitting time shifts of station traces which give maximal beam signal.
double operator()(const std::vector< double > &pars) const
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
void WriteASCII_XYZ(const utl::TraceD &power, const utl::TraceD &cc, const utl::TraceD &x, const evt::BeamPeak &pwPeak, const evt::BeamPeak &ccPeak, const evt::BeamPeak &xPeak, const utl::Triple &coords) const
Write out results using carthesian CS.
Interface class to access to the RD Reconstruction of a Shower.
powerFCN(revt::REvent *rEventP, RdBeamTimeOptimizer *beam)
void efieldtopower(const revt::StationTimeSeries &in, utl::TraceD &out, int start, int stop) const
Helper for powertrace.
vector< t2list > out
output of the algorithm: a list of clusters
Definition: XbAlgo.cc:32
const phoenix::function< PowerToImpl > power
Definition: UnitGrammar.h:47
utl::TraceD xtrace(utl::TraceD ccTrace, double ccMean, utl::TraceD pwNormal)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
boost::tuple< double, double, double > Triple
Coordinate triple for easy getting or setting of coordinates.
Definition: Triple.h:15
class to hold data at the radio Station level.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
std::vector< double > shiftsFromRRec(revt::REvent &rEvent, evt::ShowerRRecData &rrec)
void WriteASCIIPolar(const utl::TraceD &power, const utl::TraceD &cc, const utl::TraceD &x, const evt::BeamPeak &pwPeak, const evt::BeamPeak &ccPeak, const evt::BeamPeak &xPeak, const utl::Triple &coords) const
Write out results using polar CS.
void shiftsToDelays(revt::REvent &rEvent, utl::TimeStamp meanTime, std::vector< double > &times)
Module interface.
Definition: VModule.h:53
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
double operator()(const std::vector< double > &pars) const
evt::BeamPeak findPeak(const utl::TraceD &trace)
void WriteASCIISpectrum(const revt::Station &, const std::string &) const
Writes out a spectrum in an ASCII file.
REGISTER_MODULE("RdBeamTimeOptimizer", RdBeamTimeOptimizer)
void delaysToShifts(revt::REvent &rEvent, utl::TimeStamp meanTime, std::vector< double > &times)
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
char * filename
Definition: dump1090.h:266
crossFCN(revt::REvent *rEventP, RdBeamTimeOptimizer *beam)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Spherical wave arrival Delays for Radio Imaging.
Definition: XbArray.h:7
utl::TraceD powertrace(revt::REvent &rEvent, evt::ShowerRRecData &rrec, const std::vector< double > &shifts) const
power beam for given sky position

, generated on Tue Sep 26 2023.