CbmRoot
CbmMuchSignal.cxx
Go to the documentation of this file.
1 
24 #include "CbmMuchSignal.h"
25 #include "CbmMuchAddress.h"
26 #include "CbmMuchDigi.h"
27 #include "CbmMuchDigiMatch.h"
28 #include "TMath.h"
29 #include "TRandom.h"
30 
31 #include <memory>
32 
33 using namespace std;
34 
35 /*
36 CbmMuchSignal::CbmMuchSignal(CbmMuchSignal* signal)
37  : TObject(),
38  fAddress(signal->fAddress),
39  fTimeStart(signal->fTimeStart),
40  fTimeStop(signal->fTimeStop),
41  fSignalShape(signal->fSignalShape)
42 {
43 }
44 */
46  : TObject()
47  , fAddress(rhs.fAddress)
48  , fTimeStart(rhs.fTimeStart)
49  , fTimeStop(rhs.fTimeStop)
50  ,
51  //fPileUpTime(rhs.fPileUpTime),
52  fCharge(rhs.fCharge)
53  ,
54  //fModifiedCharge(rhs.fModifiedCharge),
55  fPileUpCount(rhs.fPileUpCount)
56  ,
57  //fSignalShape(rhs.fSignalShape),
58  fMatch(rhs.fMatch) {}
59 /*
60 CbmMuchSignal& CbmMuchSignal::operator=(const CbmMuchSignal& rhs)
61 {
62 
63  if (this != &rhs) {
64  TObject::operator=(rhs);
65  fAddress = rhs.fAddress;
66  fTimeStop = rhs.fTimeStop;
67  fTimeStart = rhs.fTimeStart;
68  fSignalShape = rhs.fSignalShape;
69  fMatch = rhs.fMatch;
70  }
71  return *this;
72 }
73 */
74 
75 
76 /*void CbmMuchSignal::MakeSignalShape(UInt_t charge, TArrayD shape) {
77  Int_t bin0 = 0;
78  //Int_t((fT0)/gkResponseBin);
79  Int_t nbins = bin0+shape.GetSize();
80  if (fSignalShape.GetSize()<nbins) fSignalShape.Set(nbins);
81  for (Int_t j=0;j<shape.GetSize();j++) fSignalShape[bin0 + j]+=charge*shape[j];
82 }*/
83 // -------------------------------------------------------------------------
84 //
85 //
86 // -------------------------------------------------------------------------
87 //Below function will add the Signal shapes of 2 signal
88 
90  fPileUpCount++;
91  fPileUpCount += signal->GetPileUpCount();
92  Long_t StartDiff = signal->GetTimeStart() - fTimeStart;
93  Long_t StopDiff = signal->GetTimeStop() - fTimeStop;
94  Bool_t MeFirst = kTRUE;
95  Long_t PileUpTime = 0;
96  LOG(debug4) << " Start Difference " << StartDiff << " Stop Difference "
97  << StopDiff;
98  if (StopDiff > 0)
99  fTimeStop =
100  signal
101  ->GetTimeStop(); //Shows Second signal Stop time is larger than first signal stop time, therefore fStopTime modified.
102  if (StartDiff < 0) {
103  //Shows that New Signal is earlier than This signal.
104  // std::cout<<"First Signal start time " <<fTimeStart<<" Second Signal start time is " <<signal->GetTimeStart() << endl;
105  MeFirst = kFALSE;
106  //StartDiff = (-1)*StartDiff;
107  PileUpTime = fTimeStart;
108  fTimeStart = signal->GetTimeStart();
109  } else {
110  PileUpTime = signal->GetTimeStart();
111  }
112  Long_t PileUpDiff = PileUpTime - fTimeStart;
113  if (PileUpDiff < 0) {
114  LOG(info) << GetName() << " Problem: Check this particular pile up case.";
115  }
116  if (PileUpDiff < SLOWSHAPERPEAK) {
117  fCharge += signal->GetCharge();
118  } else if (!MeFirst)
119  fCharge = signal->GetCharge();
120 
121  /*TArrayD SecondSignalShape = signal->GetSignalShape();
122  fSignalShape.Set(fSignalShape.GetSize()+StopDiff);
123  //std::cout<<"MergeSignal called and size of fSignalShape "<<fSignalShape.GetSize()<<endl;
124  for (Int_t j=0;j<fSignalShape.GetSize()&&j<SecondSignalShape.GetSize();j++)
125 
126  fSignalShape[j+StartDiff]=fSignalShape[j+StartDiff]+SecondSignalShape[j];
127  //SignalShape will be added in the first signal at location from where second signal start.
128 */
129 }
130 
131 void CbmMuchSignal::AddNoise(UInt_t meanNoise) {
132  fCharge += TMath::Abs(meanNoise * gRandom->Gaus());
133  // for (Int_t i=0;i<fSignalShape.GetSize();i++){
134  // fSignalShape[i]+=TMath::Abs(meanNoise*gRandom->Gaus());
135  // }
136 }
137 
138 
139 /*Int_t CbmMuchSignal::GetMaxCharge(){
140  Int_t max_charge = -1;
141  for (Int_t i=0;i<fSignalShape.GetSize();i++){
142  Int_t charge = fSignalShape[i];
143  if (charge>max_charge) max_charge = charge;
144  }
145  return max_charge;
146 }*/
147 
148 
149 /*Int_t CbmMuchSignal::GetTimeStamp(Int_t threshold){
150  //Int_t threshold = 10000;
151  Int_t bin1 = -1;
152  for (Int_t i=0;i<fSignalShape.GetSize();i++){
153  if (bin1<0 && fSignalShape[i]>threshold) {
154  bin1 = i;
155  return fTimeStart+bin1*gkResponseBin;
156  }
157  }
158  return -1;
159 }*/
160 // -------------------------------------------------------------------------
161 
162 
163 /* Below functions will not be used as ADC or Charge value will be calculated on the basis of fSignalShape of the Analog Signal.
164 // ----- Add charge ----------------------------------------------------
165 void CbmMuchSignal::AddAdc(Int_t adc) {
166  Int_t newAdc = GetAdc() + adc;
167  SetAdc(newAdc);
168 }
169 // -------------------------------------------------------------------------
170 
171 
172 // ----- Set new charge ------------------------------------------------
173 void CbmMuchSignal::SetAdc(Int_t adc) {
174  //Charge value should not be more than saturation
175 
176  UShort_t saturation = 4095; //2 ^ 12 - 1;
177  if(adc>saturation){
178  fCharge=saturation;
179  fSaturationFlag=1;
180  }
181  else if (adc < 0) fCharge=0;
182  else fCharge = (UShort_t)adc;
183 }
184 // -------------------------------------------------------------------------
185 */
186 
CbmMuchDigi.h
CbmMuchSignal.h
CbmMuchSignal::fTimeStop
Long64_t fTimeStop
Definition: CbmMuchSignal.h:120
CbmMuchSignal::MergeSignal
void MergeSignal(CbmMuchSignal *)
Definition: CbmMuchSignal.cxx:89
CbmMuchSignal::GetCharge
UInt_t GetCharge() const
Definition: CbmMuchSignal.h:91
CbmMuchSignal::GetPileUpCount
UInt_t GetPileUpCount() const
Definition: CbmMuchSignal.h:93
CbmMuchSignal::fTimeStart
Long64_t fTimeStart
Definition: CbmMuchSignal.h:119
CbmMuchSignal
Data class for an analog signal in the MUCH Simple data class used in the digitisation process of the...
Definition: CbmMuchSignal.h:31
CbmMuchSignal::CbmMuchSignal
CbmMuchSignal()
Definition: CbmMuchSignal.h:34
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMuchSignal::fCharge
UInt_t fCharge
Definition: CbmMuchSignal.h:122
CbmMuchSignal::GetTimeStart
Long_t GetTimeStart() const
Definition: CbmMuchSignal.h:86
CbmMuchAddress.h
CbmMuchSignal::fPileUpCount
UInt_t fPileUpCount
Definition: CbmMuchSignal.h:124
CbmMuchSignal::GetTimeStop
Long64_t GetTimeStop() const
Definition: CbmMuchSignal.h:89
CbmMuchDigiMatch.h
SLOWSHAPERPEAK
#define SLOWSHAPERPEAK
Definition: CbmMuchSignal.h:18
CbmMuchSignal::AddNoise
void AddNoise(UInt_t)
Definition: CbmMuchSignal.cxx:131