MDetector/Module.cc
Go to the documentation of this file.
1 #include <mdet/Module.h>
2 
3 #include <mdet/Counter.h>
4 #include <mdet/MHierarchyInfo.h>
5 #include <sdet/Station.h>
6 #include <utl/Vector.h>
7 #include <utl/ErrorLogger.h>
8 #include <vector>
9 #include <sstream>
10 
11 #include <boost/iterator/transform_iterator.hpp>
12 #include <boost/lambda/lambda.hpp>
13 
14 
15 namespace mdet {
16 
18 
19 
21 
22 
23  const char* const Module::AreaKindTags[] = { "small", "large" };
24 
25  const char* const Module::PhotoDetectorTags[] = { "PMT", "SiPM" };
26 
27  const Counter&
29  const
30  {
31  return fCounter;
32  }
33 
34 
35  const PMT&
37  const
38  {
39  return *fPMT;
40  }
41 
42  const SiPMArray&
44  const
45  {
46  return *fSiPMArray;
47  }
48 
49  const FrontEnd&
51  const
52  {
53  return *fFrontEnd;
54  }
55 
56  const FrontEndSiPM&
58  const
59  {
60  return *fFrontEndSiPM;
61  }
62 
63  const BackEndSiPM&
65  const
66  {
67  return *fBackEndSiPM;
68  }
69 
70  Module::Module(const int mId, const det::VManager::IndexMap& parentMap, const Counter& parent) :
71  MDetectorComponent<Module>::Type(mId, parentMap),
72  det::MPositionable<Module>(*this),
73  fScintillators(*this),
74  fFibers(*this),
75  fCounter(parent),
76  fIndexByChannel(fIndexRelations.get<ChannelTag>()),
77  fIndexByPixel(fIndexRelations.get<PixelTag>()),
78  fIndexByScintillator(fIndexRelations.get<ScintillatorTag>()),
79  fIndexByFiber(fIndexRelations.get<FiberTag>())
80  {
81  fScintillators.Update(GetIdsMap());
82  fFibers.Update(GetIdsMap());
83  // Being only one, the id is fixed to one.
84  unsigned int numberOfPixels = 0;
85  unsigned int numberOfChannels = 0;
86  if(GetPhotoDetector()==0){
87  fPMT = new PMT(1, GetIdsMap(), *this);
88  fFrontEnd = new FrontEnd(1, GetIdsMap(), *this);
89  numberOfPixels = fPMT->GetPixels().GetNumberOfComponents();
90  numberOfChannels = fFrontEnd->GetChannels().GetNumberOfComponents();
91  }else{
92  fSiPMArray = new SiPMArray(1, GetIdsMap(), *this);
93  fFrontEndSiPM = new FrontEndSiPM(1, GetIdsMap(), *this);
94  fBackEndSiPM = new BackEndSiPM(1, GetIdsMap(), *this);
95  numberOfPixels = fSiPMArray->GetSiPMs().GetNumberOfComponents();
96  numberOfChannels = fFrontEndSiPM->GetChannels().GetNumberOfComponents();
97  }
98  // Check length of vectors.
99  if (!(fScintillators.GetNumberOfComponents() == fFibers.GetNumberOfComponents() &&
100  fScintillators.GetNumberOfComponents() == numberOfPixels &&
101  fScintillators.GetNumberOfComponents() == numberOfChannels)) {
102 
103  if(GetPhotoDetector()==0)
104  INFO("This Module uses PMT.");
105  else
106  INFO("This Module uses SiPM.");
107 
108  std::ostringstream ss;
109  ss << "For the module ";
110  AddIdMessage(ss);
111  ss << " there are "
112  << fScintillators.GetNumberOfComponents() << " scintillators, "
113  << fFibers.GetNumberOfComponents() << " fibers, "
114  << numberOfPixels << " pixels/sipms, "
115  << numberOfChannels << " channels "
116  " when the quantities must be the same.";
117  FATAL(ss);
118  throw;
119  }
123  }
124 
125 
128  const
129  {
131  }
132 
133 
136  const
137  {
138  return AreaKindCreator::Create(GetData(fAreaKind, "areaKind"));
139  }
140 
141 
142  double
144  const
145  {
146  return GetData(fBackgroundMuonsFlux, "backgroundMuonsFlux");
147  }
148 
149 
152  const
153  {
154  return PhotoDetectorCreator::Create(GetData(fPhotoDetector, "photoDetector"));
155  }
156 
157  double
159  const
160  {
161  return GetEulerPhi();
162  }
163 
164 
165  double
167  const
168  {
169  double area = 0;
170 
172  area += is->GetArea();
173 
174  return area;
175  }
176 
177 
178  unsigned int
180  const
181  {
182  unsigned int nScintillators = 0;
183 
185  ++nScintillators;
186 
187  return nScintillators;
188  }
189 
190 
191  ULong64_t
193  const
194  {
195  return fFrontEnd->GetMask();
196  }
197 
198 
199  double
201  const
202  {
203  return GetDepth(GetPosition());
204  }
205 
206 
207  double
209  const
210  {
211  /*
212  * What's better: to couple or not to the station/counter
213  * this depth? At first seems to be the natural reference;
214  * and it wouldn't make much sense to have an arbitrary depth.
215  *
216  * TODO Check if sdet::GetPosition effectively returns the on-
217  * the-ground position of the tank, with X-Y defining the ground.
218  */
219  const sdet::Station& station = GetCounter().GetAssociatedTank();
220  // Construct the distance vector, ending in the point, and starting
221  // in the (surface) station position
222  const utl::Vector dist = p - station.GetPosition();
223  // Use -1 because we want this depth to be positive for an underground point.
224  const utl::Vector normal2ground(0, 0, -1, station.GetLocalCoordinateSystem());
225  // Project the Z component: should be positive for underground modules (will
226  // there be any "flying" module...? hahaah)
227  return dist * normal2ground;
228  }
229 
230  bool
232  const
233  {
234  return (bool) (GetPhotoDetector() == eSiPM);
235  }
236 
237  double
239  const
240  {
241  double length = 5000;
242  for (Module::FiberConstIterator fIt = FibersBegin(); fIt != FibersEnd(); ++fIt) {
243  length = std::min(length, fIt->GetOnManifoldLength());
244  }
245  return length;
246  }
247 
248  void
249  Module::Update(const bool invalidateData, const bool invalidateComponents)
250  {
251  MDetectorComponent<Module>::Type::Update(invalidateData, invalidateComponents);
252  fScintillators.Update(GetIdsMap(), invalidateData, invalidateComponents);
253  fFibers.Update(GetIdsMap(), invalidateData, invalidateComponents);
254 
255  INFO("rereading channel-pmt/sipm-scintillator assignment..");
256  fIndexByChannel.clear();
257  if(!IsSiPM()){
258  for (mdet::PMT::PixelConstIterator pixIt = fPMT->PixelsBegin(); pixIt != fPMT->PixelsEnd(); ++pixIt) {
259  const Pixel& pix = *pixIt;
261  if (ids.size() != 3) {
262  std::ostringstream ss;
263  ss << "The information in MModelConfig is corrupt! Number of indexes in <channelScintillatorFiberIds> has to be three";
264  FATAL(ss);
265  throw;
266  }
267 
268 
269  IdTuple newtuple;
270  newtuple.fScintillatorId = ids[1];
271  newtuple.fFiberId = ids[2];
272  newtuple.fPixelId = pixIt->GetId();
273  newtuple.fChannelId = ids[0];
274  fIndexByChannel.insert(newtuple);
275  }
276  }else{
277  for (mdet::SiPMArray::SiPMConstIterator sipmIt = fSiPMArray->SiPMsBegin(); sipmIt != fSiPMArray->SiPMsEnd(); ++sipmIt) {
278  const SiPM& sipm = *sipmIt;
280  if (ids.size() != 3) {
281  std::ostringstream ss;
282  ss << "The information in MModelConfig is corrupt! Number of indexes in <channelScintillatorFiberIds> has to be three";
283  FATAL(ss);
284  throw;
285  }
286 
287  IdTuple newtuple;
288  newtuple.fScintillatorId = ids[1];
289  newtuple.fFiberId = ids[2];
290  newtuple.fPixelId = sipmIt->GetId();
291  newtuple.fChannelId = ids[0];
292  fIndexByChannel.insert(newtuple);
293  }
294 
295  }
296  }
297 }
utl::ShadowPtr< FrontEnd > fFrontEnd
utl::ShadowPtr< PMT > fPMT
const BackEndSiPM & GetBackEndSiPM() const
static const char *const PhotoDetectorTags[]
Tags for textual representation.
Point object.
Definition: Point.h:32
const Counter & GetCounter() const
The parent counter.
unsigned int GetNumberOfScintillators() const
AreaKind GetAreaKind() const
Detector description interface for Station-related data.
static EnumType Create(const int k)
int version of the overloaded creation method.
PixelGroup::ConstIterator PixelConstIterator
Convenience typedef for const iterator over the contained mdet::Pixel instances.
Module(const int mId, const det::VManager::IndexMap &parentMap, const Counter &parent)
Constructs the Module (obviously!).
static const char *const kComponentsNames[13]
Defines within it the common (templated) type for muon detector hierarchy components.
bool is(const double a, const double b)
Definition: testlib.cc:113
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Local system based on position and configured rotations.
void Update(std::vector< double > &init, const std::vector< double > &res)
Definition: Util.h:100
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
static const char *const kComponentsIds[13]
ScintillatorConstIterator ScintillatorsBegin() const
Begin iterator over the contained scitillators.
utl::Point GetPosition() const
Electronic front-end for the modules.
Definition: FrontEnd.h:33
#define FATAL(message)
Macro for logging fatal messages.
Definition: ErrorLogger.h:167
const IdsContainer & GetChannelSiPMScintillatorFiberIds() const
Indices for Channel, Scintillator, Fiber of corrresponding Pixel.
Definition: SiPM.cc:49
const VManager::IndexMap & GetIdsMap() const
The id identifying this component within its detector hierarhy.
void Register(utl::VValidated &v)
Register the field so as to allow handling it.
utl::Validated< AreaKindForConfig > fAreaKind
T & GetData(P< T > &d, const std::string &p) const
Common utility function for configuration.
Electronic front-end for the modules.
Definition: FrontEndSiPM.h:35
utl::Point GetPosition() const
Tank position.
const SiPMArray & GetSiPMArray() const
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
64 SiPM Array
Definition: SiPMArray.h:36
PhotoDetector GetPhotoDetector() const
IndexByChannelId & fIndexByChannel
FiberConstIterator FibersBegin() const
Begin iterator over the contained fibers.
static const char *const AreaKindTags[]
Tags for textual representation.
Array of Scintillator.
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the tank.
double GetArea() const
FiberConstIterator FibersEnd() const
End iterator over the contained fibers.
SiPMGroup::ConstIterator SiPMConstIterator
Definition: SiPMArray.h:50
ScintillatorGroup::ConstIterator ScintillatorConstIterator
Scintillator handling.
std::vector< int > IdsContainer
Typedef for container of corresponding Channel, Scintillator, Fiber indices.
double GetBackgroundMuonsFlux() const
Background muons Flux.
Multiple-pixel photo-multiplier tube.
Definition: MDetector/PMT.h:49
double GetShortestFiber() const
const FrontEnd & GetFrontEnd() const
ULong64_t GetMask() const
virtual double GetEulerPhi() const
First Euler angle for rotation over (original) z.
Root detector of the muon detector hierarchy.
utl::Validated< double > fBackgroundMuonsFlux
FiberGroup fFibers
PMT pixel.
utl::Validated< PhotoDetectorForConfig > fPhotoDetector
static const char *const kComponentName
ScintillatorConstIterator ScintillatorsEnd() const
End iterator over the contained scintillators.
FiberGroup::ConstIterator FiberConstIterator
Fiber handling.
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
const FrontEndSiPM & GetFrontEndSiPM() const
double GetPhi0() const
double GetDepth() const
The depth of the origin of the module. This quantity is positive for an underground module...
Vector object.
Definition: Vector.h:30
utl::ShadowPtr< FrontEndSiPM > fFrontEndSiPM
Eletronic BackEndSiPM.
Definition: BackEndSiPM.h:37
AreaKind
Kind of module based on its area.
const sdet::Station & GetAssociatedTank() const
Retrieve the associated tank.
utl::ShadowPtr< BackEndSiPM > fBackEndSiPM
bool IsSiPM() const
const IdsContainer & GetChannelScintillatorFiberIds() const
Indices for Channel, Scintillator, Fiber of corrresponding Pixel.
const Counter & fCounter
static const char *const kComponentId
Type
The type of file that we are acutally opening.
Definition: IoCodes.h:33
void Update(const bool invalidateData, const bool invalidateComponents)
utl::ShadowPtr< SiPMArray > fSiPMArray
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
The reference is the local coordinate system of mdet::Counter.
ScintillatorGroup fScintillators
const PMT & GetPMT() const
structure that holds the mapping between different Ids

, generated on Tue Sep 26 2023.