1 #include <det/Detector.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>
12 #include <fdet/Camera.h>
14 #include <fdet/FDetector.h>
15 #include <fdet/Pixel.h>
16 #include <fdet/Telescope.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>
28 #include <fwk/CentralConfig.h>
29 #include <fwk/LocalCoordinateSystem.h>
30 #include <fwk/RandomEngineRegistry.h>
31 #include <fwk/VModule.h>
33 #include <sdet/SDetector.h>
34 #include <sdet/Station.h>
36 #include <sevt/Header.h>
37 #include <sevt/SEvent.h>
38 #include <sevt/Station.h>
39 #include <sevt/StationRecData.h>
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>
68 using namespace evt::gh;
69 using namespace fdDoubleBumpFinder;
72 FdDoubleBumpFinder::FdDoubleBumpFinder() : fProfileFitter()
83 ERROR(
"Could not find branch FdDoubleBumpFinder");
88 if (!preSelectEventsB) {
89 ERROR(
"Could not find branch preSelectEvents");
96 ERROR(
"Could not find branch maxZenith");
102 if (!minAxisPixelsB) {
103 ERROR(
"Could not find branch minAxisPixels");
109 if (!maxCoreTankDistB) {
110 ERROR(
"Could not find branch maxCoreTankDist");
117 ERROR(
"Could not find branch cutValue");
123 if (!constraintXFirstB) {
124 ERROR(
"Could not find branch constraintXFirst");
130 if (!constraintLambdaB) {
131 ERROR(
"Could not find branch constraintLambda");
136 Branch constraintXFirstMinusXMaxB = topB.
GetChild(
"constraintXFirstMinusXMax");
137 if (!constraintXFirstMinusXMaxB) {
138 ERROR(
"Could not find branch constraintXFirstMinusXMax");
145 ERROR(
"Could not find branch verbosity");
152 std::ostringstream info;
153 info <<
" Version: " << version
154 <<
"\n\t Parameters:"
180 INFO(
"---Starting FdDoubleBumpFinder");
188 FEvent& fdEvent =
event.GetFEvent();
190 eyeIter != fdEvent.
EyesEnd(ComponentSelector::eHasData); ++eyeIter) {
194 ostr <<
"---Processing eye " << eyeIter->GetId();
201 INFO(
"---Not Preselected");
206 if (!
Fit(*eyeIter)) {
208 INFO(
"---Not Fitted");
214 WARNING(
"!!!Error writing to event");
225 const vector<double>& dEdX,
const vector<double>& dEdXError,
226 double& xMax1,
double& xMax2,
double& dEdXMax1,
double& dEdXMax2)
228 double trackMax, trackMin;
229 if (depth.size() > 1) {
230 trackMax = depth.back();
231 trackMin = depth.front();
234 WARNING(
"Depth.size() < 2; aborting scan");
238 vector<double>::const_iterator ite = dEdX.begin();
239 double energyMax = *ite;
240 while (ite < dEdX.end()) {
241 if (*ite > energyMax)
246 const double energyMin = energyMax/10.;
248 double chi2Min = 1e99;
250 vector<double>::const_iterator itd;
251 vector<double>::const_iterator itee;
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) {
263 itee = dEdXError.begin();
265 while (itd < depth.end()) {
267 chi2 +=
pow(
profileFit::DoubleGHFunction(*itd, xfirst1, lambda, ixMax1, idEdXMax1, ixMax2 + xfirstminusxmax, lambda, ixMax2, idEdXMax2) - *ite,2)/ *itee / *itee;
272 if (chi2 < chi2Min) {
276 dEdXMax1 = idEdXMax1;
277 dEdXMax2 = idEdXMax2;
284 if (chi2Min == 1e99) {
286 WARNING(
"No Min Found; aborting scan");
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;
322 WARNING(
"Need >= 2 points for profile fit; aborting fit");
326 vector<double> depth;
327 transform(profile.
XBegin(), profile.
XEnd(), back_inserter(depth),
328 [](
const auto& elem) {
return elem / (
g/
cm2); });
331 transform(profile.
YBegin(), profile.
YEnd(), back_inserter(dEdX),
332 [](
const auto& elem) {
return elem / (
PeV / (
g/
cm2)); });
334 vector<double> dEdXError;
336 [](
const auto& elem) {
return elem / (
PeV / (
g/
cm2)); });
343 vector<double> fitParameters;
344 vector<double> fitSteps;
345 vector<double> fitLimitsDown;
346 vector<double> fitLimitsUp;
350 double dEdXMax1start;
351 double dEdXMax2start;
354 if (
Scan(depth, dEdX, dEdXError,
355 xMax1start, xMax2start, dEdXMax1start, dEdXMax2start))
418 WARNING(
"No GH Paramaters; aborting fit");
429 WARNING(
"Casting of GH Parameters failed; aborting fit");
473 WARNING(
"No dE/dX profile available: aborting fit");
478 WARNING(
"No shower rec data available; aborting fit");
483 WARNING(
"No rec data available; aborting fit");
496 INFO (
"No FRecShower; rejecting event");
511 ostr <<
"Zenith angle = " << showerAxis.
GetTheta(localCS) /
degree
512 <<
"°; rejecting event";
523 <<
"; rejecting event";
533 INFO(
"No GH Parameters; rejecting event");
545 telIter->PixelsBegin(ComponentSelector::eHasData);
546 pixelIter != telIter->PixelsEnd(ComponentSelector::eHasData);
549 if (pixelIter->IsHighGainSaturation()) {
551 INFO(
"Saturated; rejecting event");
560 INFO(
"No SEvent; rejecting event");
563 const SEvent& sevent =
event.GetSEvent();
570 Vector vertical(0,0,1,CS,Vector::kCartesian);
576 double Rp = eyeData.
GetRp();
578 Vector eyeCoreVec = Rp / sin(
kPi - Chi0) * horizontal;
579 eyeCoreVec.TransformTo(CS) ;
583 Vector axis(rot*horizontal);
589 double hottestRho = 0;
590 double hottestSignal = 0;
591 unsigned int hottestId = 0;
595 if (!sditer->HasRecData())
600 if (sditer->IsSilent())
603 if (!sditer->IsCandidate())
606 unsigned int thisStationId = (
unsigned int)sditer->GetId();
613 Vector coreTankVec = eyeTankVec - eyeCoreVec ;
615 double tankProj = (coreTankVec * axis);
616 Vector tankInAxisVec = eyeCoreVec + tankProj * axis;
617 Vector tankAxisVec = coreTankVec - (tankProj * axis);
618 double rho = tankAxisVec.
GetMag();
620 const vector<unsigned short int>& hybridStations =
623 for (
unsigned int k = 0; k < hybridStations.size(); k++) {
624 if (hybridStations[k] == thisStationId) {
628 hottestSignal = signal;
629 hottestId = thisStationId;
631 else if (signal > hottestSignal) {
632 hottestSignal = signal;
634 hottestId = thisStationId;
640 const double fdStationAxisDistance = hottestRho;
645 INFO(
"No hottest station; rejecting event");
653 INFO(
"No time fit pixels; rejecting event");
660 ostr <<
"CoreTankDist: " << fdStationAxisDistance
661 <<
"; rejecting event";
677 INFO(
"No FRecShower; rejecting event");
685 ostr <<
"Cut Not Fulfilled: (dghChi2 + 2) - chi2 = " << (
fDGHChi2 + 2) -
fGHChi2
686 <<
"; rejecting event";
696 const unsigned int size = profile.
GetNPoints();
699 INFO(
"Size of depth = 0; rejecting event");
703 const double trackMax = *(--profile.
XEnd());
704 const double trackMin = *profile.
XBegin();
706 if (fXMax1 < trackMin || fXMax1 > trackMax ||
707 fXMax2 < trackMin || fXMax2 > trackMax) {
710 ostr <<
"XMax not in FoV; rejecting event: not between "
711 << trackMin / (
g/
cm2)
712 <<
"<>" << trackMax / (
g/
cm2);
742 if (mghPars.GetVirtualParameters().size() != 2) {
744 WARNING(
"Error in writing to event; rejecting event");
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)
789 INFO(
"---Closing FdDoubleBumpFinder");
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
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
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.
Detector description interface for Station-related data.
Report success to RunController.
Fluorescence Detector Eye Event.
void Add(const VGaisserHillasParameter &val)
Interface class to access to the SD part of an event.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
double GetChiZero() const
ArrayIterator XEnd()
end of array of X
Skip remaining modules in the current loop and continue with next iteration of the loop...
Class to access parameters that were fitted by more than one Gaisser-Hillas function.
double fConstraintXFirstMinusXMax
std::vector< unsigned short int > & GetStationIds()
retrieve vector of station IDs used in hybrid fit
unsigned int GetSDPFitNDof() const
EyeIterator EyesEnd(const ComponentSelector::Status status)
bool IsSelected(fevt::Eye &eye) const
unsigned int GetTimeFitNDof() const
std::pair< gh::EShapeParameter, double > ShapeParameter
#define INFO(message)
Macro for logging informational messages.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
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.
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.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
double GetTotalSignal() const
Total integrated signal in VEM unit, averaged over pmts.
Top of the hierarchy of the detector description interface.
bool HasFRecShower() const
Check if reconstructed shower info has been allocated.
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
const sdet::SDetector & GetSDetector() const
EyeIterator EyesBegin(const ComponentSelector::Status status)
unsigned int GetNdf() const
boost::filter_iterator< ComponentSelector, ConstAllPixelIterator > ConstPixelIterator
const fdet::FDetector & GetFDetector() const
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetChiSquare(const double chi, const unsigned int ndof)
Top of Fluorescence Detector event hierarchy.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Eye-specific shower reconstruction data.
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)
const utl::AxialVector & GetSDP() const
ArrayIterator YBegin()
begin of array of Y
unsigned int GetNTimeFitPixels() const
Get number of Time Fit pixels.
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
profileFit::ProfileFitter fProfileFitter
ResultFlag
Flag returned by module methods to the RunController.
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)
ArrayIterator XBegin()
begin of array of X
StationIterator StationsBegin()
Beginning of all stations.
Interface class to access to Fluorescence reconstruction of a Shower.
Detector description interface for SDetector-related data.
bool IsPreselected(evt::Event &event, fevt::Eye &eye) const
Report failure to RunController, causing RunController to terminate execution.
bool FillRecData(evt::Event &event, fevt::Eye &eye)
Main configuration utility.
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)
unsigned int fMinAxisPixels
ArrayIterator YEnd()
end of array of Y
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Gaisser Hillas with 4 parameters.
const Station & GetStation(const int stationId) const
Get station by Station Id.
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
#define ERROR(message)
Macro for logging error messages.
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
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
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
void SetThreshold(double t)
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.