MdCornerClippingCorrecter.cc
Go to the documentation of this file.
1 #include <utl/ErrorLogger.h>
2 #include <fwk/CentralConfig.h>
3 
4 #include <det/Detector.h>
5 #include <mdet/MDetector.h>
6 #include <mdet/Counter.h>
7 #include <mdet/Module.h>
8 
9 #include <evt/Event.h>
10 #include <mevt/MEvent.h>
11 #include <mevt/Counter.h>
12 #include <sevt/SEvent.h>
13 
14 #include <evt/ShowerRecData.h>
15 #include <evt/ShowerSRecData.h>
16 #include <evt/ShowerMRecData.h>
17 #include <mevt/Scintillator.h>
18 
19 #include <utl/Branch.h>
20 #include <utl/ConfigUtils.h>
21 #include <utl/CoordinateSystemPtr.h>
22 
23 #include <fwk/LocalCoordinateSystem.h>
24 
26 
27 #include <sstream>
28 
29 using namespace fwk;
30 using namespace utl;
31 using namespace MdCornerClippingCorrecterAG;
32 
33 namespace MdCornerClippingCorrecterAG {
34  MdCornerClippingCorrecter::MdCornerClippingCorrecter()
35  { }
36 
37  MdCornerClippingCorrecter::~MdCornerClippingCorrecter()
38  { }
39 
42  {
43  // Configuration reading
44  utl::Branch config = fwk::CentralConfig::GetInstance()->GetTopBranch("MdCornerClippingCorrecter");
45  LoadConfig(config, "computeCornerClippingProbability", fComputeCornerClippingProbability, false);
46  LoadConfig(config, "par0", fPar0, 0);
47  LoadConfig(config, "par1", fPar1, 0);
48  LoadConfig(config, "par2", fPar2, 0);
49  LoadConfig(config, "par3", fPar3, 0);
50 
51  std::ostringstream os;
52  os << "\ncomputeCornerClippingProbability = " << fComputeCornerClippingProbability << '\n'
53  << "par0 = " << fPar0 << '\n'
54  << "par1 = " << fPar1 << '\n'
55  << "par2 = " << fPar2 << '\n'
56  << "par3 = " << fPar3;
57  INFO(os.str());
58 
59  return eSuccess;
60  }
61 
63  MdCornerClippingCorrecter::Run(evt::Event& event)
64  {
65  if (!fComputeCornerClippingProbability) {
66  INFO("No corner clipping probability will be computed.");
67  return eSuccess;
68  }
69 
70  if (!event.HasMEvent()) {
71  WARNING("Event without MEvent: nothing to be done. Skipping to next event.");
72  return eContinueLoop;
73  }
74 
75  INFO("Starting");
76 
77  mevt::MEvent& me = event.GetMEvent();
78  const mdet::MDetector& md = det::Detector::GetInstance().GetMDetector();
79 
80  std::ostringstream os;
81  for (auto cIt = me.CountersBegin(), cEnd = me.CountersEnd(); cIt != cEnd; ++cIt) {
82 
83  mevt::Counter& counter = *cIt;
84  const int counterId = counter.GetId();
85 
86  if (counter.IsRejected()) {
87  os.str("");
88  os << "No corner clipping probability for the rejected counter " << counterId << ".";
89  INFO(os);
90  continue;
91  }
92 
93  if (counter.IsSilent()) {
94  os.str("");
95  os << "No corner clipping probability for the silent counter " << counterId << ".";
96  INFO(os);
97  continue;
98  }
99 
100  os.str("");
101  os << "Processing counter " << counterId;
102  INFO(os);
103 
104  const mdet::Counter& mdc = md.GetCounter(counterId);
105 
106  for (auto mIt = counter.ModulesBegin(), mEnd = counter.ModulesEnd(); mIt != mEnd; ++mIt) {
107 
108  DEBUGLOG("Starting module loop");
109  mevt::Module& module = *mIt;
110  const int moduleId = module.GetId();
111 
112  os.str("");
113  os << "Processing module " << moduleId;
114  INFO(os);
115 
116  const mdet::Module& mdm = mdc.GetModule(moduleId);
117 
118  if (module.IsRejected()) {
119  os.str("");
120  os << "Module " << module.GetId() << " of counter " << counterId
121  << " discarded because flagged as: " << module.GetRejectionReason();
122  WARNING(os);
123  continue;
124  }
125 
126  FillCornerClippingProbability(event, module, mdm);
127 
128  }
129  }
130  return eSuccess;
131  }
132 
134  MdCornerClippingCorrecter::Finish()
135  {
136  return eSuccess;
137  }
138 
139  // private methods
140  void
141  MdCornerClippingCorrecter::FillCornerClippingProbability(const evt::Event& event, mevt::Module& module, const mdet::Module& mdetModule)
142  {
143  // Shower geometry
144  const evt::ShowerSRecData& sRecShower = event.GetRecShower().GetSRecShower();
145  const utl::Point& rCore = sRecShower.GetCorePosition();
146  const utl::Vector& rAxis = sRecShower.GetAxis();
147  const utl::CoordinateSystemPtr& coreLocalCS = LocalCoordinateSystem::Create(rCore);
148  const double cosTheta = rAxis.GetCosTheta(coreLocalCS);
149  const double phi = rAxis.GetPhi(coreLocalCS) / utl::rad;
150 
151  // Orientation of module
152  const double phi0 = mdetModule.GetPhi0() / utl::rad;
153 
154  // pcc computation
155  const double sindphi = std::abs(std::sin(phi-phi0));
156  const double m = fPar0 + fPar1 / cosTheta;
157  const double b = fPar2 + fPar3 / cosTheta;
158  const double pcc = b + m*sindphi;
159 
160  // Filling mRecData
161  mevt::ModuleRecData& mRecData = module.GetRecData();
162  mRecData.SetCornerClippingProbability(pcc);
163 
164  std::ostringstream os;
165  os << "phi = " << phi << " rad, "
166  "phi = " << phi / utl::deg << " deg, "
167  "phi0 = " << phi0 << " rad, "
168  "phi0 = " << phi0 / utl::deg << " deg, "
169  "sin(phi-phi0) = " << sindphi << ", "
170  "cosTheta = " << cosTheta << ", "
171  "m = " << m << ", "
172  "b = " << b << ", "
173  "pcc = " << pcc;
174  INFO(os);
175  }
176 
177 }
Module level reconstruction data. This class contains all data required by the muon reconstruction...
Definition: ModuleRecData.h:29
const Module & GetModule(const int mId) const
Retrieve by id a constant module.
CounterConstIterator CountersBegin() const
Definition: MEvent.h:49
Point object.
Definition: Point.h:32
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
bool HasMEvent() const
Interface class to access to the SD Reconstruction of a Shower.
Counter level event data.
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
Definition: BasicVector.h:251
constexpr double rad
Definition: AugerUnits.h:137
std::string GetRejectionReason() const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
bool IsRejected() const
Check if the counter is rejected.
int GetId() const
bool IsSilent() const
Check if the counter is silent.
Detector associated to muon detector hierarchy.
Definition: MDetector.h:32
constexpr double deg
Definition: AugerUnits.h:140
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
Module level event data.
Definition: MEvent/Module.h:41
double abs(const SVector< n, T > &v)
#define DEBUGLOG(message)
Macro for logging debugging messages.
Definition: ErrorLogger.h:157
Array of Scintillator.
const utl::Vector & GetAxis() const
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
ModuleConstIterator ModulesBegin() const
Root detector of the muon detector hierarchy.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
int GetId() const
The id of the counter.
ModuleConstIterator ModulesEnd() const
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
ModuleRecData & GetRecData()
bool IsRejected() const
double GetPhi0() const
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
Definition: ConfigUtils.h:35
Vector object.
Definition: Vector.h:30
CounterConstIterator CountersEnd() const
Definition: MEvent.h:52
const utl::Point & GetCorePosition() const
const Counter & GetCounter(int id) const
Retrieve Counter by id.
Definition: MDetector.h:68
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
constexpr double m
Definition: AugerUnits.h:121
Root of the Muon event hierarchy.
Definition: MEvent.h:25
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
void SetCornerClippingProbability(const double p)

, generated on Tue Sep 26 2023.