8 #include "TClonesArray.h"
11 #include "FairRootManager.h"
12 #include "FairGeoVolume.h"
14 #include "FairRuntimeDb.h"
15 #include "FairGeoNode.h"
31 fTimeOrderedDigi(kFALSE),
32 fBranchName(
"MVDStripDigis"),
33 fDigiStripArray(NULL),
34 fDigiPixelArray(NULL),
35 fDigiPixelBuffer(NULL),
36 fDigiStripBuffer(NULL),
40 fTotDigiParRect(NULL),
41 fTotDigiParTrap(NULL),
52 fStripRectChargeConv(NULL),
53 fStripTrapChargeConv(NULL),
54 fCurrentChargeConv(NULL),
77 FairRootManager* ioman = FairRootManager::Instance();
81 std::cout <<
" -E- PndMvdNoiseProducer::Init: RootManager not instantiated!" << std::endl;
95 fMCEventheader = (FairMCEventHeader*) ioman->GetObject(
"MCEventHeader.");
97 Warning(
"Init",
"Did not find the MC event header, assume 50ns of noise clockticks per call of Exec().");
107 std::cout <<
" -I- PndMvdNoiseProducer: Registered Sensors: "
113 std::cout <<
" -I- PndMvdNoiseProducer: Intialisation successfull" << std::endl;
116 if(
fVerbose>0) Info(
"Init()",
"ideal charge conversion for rect. strips");
120 if(
fVerbose>0) Info(
"Init()",
"use TOT charge conversion for rect. strips");
128 else Fatal (
"Init()",
"rect. strips: charge conversion method not defined!");
131 if(
fVerbose>0) Info(
"Init()",
"ideal charge conversion for trap. strips");
135 if(
fVerbose>0) Info(
"Init()",
"use TOT charge conversion for trap. strips");
143 else Fatal (
"Init()",
"trap. strips: charge conversion method not defined!");
146 if(
fVerbose>0) Info(
"Init()",
"ideal charge conversion for pixel part");
150 if(
fVerbose>0) Info(
"Init()",
"use TOT charge conversion for pixel part");
158 else Fatal (
"Init()",
"pixel part: charge conversion method not defined!");
167 for (
int i = 0;
i < sensorNames->GetEntries();
i++)
169 TString volpath = ((TObjString*)(sensorNames->At(
i)))->GetString();
170 if(!volpath.Contains(
"Mvd"))
continue;
173 TString volname = volvec[volvec.size()-1].c_str();
174 if(
fVerbose>2)std::cout <<
"VolName: " << volname.Data();
175 if(volname.Contains(
"Active"))
177 if(volname.Contains(
"RectL")) {
fStripRectLIds.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to StripRectL" << std::endl;}
178 if(volname.Contains(
"RectS")) {
fStripRectSIds.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to StripRectS" << std::endl;}
179 if(volname.Contains(
"Trap")) {
fStripTrapIds.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to StripTrap" << std::endl;}
180 if(volname.Contains(
"Pixel"))
182 if(volname.Contains(
"2")) {
fPixelIds2.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to Pixel 2" << std::endl;}
183 if(volname.Contains(
"4")) {
fPixelIds4.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to Pixel 4" << std::endl;}
184 if(volname.Contains(
"5")) {
fPixelIds5.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to Pixel 5" << std::endl;}
185 if(volname.Contains(
"6")) {
fPixelIds6.push_back(
i);
if(
fVerbose>2)std::cout <<
" \tAdded to Pixel 6" << std::endl;}
194 if (
fGeoH == NULL ) {
200 FairRun* ana = FairRun::Instance();
201 FairRuntimeDb*
rtdb=ana->GetRuntimeDb();
233 chanmax = nrCh * nrFE * nrSensors;
237 chanwhite = gRandom->Poisson(xfrac*chanmax);
238 if(
fVerbose>1) std::cout <<
" -I- PndMvdNoiseProducer: RECT <N> = " << xfrac*cycles*chanmax
239 <<
" leading to " << chanwhite <<
" noisy digis of " << chanmax
240 <<
" total channels" << std::endl;
241 for(Int_t
i = 0;
i < chanwhite;
i++)
244 rnd = gRandom->Integer(chanmax);
245 sens = rnd/(nrFE*nrCh);
246 rnd = rnd % (nrFE*nrCh);
261 chanmax = nrCh * nrFE * nrSensors;
264 chanwhite = gRandom->Poisson(xfrac*cycles*chanmax);
265 if(
fVerbose>1) std::cout <<
" -I- PndMvdNoiseProducer: RECT <N> = " << xfrac*cycles*chanmax
266 <<
" leading to " << chanwhite <<
" noisy digis of " << chanmax
267 <<
" total channels" << std::endl;
268 for(Int_t
i = 0;
i < chanwhite;
i++)
271 rnd = gRandom->Integer(chanmax);
272 sens = rnd/(nrFE*nrCh);
273 rnd = rnd % (nrFE*nrCh);
290 chanmax = nrCh * nrFE * nrSensors;
293 chanwhite = gRandom->Poisson(xfrac*cycles*chanmax);
294 if(
fVerbose>1) std::cout <<
" -I- PndMvdNoiseProducer: TRAP <N> = " << xfrac*cycles*chanmax
295 <<
" leading to " << chanwhite <<
" noisy digis of " << chanmax
296 <<
" total channels" << std::endl;
297 for(Int_t
i = 0;
i < chanwhite;
i++)
299 rnd = gRandom->Integer(chanmax);
300 sens = rnd/(nrFE*nrCh);
301 rnd = rnd % (nrFE*nrCh);
316 nrFE = pixx2 + pixx4 + pixx5 + pixx6;
317 chanmax = nrCh * nrFE;
320 chanwhite = gRandom->Poisson(xfrac*cycles*chanmax);
321 if(
fVerbose>1) std::cout <<
" -I- PndMvdNoiseProducer: PIXEL <N> = " << xfrac*cycles*chanmax
322 <<
" leading to " << chanwhite <<
" noisy digis of " << chanmax
323 <<
" total channels" << std::endl;
324 for(Int_t
i = 0;
i < chanwhite;
i++)
327 rnd = gRandom->Integer(chanmax);
332 if(
fe >= (Int_t)(pixx2 + pixx4 + pixx5) )
334 fe =
fe - pixx2 - pixx4 - pixx5;
339 }
else if(
fe >= (Int_t)(pixx2 + pixx4) )
341 fe =
fe - pixx2 - pixx4;
346 }
else if(
fe >= (Int_t)(pixx2) )
367 std::cout <<
" -I- PndMvdNoiseProducer: Noise produced\t"
368 <<nNoisyStripRects <<
"xStripRect\t"
369 <<nNoisyStripTraps <<
"xStripTrap\t"
370 <<nNoisyPixels <<
"xPixels"<<std::endl;
379 return TMath::Erfc( threshold / (TMath::Sqrt2()*spread) );
386 temp = TMath::Gaus(threshold,0,spread);
387 temp = gRandom->Uniform(0.,temp);
388 temp = -2.*spread*spread*
log(temp);
390 return (Int_t)ceil(temp);
399 timewindow = FairRootManager::Instance()->GetEventTime();
405 if(
fVerbose>1)
printf(
" -I- PndMvdNoiseProducer::CalcReadoutCycles(): %g cycles (%gMHz,%gns)\n",cycles,clock,timewindow);
446 std::vector<Int_t> indices;
447 indices.push_back(iPoint);
450 fDigiStripBuffer->FillNewData(tempStrip, FairRootManager::Instance()->GetEventTime(), FairRootManager::Instance()->GetEventTime() + 10);
461 std::vector<Int_t> indices;
462 indices.push_back(iPoint);
std::vector< Int_t > fPixelIds4
std::vector< Int_t > fPixelIds5
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
PndSdsTotDigiPar * fTotDigiParRect
PndSdsTotDigiPar * fTotDigiParPix
std::vector< std::string > GetStringVector(void)
Int_t GetChargeConvMethod() const
friend F32vec4 sqrt(const F32vec4 &a)
std::vector< Int_t > fPixelIds2
std::vector< Int_t > fStripRectSIds
virtual void SetParContainers()
void AddDigiPixel(Int_t &noisies, Int_t iPoint, Int_t sensorID, Int_t fe, Int_t col, Int_t row, Double_t charge)
virtual void SetParContainers()
Class for digitised strip hits.
friend F32vec4 log(const F32vec4 &a)
Double_t GetCharge() const
PndSdsChargeConversion * fStripTrapChargeConv
Double_t GetNoise() const
std::vector< Int_t > fPixelIds6
virtual Double_t GetTimeStamp(Double_t tof, Double_t charge, Double_t MCEventTime)=0
absolute time stamp of a hit in ns (clock is taken into account)
Double_t GetThreshold() const
Charge Digitization Parameter Class for SDS.
PndSdsDigiPixelWriteoutBuffer * fDigiPixelBuffer
Double_t GetFeBusClock() const
Double_t GetConstCurrent() const
Double_t GetNoise() const
Bool_t fTimeOrderedDigi
parameter to switch to time ordered simulation
Double_t GetClockFrequency() const
virtual void FinishEvent()
PndSdsChargeConversion * fStripRectChargeConv
virtual InitStatus Init()
void AddDigiStrip(Int_t &iStrip, Int_t iPoint, Int_t sensorID, Int_t fe, Int_t chan, Double_t charge)
PndSdsStripDigiPar * fDigiParTrap
Double_t CalcReadoutCycles(Double_t clock)
std::vector< Int_t > fStripRectLIds
Digitization Parameter Class for MVD-Strip part.
Double_t GetFeBusClock() const
PndSdsDigiStripWriteoutBuffer * fDigiStripBuffer
TObjArray * GetSensorNames()
PndSdsStripDigiPar * fDigiParRect
static PndGeoHandling * Instance()
virtual Double_t GetTimeStampErrorAfterCorrection()
PndSdsChargeConversion * fPixChargeConv
virtual Double_t ChargeToDigiValue(Double_t Charge)=0
Converts a given charge in electrons into the electronics answer e.g. ToT [ns].
PndSdsPixelDigiPar * fDigiParPix
Double_t GetChargingTime() const
std::vector< Int_t > fStripTrapIds
virtual ~PndMvdNoiseProducer()
PndSdsChargeConversion * fCurrentChargeConv
Data class to store the digi output of a pixel module.
virtual Double_t GetTimeWalk(Double_t)
PndSdsTotDigiPar * fTotDigiParTrap
virtual void Exec(Option_t *opt)
FairMCEventHeader * fMCEventheader
Geometry name handling.
Int_t GetChargeConvMethod() const
Double_t CalcDistFraction(Double_t spread, Double_t threshold)
Double_t GetThreshold() const
Int_t CalcChargeAboveThreshold(Double_t spread, Double_t threshold)
Digitization Parameter Class for SDS-Pixel part.