FrontEnd.cc
Go to the documentation of this file.
1 #include <mdet/FrontEnd.h>
2 
3 #include <mdet/Pixel.h>
4 #include <mdet/MHierarchyInfo.h>
5 
6 #include <sstream>
7 #include <iostream>
8 #include <bitset>
9 #include <iomanip>
10 
11 namespace mdet {
12 
13  const char* const
15 
16  const char* const
18 
20  (int fId, const det::VManager::IndexMap& parentMap, const Module& parent) :
21  MDetectorComponent<FrontEnd>::Type(fId, parentMap),
22  fChannels(*this),
23  fModule(parent)
24  {
25  Register(fMeanSampleRatePeriod);
26  Register(fSampleRatePeriodJitter);
27  Register(fPreT1BufferLength);
28  Register(fPostT1BufferLength);
29  Register(fExternalMemoryBufferLength);
30  Register(fTrueRangeLowThreshold);
31  Register(fFalseRangeHiThreshold);
32  fChannels.Update(GetIdsMap());
33  }
34 
35  const Module&
37  const
38  {
39  return fModule;
40  }
41 
42  double
44  const
45  {
46  return GetData(fMeanSampleRatePeriod, "meanSampleRatePeriod");
47  }
48 
49  double
51  const
52  {
53  return GetData(fSampleRatePeriodJitter, "sampleRatePeriodJitter");
54  }
55 
56  unsigned int
58  const
59  {
60  // See field declaration: there's a signed to unsigned conversion.
61  return GetData(fPreT1BufferLength, "preT1BufferLength");
62  }
63 
64  unsigned int
66  const
67  {
68  // See GetPreT1BufferLength
69  return GetData(fPostT1BufferLength, "postT1BufferLength");
70  }
71 /*
72  unsigned int
73  FrontEnd::GetExternalMemoryBufferLength()
74  const
75  {
76  // See GetPreT1BufferLength
77  return GetData(fExternalMemoryBufferLength, "externalMemoryBufferLength");
78  }
79 */
80  double
82  const
83  {
84  return GetData(fTrueRangeLowThreshold, "trueRangeLowThreshold");
85  }
86 
87  double
89  const
90  {
91  return GetData(fFalseRangeHiThreshold, "falseRangeHiThreshold");
92  }
93 
96  const
97  {
98  // Note that's shared: so once initialized no further loading
99  // will be done.
100  return GetData<BrokenChannelContainer,utl::ThrowOnZeroDereference,utl::ShadowPtr>(fBrokenChannels, "channelsBroken");
101  }
102 
103  ULong64_t
105  const
106  {
107  std::ostringstream msg;
108 
109  ULong64_t mask = 0;
110 
111  std::bitset<64> bit_mask;
112  bit_mask.reset();//sets all bits to zero
113 
114  msg.str("");
115  const BrokenChannelContainer * channels = 0;
116  channels = & GetBrokenChannels();
117 
118  for ( BrokenChannelContainer::const_iterator chIt = channels->begin(), chIte = channels->end();
119  chIt != chIte; ++chIt ){
120  msg << *chIt << " " ;
121  bit_mask.set(*chIt);//set channel X to one
122  mask |= ULong64_t(1) << *chIt;
123  }
124  msg << std::endl;
125 
126  msg << "MD MASK -- " << std::setw( 10 ) << std::setfill(' ')
127  << bit_mask << " "
128  << " ==> (" << bit_mask.count() << ")\n";
129  msg << "mask in decimal: " << std::endl;
130  msg << mask << std::endl;
131 
132  return mask;
133  }
134 
135 
136 
139  const
140  {
141  return Sampler(*this);
142  }
143 
145  fLastSample(false), // Take as false the non-existing previous sample
146  fFrontEnd(fe)
147  {
148  }
149 
150  bool
152  {
153  // Note that we use both comps with =, tough, if both
154  // limits coincide, we are privileging one of them
155  // (the first we are comparing with).
156  bool ret;
157  if (v >= fFrontEnd.GetTrueRangeLowThreshold())
158  ret = true;
159  else if (v <= fFrontEnd.GetFalseRangeHiThreshold())
160  ret = false;
161  else
162  ret = fLastSample;
163  // Keep this as the new last sample.
164  fLastSample = ret;
165  return ret;
166  }
167 
168  void
169  FrontEnd::Update(bool invalidateData, bool invalidateComponents)
170  {
171  MDetectorComponent<FrontEnd>::Type::Update(invalidateData, invalidateComponents);
172  fChannels.Update(GetIdsMap(), invalidateData, invalidateComponents);
173  if ( invalidateData )
174  fBrokenChannels = 0;
175  }
176 
177 }
Sampler(const FrontEnd &fe)
Construct with the associated FrontEnd.
Definition: FrontEnd.cc:144
utl::Validated< int > fPreT1BufferLength
Definition: FrontEnd.h:265
utl::ShadowPtr< BrokenChannelContainer > fBrokenChannels
Definition: FrontEnd.h:275
void Update(bool invalidateData, bool invalidateComponents)
Forward to channels and to base-class.
Definition: FrontEnd.cc:169
static const char *const kComponentsNames[13]
det::DetectorComponent< C, MManagerProvider > Type
Type specializing det::DetectorComponent for Muon hierarchy.
unsigned int GetPostT1BufferLength() const
Number of bins of the post-T1 buffer.
Definition: FrontEnd.cc:65
ChannelGroup fChannels
Definition: FrontEnd.h:251
double GetFalseRangeHiThreshold() const
Hi end-point of the range where the voltage is taken as a false-value by the FPGA sampling process...
Definition: FrontEnd.cc:88
void Update(std::vector< double > &init, const std::vector< double > &res)
Definition: Util.h:100
static const char *const kComponentsIds[13]
Electronic front-end for the modules.
Definition: FrontEnd.h:33
utl::Validated< double > fFalseRangeHiThreshold
Definition: FrontEnd.h:273
unsigned int GetPreT1BufferLength() const
Number of bins of the (cyclic) pre-T1 buffer.
Definition: FrontEnd.cc:57
const VManager::IndexMap & GetIdsMap() const
The id identifying this component within its detector hierarhy.
T & GetData(P< T > &d, const std::string &p) const
Common utility function for configuration.
Sampler MakeSampler() const
Create a new sampler object.
Definition: FrontEnd.cc:138
double GetMeanSampleRatePeriod() const
Mean electronic sample rate period.
Definition: FrontEnd.cc:43
Encapsulates the sampling logic.
Definition: FrontEnd.h:51
bool operator()(double v)
Digitally sample the voltage.
Definition: FrontEnd.cc:151
Array of Scintillator.
static const char *const kComponentId
Definition: FrontEnd.h:73
const BrokenChannelContainer & GetBrokenChannels() const
List of broken channels.
Definition: FrontEnd.cc:95
utl::Validated< double > fMeanSampleRatePeriod
Definition: FrontEnd.h:255
ULong64_t GetMask() const
Size of the (cyclic) external memory buffer associated to each module.
Definition: FrontEnd.cc:104
const Module & fModule
Definition: FrontEnd.h:277
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
utl::Validated< double > fSampleRatePeriodJitter
Definition: FrontEnd.h:257
double GetSampleRatePeriodJitter() const
Electronic&#39;s jitter in sample rate.
Definition: FrontEnd.cc:50
utl::Validated< double > fTrueRangeLowThreshold
Definition: FrontEnd.h:271
const Module & GetModule() const
The module to which this FrontEnd belongs.
Definition: FrontEnd.cc:36
static const char *const kComponentName
Definition: FrontEnd.h:71
FrontEnd(int fId, const det::VManager::IndexMap &parentMap, const Module &parent)
Constructs the electronic front-end.
Definition: FrontEnd.cc:20
double GetTrueRangeLowThreshold() const
Low end-point of the range where the voltage is taken as a true-value by the FPGA sampling proccess...
Definition: FrontEnd.cc:81
utl::Validated< int > fPostT1BufferLength
Definition: FrontEnd.h:267
std::vector< int > BrokenChannelContainer
Definition: FrontEnd.h:75

, generated on Tue Sep 26 2023.