1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Creates and handles digits from TRD hits //
22 // Authors: C. Blume (blume@ikf.uni-frankfurt.de) //
26 // The following effects are included: //
29 // - Gas gain including fluctuations //
30 // - Pad-response (simple Gaussian approximation) //
32 // - Electronics noise //
33 // - Electronics gain //
35 // - Zero suppression //
37 ////////////////////////////////////////////////////////////////////////////
39 #include <TGeoManager.h>
47 #include "AliRunLoader.h"
48 #include "AliLoader.h"
49 #include "AliConfig.h"
50 #include "AliRunDigitizer.h"
51 #include "AliRunLoader.h"
52 #include "AliLoader.h"
56 #include "AliTRDhit.h"
57 #include "AliTRDdigitizer.h"
58 #include "AliTRDarrayDictionary.h"
59 #include "AliTRDarrayADC.h"
60 #include "AliTRDarraySignal.h"
61 #include "AliTRDdigitsManager.h"
62 #include "AliTRDgeometry.h"
63 #include "AliTRDpadPlane.h"
64 #include "AliTRDcalibDB.h"
65 #include "AliTRDSimParam.h"
66 #include "AliTRDCommonParam.h"
67 #include "AliTRDfeeParam.h"
68 #include "AliTRDmcmSim.h"
69 #include "AliTRDdigitsParam.h"
71 #include "Cal/AliTRDCalROC.h"
72 #include "Cal/AliTRDCalDet.h"
74 ClassImp(AliTRDdigitizer)
76 //_____________________________________________________________________________
77 AliTRDdigitizer::AliTRDdigitizer()
82 ,fSDigitsManagerList(0)
89 ,fMergeSignalOnly(kFALSE)
92 // AliTRDdigitizer default constructor
97 //_____________________________________________________________________________
98 AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)
99 :AliDigitizer(name,title)
103 ,fSDigitsManagerList(0)
110 ,fMergeSignalOnly(kFALSE)
113 // AliTRDdigitizer constructor
118 //_____________________________________________________________________________
119 AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
120 , const Text_t *name, const Text_t *title)
121 :AliDigitizer(manager,name,title)
125 ,fSDigitsManagerList(0)
132 ,fMergeSignalOnly(kFALSE)
135 // AliTRDdigitizer constructor
140 //_____________________________________________________________________________
141 AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager)
142 :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer")
146 ,fSDigitsManagerList(0)
153 ,fMergeSignalOnly(kFALSE)
156 // AliTRDdigitizer constructor
161 //_____________________________________________________________________________
162 AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d)
167 ,fSDigitsManagerList(0)
172 ,fCompress(d.fCompress)
173 ,fSDigits(d.fSDigits)
174 ,fMergeSignalOnly(d.fMergeSignalOnly)
177 // AliTRDdigitizer copy constructor
182 //_____________________________________________________________________________
183 AliTRDdigitizer::~AliTRDdigitizer()
186 // AliTRDdigitizer destructor
189 if (fDigitsManager) {
190 delete fDigitsManager;
194 if (fSDigitsManager) {
195 // s-digitsmanager will be deleted via list
199 if (fSDigitsManagerList) {
200 fSDigitsManagerList->Delete();
201 delete fSDigitsManagerList;
202 fSDigitsManagerList = 0;
217 //_____________________________________________________________________________
218 AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d)
221 // Assignment operator
225 ((AliTRDdigitizer &) d).Copy(*this);
232 //_____________________________________________________________________________
233 void AliTRDdigitizer::Copy(TObject &d) const
239 ((AliTRDdigitizer &) d).fRunLoader = 0;
240 ((AliTRDdigitizer &) d).fDigitsManager = 0;
241 ((AliTRDdigitizer &) d).fSDigitsManager = 0;
242 ((AliTRDdigitizer &) d).fSDigitsManagerList = 0;
243 ((AliTRDdigitizer &) d).fTRD = 0;
244 ((AliTRDdigitizer &) d).fGeo = 0;
245 ((AliTRDdigitizer &) d).fEvent = 0;
246 ((AliTRDdigitizer &) d).fMasks = 0;
247 ((AliTRDdigitizer &) d).fCompress = fCompress;
248 ((AliTRDdigitizer &) d).fSDigits = fSDigits;
249 ((AliTRDdigitizer &) d).fMergeSignalOnly = fMergeSignalOnly;
253 //_____________________________________________________________________________
254 void AliTRDdigitizer::Exec(const Option_t * const option)
257 // Executes the merging
262 AliTRDdigitsManager *sdigitsManager;
264 TString optionString = option;
265 if (optionString.Contains("deb")) {
266 AliLog::SetClassDebugLevel("AliTRDdigitizer",1);
267 AliInfo("Called with debug option");
270 // The AliRoot file is already connected by the manager
271 AliRunLoader *inrl = 0x0;
274 AliDebug(1,"AliRun object found on file.");
277 inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
279 gAlice = inrl->GetAliRun();
281 AliError("Could not find AliRun object.")
286 Int_t nInput = fManager->GetNinputs();
287 fMasks = new Int_t[nInput];
288 for (iInput = 0; iInput < nInput; iInput++) {
289 fMasks[iInput] = fManager->GetMask(iInput);
296 AliRunLoader *orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
298 if (InitDetector()) {
300 AliLoader *ogime = orl->GetLoader("TRDLoader");
304 // If we produce SDigits
305 tree = ogime->TreeS();
307 ogime->MakeTree("S");
308 tree = ogime->TreeS();
312 // If we produce Digits
313 tree = ogime->TreeD();
315 ogime->MakeTree("D");
316 tree = ogime->TreeD();
324 for (iInput = 0; iInput < nInput; iInput++) {
326 AliDebug(1,Form("Add input stream %d",iInput));
328 // Check if the input tree exists
329 inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
330 AliLoader *gime = inrl->GetLoader("TRDLoader");
332 TTree *treees = gime->TreeS();
334 if (gime->LoadSDigits()) {
335 AliError(Form("Error Occured while loading S. Digits for input %d.",iInput));
338 treees = gime->TreeS();
342 AliError(Form("Input stream %d does not exist",iInput));
346 // Read the s-digits via digits manager
347 sdigitsManager = new AliTRDdigitsManager();
348 sdigitsManager->SetSDigits(kTRUE);
350 AliRunLoader *rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
351 AliLoader *gimme = rl->GetLoader("TRDLoader");
354 gimme->LoadSDigits();
357 sdigitsManager->ReadDigits(gimme->TreeS());
359 // Add the s-digits to the input list
360 AddSDigitsManager(sdigitsManager);
364 // Convert the s-digits to normal digits
365 AliDebug(1,"Do the conversion");
369 AliDebug(1,"Write the digits");
370 fDigitsManager->WriteDigits();
376 DeleteSDigitsManager();
382 //_____________________________________________________________________________
383 Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent)
386 // Opens a ROOT-file with TRD-hits and reads in the hit-tree
388 // Connect the AliRoot file containing Geometry, Kine, and Hits
391 TString evfoldname = AliConfig::GetDefaultEventFolderName();
393 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
395 fRunLoader = AliRunLoader::Open(file,evfoldname,"UPDATE");
398 AliError(Form("Can not open session for file %s.",file));
402 if (!fRunLoader->GetAliRun()) {
403 fRunLoader->LoadgAlice();
405 gAlice = fRunLoader->GetAliRun();
408 AliDebug(1,"AliRun object found on file.");
411 AliError("Could not find AliRun object.");
417 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
419 AliError("Can not get TRD loader from Run Loader");
423 if (InitDetector()) {
426 // If we produce SDigits
427 tree = loader->TreeS();
429 loader->MakeTree("S");
430 tree = loader->TreeS();
434 // If we produce Digits
435 tree = loader->TreeD();
437 loader->MakeTree("D");
438 tree = loader->TreeD();
441 return MakeBranch(tree);
449 //_____________________________________________________________________________
450 Bool_t AliTRDdigitizer::Open(AliRunLoader * const runLoader, Int_t nEvent)
453 // Opens a ROOT-file with TRD-hits and reads in the hit-tree
455 // Connect the AliRoot file containing Geometry, Kine, and Hits
458 fRunLoader = runLoader;
460 AliError("RunLoader does not exist");
464 if (!fRunLoader->GetAliRun()) {
465 fRunLoader->LoadgAlice();
467 gAlice = fRunLoader->GetAliRun();
470 AliDebug(1,"AliRun object found on file.");
473 AliError("Could not find AliRun object.");
479 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
481 AliError("Can not get TRD loader from Run Loader");
485 if (InitDetector()) {
488 // If we produce SDigits
489 tree = loader->TreeS();
491 loader->MakeTree("S");
492 tree = loader->TreeS();
496 // If we produce Digits
497 tree = loader->TreeD();
499 loader->MakeTree("D");
500 tree = loader->TreeD();
503 return MakeBranch(tree);
511 //_____________________________________________________________________________
512 Bool_t AliTRDdigitizer::InitDetector()
515 // Sets the pointer to the TRD detector and the geometry
518 // Get the pointer to the detector class and check for version 1
519 fTRD = (AliTRD *) gAlice->GetDetector("TRD");
521 AliFatal("No TRD module found");
524 if (fTRD->IsVersion() != 1) {
525 AliFatal("TRD must be version 1 (slow simulator)");
530 fGeo = new AliTRDgeometry();
532 // Create a digits manager
533 if (fDigitsManager) {
534 delete fDigitsManager;
536 fDigitsManager = new AliTRDdigitsManager();
537 fDigitsManager->SetSDigits(fSDigits);
538 fDigitsManager->CreateArrays();
539 fDigitsManager->SetEvent(fEvent);
541 // The list for the input s-digits manager to be merged
542 if (fSDigitsManagerList) {
543 fSDigitsManagerList->Delete();
546 fSDigitsManagerList = new TList();
552 //_____________________________________________________________________________
553 Bool_t AliTRDdigitizer::MakeBranch(TTree *tree) const
556 // Create the branches for the digits array
559 return fDigitsManager->MakeBranch(tree);
563 //_____________________________________________________________________________
564 void AliTRDdigitizer::AddSDigitsManager(AliTRDdigitsManager *man)
567 // Add a digits manager for s-digits to the input list.
570 fSDigitsManagerList->Add(man);
574 //_____________________________________________________________________________
575 void AliTRDdigitizer::DeleteSDigitsManager()
578 // Removes digits manager from the input list.
581 fSDigitsManagerList->Delete();
585 //_____________________________________________________________________________
586 Bool_t AliTRDdigitizer::MakeDigits()
592 AliDebug(1,"Start creating digits");
595 AliError("No geometry defined");
599 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
601 AliFatal("Could not get calibration object");
605 const Int_t kNdet = AliTRDgeometry::Ndet();
607 Float_t **hits = new Float_t*[kNdet];
608 Int_t *nhit = new Int_t[kNdet];
610 AliTRDarraySignal *signals = 0x0;
613 if (calibration->GetNumberOfTimeBinsDCS() != AliTRDSimParam::Instance()->GetNTimeBins()) {
614 AliWarning(Form("Number of time bins is different to OCDB value [SIM=%d, OCDB=%d]"
615 ,AliTRDSimParam::Instance()->GetNTimeBins()
616 ,calibration->GetNumberOfTimeBinsDCS()));
619 // Sort all hits according to detector number
620 if (!SortHits(hits,nhit)) {
621 AliError("Sorting hits failed");
625 // Loop through all detectors
626 for (Int_t det = 0; det < kNdet; det++) {
628 // Detectors that are switched off, not installed, etc.
629 if (( calibration->IsChamberInstalled(det)) &&
630 (!calibration->IsChamberMasked(det)) &&
631 ( fGeo->ChamberInGeometry(det)) &&
634 signals = new AliTRDarraySignal();
636 // Convert the hits of the current detector to detector signals
637 if (!ConvertHits(det,hits[det],nhit[det],signals)) {
638 AliError(Form("Conversion of hits failed for detector=%d",det));
641 // Convert the detector signals to digits or s-digits
642 if (!ConvertSignals(det,signals)) {
643 AliError(Form("Conversion of signals failed for detector=%d",det));
647 // Delete the signals array
651 } // if: detector status
658 AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")->WriteData("OVERWRITE");
663 // Save the values for the raw data headers
664 fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
665 fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
671 //_____________________________________________________________________________
672 Bool_t AliTRDdigitizer::SortHits(Float_t **hits, Int_t *nhit)
675 // Read all the hits and sorts them according to detector number
676 // in the output array <hits>.
679 AliDebug(1,"Start sorting hits");
681 const Int_t kNdet = AliTRDgeometry::Ndet();
682 // Size of the hit vector
683 const Int_t kNhit = 6;
688 Int_t *lhit = new Int_t[kNdet];
690 for (Int_t det = 0; det < kNdet; det++) {
696 AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
697 if (!gimme->TreeH()) {
700 TTree *hitTree = gimme->TreeH();
701 if (hitTree == 0x0) {
702 AliError("Can not get TreeH");
705 fTRD->SetTreeAddress();
707 // Get the number of entries in the hit tree
708 // (Number of primary particles creating a hit somewhere)
709 Int_t nTrk = (Int_t) hitTree->GetEntries();
710 AliDebug(1,Form("Found %d tracks",nTrk));
712 // Loop through all the tracks in the tree
713 for (Int_t iTrk = 0; iTrk < nTrk; iTrk++) {
715 gAlice->GetMCApp()->ResetHits();
716 hitTree->GetEvent(iTrk);
719 AliError(Form("No hits array for track = %d",iTrk));
723 // Number of hits for this track
724 nhitTrk = fTRD->Hits()->GetEntriesFast();
727 // Loop through the TRD hits
728 AliTRDhit *hit = (AliTRDhit *) fTRD->FirstHit(-1);
733 // Don't analyze test hits
734 if (((Int_t) hit->GetCharge()) != 0) {
736 Int_t trk = hit->Track();
737 Int_t det = hit->GetDetector();
738 Int_t q = hit->GetCharge();
739 Float_t x = hit->X();
740 Float_t y = hit->Y();
741 Float_t z = hit->Z();
742 Float_t time = hit->GetTime();
744 if (nhit[det] == lhit[det]) {
745 // Inititialization of new detector
746 xyz = new Float_t[kNhit*(nhitTrk+lhit[det])];
748 memcpy(xyz,hits[det],sizeof(Float_t)*kNhit*lhit[det]);
751 lhit[det] += nhitTrk;
757 xyz[nhit[det]*kNhit+0] = x;
758 xyz[nhit[det]*kNhit+1] = y;
759 xyz[nhit[det]*kNhit+2] = z;
760 xyz[nhit[det]*kNhit+3] = q;
761 xyz[nhit[det]*kNhit+4] = trk;
762 xyz[nhit[det]*kNhit+5] = time;
767 hit = (AliTRDhit *) fTRD->NextHit();
769 } // for: hits of one track
779 //_____________________________________________________________________________
780 Bool_t AliTRDdigitizer::ConvertHits(Int_t det
781 , const Float_t * const hits
783 , AliTRDarraySignal *signals)
786 // Converts the detectorwise sorted hits to detector signals
789 AliDebug(1,Form("Start converting hits for detector=%d (nhits=%d)",det,nhit));
791 // Number of pads included in the pad response
792 const Int_t kNpad = 3;
793 // Number of track dictionary arrays
794 const Int_t kNdict = AliTRDdigitsManager::kNDict;
795 // Size of the hit vector
796 const Int_t kNhit = 6;
798 // Width of the amplification region
799 const Float_t kAmWidth = AliTRDgeometry::AmThick();
800 // Width of the drift region
801 const Float_t kDrWidth = AliTRDgeometry::DrThick();
802 // Drift + amplification region
803 const Float_t kDrMin = - 0.5 * kAmWidth;
804 const Float_t kDrMax = kDrWidth + 0.5 * kAmWidth;
808 Int_t timeBinTRFend = 1;
812 Double_t padSignal[kNpad];
813 Double_t signalOld[kNpad];
815 AliTRDarrayDictionary *dictionary[kNdict];
817 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
818 AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
819 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
822 AliFatal("Could not get common parameterss");
826 AliFatal("Could not get simulation parameters");
830 AliFatal("Could not get calibration object");
834 // Get the detector wise calibration objects
835 AliTRDCalROC *calVdriftROC = 0;
836 Float_t calVdriftDetValue = 0.0;
837 const AliTRDCalDet *calVdriftDet = calibration->GetVdriftDet();
838 AliTRDCalROC *calT0ROC = 0;
839 Float_t calT0DetValue = 0.0;
840 const AliTRDCalDet *calT0Det = calibration->GetT0Det();
842 if (simParam->TRFOn()) {
843 timeBinTRFend = ((Int_t) (simParam->GetTRFhi()
844 * commonParam->GetSamplingFrequency())) - 1;
847 Int_t nTimeTotal = simParam->GetNTimeBins();
848 Float_t samplingRate = commonParam->GetSamplingFrequency();
849 Float_t elAttachProp = simParam->GetElAttachProp() / 100.0;
851 AliTRDpadPlane *padPlane = fGeo->GetPadPlane(det);
852 Int_t layer = fGeo->GetLayer(det); //update
853 Float_t row0 = padPlane->GetRow0ROC();
854 Int_t nRowMax = padPlane->GetNrows();
855 Int_t nColMax = padPlane->GetNcols();
857 // Create a new array for the signals
858 signals->Allocate(nRowMax,nColMax,nTimeTotal);
860 // Create a new array for the dictionary
861 for (dict = 0; dict < kNdict; dict++) {
862 dictionary[dict] = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
863 dictionary[dict]->Allocate(nRowMax,nColMax,nTimeTotal);
866 // Loop through the hits in this detector
867 for (Int_t hit = 0; hit < nhit; hit++) {
869 pos[0] = hits[hit*kNhit+0];
870 pos[1] = hits[hit*kNhit+1];
871 pos[2] = hits[hit*kNhit+2];
872 Float_t q = hits[hit*kNhit+3];
873 Float_t hittime = hits[hit*kNhit+5];
874 Int_t track = ((Int_t) hits[hit*kNhit+4]);
878 // Find the current volume with the geo manager
879 gGeoManager->SetCurrentPoint(pos);
880 gGeoManager->FindNode();
881 if (strstr(gGeoManager->GetPath(),"/UK")) {
885 // Get the calibration objects
886 calVdriftROC = calibration->GetVdriftROC(det);
887 calVdriftDetValue = calVdriftDet->GetValue(det);
888 calT0ROC = calibration->GetT0ROC(det);
889 calT0DetValue = calT0Det->GetValue(det);
891 // Go to the local coordinate system:
892 // loc[0] - col direction in amplification or driftvolume
893 // loc[1] - row direction in amplification or driftvolume
894 // loc[2] - time direction in amplification or driftvolume
895 gGeoManager->MasterToLocal(pos,loc);
897 // Relative to middle of amplification region
898 loc[2] = loc[2] - kDrWidth/2.0 - kAmWidth/2.0;
901 // The driftlength [cm] (w/o diffusion yet !).
902 // It is negative if the hit is between pad plane and anode wires.
903 Double_t driftlength = -1.0 * loc[2];
905 // Stupid patch to take care of TR photons that are absorbed
906 // outside the chamber volume. A real fix would actually need
907 // a more clever implementation of the TR hit generation
909 if ((loc[1] < padPlane->GetRowEndROC()) ||
910 (loc[1] > padPlane->GetRow0ROC())) {
913 if ((driftlength < kDrMin) ||
914 (driftlength > kDrMax)) {
919 // Get row and col of unsmeared electron to retrieve drift velocity
920 // The pad row (z-direction)
921 Int_t rowE = padPlane->GetPadRowNumberROC(loc[1]);
925 Double_t rowOffset = padPlane->GetPadRowOffsetROC(rowE,loc[1]);
926 // The pad column (rphi-direction)
927 Double_t offsetTilt = padPlane->GetTiltOffset(rowOffset);
928 Int_t colE = padPlane->GetPadColNumber(loc[0]+offsetTilt);
932 Double_t colOffset = 0.0;
934 // Normalized drift length
935 Float_t driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
936 Double_t absdriftlength = TMath::Abs(driftlength);
937 if (commonParam->ExBOn()) {
938 absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity));
941 // Loop over all electrons of this hit
942 // TR photons produce hits with negative charge
943 Int_t nEl = ((Int_t) TMath::Abs(q));
944 for (Int_t iEl = 0; iEl < nEl; iEl++) {
946 // Now the real local coordinate system of the ROC
947 // column direction: locC
948 // row direction: locR
949 // time direction: locT
950 // locR and locC are identical to the coordinates of the corresponding
951 // volumina of the drift or amplification region.
952 // locT is defined relative to the wire plane (i.e. middle of amplification
953 // region), meaning locT = 0, and is negative for hits coming from the
955 Double_t locC = loc[0];
956 Double_t locR = loc[1];
957 Double_t locT = loc[2];
959 // Electron attachment
960 if (simParam->ElAttachOn()) {
961 if (gRandom->Rndm() < (absdriftlength * elAttachProp)) {
966 // Apply the diffusion smearing
967 if (simParam->DiffusionOn()) {
968 if (!(Diffusion(driftvelocity,absdriftlength,locR,locC,locT))) {
973 // Apply E x B effects (depends on drift direction)
974 if (commonParam->ExBOn()) {
975 if (!(ExB(driftvelocity,driftlength,locC))) {
980 // The electron position after diffusion and ExB in pad coordinates.
981 // The pad row (z-direction)
982 rowE = padPlane->GetPadRowNumberROC(locR);
983 if (rowE < 0) continue;
984 rowOffset = padPlane->GetPadRowOffsetROC(rowE,locR);
986 // The pad column (rphi-direction)
987 offsetTilt = padPlane->GetTiltOffset(rowOffset);
988 colE = padPlane->GetPadColNumber(locC+offsetTilt);
989 if (colE < 0) continue;
990 colOffset = padPlane->GetPadColOffset(colE,locC+offsetTilt);
992 // Also re-retrieve drift velocity because col and row may have changed
993 driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
994 Float_t t0 = calT0DetValue + calT0ROC->GetValue(colE,rowE);
996 // Convert the position to drift time [mus], using either constant drift velocity or
997 // time structure of drift cells (non-isochronity, GARFIELD calculation).
998 // Also add absolute time of hits to take pile-up events into account properly
1000 if (simParam->TimeStructOn()) {
1001 // Get z-position with respect to anode wire
1002 Double_t zz = row0 - locR + padPlane->GetAnodeWireOffset();
1003 zz -= ((Int_t)(2 * zz)) / 2.0;
1007 // Use drift time map (GARFIELD)
1008 drifttime = commonParam->TimeStruct(driftvelocity,0.5*kAmWidth-1.0*locT,zz)
1012 // Use constant drift velocity
1013 drifttime = TMath::Abs(locT) / driftvelocity
1017 // Apply the gas gain including fluctuations
1018 Double_t ggRndm = 0.0;
1020 ggRndm = gRandom->Rndm();
1021 } while (ggRndm <= 0);
1022 Double_t signal = -(simParam->GetGasGain()) * TMath::Log(ggRndm);
1024 // Apply the pad response
1025 if (simParam->PRFOn()) {
1026 // The distance of the electron to the center of the pad
1027 // in units of pad width
1028 Double_t dist = (colOffset - 0.5*padPlane->GetColSize(colE))
1029 / padPlane->GetColSize(colE);
1030 // This is a fixed parametrization, i.e. not dependent on
1031 // calibration values !
1032 if (!(calibration->PadResponse(signal,dist,layer,padSignal))) continue;
1036 padSignal[1] = signal;
1040 // The time bin (always positive), with t0 distortion
1041 Double_t timeBinIdeal = drifttime * samplingRate + t0;
1043 if (TMath::Abs(timeBinIdeal) > 2*nTimeTotal) {
1044 timeBinIdeal = 2 * nTimeTotal;
1046 Int_t timeBinTruncated = ((Int_t) timeBinIdeal);
1047 // The distance of the position to the middle of the timebin
1048 Double_t timeOffset = ((Float_t) timeBinTruncated
1049 + 0.5 - timeBinIdeal) / samplingRate;
1051 // Sample the time response inside the drift region
1052 // + additional time bins before and after.
1053 // The sampling is done always in the middle of the time bin
1054 for (Int_t iTimeBin = TMath::Max(timeBinTruncated,0)
1055 ;iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal)
1058 // Apply the time response
1059 Double_t timeResponse = 1.0;
1060 Double_t crossTalk = 0.0;
1061 Double_t time = (iTimeBin - timeBinTruncated) / samplingRate + timeOffset;
1063 if (simParam->TRFOn()) {
1064 timeResponse = simParam->TimeResponse(time);
1066 if (simParam->CTOn()) {
1067 crossTalk = simParam->CrossTalk(time);
1074 for (iPad = 0; iPad < kNpad; iPad++) {
1076 Int_t colPos = colE + iPad - 1;
1077 if (colPos < 0) continue;
1078 if (colPos >= nColMax) break;
1081 signalOld[iPad] = signals->GetData(rowE,colPos,iTimeBin);
1083 if (colPos != colE) {
1084 // Cross talk added to non-central pads
1085 signalOld[iPad] += padSignal[iPad]
1086 * (timeResponse + crossTalk);
1089 // W/o cross talk at central pad
1090 signalOld[iPad] += padSignal[iPad]
1094 signals->SetData(rowE,colPos,iTimeBin,signalOld[iPad]);
1096 // Store the track index in the dictionary
1097 // Note: We store index+1 in order to allow the array to be compressed
1098 // Note2: Taking out the +1 in track
1099 if (signalOld[iPad] > 0.0) {
1100 for (dict = 0; dict < kNdict; dict++) {
1101 Int_t oldTrack = dictionary[dict]->GetData(rowE,colPos,iTimeBin);
1102 if (oldTrack == track) break;
1103 if (oldTrack == -1 ) {
1104 dictionary[dict]->SetData(rowE,colPos,iTimeBin,track);
1112 } // Loop: time bins
1114 } // Loop: electrons of a single hit
1118 AliDebug(2,Form("Finished analyzing %d hits",nhit));
1124 //_____________________________________________________________________________
1125 Bool_t AliTRDdigitizer::ConvertSignals(Int_t det, AliTRDarraySignal *signals)
1128 // Convert signals to digits
1131 AliDebug(1,Form("Start converting the signals for detector %d",det));
1134 // Convert the signal array to s-digits
1135 if (!Signal2SDigits(det,signals)) {
1140 // Convert the signal array to digits
1141 if (!Signal2ADC(det,signals)) {
1144 // Run digital processing for digits
1145 RunDigitalProcessing(det);
1148 // Compress the arrays
1149 CompressOutputArrays(det);
1155 //_____________________________________________________________________________
1156 Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
1159 // Converts the sampled electron signals to ADC values for a given chamber
1162 AliDebug(1,Form("Start converting signals to ADC values for detector=%d",det));
1164 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1166 AliFatal("Could not get calibration object");
1170 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1172 AliFatal("Could not get simulation parameters");
1176 // Converts number of electrons to fC
1177 const Double_t kEl2fC = 1.602e-19 * 1.0e15;
1180 Double_t coupling = simParam->GetPadCoupling()
1181 * simParam->GetTimeCoupling();
1182 // Electronics conversion factor
1183 Double_t convert = kEl2fC
1184 * simParam->GetChipGain();
1185 // ADC conversion factor
1186 Double_t adcConvert = simParam->GetADCoutRange()
1187 / simParam->GetADCinRange();
1188 // The electronics baseline in mV
1189 Double_t baseline = simParam->GetADCbaseline()
1191 // The electronics baseline in electrons
1192 Double_t baselineEl = baseline
1199 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1200 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1201 Int_t nTimeTotal = simParam->GetNTimeBins();
1203 // The gainfactor calibration objects
1204 const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
1205 AliTRDCalROC *calGainFactorROC = 0;
1206 Float_t calGainFactorDetValue = 0.0;
1208 AliTRDarrayADC *digits = 0x0;
1211 AliError(Form("Signals array for detector %d does not exist\n",det));
1214 if (signals->HasData()) {
1215 // Expand the container if neccessary
1219 // Create missing containers
1220 signals->Allocate(nRowMax,nColMax,nTimeTotal);
1223 // Get the container for the digits of this detector
1224 if (fDigitsManager->HasSDigits()) {
1225 AliError("Digits manager has s-digits");
1229 digits = (AliTRDarrayADC *) fDigitsManager->GetDigits(det);
1230 // Allocate memory space for the digits buffer
1231 if (!digits->HasData()) {
1232 digits->Allocate(nRowMax,nColMax,nTimeTotal);
1235 // Get the calibration objects
1236 calGainFactorROC = calibration->GetGainFactorROC(det);
1237 calGainFactorDetValue = calGainFactorDet->GetValue(det);
1239 // Create the digits for this chamber
1240 for (row = 0; row < nRowMax; row++ ) {
1241 for (col = 0; col < nColMax; col++ ) {
1243 // Check whether pad is masked
1244 // Bridged pads are not considered yet!!!
1245 if (calibration->IsPadMasked(det,col,row)) {
1250 Float_t padgain = calGainFactorDetValue
1251 * calGainFactorROC->GetValue(col,row);
1253 AliError(Form("Not a valid gain %f, %d %d %d",padgain,det,col,row));
1256 for (time = 0; time < nTimeTotal; time++) {
1258 // Get the signal amplitude
1259 Float_t signalAmp = signals->GetData(row,col,time);
1260 // Pad and time coupling
1261 signalAmp *= coupling;
1263 signalAmp *= padgain;
1265 // Add the noise, starting from minus ADC baseline in electrons
1266 signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,simParam->GetNoise())
1270 signalAmp *= convert;
1271 // Add ADC baseline in mV
1272 signalAmp += baseline;
1274 // Convert to ADC counts. Set the overflow-bit fADCoutRange if the
1275 // signal is larger than fADCinRange
1277 if (signalAmp >= simParam->GetADCinRange()) {
1278 adc = ((Short_t) simParam->GetADCoutRange());
1281 adc = TMath::Nint(signalAmp * adcConvert);
1284 // Saving all digits
1285 digits->SetData(row,col,time,adc);
1296 //_____________________________________________________________________________
1297 Bool_t AliTRDdigitizer::Signal2SDigits(Int_t det, AliTRDarraySignal *signals)
1300 // Converts the sampled electron signals to s-digits
1303 AliDebug(1,Form("Start converting signals to s-digits for detector=%d",det));
1305 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1307 AliFatal("Could not get calibration object");
1315 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1316 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1317 Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
1319 // Get the container for the digits of this detector
1321 if (!fDigitsManager->HasSDigits()) {
1322 AliError("Digits manager has no s-digits");
1326 AliTRDarraySignal *digits = (AliTRDarraySignal *) fDigitsManager->GetSDigits(det);
1327 // Allocate memory space for the digits buffer
1328 if (!digits->HasData()) {
1329 digits->Allocate(nRowMax,nColMax,nTimeTotal);
1332 // Create the sdigits for this chamber
1333 for (row = 0; row < nRowMax; row++ ) {
1334 for (col = 0; col < nColMax; col++ ) {
1335 for (time = 0; time < nTimeTotal; time++) {
1336 digits->SetData(row,col,time,signals->GetData(row,col,time));
1345 //_____________________________________________________________________________
1346 Bool_t AliTRDdigitizer::Digits2SDigits(AliTRDdigitsManager * const manDig
1347 , AliTRDdigitsManager * const manSDig)
1350 // Converts digits into s-digits. Needed for embedding into real data.
1353 AliDebug(1,"Start converting digits to s-digits");
1356 fGeo = new AliTRDgeometry();
1359 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1361 AliFatal("Could not get calibration object");
1365 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1367 AliFatal("Could not get simulation parameters");
1371 // Converts number of electrons to fC
1372 const Double_t kEl2fC = 1.602e-19 * 1.0e15;
1375 Double_t coupling = simParam->GetPadCoupling()
1376 * simParam->GetTimeCoupling();
1377 // Electronics conversion factor
1378 Double_t convert = kEl2fC
1379 * simParam->GetChipGain();
1380 // ADC conversion factor
1381 Double_t adcConvert = simParam->GetADCoutRange()
1382 / simParam->GetADCinRange();
1383 // The electronics baseline in mV
1384 Double_t baseline = simParam->GetADCbaseline()
1386 // The electronics baseline in electrons
1387 //Double_t baselineEl = baseline
1390 // The gainfactor calibration objects
1391 //const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
1392 //AliTRDCalROC *calGainFactorROC = 0;
1393 //Float_t calGainFactorDetValue = 0.0;
1399 for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
1401 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1402 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1403 Int_t nTimeTotal = manDig->GetDigitsParam()->GetNTimeBins(det);
1405 // Get the calibration objects
1406 //calGainFactorROC = calibration->GetGainFactorROC(det);
1407 //calGainFactorDetValue = calGainFactorDet->GetValue(det);
1410 AliTRDarrayADC *digits = (AliTRDarrayADC *) manDig->GetDigits(det);
1412 if (!manSDig->HasSDigits()) {
1413 AliError("SDigits manager has no s-digits");
1417 AliTRDarraySignal *sdigits = (AliTRDarraySignal *) manSDig->GetSDigits(det);
1418 AliTRDarrayDictionary *tracks0 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,0);
1419 AliTRDarrayDictionary *tracks1 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,1);
1420 AliTRDarrayDictionary *tracks2 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,2);
1421 // Allocate memory space for the digits buffer
1422 sdigits->Allocate(nRowMax,nColMax,nTimeTotal);
1423 tracks0->Allocate(nRowMax,nColMax,nTimeTotal);
1424 tracks1->Allocate(nRowMax,nColMax,nTimeTotal);
1425 tracks2->Allocate(nRowMax,nColMax,nTimeTotal);
1427 // Keep the digits param
1428 manSDig->GetDigitsParam()->SetNTimeBinsAll(manDig->GetDigitsParam()->GetNTimeBins(0));
1429 manSDig->GetDigitsParam()->SetADCbaselineAll(manDig->GetDigitsParam()->GetADCbaseline(0));
1431 if (digits->HasData()) {
1435 // Create the sdigits for this chamber
1436 for (row = 0; row < nRowMax; row++ ) {
1437 for (col = 0; col < nColMax; col++ ) {
1440 //Float_t padgain = calGainFactorDetValue
1441 // * calGainFactorROC->GetValue(col,row);
1443 for (time = 0; time < nTimeTotal; time++) {
1445 Short_t adcVal = digits->GetData(row,col,time);
1446 Double_t signal = (Double_t) adcVal;
1447 // ADC -> signal in mV
1448 signal /= adcConvert;
1449 // Subtract baseline in mV
1451 // Signal in mV -> signal in #electrons
1454 //signal /= padgain; // Not needed for real data
1455 // Pad and time coupling
1458 sdigits->SetData(row,col,time,signal);
1459 tracks0->SetData(row,col,time,0);
1460 tracks1->SetData(row,col,time,0);
1461 tracks2->SetData(row,col,time,0);
1470 sdigits->Compress(0);
1471 tracks0->Compress();
1472 tracks1->Compress();
1473 tracks2->Compress();
1475 // No compress just remove
1476 manDig->RemoveDigits(det);
1477 manDig->RemoveDictionaries(det);
1485 //_____________________________________________________________________________
1486 Bool_t AliTRDdigitizer::SDigits2Digits()
1489 // Merges the input s-digits and converts them to normal digits
1492 if (!MergeSDigits()) {
1496 return ConvertSDigits();
1500 //_____________________________________________________________________________
1501 Bool_t AliTRDdigitizer::MergeSDigits()
1504 // Merges the input s-digits:
1505 // - The amplitude of the different inputs are summed up.
1506 // - Of the track IDs from the input dictionaries only one is
1507 // kept for each input. This works for maximal 3 different merged inputs.
1510 // Number of track dictionary arrays
1511 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1513 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1515 AliFatal("Could not get simulation parameters");
1519 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1521 AliFatal("Could not get calibration object");
1528 AliTRDarraySignal *digitsA;
1529 AliTRDarraySignal *digitsB;
1530 AliTRDarrayDictionary *dictionaryA[kNDict];
1531 AliTRDarrayDictionary *dictionaryB[kNDict];
1533 AliTRDdigitsManager *mergeSDigitsManager = 0x0;
1534 // Get the first s-digits
1535 fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First();
1536 if (!fSDigitsManager) {
1537 AliError("No SDigits manager");
1541 // Loop through the other sets of s-digits
1542 mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(fSDigitsManager);
1544 if (mergeSDigitsManager) {
1545 AliDebug(1,Form("Merge %d input files.",fSDigitsManagerList->GetSize()));
1548 AliDebug(1,"Only one input file.");
1553 while (mergeSDigitsManager) {
1557 // Loop through the detectors
1558 for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
1560 Int_t nTimeTotal = fSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet);
1561 if (mergeSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet) != nTimeTotal) {
1562 AliError(Form("Mismatch in the number of time bins [%d,%d] in detector %d"
1564 ,mergeSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet)
1569 Int_t nRowMax = fGeo->GetPadPlane(iDet)->GetNrows();
1570 Int_t nColMax = fGeo->GetPadPlane(iDet)->GetNcols();
1572 // Loop through the pixels of one detector and add the signals
1573 digitsA = (AliTRDarraySignal *) fSDigitsManager->GetSDigits(iDet);
1574 digitsB = (AliTRDarraySignal *) mergeSDigitsManager->GetSDigits(iDet);
1576 if (!digitsA->HasData()) continue;
1578 if (!digitsB->HasData()) continue;
1580 for (iDict = 0; iDict < kNDict; iDict++) {
1581 dictionaryA[iDict] = (AliTRDarrayDictionary *) fSDigitsManager->GetDictionary(iDet,iDict);
1582 dictionaryB[iDict] = (AliTRDarrayDictionary *) mergeSDigitsManager->GetDictionary(iDet,iDict);
1583 dictionaryA[iDict]->Expand();
1584 dictionaryB[iDict]->Expand();
1587 // Merge only detectors that contain a signal
1588 Bool_t doMerge = kTRUE;
1589 if (fMergeSignalOnly) {
1590 if (digitsA->GetOverThreshold(0) == 0) {
1597 AliDebug(1,Form("Merge detector %d of input no.%d",iDet,iMerge+1));
1599 for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) {
1600 for (Int_t iCol = 0; iCol < nColMax; iCol++ ) {
1601 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
1603 // Add the amplitudes of the summable digits
1604 Float_t ampA = digitsA->GetData(iRow,iCol,iTime);
1605 Float_t ampB = digitsB->GetData(iRow,iCol,iTime);
1607 digitsA->SetData(iRow,iCol,iTime,ampA);
1609 // Add the mask to the track id if defined.
1610 for (iDict = 0; iDict < kNDict; iDict++) {
1611 Int_t trackB = dictionaryB[iDict]->GetData(iRow,iCol,iTime);
1612 if ((fMasks) && (trackB > 0)) {
1613 for (jDict = 0; jDict < kNDict; jDict++) {
1614 Int_t trackA = dictionaryA[iDict]->GetData(iRow,iCol,iTime);
1616 trackA = trackB + fMasks[iMerge];
1617 dictionaryA[iDict]->SetData(iRow,iCol,iTime,trackA);
1618 } // if: track A == 0
1620 } // if: fMasks and trackB > 0
1629 mergeSDigitsManager->RemoveDigits(iDet);
1630 mergeSDigitsManager->RemoveDictionaries(iDet);
1633 digitsA->Compress(0);
1634 for (iDict = 0; iDict < kNDict; iDict++) {
1635 dictionaryA[iDict]->Compress();
1641 // The next set of s-digits
1642 mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(mergeSDigitsManager);
1644 } // while: mergeDigitsManagers
1650 //_____________________________________________________________________________
1651 Bool_t AliTRDdigitizer::ConvertSDigits()
1654 // Converts s-digits to normal digits
1657 AliTRDarraySignal *digitsIn = 0x0;
1659 if (!fSDigitsManager->HasSDigits()) {
1660 AliError("No s-digits in digits manager");
1664 // Loop through the detectors
1665 for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
1667 // Get the merged s-digits (signals)
1668 digitsIn = (AliTRDarraySignal *) fSDigitsManager->GetSDigits(det);
1669 if (!digitsIn->HasData()) {
1670 AliDebug(2,Form("No digits for det=%d",det));
1674 // Convert the merged sdigits to digits
1675 if (!Signal2ADC(det,digitsIn)) {
1679 // Copy the dictionary information to the output array
1680 if (!CopyDictionary(det)) {
1685 fSDigitsManager->RemoveDigits(det);
1686 fSDigitsManager->RemoveDictionaries(det);
1688 // Run digital processing
1689 RunDigitalProcessing(det);
1691 // Compress the arrays
1692 CompressOutputArrays(det);
1694 } // for: detector numbers
1696 AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")->WriteData("OVERWRITE");
1697 // Save the values for the raw data headers
1698 fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
1699 fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
1705 //_____________________________________________________________________________
1706 Bool_t AliTRDdigitizer::CopyDictionary(Int_t det)
1709 // Copies the dictionary information from the s-digits arrays
1710 // to the output arrays
1713 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1715 AliFatal("Could not get calibration object");
1719 AliDebug(1,Form("Start copying dictionaries for detector=%d",det));
1721 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1722 AliTRDarrayDictionary *dictionaryIn[kNDict];
1723 AliTRDarrayDictionary *dictionaryOut[kNDict];
1725 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1726 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1727 Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
1734 for (dict = 0; dict < kNDict; dict++) {
1736 dictionaryIn[dict] = (AliTRDarrayDictionary *) fSDigitsManager->GetDictionary(det,dict);
1737 dictionaryIn[dict]->Expand();
1738 dictionaryOut[dict] = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
1739 dictionaryOut[dict]->Allocate(nRowMax,nColMax,nTimeTotal);
1741 for (row = 0; row < nRowMax; row++) {
1742 for (col = 0; col < nColMax; col++) {
1743 for (time = 0; time < nTimeTotal; time++) {
1744 Int_t track = dictionaryIn[dict]->GetData(row,col,time);
1745 dictionaryOut[dict]->SetData(row,col,time,track);
1750 } // for: dictionaries
1756 //_____________________________________________________________________________
1757 void AliTRDdigitizer::CompressOutputArrays(Int_t det)
1760 // Compress the output arrays
1763 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1764 AliTRDarrayDictionary *dictionary = 0x0;
1769 AliTRDarrayADC *digits = 0x0;
1770 digits = (AliTRDarrayADC *) fDigitsManager->GetDigits(det);
1775 AliTRDarraySignal *digits = 0x0;
1776 digits = (AliTRDarraySignal *) fDigitsManager->GetSDigits(det);
1777 digits->Compress(0);
1780 for (Int_t dict = 0; dict < kNDict; dict++) {
1781 dictionary = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
1782 dictionary->Compress();
1789 //_____________________________________________________________________________
1790 Bool_t AliTRDdigitizer::WriteDigits() const
1793 // Writes out the TRD-digits and the dictionaries
1797 fRunLoader->CdGAFile();
1799 // Store the digits and the dictionary in the tree
1800 return fDigitsManager->WriteDigits();
1804 //_____________________________________________________________________________
1805 void AliTRDdigitizer::InitOutput(Int_t iEvent)
1808 // Initializes the output branches
1814 AliError("Run Loader is NULL");
1818 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
1820 AliError("Can not get TRD loader from Run Loader");
1827 // If we produce SDigits
1828 tree = loader->TreeS();
1830 loader->MakeTree("S");
1831 tree = loader->TreeS();
1835 // If we produce Digits
1836 tree = loader->TreeD();
1838 loader->MakeTree("D");
1839 tree = loader->TreeD();
1842 fDigitsManager->SetEvent(iEvent);
1843 fDigitsManager->MakeBranch(tree);
1847 //_____________________________________________________________________________
1848 Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
1849 , Double_t &lRow, Double_t &lCol, Double_t &lTime)
1852 // Applies the diffusion smearing to the position of a single electron.
1853 // Depends on absolute drift length.
1856 Float_t diffL = 0.0;
1857 Float_t diffT = 0.0;
1859 if (AliTRDCommonParam::Instance()->GetDiffCoeff(diffL,diffT,vdrift)) {
1861 Float_t driftSqrt = TMath::Sqrt(absdriftlength);
1862 Float_t sigmaT = driftSqrt * diffT;
1863 Float_t sigmaL = driftSqrt * diffL;
1864 lRow = gRandom->Gaus(lRow ,sigmaT);
1865 lCol = gRandom->Gaus(lCol ,sigmaT * GetLorentzFactor(vdrift));
1866 lTime = gRandom->Gaus(lTime,sigmaL * GetLorentzFactor(vdrift));
1879 //_____________________________________________________________________________
1880 Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd)
1883 // Returns the Lorentz factor
1886 Double_t omegaTau = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
1887 Double_t lorentzFactor = 1.0;
1888 if (AliTRDCommonParam::Instance()->ExBOn()) {
1889 lorentzFactor = 1.0 / (1.0 + omegaTau*omegaTau);
1892 return lorentzFactor;
1896 //_____________________________________________________________________________
1897 Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t &lCol)
1900 // Applies E x B effects to the position of a single electron.
1901 // Depends on signed drift length.
1905 + AliTRDCommonParam::Instance()->GetOmegaTau(vdrift)
1912 //_____________________________________________________________________________
1913 void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
1916 // Run the digital processing in the TRAP
1919 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
1921 //Create and initialize the mcm object
1922 AliTRDmcmSim* mcmfast = new AliTRDmcmSim();
1924 AliTRDarrayADC *digits = fDigitsManager->GetDigits(det);
1928 //Call the methods in the mcm class using the temporary array as input
1929 for(Int_t rob = 0; rob < digits->GetNrow() / 2; rob++)
1931 for(Int_t mcm = 0; mcm < 16; mcm++)
1933 mcmfast->Init(det, rob, mcm);
1934 mcmfast->SetData(digits, fDigitsManager);
1936 if (feeParam->GetTracklet()) {
1937 mcmfast->Tracklet();
1938 mcmfast->StoreTracklets();
1940 mcmfast->ZSMapping();
1941 mcmfast->WriteData(digits);