8 #include <fwk/CentralConfig.h>
9 #include <fwk/RunController.h>
10 #include <fwk/LocalCoordinateSystem.h>
12 #include <mdet/MDetector.h>
13 #include <mdet/MTimeVariance.h>
15 #include <evt/ShowerRecData.h>
16 #include <evt/ShowerSRecData.h>
18 #include <sevt/SEvent.h>
19 #include <sevt/EventTrigger.h>
20 #include <mevt/Counter.h>
25 #define OUT(x) if ((x) <= fInfoLevel) cerr
27 namespace MdGeometryFitterAG {
36 << g.GetX(cs)/
meter <<
", "
37 << g.GetY(cs)/
meter <<
", "
38 << g.GetZ(cs)/
meter <<
") [m]";
46 RPerp(
const TVector3& axis,
const TVector3& station)
48 const double scal = axis.Dot(station);
49 double r2 = station.Dot(station) - scal*scal;
63 if (fInfoLevel < eNone || fInfoLevel > eMinuit) {
64 INFO(
"<infoLevel> out of bounds");
67 fMinuitOutput = (fInfoLevel >= eMinuit) ?
true :
false;
70 if (fMinNumberOfStations <= 2) {
71 INFO(
"<minNumberOfStations> must be > 2");
75 topB.
GetChild(
"minNumberForFullCurvatureFit").
GetData(fMinNumberForFullCurvatureFit);
76 if (fMinNumberForFullCurvatureFit <= 3) {
77 INFO(
"<fMinNumberForFullCurvatureFit> must be > 3");
81 topB.
GetChild(
"CurvatureRadiusParameter1").
GetData(fCurvatureRadiusParameter1);
82 topB.
GetChild(
"CurvatureRadiusParameter2").
GetData(fCurvatureRadiusParameter2);
90 INFO(
"MD geometrical reconstruction");
93 if ( !event.
HasMEvent() || !
event.HasSEvent() || !
event.GetSEvent().HasTrigger() ) {
98 if ( !event.
HasRecShower() || !
event.GetRecShower().HasSRecShower() ) {
104 const det::Detector& detector = det::Detector::GetInstance();
118 sdAxis.SetMagThetaPhi( 1., sdTheta, sdPhi);
121 const double curvatureRadius = fCurvatureRadiusParameter1 + fCurvatureRadiusParameter2*sdTheta*sdTheta;
127 TVector3 sdCorePositionLCS;
128 sdCorePositionLCS.SetX( sdCorePosition.
GetX(localCS) );
129 sdCorePositionLCS.SetY( sdCorePosition.
GetY(localCS) );
130 sdCorePositionLCS.SetZ( sdCorePosition.
GetZ(localCS) );
131 geometryFitter.
SetCore(sdCorePositionLCS);
133 geometryFitter.
SetRadius(curvatureRadius);
135 SetTimeData(mEvent, sdCorePosition, sdCoreTime, sdAxis, geometryFitter);
139 if (nCounters < fMinNumberOfStations) {
141 <<
"Not enough counters to reconstruct the geometry." << endl;
142 return eContinueLoop;
147 if ( nCounters < fMinNumberForFullCurvatureFit ) {
160 if (geometryFitter.
Fit() != EXIT_SUCCESS) {
161 OUT(eIntermediate) <<
"Failed geometrical reconstruction.\n";
162 return eContinueLoop;
166 FillRecShower(event, geometryFitter, sdCorePosition, sdCoreTime, sdAxis);
168 FillCounter(mEvent, geometryFitter);
171 <<
"MD geometrical reconstruction \n"
172 " selected counters = " << nCounters <<
"\n"
173 " axis = (" << geometryFitter.
GetU() <<
", " << geometryFitter.
GetV() <<
", " << geometryFitter.
GetW() <<
") (SD core)\n"
178 " radius of curvature = " << geometryFitter.
GetRadius() <<
" +/- "
180 " ct0 = " << geometryFitter.
GetCt0()/
meter <<
" [m]\n"
181 " time chi2 = " << geometryFitter.
GetChi2() <<
" / " << geometryFitter.
GetNdof() <<
"\n"
183 " sd axis diff = " << acos( sdAxis.Dot(geometryFitter.
GetAxis()) ) /
degree <<
" [deg]" << endl << endl;
185 ++fwk::RunController::GetInstance().GetRunData().GetNamedCounters()[
"MdGeometryFitter/Geometry"];
191 MdGeometryFitter::Finish()
201 const mdet::MDetector& mDetector = det::Detector::GetInstance().GetMDetector();
209 if ( !cIt->IsCandidate() || !cIt->HasT50() || cIt->IsEmpty() ) {
213 const int counterId = cIt->GetId();
216 const double x = cPos.
GetX(localCS);
217 const double y = cPos.
GetY(localCS);
218 const double z = cPos.
GetZ(localCS);
219 const TVector3 pos(x, y, z);
220 const double time = (cIt->GetSignalT50() - sdCoreTime).GetInterval();
222 const int nChannelsOn = cIt->GetNumberOfChannelsOn();
223 const double distance =
RPerp(axis, pos);
237 event.MakeRecShower();
241 event.GetRecShower().MakeMRecShower();
249 const Vector axis(geometryFitter.
GetU(), geometryFitter.
GetV(), geometryFitter.
GetW(), localCS);
262 const double curvatureRadius = geometryFitter.
GetRadius();
263 const double curvatureRadiusError = geometryFitter.
GetRadiusError();
264 showerMRec.
SetCurvature(curvatureRadius, curvatureRadiusError);
267 const TVector3 corePosition1 = geometryFitter.
GetCore();
268 const double xcore = corePosition1.x();
269 const double ycore = corePosition1.y();
270 const double zcore = corePosition1.z();
271 const utl::Point corePosition2( xcore, ycore, zcore, localCS);
275 const double chi2 = geometryFitter.
GetChi2();
276 const int angleNDOF = geometryFitter.
GetNdof();
280 const double mdSdAngle = acos( sdAxis.Dot(geometryFitter.
GetAxis()));
301 if ( !cIt->IsCandidate() || !cIt->HasT50() || cIt->IsEmpty() ) {
305 const int counterId = cIt->GetId();
310 cIt->SetTimeResidual(residual);
313 cIt->SetPlaneFrontDelay(planeFrontDelay);
316 cIt->SetT50Error(t50error);
void SetPhiError(double error)
InternalCounterCollection::ComponentConstIterator CounterConstIterator
double RPerp(const Vector &axis, const Vector &station)
void SetCore(const TVector3 &core)
CounterConstIterator CountersBegin() const
void SetCurvature(const double curvature, const double error)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
double GetTimeResidual(int detectorId) const
double GetTimeResidualSpread() const
Interface class to access to the SD Reconstruction of a Shower.
void SetCurvatureFixed(bool flag)
bool HasRecShower() const
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
bool HasDetector(int detectorId) const
void SetCoreTime(const utl::TimeStamp &coreTime, const utl::TimeInterval &coreTimeErr)
ShowerRecData & GetRecShower()
#define INFO(message)
Macro for logging informational messages.
utl::Point GetPosition() const
string ToString(const G &g, const CoordinateSystemPtr cs)
void Init()
Initialise the registry.
double GetPlaneFrontDelay(int detectorId) const
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
utl::CoordinateSystemPtr GetSiteCoordinateSystem() const
Get the coordinate system for the site.
bool IsCurvatureFix() const
Detector associated to muon detector hierarchy.
double GetPhiError() const
void SetMdSdAngle(double a)
A TimeStamp holds GPS second and nanosecond for some event.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
void SetTimeResidualMean(const double mean)
Class representing a document branch.
void SetMinuitOutput(bool flag=true)
void SetRadius(double radius)
double GetX(const CoordinateSystemPtr &coordinateSystem) const
const utl::TimeStamp & GetCoreTime() const
time when shower front passes through the core point
Top of the hierarchy of the detector description interface.
void SetThetaPhiCorrelation(double corr)
void SetCorePosition(const utl::Point &core)
double GetTimeSigma2(const unsigned int nmuons, const double distance) const
const utl::Vector & GetAxis() const
void GetData(bool &b) const
Overloads of the GetData member template function.
bool HasMRecShower() const
double GetCt0Error() const
double GetThetaError() const
void SetThetaError(double error)
double GetY(const CoordinateSystemPtr &coordinateSystem) const
constexpr double kSpeedOfLight
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
void SetAxis(const utl::Vector &axis)
double GetRadiusError() const
void SetGeometryReconstructed(bool flag=true)
Reconstruction of the shower geometry.
InternalCounterCollection::ComponentIterator CounterIterator
void SetTimeResidualSpread(const double spread)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
void SetAngleChi2(const double chi2, const unsigned int ndof)
double GetTimeError(int detectorId) const
CounterConstIterator CountersEnd() const
const utl::Point & GetCorePosition() const
Main configuration utility.
Interface class to access to the Muon Reconstruction of a Shower.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
void SetCoreFixedGeo(bool flag)
const Counter & GetCounter(int id) const
Retrieve Counter by id.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
Root of the Muon event hierarchy.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
int GetNDetectors() const
void AddDetector(int id, TVector3 pos, double time, double sigma)
Note about vectors The TVector3 class is used here instead of the utl::Vector and utl::Point classses...
double GetMeanTimeResidual() const