From 0c24ba98f9a6562f146d17265361f1a01a5ea865 Mon Sep 17 00:00:00 2001 From: cblume Date: Tue, 8 Oct 2002 20:46:12 +0000 Subject: [PATCH] Do coupling factors before noise is applied --- TRD/AliTRDdigitizer.cxx | 176 ++++++++++++++++++++++++++++------------ 1 file changed, 122 insertions(+), 54 deletions(-) diff --git a/TRD/AliTRDdigitizer.cxx b/TRD/AliTRDdigitizer.cxx index 9c6c06b250d..f64a827c207 100644 --- a/TRD/AliTRDdigitizer.cxx +++ b/TRD/AliTRDdigitizer.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.38 2002/04/30 08:30:40 cblume +gAlice now only read by AliRunDigitizer. Therefore it is just deleted in AliTRDmerge.C + Revision 1.37 2002/04/29 11:50:47 cblume Change initialization of gAlice in the merging case @@ -224,7 +227,9 @@ AliTRDdigitizer::AliTRDdigitizer() fSDigits = kFALSE; fSDigitsScale = 0.0; fMergeSignalOnly = kFALSE; - + fSimpleSim = kFALSE; + fSimpleDet = 0; + } //_____________________________________________________________________________ @@ -248,7 +253,9 @@ AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) fDebug = 0; fSDigits = kFALSE; fMergeSignalOnly = kFALSE; - + fSimpleSim = kFALSE; + fSimpleDet = 0; + // For the summable digits fSDigitsScale = 100.; @@ -276,7 +283,9 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager fDebug = 0; fSDigits = kFALSE; fMergeSignalOnly = kFALSE; - + fSimpleSim = kFALSE; + fSimpleDet = 0; + // For the summable digits fSDigitsScale = 100.; @@ -303,6 +312,8 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager) fDebug = 0; fSDigits = kFALSE; fMergeSignalOnly = kFALSE; + fSimpleSim = kFALSE; + fSimpleDet = 0; // For the summable digits fSDigitsScale = 100.; @@ -388,7 +399,9 @@ void AliTRDdigitizer::Copy(TObject &d) ((AliTRDdigitizer &) d).fSDigits = fSDigits; ((AliTRDdigitizer &) d).fSDigitsScale = fSDigitsScale; ((AliTRDdigitizer &) d).fMergeSignalOnly = fMergeSignalOnly; - + ((AliTRDdigitizer &) d).fSimpleSim = fSimpleSim; + ((AliTRDdigitizer &) d).fSimpleDet = fSimpleDet; + } //_____________________________________________________________________________ @@ -677,11 +690,14 @@ Bool_t AliTRDdigitizer::MakeDigits() // Get the number of entries in the hit tree // (Number of primary particles creating a hit somewhere) - Int_t nTrack = (Int_t) hitTree->GetEntries(); - if (fDebug > 0) { - printf(" "); - printf("Found %d primary particles\n",nTrack); - } + Int_t nTrack = 1; + if (!fSimpleSim) { + nTrack = (Int_t) hitTree->GetEntries(); + if (fDebug > 0) { + printf(" "); + printf("Found %d primary particles\n",nTrack); + } + } Int_t detectorOld = -1; Int_t countHits = 0; @@ -689,8 +705,10 @@ Bool_t AliTRDdigitizer::MakeDigits() // Loop through all entries in the tree for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { - gAlice->ResetHits(); - nBytes += hitTree->GetEvent(iTrack); + if (!fSimpleSim) { + gAlice->ResetHits(); + nBytes += hitTree->GetEvent(iTrack); + } // Loop through the TRD hits Int_t iHit = 0; @@ -774,6 +792,14 @@ Bool_t AliTRDdigitizer::MakeDigits() } signals->Allocate(nRowMax,nColMax,nTimeTotal); } + else if (fSimpleSim) { + // Clear an old one for the simple simulation + if (fDebug > 1) { + printf(" "); + printf("Clear a old container ... "); + } + signals->Clear(); + } else { // Expand an existing one if (fCompress) { @@ -785,13 +811,15 @@ Bool_t AliTRDdigitizer::MakeDigits() } } // The same for the dictionary - for (iDict = 0; iDict < kNDict; iDict++) { - dictionary[iDict] = fDigitsManager->GetDictionary(detector,iDict); - if (dictionary[iDict]->GetNtime() == 0) { - dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); - } - else { - if (fCompress) dictionary[iDict]->Expand(); + if (!fSimpleSim) { + for (iDict = 0; iDict < kNDict; iDict++) { + dictionary[iDict] = fDigitsManager->GetDictionary(detector,iDict); + if (dictionary[iDict]->GetNtime() == 0) { + dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); + } + else { + if (fCompress) dictionary[iDict]->Expand(); + } } } if (fDebug > 1) printf("done\n"); @@ -799,7 +827,14 @@ Bool_t AliTRDdigitizer::MakeDigits() } // Rotate the sectors on top of each other - fGeo->Rotate(detector,pos,rot); + if (fSimpleSim) { + rot[0] = pos[0]; + rot[1] = pos[1]; + rot[2] = pos[2]; + } + else { + fGeo->Rotate(detector,pos,rot); + } // The driftlength. It is negative if the hit is in the // amplification region. @@ -936,7 +971,7 @@ Bool_t AliTRDdigitizer::MakeDigits() // Store the track index in the dictionary // Note: We store index+1 in order to allow the array to be compressed - if (signalOld[iPad] > 0) { + if ((signalOld[iPad] > 0) && (!fSimpleSim)) { for (iDict = 0; iDict < kNDict; iDict++) { Int_t oldTrack = dictionary[iDict]->GetDataUnchecked(rowE ,colPos @@ -968,13 +1003,22 @@ Bool_t AliTRDdigitizer::MakeDigits() printf("Finished analyzing %d hits\n",countHits); } - // The total conversion factor - Float_t convert = kEl2fC * fPar->GetPadCoupling() - * fPar->GetTimeCoupling() - * fPar->GetChipGain(); + // The coupling factor + Float_t coupling = fPar->GetPadCoupling() + * fPar->GetTimeCoupling(); + + // The conversion factor + Float_t convert = kEl2fC + * fPar->GetChipGain(); // Loop through all chambers to finalize the digits - for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { + Int_t iDetBeg = 0; + Int_t iDetEnd = AliTRDgeometry::Ndet(); + if (fSimpleSim) { + iDetBeg = fSimpleDet; + iDetEnd = iDetBeg + 1; + } + for (Int_t iDet = iDetBeg; iDet < iDetEnd; iDet++) { Int_t plane = fGeo->GetPlane(iDet); Int_t sector = fGeo->GetSector(iDet); @@ -995,8 +1039,13 @@ Bool_t AliTRDdigitizer::MakeDigits() // Add a container for the digits of this detector digits = fDigitsManager->GetDigits(iDet); // Allocate memory space for the digits buffer - digits->Allocate(nRowMax,nColMax,nTimeTotal); - + if (digits->GetNtime() == 0) { + digits->Allocate(nRowMax,nColMax,nTimeTotal); + } + else if (fSimpleSim) { + digits->Clear(); + } + // Get the signal container signals = (AliTRDdataArrayF *) signalsArray->At(iDet); if (signals->GetNtime() == 0) { @@ -1008,11 +1057,13 @@ Bool_t AliTRDdigitizer::MakeDigits() if (fCompress) signals->Expand(); } // Create the missing dictionary containers - for (iDict = 0; iDict < kNDict; iDict++) { - dictionary[iDict] = fDigitsManager->GetDictionary(iDet,iDict); - if (dictionary[iDict]->GetNtime() == 0) { - dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); - } + if (!fSimpleSim) { + for (iDict = 0; iDict < kNDict; iDict++) { + dictionary[iDict] = fDigitsManager->GetDictionary(iDet,iDict); + if (dictionary[iDict]->GetNtime() == 0) { + dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); + } + } } Int_t nDigits = 0; @@ -1042,6 +1093,8 @@ Bool_t AliTRDdigitizer::MakeDigits() for (iTime = 0; iTime < nTimeTotal; iTime++) { Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); + // Pad and time coupling + signalAmp *= coupling; // Add the noise signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,fPar->GetNoise()),0.0); // Convert to mV @@ -1085,39 +1138,49 @@ Bool_t AliTRDdigitizer::MakeDigits() } // Compress the arrays - digits->Compress(1,0); - for (iDict = 0; iDict < kNDict; iDict++) { - dictionary[iDict]->Compress(1,0); - } + if (!fSimpleSim) { + digits->Compress(1,0); + for (iDict = 0; iDict < kNDict; iDict++) { + dictionary[iDict]->Compress(1,0); + } - totalSizeDigits += digits->GetSize(); - totalSizeDict0 += dictionary[0]->GetSize(); - totalSizeDict1 += dictionary[1]->GetSize(); - totalSizeDict2 += dictionary[2]->GetSize(); + totalSizeDigits += digits->GetSize(); + totalSizeDict0 += dictionary[0]->GetSize(); + totalSizeDict1 += dictionary[1]->GetSize(); + totalSizeDict2 += dictionary[2]->GetSize(); - Float_t nPixel = nRowMax * nColMax * nTimeMax; - if (fDebug > 0) { - printf(" "); - printf("Found %d digits in detector %d (%3.0f).\n" - ,nDigits,iDet - ,100.0 * ((Float_t) nDigits) / nPixel); - } + Float_t nPixel = nRowMax * nColMax * nTimeMax; + if (fDebug > 0) { + printf(" "); + printf("Found %d digits in detector %d (%3.0f).\n" + ,nDigits,iDet + ,100.0 * ((Float_t) nDigits) / nPixel); + } + + if (fCompress) signals->Compress(1,0); - if (fCompress) signals->Compress(1,0); + } delete [] inADC; delete [] outADC; } + if (signalsArray) { + delete signalsArray; + signalsArray = 0; + } + if (fDebug > 0) { printf(" "); printf("Total number of analyzed hits = %d\n",countHits); - printf(" "); - printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits - ,totalSizeDict0 - ,totalSizeDict1 - ,totalSizeDict2); + if (!fSimpleSim) { + printf(" "); + printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits + ,totalSizeDict0 + ,totalSizeDict1 + ,totalSizeDict2); + } } return kTRUE; @@ -1177,7 +1240,8 @@ Bool_t AliTRDdigitizer::ConvertSDigits() Double_t padCoupling = fPar->GetPadCoupling(); Double_t timeCoupling = fPar->GetTimeCoupling(); Double_t chipGain = fPar->GetChipGain(); - Double_t convert = kEl2fC * padCoupling * timeCoupling * chipGain;; + Double_t coupling = padCoupling * timeCoupling; + Double_t convert = kEl2fC * chipGain; Double_t adcInRange = fPar->GetADCinRange(); Double_t adcOutRange = fPar->GetADCoutRange(); Int_t adcThreshold = fPar->GetADCthreshold(); @@ -1222,6 +1286,8 @@ Bool_t AliTRDdigitizer::ConvertSDigits() for (iTime = 0; iTime < nTimeTotal; iTime++) { Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime); signal *= sDigitsScale; + // Pad and time coupling + signal *= coupling; // Add the noise signal = TMath::Max((Double_t) gRandom->Gaus(signal,noise),0.0); // Convert to mV @@ -1439,6 +1505,8 @@ Bool_t AliTRDdigitizer::CheckDetector(Int_t plane, Int_t chamber, Int_t sector) // Checks whether a detector is enabled // + if (fSimpleSim) return kTRUE; + if ((fTRD->GetSensChamber() >= 0) && (fTRD->GetSensChamber() != chamber)) return kFALSE; if ((fTRD->GetSensPlane() >= 0) && -- 2.31.1