InhibitionStrategy.cc
Go to the documentation of this file.
1 #include "InhibitionStrategy.h"
2 //
3 #include <mevt/Module.h>
4 #include <mdet/Module.h>
5 //
6 #include <utl/Trace.h>
7 #include <utl/TabularStream.h>
8 
9 namespace MdPileUpCorrecterAG {
10 
12  {
13  }
14 
15  boost::tuple<double, double>
17  const
18  {
19  double nSingleRealizationMuons = 0;
20  double nAverageMuons = 0;
21 
22  const unsigned int numberOfSamples = mdetModule.IsSiPM() ?
23  mdetModule.GetFrontEndSiPM().GetBufferLength() :
24  mdetModule.GetFrontEnd().GetBufferLength();
25 
26  mevt::ModuleRecData& mRecData = module.GetRecData();
27  unsigned int ns = mRecData.GetSegmentation();
28 
29  //Create the Channels On trace
30  if (!mRecData.HasChannelsOn())
31  mRecData.MakeChannelsOn();
32 
33  utl::TraceUI& channelsOnTrace = mRecData.GetChannelsOn();
34 
35  //Create the Channels Inhibited trace
36  if (!mRecData.HasChannelsInhibited())
37  mRecData.MakeChannelsInhibited();
38 
39  utl::TraceUI& channelsInhiTrace = mRecData.GetChannelsInhibited();
40 
41  for ( size_t bin = 0; bin < numberOfSamples; ++bin ) {
42 
43  size_t chanOn = 0;
44  size_t chanIn = 0;
45  for (mevt::Module::ChannelIterator ch = module.ChannelsBegin(), ech = module.ChannelsEnd(); ch != ech; ++ch) {
46 
47  mevt::Channel& channel = *ch;
48 
49  if (channel.HasRecData() && !channel.IsMasked() && channel.GetRecData().HasTrace() ) {//use unmasked channels only with reconstructed trace
50 
51  const utl::TraceUI traceRec = channel.GetRecData().GetTrace();
52 
53  if ( traceRec.GetSize() ){
54 
55  if ( traceRec.At(bin) == 1 )
56  chanOn++;
57  else
58  if ( traceRec.At(bin) == 2 )
59  chanIn++;
60 
61  }
62  }
63  }//end loop on channels at fixed bin
64 
65  //Set values of channels On and Inhibited per bin
66  channelsOnTrace.PushBack(chanOn);
67  channelsInhiTrace.PushBack(chanIn);
68  // If saturated (this is, even a single bin in the channels ON trace
69  // with number of channels on equal to
70  // segmentation) not possible to estimate the number of muons
71  if ( chanOn + chanIn == ns )
72  mRecData.SetSaturated(true);
73  }//end loop on bins
74 
75  if ( mRecData.IsSaturated() )
76  return boost::tuple<double, double>(-1, -1);
77 
78  //Create the muons Vs time trace
79  if (!mRecData.HasNumberOfMuonsVsTime())
80  mRecData.MakeNumberOfMuonsVsTime();
81 
82  utl::Trace<double>& muSTrace = mRecData.GetNumberOfMuonsVsTime();
83  muSTrace.Clear();
84 
85  if (!mRecData.HasMeanMuonsVsTime())
86  mRecData.MakeMeanMuonsVsTime();
87 
88  utl::Trace<double>& muATrace = mRecData.GetMeanMuonsVsTime();
89  muATrace.Clear();
90 
91  //Apply pile-up correction in bin-by-bin basis
92  for ( size_t bin = 0; bin < numberOfSamples; ++bin ) {
93 
94  unsigned int k = channelsOnTrace.At(bin);
95 
96  if ( !k ) continue;//Nothing to be done
97 
98  unsigned int ni = channelsInhiTrace.At(bin);
99 
100  //NOTE: ni==ns if k==0
101  unsigned int bin_segmentation = ns-ni;
102 
103  double S = double(ns)/bin_segmentation * std::log(1 - double(k)/bin_segmentation)/std::log(1 - 1.0/bin_segmentation);
104  double A = ns * std::log(1 - double(k)/bin_segmentation);
105 
106  nSingleRealizationMuons += S;
107  nAverageMuons -= A;
108 
109  muSTrace.PushBack(S);
110  muATrace.PushBack(A);
111 
112  }
113  return boost::tuple<double, double>(nAverageMuons, nSingleRealizationMuons);
114  }
115 
116 
117 }
118 
Module level reconstruction data. This class contains all data required by the muon reconstruction...
Definition: ModuleRecData.h:29
void SetSaturated(const bool sat)
Definition: ModuleRecData.h:84
bool HasChannelsInhibited() const
T & At(const SizeType i)
trace entry with checked address
Definition: Trace.h:205
utl::TraceD & GetNumberOfMuonsVsTime()
boost::tuple< double, double > operator()(mevt::Module &module, const mdet::Module &mdetModule) const
Performs the counting.
ChannelRecData & GetRecData()
utl::TraceUI & GetChannelsInhibited()
Module level event data.
Definition: MEvent/Module.h:41
utl::TraceUI & GetChannelsOn()
Number of windows with a signal in a module.
Definition: ModuleRecData.cc:9
bool HasChannelsOn() const
bool HasMeanMuonsVsTime() const
const double ns
bool HasRecData() const
ChannelConstIterator ChannelsBegin() const
Array of Scintillator.
#define S
void Clear()
Definition: Trace.h:158
SizeType GetSize() const
Definition: Trace.h:156
bool IsMasked() const
unsigned int GetBufferLength() const
Number of bins of the buffer.
Definition: FrontEnd.h:130
const FrontEnd & GetFrontEnd() const
ChannelConstIterator ChannelsEnd() const
bool HasNumberOfMuonsVsTime() const
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
Definition: Trace-fwd.h:19
ModuleRecData & GetRecData()
const FrontEndSiPM & GetFrontEndSiPM() const
Channel level event data.
size_t GetSegmentation() const
bool IsSiPM() const
void PushBack(const T &value)
Insert a single value at the end.
Definition: Trace.h:119
utl::TraceD & GetMeanMuonsVsTime()
bool IsSaturated() const
Definition: ModuleRecData.h:85
InternalChannelCollection::ComponentIterator ChannelIterator
Definition: MEvent/Module.h:68
unsigned int GetBufferLength() const
Number of bins of the buffer.
Definition: FrontEndSiPM.h:120

, generated on Tue Sep 26 2023.