9 #include "ERNeuRadDigitizer.h" 20 #include "TClonesArray.h" 26 #include "FairRootManager.h" 27 #include "FairRunAna.h" 28 #include "FairRuntimeDb.h" 30 #include "EREventHeader.h" 32 const Double_t ERNeuRadDigitizer::cSciFiLightYield= 8000.;
33 const Double_t ERNeuRadDigitizer::cSpeedOfLight = 0.299792458e2;
34 const Double_t ERNeuRadDigitizer::cMaterialSpeedOfLight = ERNeuRadDigitizer::cSpeedOfLight/1.58;
35 const Double_t ERNeuRadDigitizer::cLightFractionInTotalIntReflection = 0.04;
37 const Double_t ERNeuRadDigitizer::cPixelDelay=6.;
38 const Double_t ERNeuRadDigitizer::cPixelJitter = 0.4/2.36;
39 const Double_t ERNeuRadDigitizer::cScincilationTau = 3.2;
43 : FairTask(
"ER NeuRad Digitization scheme"),
44 fPixelJitter(cPixelJitter),
45 fPixelDelay(cPixelDelay),
46 fScincilationTau(cScincilationTau),
47 fPhotoElectronsCreatingTime(0),
48 fPixelSignalCreatingTime(0),
51 fNeuRadPhotoElectron(NULL),
52 fNeuRadPixelSignal(NULL),
57 fUseCrosstalks(kFALSE)
59 fPEA =
new TF1(
"fPEA",
"ERNeuRadDigitizer::PeFunc", 0., 2000., 7);
60 fPEA->SetParameters(85.8656,30.6158,447.112,447.111,52.,433.,141.);
67 : FairTask(
"ER NeuRad Digitization scheme ", verbose),
68 fPixelJitter(cPixelJitter),
69 fPixelDelay(cPixelDelay),
70 fScincilationTau(cScincilationTau),
71 fPhotoElectronsCreatingTime(0),
72 fPixelSignalCreatingTime(0),
75 fNeuRadPhotoElectron(NULL),
76 fNeuRadPixelSignal(NULL),
81 fUseCrosstalks(kFALSE)
83 fPEA =
new TF1(
"fPEA", ERNeuRadDigitizer::PeFunc, 0., 2000., 7);
84 fPEA->SetParameters(85.8656,30.6158,447.112,447.111,52.,433.,141.);
96 void ERNeuRadDigitizer::SetParContainers()
98 fNeuRadSetup = ERNeuRadSetup::Instance();
99 fNeuRadSetup->SetParContainers();
107 cout <<
"Init" << endl;
108 FairRootManager* ioman = FairRootManager::Instance();
109 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
111 fNeuRadPoints = (TClonesArray*) ioman->GetObject(
"NeuRadPoint");
112 if ( ! fNeuRadPoints) Fatal(
"ERNeuRadDigitizer::Init",
"No NeuRadPoint Collection");
115 fNeuRadPhotoElectron =
new TClonesArray(
"ERNeuRadPhotoElectron",1000);
116 ioman->Register(
"NeuRadPhotoElectron",
"NeuRad photoelectrons", fNeuRadPhotoElectron, kTRUE);
117 fNeuRadPixelSignal =
new TClonesArray(
"ERNeuRadPixelSignal", 1000);
118 ioman->Register(
"NeuRadPixelSignal",
"Signal Pixel", fNeuRadPixelSignal, kTRUE);
120 fNeuRadSetup->Print();
134 FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber();
135 std::cout <<
"Event " << iEvent << std::endl;
138 Int_t nofPixels = fNeuRadSetup->NofPixels();
139 Int_t nofModules = fNeuRadSetup->NofModules();
141 vector<ERNeuRadPhotoElectron* >** peInPixelsF =
new vector<ERNeuRadPhotoElectron*>* [nofModules];
142 vector<ERNeuRadPhotoElectron* >** peInPixelsB =
new vector<ERNeuRadPhotoElectron*>* [nofModules];
143 for (Int_t i = 0; i<nofModules; i++){
144 peInPixelsF[i] =
new vector<ERNeuRadPhotoElectron*> [nofPixels];
145 peInPixelsB[i] =
new vector<ERNeuRadPhotoElectron*> [nofPixels];
148 Int_t points_count = fNeuRadPoints->GetEntries();
151 fPhotoElectronsCreatingTimer.Start();
152 for (Int_t iPoint=0; iPoint < points_count; iPoint++) {
154 PhotoElectronsCreating(iPoint,point,peInPixelsF,0,fPECountF,fSumAmplitudeF);
155 PhotoElectronsCreating(iPoint,point,peInPixelsB,1,fPECountB,fSumAmplitudeB);
157 fPhotoElectronsCreatingTimer.Stop();
159 fPhotoElectronsCreatingTime += fPhotoElectronsCreatingTimer.RealTime();
161 fPixelSignalCreatingTimer.Start();
163 for (Int_t iModule = 0; iModule < nofModules; iModule++){
165 for (Int_t iPixel = 0; iPixel < nofPixels; iPixel++) {
166 PixelSignalsCreating(iModule, iPixel, peInPixelsF,0);
167 PixelSignalsCreating(iModule, iPixel, peInPixelsB,1);
171 fPixelSignalCreatingTimer.Stop();
172 fPixelSignalCreatingTime += fPixelSignalCreatingTimer.RealTime();
175 for (Int_t i = 0; i<nofModules; i++){
176 delete [] peInPixelsF[i];
177 delete [] peInPixelsB[i];
179 delete [] peInPixelsF;
180 delete [] peInPixelsB;
182 FairRunAna* run = FairRunAna::Instance();
184 header->SetNeuRadPECountF(fPECountF);
185 header->SetNeuRadPECountB(fPECountB);
186 header->SetNeuRadSumAmplitudeF(fSumAmplitudeF);
187 header->SetNeuRadSumAmplitudeB(fSumAmplitudeB);
192 void ERNeuRadDigitizer::PhotoElectronsCreating(Int_t iPoint,
ERNeuRadPoint *point,
193 std::vector<ERNeuRadPhotoElectron* >** peInPixels,Int_t side, Int_t& sumPECount,Float_t& sumAmplitude)
198 Double_t fiberLength = fNeuRadSetup->FiberLength();
199 Int_t pointModule = point->GetModuleNb();
200 Int_t pointPixel = point->GetPixelNb();
201 Double_t pointELoss = point->GetEnergyLoss();
202 Double_t pointLYield = point->GetLightYield();
203 Double_t pointZ = point->GetZInLocal();
204 Double_t pointTime = point->GetTimeIn();
206 Double_t pointZInFiber = pointZ + fiberLength/2.;
209 Double_t PixelQuantumEfficiency = fNeuRadSetup->PixelQuantumEfficiency(pointModule,pointPixel);
212 Double_t photonCount = pointLYield*1000.*cSciFiLightYield;
215 Double_t k1 = 0.5-cLightFractionInTotalIntReflection;
216 Double_t k2 = cLightFractionInTotalIntReflection;
217 Double_t flightLength = 0;
219 flightLength = pointZInFiber;
221 flightLength = fiberLength-pointZInFiber;
222 Double_t pePhotonCount = photonCount*(k1*exp(-flightLength/0.5) + k2*exp(-flightLength/200.));
225 Int_t peCount = (Int_t)gRandom->Poisson(pePhotonCount*PixelQuantumEfficiency);
228 for(Int_t iPE=0;iPE<peCount;iPE++){
230 Double_t peLYTime = pointTime + (-1)*fScincilationTau*TMath::Log(1-gRandom->Uniform());
232 Double_t peCathodeTime = peLYTime + flightLength/cMaterialSpeedOfLight;
234 Int_t pePixel = pointPixel, peModule = pointModule;
236 Crosstalks(pointModule,pointPixel, peModule, pePixel);
238 Double_t PixelGain = fNeuRadSetup->PixelGain(peModule,pePixel);
239 Double_t PixelSigma = fNeuRadSetup->PixelSigma(peModule,pePixel);
241 Double_t peAmplitude = TMath::Abs(fPEA->GetRandom());
242 sumAmplitude+=peAmplitude;
244 Double_t peAnodeTime = peCathodeTime + (Double_t)gRandom->Gaus(fPixelDelay, fPixelJitter);
246 ERNeuRadPhotoElectron* pe = AddPhotoElectron(iPoint, side, peLYTime, peCathodeTime, peAnodeTime, pePhotonCount, peAmplitude);
247 peInPixels[peModule][pePixel].push_back(pe);
253 Int_t ERNeuRadDigitizer::Crosstalks(Int_t pointModule, Int_t pointPixel, Int_t& peModule, Int_t& pePixel){
256 pePixel = pointPixel;
257 peModule = pointModule;
259 fNeuRadSetup->Crosstalks(pePixel, crosstalks);
260 Float_t prob = gRandom->Uniform();
267 for (Int_t i = 0; i < 3; i++){
268 for (Int_t j = 0; j < 3; j++){
269 if (crosstalks[i*3+j] == 0 || (i==1 && j==1))
272 curProb += crosstalks[i*3+j];
285 pePixel-= fNeuRadSetup->RowNofPixels();
288 pePixel+=fNeuRadSetup->RowNofPixels();
302 if (fNeuRadPhotoElectron){
303 fNeuRadPhotoElectron->Delete();
305 if (fNeuRadPixelSignal){
306 fNeuRadPixelSignal->Delete();
311 void ERNeuRadDigitizer::PixelSignalsCreating(Int_t iModule, Int_t iPixel,
312 std::vector<ERNeuRadPhotoElectron* >** peInPixels,Int_t side)
314 if(peInPixels[iModule][iPixel].size() > 0){
315 ERNeuRadPixelSignal* PixelSignal = AddPixelSignal(iModule, iPixel,peInPixels[iModule][iPixel].size(),side);
316 for(Int_t iPE = 0; iPE < peInPixels[iModule][iPixel].size(); iPE++){
318 PixelSignal->AddPhotoElectron(pe);
320 PixelSignal->Generate();
326 std::cout <<
"========== Finish of ERNeuRadDigitizer =================="<< std::endl;
327 std::cout <<
"===== Time on PhotoElectrons creating : " << fPhotoElectronsCreatingTime <<
" s" << std::endl;
328 std::cout <<
"===== Time on Pixel signal creating : " << fPixelSignalCreatingTime <<
" s" << std::endl;
329 std::cout <<
"=========================================================" << std::endl;
333 ERNeuRadPixelSignal* ERNeuRadDigitizer::AddPixelSignal(Int_t iModule, Int_t iPixel, Int_t fpoints_count, Int_t side){
338 ERNeuRadPhotoElectron* ERNeuRadDigitizer::AddPhotoElectron(Int_t iPoint, Int_t side, Double_t lytime, Double_t cathode_time, Double_t anode_time,
339 Int_t photonCount, Double_t amplitude){
342 fp->AddLink(FairLink(
"NeuRadPoint",iPoint));
349 return fNeuRadPhotoElectron->GetEntriesFast();
354 Int_t ERNeuRadDigitizer::PixelSignalCount()
const {
355 return fNeuRadPixelSignal->GetEntriesFast();
360 Double_t ERNeuRadDigitizer::PeFunc(Double_t *x, Double_t *par) {
365 if (x[0]>=63 && x[0]<par[0]) {
366 fitval = (x[0]-63) * (par[1]) / (par[0]-63) + par[4]*exp( -0.5*(x[0]-par[5])*(x[0]-par[5])/(par[6]*par[6]));
369 fitval = par[1]*(x[0]-par[2])*(x[0]+par[2]-2*par[3])/((par[0]-par[2])*(par[0]+par[2]-2*par[3])) + par[4]*exp( -0.5*(x[0]-par[5])*(x[0]-par[5])/(par[6]*par[6]));
372 fitval = par[4]*exp( -0.5*(x[0]-par[5])*(x[0]-par[5])/(par[6]*par[6]));
virtual InitStatus Init()
Int_t PhotoElectronCount() const
Class for the NeuRad digital response calculation.
virtual void Exec(Option_t *opt)
The data class for storing pieces of charged tracks in sensitive volumes in NeuRad.