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)
85 ,fMcmSim(new AliTRDmcmSim)
90 ,fMergeSignalOnly(kFALSE)
93 // AliTRDdigitizer default constructor
98 //_____________________________________________________________________________
99 AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)
100 :AliDigitizer(name,title)
104 ,fSDigitsManagerList(0)
107 ,fMcmSim(new AliTRDmcmSim)
112 ,fMergeSignalOnly(kFALSE)
115 // AliTRDdigitizer constructor
120 //_____________________________________________________________________________
121 AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
122 , const Text_t *name, const Text_t *title)
123 :AliDigitizer(manager,name,title)
127 ,fSDigitsManagerList(0)
130 ,fMcmSim(new AliTRDmcmSim)
135 ,fMergeSignalOnly(kFALSE)
138 // AliTRDdigitizer constructor
143 //_____________________________________________________________________________
144 AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager)
145 :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer")
149 ,fSDigitsManagerList(0)
152 ,fMcmSim(new AliTRDmcmSim)
157 ,fMergeSignalOnly(kFALSE)
160 // AliTRDdigitizer constructor
165 //_____________________________________________________________________________
166 AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d)
171 ,fSDigitsManagerList(0)
174 ,fMcmSim(new AliTRDmcmSim)
177 ,fCompress(d.fCompress)
178 ,fSDigits(d.fSDigits)
179 ,fMergeSignalOnly(d.fMergeSignalOnly)
182 // AliTRDdigitizer copy constructor
187 //_____________________________________________________________________________
188 AliTRDdigitizer::~AliTRDdigitizer()
191 // AliTRDdigitizer destructor
194 if (fDigitsManager) {
195 delete fDigitsManager;
199 if (fSDigitsManager) {
200 // s-digitsmanager will be deleted via list
204 if (fSDigitsManagerList) {
205 fSDigitsManagerList->Delete();
206 delete fSDigitsManagerList;
207 fSDigitsManagerList = 0;
227 //_____________________________________________________________________________
228 AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d)
231 // Assignment operator
235 ((AliTRDdigitizer &) d).Copy(*this);
242 //_____________________________________________________________________________
243 void AliTRDdigitizer::Copy(TObject &d) const
249 ((AliTRDdigitizer &) d).fRunLoader = 0;
250 ((AliTRDdigitizer &) d).fDigitsManager = 0;
251 ((AliTRDdigitizer &) d).fSDigitsManager = 0;
252 ((AliTRDdigitizer &) d).fSDigitsManagerList = 0;
253 ((AliTRDdigitizer &) d).fTRD = 0;
254 ((AliTRDdigitizer &) d).fGeo = 0;
255 ((AliTRDdigitizer &) d).fEvent = 0;
256 ((AliTRDdigitizer &) d).fMasks = 0;
257 ((AliTRDdigitizer &) d).fCompress = fCompress;
258 ((AliTRDdigitizer &) d).fSDigits = fSDigits;
259 ((AliTRDdigitizer &) d).fMergeSignalOnly = fMergeSignalOnly;
263 //_____________________________________________________________________________
264 void AliTRDdigitizer::Exec(const Option_t * const option)
267 // Executes the merging
272 AliTRDdigitsManager *sdigitsManager;
274 TString optionString = option;
275 if (optionString.Contains("deb")) {
276 AliLog::SetClassDebugLevel("AliTRDdigitizer",1);
277 AliInfo("Called with debug option");
280 // The AliRoot file is already connected by the manager
281 AliRunLoader *inrl = 0x0;
284 AliDebug(1,"AliRun object found on file.");
287 inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
289 gAlice = inrl->GetAliRun();
291 AliError("Could not find AliRun object.")
296 Int_t nInput = fManager->GetNinputs();
297 fMasks = new Int_t[nInput];
298 for (iInput = 0; iInput < nInput; iInput++) {
299 fMasks[iInput] = fManager->GetMask(iInput);
306 AliRunLoader *orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
308 if (InitDetector()) {
310 AliLoader *ogime = orl->GetLoader("TRDLoader");
314 // If we produce SDigits
315 tree = ogime->TreeS();
317 ogime->MakeTree("S");
318 tree = ogime->TreeS();
322 // If we produce Digits
323 tree = ogime->TreeD();
325 ogime->MakeTree("D");
326 tree = ogime->TreeD();
334 for (iInput = 0; iInput < nInput; iInput++) {
336 AliDebug(1,Form("Add input stream %d",iInput));
338 // Check if the input tree exists
339 inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
340 AliLoader *gime = inrl->GetLoader("TRDLoader");
342 TTree *treees = gime->TreeS();
344 if (gime->LoadSDigits()) {
345 AliError(Form("Error Occured while loading S. Digits for input %d.",iInput));
348 treees = gime->TreeS();
352 AliError(Form("Input stream %d does not exist",iInput));
356 // Read the s-digits via digits manager
357 sdigitsManager = new AliTRDdigitsManager();
358 sdigitsManager->SetSDigits(kTRUE);
360 AliRunLoader *rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
361 AliLoader *gimme = rl->GetLoader("TRDLoader");
364 gimme->LoadSDigits();
367 sdigitsManager->ReadDigits(gimme->TreeS());
369 // Add the s-digits to the input list
370 AddSDigitsManager(sdigitsManager);
374 // Convert the s-digits to normal digits
375 AliDebug(1,"Do the conversion");
379 AliDebug(1,"Write the digits");
380 fDigitsManager->WriteDigits();
386 DeleteSDigitsManager();
392 //_____________________________________________________________________________
393 Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent)
396 // Opens a ROOT-file with TRD-hits and reads in the hit-tree
398 // Connect the AliRoot file containing Geometry, Kine, and Hits
401 TString evfoldname = AliConfig::GetDefaultEventFolderName();
403 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
405 fRunLoader = AliRunLoader::Open(file,evfoldname,"UPDATE");
408 AliError(Form("Can not open session for file %s.",file));
412 if (!fRunLoader->GetAliRun()) {
413 fRunLoader->LoadgAlice();
415 gAlice = fRunLoader->GetAliRun();
418 AliDebug(1,"AliRun object found on file.");
421 AliError("Could not find AliRun object.");
427 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
429 AliError("Can not get TRD loader from Run Loader");
433 if (InitDetector()) {
436 // If we produce SDigits
437 tree = loader->TreeS();
439 loader->MakeTree("S");
440 tree = loader->TreeS();
444 // If we produce Digits
445 tree = loader->TreeD();
447 loader->MakeTree("D");
448 tree = loader->TreeD();
451 return MakeBranch(tree);
459 //_____________________________________________________________________________
460 Bool_t AliTRDdigitizer::Open(AliRunLoader * const runLoader, Int_t nEvent)
463 // Opens a ROOT-file with TRD-hits and reads in the hit-tree
465 // Connect the AliRoot file containing Geometry, Kine, and Hits
468 fRunLoader = runLoader;
470 AliError("RunLoader does not exist");
474 if (!fRunLoader->GetAliRun()) {
475 fRunLoader->LoadgAlice();
477 gAlice = fRunLoader->GetAliRun();
480 AliDebug(1,"AliRun object found on file.");
483 AliError("Could not find AliRun object.");
489 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
491 AliError("Can not get TRD loader from Run Loader");
495 if (InitDetector()) {
498 // If we produce SDigits
499 tree = loader->TreeS();
501 loader->MakeTree("S");
502 tree = loader->TreeS();
506 // If we produce Digits
507 tree = loader->TreeD();
509 loader->MakeTree("D");
510 tree = loader->TreeD();
513 return MakeBranch(tree);
521 //_____________________________________________________________________________
522 Bool_t AliTRDdigitizer::InitDetector()
525 // Sets the pointer to the TRD detector and the geometry
528 // Get the pointer to the detector class and check for version 1
529 fTRD = (AliTRD *) gAlice->GetDetector("TRD");
531 AliFatal("No TRD module found");
534 if (fTRD->IsVersion() != 1) {
535 AliFatal("TRD must be version 1 (slow simulator)");
540 fGeo = new AliTRDgeometry();
542 // Create a digits manager
543 if (fDigitsManager) {
544 delete fDigitsManager;
546 fDigitsManager = new AliTRDdigitsManager();
547 fDigitsManager->SetSDigits(fSDigits);
548 fDigitsManager->CreateArrays();
549 fDigitsManager->SetEvent(fEvent);
551 // The list for the input s-digits manager to be merged
552 if (fSDigitsManagerList) {
553 fSDigitsManagerList->Delete();
556 fSDigitsManagerList = new TList();
562 //_____________________________________________________________________________
563 Bool_t AliTRDdigitizer::MakeBranch(TTree *tree) const
566 // Create the branches for the digits array
569 return fDigitsManager->MakeBranch(tree);
573 //_____________________________________________________________________________
574 void AliTRDdigitizer::AddSDigitsManager(AliTRDdigitsManager *man)
577 // Add a digits manager for s-digits to the input list.
580 fSDigitsManagerList->Add(man);
584 //_____________________________________________________________________________
585 void AliTRDdigitizer::DeleteSDigitsManager()
588 // Removes digits manager from the input list.
591 fSDigitsManagerList->Delete();
595 //_____________________________________________________________________________
596 Bool_t AliTRDdigitizer::MakeDigits()
602 AliDebug(1,"Start creating digits");
605 AliError("No geometry defined");
609 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
611 AliFatal("Could not get calibration object");
615 const Int_t kNdet = AliTRDgeometry::Ndet();
617 Float_t **hits = new Float_t*[kNdet];
618 Int_t *nhit = new Int_t[kNdet];
620 AliTRDarraySignal *signals = 0x0;
623 if (calibration->GetNumberOfTimeBinsDCS() != AliTRDSimParam::Instance()->GetNTimeBins()) {
624 AliWarning(Form("Number of time bins is different to OCDB value [SIM=%d, OCDB=%d]"
625 ,AliTRDSimParam::Instance()->GetNTimeBins()
626 ,calibration->GetNumberOfTimeBinsDCS()));
629 // Sort all hits according to detector number
630 if (!SortHits(hits,nhit)) {
631 AliError("Sorting hits failed");
635 // Loop through all detectors
636 for (Int_t det = 0; det < kNdet; det++) {
638 // Detectors that are switched off, not installed, etc.
639 if (( calibration->IsChamberInstalled(det)) &&
640 (!calibration->IsChamberMasked(det)) &&
641 ( fGeo->ChamberInGeometry(det)) &&
644 signals = new AliTRDarraySignal();
646 // Convert the hits of the current detector to detector signals
647 if (!ConvertHits(det,hits[det],nhit[det],signals)) {
648 AliError(Form("Conversion of hits failed for detector=%d",det));
651 // Convert the detector signals to digits or s-digits
652 if (!ConvertSignals(det,signals)) {
653 AliError(Form("Conversion of signals failed for detector=%d",det));
657 // Delete the signals array
661 } // if: detector status
668 if (AliDataLoader *trklLoader = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")) {
669 if (trklLoader->Tree())
670 trklLoader->WriteData("OVERWRITE");
677 // Save the values for the raw data headers
678 fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
679 fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
685 //_____________________________________________________________________________
686 Bool_t AliTRDdigitizer::SortHits(Float_t **hits, Int_t *nhit)
689 // Read all the hits and sorts them according to detector number
690 // in the output array <hits>.
693 AliDebug(1,"Start sorting hits");
695 const Int_t kNdet = AliTRDgeometry::Ndet();
696 // Size of the hit vector
697 const Int_t kNhit = 6;
702 Int_t *lhit = new Int_t[kNdet];
704 for (Int_t det = 0; det < kNdet; det++) {
710 AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
711 if (!gimme->TreeH()) {
714 TTree *hitTree = gimme->TreeH();
715 if (hitTree == 0x0) {
716 AliError("Can not get TreeH");
719 fTRD->SetTreeAddress();
721 // Get the number of entries in the hit tree
722 // (Number of primary particles creating a hit somewhere)
723 Int_t nTrk = (Int_t) hitTree->GetEntries();
724 AliDebug(1,Form("Found %d tracks",nTrk));
726 // Loop through all the tracks in the tree
727 for (Int_t iTrk = 0; iTrk < nTrk; iTrk++) {
729 gAlice->GetMCApp()->ResetHits();
730 hitTree->GetEvent(iTrk);
733 AliError(Form("No hits array for track = %d",iTrk));
737 // Number of hits for this track
738 nhitTrk = fTRD->Hits()->GetEntriesFast();
741 // Loop through the TRD hits
742 AliTRDhit *hit = (AliTRDhit *) fTRD->FirstHit(-1);
747 // Don't analyze test hits
748 if (((Int_t) hit->GetCharge()) != 0) {
750 Int_t trk = hit->Track();
751 Int_t det = hit->GetDetector();
752 Int_t q = hit->GetCharge();
753 Float_t x = hit->X();
754 Float_t y = hit->Y();
755 Float_t z = hit->Z();
756 Float_t time = hit->GetTime();
758 if (nhit[det] == lhit[det]) {
759 // Inititialization of new detector
760 xyz = new Float_t[kNhit*(nhitTrk+lhit[det])];
762 memcpy(xyz,hits[det],sizeof(Float_t)*kNhit*lhit[det]);
765 lhit[det] += nhitTrk;
771 xyz[nhit[det]*kNhit+0] = x;
772 xyz[nhit[det]*kNhit+1] = y;
773 xyz[nhit[det]*kNhit+2] = z;
774 xyz[nhit[det]*kNhit+3] = q;
775 xyz[nhit[det]*kNhit+4] = trk;
776 xyz[nhit[det]*kNhit+5] = time;
781 hit = (AliTRDhit *) fTRD->NextHit();
783 } // for: hits of one track
793 //_____________________________________________________________________________
794 Bool_t AliTRDdigitizer::ConvertHits(Int_t det
795 , const Float_t * const hits
797 , AliTRDarraySignal *signals)
800 // Converts the detectorwise sorted hits to detector signals
803 AliDebug(1,Form("Start converting hits for detector=%d (nhits=%d)",det,nhit));
805 // Number of pads included in the pad response
806 const Int_t kNpad = 3;
807 // Number of track dictionary arrays
808 const Int_t kNdict = AliTRDdigitsManager::kNDict;
809 // Size of the hit vector
810 const Int_t kNhit = 6;
812 // Width of the amplification region
813 const Float_t kAmWidth = AliTRDgeometry::AmThick();
814 // Width of the drift region
815 const Float_t kDrWidth = AliTRDgeometry::DrThick();
816 // Drift + amplification region
817 const Float_t kDrMin = - 0.5 * kAmWidth;
818 const Float_t kDrMax = kDrWidth + 0.5 * kAmWidth;
822 Int_t timeBinTRFend = 1;
826 Double_t padSignal[kNpad];
827 Double_t signalOld[kNpad];
829 AliTRDarrayDictionary *dictionary[kNdict];
831 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
832 AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
833 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
836 AliFatal("Could not get common parameterss");
840 AliFatal("Could not get simulation parameters");
844 AliFatal("Could not get calibration object");
848 // Get the detector wise calibration objects
849 AliTRDCalROC *calVdriftROC = 0;
850 Float_t calVdriftDetValue = 0.0;
851 const AliTRDCalDet *calVdriftDet = calibration->GetVdriftDet();
852 AliTRDCalROC *calT0ROC = 0;
853 Float_t calT0DetValue = 0.0;
854 const AliTRDCalDet *calT0Det = calibration->GetT0Det();
856 if (simParam->TRFOn()) {
857 timeBinTRFend = ((Int_t) (simParam->GetTRFhi()
858 * commonParam->GetSamplingFrequency())) - 1;
861 Int_t nTimeTotal = simParam->GetNTimeBins();
862 Float_t samplingRate = commonParam->GetSamplingFrequency();
863 Float_t elAttachProp = simParam->GetElAttachProp() / 100.0;
865 AliTRDpadPlane *padPlane = fGeo->GetPadPlane(det);
866 Int_t layer = fGeo->GetLayer(det); //update
867 Float_t row0 = padPlane->GetRow0ROC();
868 Int_t nRowMax = padPlane->GetNrows();
869 Int_t nColMax = padPlane->GetNcols();
871 // Create a new array for the signals
872 signals->Allocate(nRowMax,nColMax,nTimeTotal);
874 // Create a new array for the dictionary
875 for (dict = 0; dict < kNdict; dict++) {
876 dictionary[dict] = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
877 dictionary[dict]->Allocate(nRowMax,nColMax,nTimeTotal);
880 // Loop through the hits in this detector
881 for (Int_t hit = 0; hit < nhit; hit++) {
883 pos[0] = hits[hit*kNhit+0];
884 pos[1] = hits[hit*kNhit+1];
885 pos[2] = hits[hit*kNhit+2];
886 Float_t q = hits[hit*kNhit+3];
887 Float_t hittime = hits[hit*kNhit+5];
888 Int_t track = ((Int_t) hits[hit*kNhit+4]);
892 // Find the current volume with the geo manager
893 gGeoManager->SetCurrentPoint(pos);
894 gGeoManager->FindNode();
895 if (strstr(gGeoManager->GetPath(),"/UK")) {
899 // Get the calibration objects
900 calVdriftROC = calibration->GetVdriftROC(det);
901 calVdriftDetValue = calVdriftDet->GetValue(det);
902 calT0ROC = calibration->GetT0ROC(det);
903 calT0DetValue = calT0Det->GetValue(det);
905 // Go to the local coordinate system:
906 // loc[0] - col direction in amplification or driftvolume
907 // loc[1] - row direction in amplification or driftvolume
908 // loc[2] - time direction in amplification or driftvolume
909 gGeoManager->MasterToLocal(pos,loc);
911 // Relative to middle of amplification region
912 loc[2] = loc[2] - kDrWidth/2.0 - kAmWidth/2.0;
915 // The driftlength [cm] (w/o diffusion yet !).
916 // It is negative if the hit is between pad plane and anode wires.
917 Double_t driftlength = -1.0 * loc[2];
919 // Stupid patch to take care of TR photons that are absorbed
920 // outside the chamber volume. A real fix would actually need
921 // a more clever implementation of the TR hit generation
923 if ((loc[1] < padPlane->GetRowEndROC()) ||
924 (loc[1] > padPlane->GetRow0ROC())) {
927 if ((driftlength < kDrMin) ||
928 (driftlength > kDrMax)) {
933 // Get row and col of unsmeared electron to retrieve drift velocity
934 // The pad row (z-direction)
935 Int_t rowE = padPlane->GetPadRowNumberROC(loc[1]);
939 Double_t rowOffset = padPlane->GetPadRowOffsetROC(rowE,loc[1]);
940 // The pad column (rphi-direction)
941 Double_t offsetTilt = padPlane->GetTiltOffset(rowOffset);
942 Int_t colE = padPlane->GetPadColNumber(loc[0]+offsetTilt);
946 Double_t colOffset = 0.0;
948 // Normalized drift length
949 Float_t driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
950 Double_t absdriftlength = TMath::Abs(driftlength);
951 if (commonParam->ExBOn()) {
952 absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity));
955 // Loop over all electrons of this hit
956 // TR photons produce hits with negative charge
957 Int_t nEl = ((Int_t) TMath::Abs(q));
958 for (Int_t iEl = 0; iEl < nEl; iEl++) {
960 // Now the real local coordinate system of the ROC
961 // column direction: locC
962 // row direction: locR
963 // time direction: locT
964 // locR and locC are identical to the coordinates of the corresponding
965 // volumina of the drift or amplification region.
966 // locT is defined relative to the wire plane (i.e. middle of amplification
967 // region), meaning locT = 0, and is negative for hits coming from the
969 Double_t locC = loc[0];
970 Double_t locR = loc[1];
971 Double_t locT = loc[2];
973 // Electron attachment
974 if (simParam->ElAttachOn()) {
975 if (gRandom->Rndm() < (absdriftlength * elAttachProp)) {
980 // Apply the diffusion smearing
981 if (simParam->DiffusionOn()) {
982 if (!(Diffusion(driftvelocity,absdriftlength,locR,locC,locT))) {
987 // Apply E x B effects (depends on drift direction)
988 if (commonParam->ExBOn()) {
989 if (!(ExB(driftvelocity,driftlength,locC))) {
994 // The electron position after diffusion and ExB in pad coordinates.
995 // The pad row (z-direction)
996 rowE = padPlane->GetPadRowNumberROC(locR);
997 if (rowE < 0) continue;
998 rowOffset = padPlane->GetPadRowOffsetROC(rowE,locR);
1000 // The pad column (rphi-direction)
1001 offsetTilt = padPlane->GetTiltOffset(rowOffset);
1002 colE = padPlane->GetPadColNumber(locC+offsetTilt);
1003 if (colE < 0) continue;
1004 colOffset = padPlane->GetPadColOffset(colE,locC+offsetTilt);
1006 // Also re-retrieve drift velocity because col and row may have changed
1007 driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
1008 Float_t t0 = calT0DetValue + calT0ROC->GetValue(colE,rowE);
1010 // Convert the position to drift time [mus], using either constant drift velocity or
1011 // time structure of drift cells (non-isochronity, GARFIELD calculation).
1012 // Also add absolute time of hits to take pile-up events into account properly
1014 if (simParam->TimeStructOn()) {
1015 // Get z-position with respect to anode wire
1016 Double_t zz = row0 - locR + padPlane->GetAnodeWireOffset();
1017 zz -= ((Int_t)(2 * zz)) / 2.0;
1021 // Use drift time map (GARFIELD)
1022 drifttime = commonParam->TimeStruct(driftvelocity,0.5*kAmWidth-1.0*locT,zz)
1026 // Use constant drift velocity
1027 drifttime = TMath::Abs(locT) / driftvelocity
1031 // Apply the gas gain including fluctuations
1032 Double_t ggRndm = 0.0;
1034 ggRndm = gRandom->Rndm();
1035 } while (ggRndm <= 0);
1036 Double_t signal = -(simParam->GetGasGain()) * TMath::Log(ggRndm);
1038 // Apply the pad response
1039 if (simParam->PRFOn()) {
1040 // The distance of the electron to the center of the pad
1041 // in units of pad width
1042 Double_t dist = (colOffset - 0.5*padPlane->GetColSize(colE))
1043 / padPlane->GetColSize(colE);
1044 // This is a fixed parametrization, i.e. not dependent on
1045 // calibration values !
1046 if (!(calibration->PadResponse(signal,dist,layer,padSignal))) continue;
1050 padSignal[1] = signal;
1054 // The time bin (always positive), with t0 distortion
1055 Double_t timeBinIdeal = drifttime * samplingRate + t0;
1057 if (TMath::Abs(timeBinIdeal) > 2*nTimeTotal) {
1058 timeBinIdeal = 2 * nTimeTotal;
1060 Int_t timeBinTruncated = ((Int_t) timeBinIdeal);
1061 // The distance of the position to the middle of the timebin
1062 Double_t timeOffset = ((Float_t) timeBinTruncated
1063 + 0.5 - timeBinIdeal) / samplingRate;
1065 // Sample the time response inside the drift region
1066 // + additional time bins before and after.
1067 // The sampling is done always in the middle of the time bin
1068 for (Int_t iTimeBin = TMath::Max(timeBinTruncated,0)
1069 ;iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal)
1072 // Apply the time response
1073 Double_t timeResponse = 1.0;
1074 Double_t crossTalk = 0.0;
1075 Double_t time = (iTimeBin - timeBinTruncated) / samplingRate + timeOffset;
1077 if (simParam->TRFOn()) {
1078 timeResponse = simParam->TimeResponse(time);
1080 if (simParam->CTOn()) {
1081 crossTalk = simParam->CrossTalk(time);
1088 for (iPad = 0; iPad < kNpad; iPad++) {
1090 Int_t colPos = colE + iPad - 1;
1091 if (colPos < 0) continue;
1092 if (colPos >= nColMax) break;
1095 signalOld[iPad] = signals->GetData(rowE,colPos,iTimeBin);
1097 if (colPos != colE) {
1098 // Cross talk added to non-central pads
1099 signalOld[iPad] += padSignal[iPad]
1100 * (timeResponse + crossTalk);
1103 // W/o cross talk at central pad
1104 signalOld[iPad] += padSignal[iPad]
1108 signals->SetData(rowE,colPos,iTimeBin,signalOld[iPad]);
1110 // Store the track index in the dictionary
1111 // Note: We store index+1 in order to allow the array to be compressed
1112 // Note2: Taking out the +1 in track
1113 if (signalOld[iPad] > 0.0) {
1114 for (dict = 0; dict < kNdict; dict++) {
1115 Int_t oldTrack = dictionary[dict]->GetData(rowE,colPos,iTimeBin);
1116 if (oldTrack == track) break;
1117 if (oldTrack == -1 ) {
1118 dictionary[dict]->SetData(rowE,colPos,iTimeBin,track);
1126 } // Loop: time bins
1128 } // Loop: electrons of a single hit
1132 AliDebug(2,Form("Finished analyzing %d hits",nhit));
1138 //_____________________________________________________________________________
1139 Bool_t AliTRDdigitizer::ConvertSignals(Int_t det, AliTRDarraySignal *signals)
1142 // Convert signals to digits
1145 AliDebug(1,Form("Start converting the signals for detector %d",det));
1148 // Convert the signal array to s-digits
1149 if (!Signal2SDigits(det,signals)) {
1154 // Convert the signal array to digits
1155 if (!Signal2ADC(det,signals)) {
1158 // Run digital processing for digits
1159 RunDigitalProcessing(det);
1162 // Compress the arrays
1163 CompressOutputArrays(det);
1169 //_____________________________________________________________________________
1170 Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
1173 // Converts the sampled electron signals to ADC values for a given chamber
1176 AliDebug(1,Form("Start converting signals to ADC values for detector=%d",det));
1178 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1180 AliFatal("Could not get calibration object");
1184 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1186 AliFatal("Could not get simulation parameters");
1190 // Converts number of electrons to fC
1191 const Double_t kEl2fC = 1.602e-19 * 1.0e15;
1194 Double_t coupling = simParam->GetPadCoupling()
1195 * simParam->GetTimeCoupling();
1196 // Electronics conversion factor
1197 Double_t convert = kEl2fC
1198 * simParam->GetChipGain();
1199 // ADC conversion factor
1200 Double_t adcConvert = simParam->GetADCoutRange()
1201 / simParam->GetADCinRange();
1202 // The electronics baseline in mV
1203 Double_t baseline = simParam->GetADCbaseline()
1205 // The electronics baseline in electrons
1206 Double_t baselineEl = baseline
1213 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1214 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1215 Int_t nTimeTotal = simParam->GetNTimeBins();
1217 // The gainfactor calibration objects
1218 const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
1219 AliTRDCalROC *calGainFactorROC = 0;
1220 Float_t calGainFactorDetValue = 0.0;
1222 AliTRDarrayADC *digits = 0x0;
1225 AliError(Form("Signals array for detector %d does not exist\n",det));
1228 if (signals->HasData()) {
1229 // Expand the container if neccessary
1233 // Create missing containers
1234 signals->Allocate(nRowMax,nColMax,nTimeTotal);
1237 // Get the container for the digits of this detector
1238 if (fDigitsManager->HasSDigits()) {
1239 AliError("Digits manager has s-digits");
1243 digits = (AliTRDarrayADC *) fDigitsManager->GetDigits(det);
1244 // Allocate memory space for the digits buffer
1245 if (!digits->HasData()) {
1246 digits->Allocate(nRowMax,nColMax,nTimeTotal);
1249 // Get the calibration objects
1250 calGainFactorROC = calibration->GetGainFactorROC(det);
1251 calGainFactorDetValue = calGainFactorDet->GetValue(det);
1253 // Create the digits for this chamber
1254 for (row = 0; row < nRowMax; row++ ) {
1255 for (col = 0; col < nColMax; col++ ) {
1257 // Check whether pad is masked
1258 // Bridged pads are not considered yet!!!
1259 if (calibration->IsPadMasked(det,col,row) || calibration->IsPadNotConnected(det,col,row)) {
1264 Float_t padgain = calGainFactorDetValue
1265 * calGainFactorROC->GetValue(col,row);
1267 AliError(Form("Not a valid gain %f, %d %d %d",padgain,det,col,row));
1270 for (time = 0; time < nTimeTotal; time++) {
1272 // Get the signal amplitude
1273 Float_t signalAmp = signals->GetData(row,col,time);
1274 // Pad and time coupling
1275 signalAmp *= coupling;
1277 signalAmp *= padgain;
1279 // Add the noise, starting from minus ADC baseline in electrons
1280 signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,simParam->GetNoise())
1284 signalAmp *= convert;
1285 // Add ADC baseline in mV
1286 signalAmp += baseline;
1288 // Convert to ADC counts. Set the overflow-bit fADCoutRange if the
1289 // signal is larger than fADCinRange
1291 if (signalAmp >= simParam->GetADCinRange()) {
1292 adc = ((Short_t) simParam->GetADCoutRange());
1295 adc = TMath::Nint(signalAmp * adcConvert);
1298 // Saving all digits
1299 digits->SetData(row,col,time,adc);
1310 //_____________________________________________________________________________
1311 Bool_t AliTRDdigitizer::Signal2SDigits(Int_t det, AliTRDarraySignal *signals)
1314 // Converts the sampled electron signals to s-digits
1317 AliDebug(1,Form("Start converting signals to s-digits for detector=%d",det));
1319 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1321 AliFatal("Could not get calibration object");
1329 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1330 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1331 Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
1333 // Get the container for the digits of this detector
1335 if (!fDigitsManager->HasSDigits()) {
1336 AliError("Digits manager has no s-digits");
1340 AliTRDarraySignal *digits = (AliTRDarraySignal *) fDigitsManager->GetSDigits(det);
1341 // Allocate memory space for the digits buffer
1342 if (!digits->HasData()) {
1343 digits->Allocate(nRowMax,nColMax,nTimeTotal);
1346 // Create the sdigits for this chamber
1347 for (row = 0; row < nRowMax; row++ ) {
1348 for (col = 0; col < nColMax; col++ ) {
1349 for (time = 0; time < nTimeTotal; time++) {
1350 digits->SetData(row,col,time,signals->GetData(row,col,time));
1359 //_____________________________________________________________________________
1360 Bool_t AliTRDdigitizer::Digits2SDigits(AliTRDdigitsManager * const manDig
1361 , AliTRDdigitsManager * const manSDig)
1364 // Converts digits into s-digits. Needed for embedding into real data.
1367 AliDebug(1,"Start converting digits to s-digits");
1370 fGeo = new AliTRDgeometry();
1373 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1375 AliFatal("Could not get calibration object");
1379 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1381 AliFatal("Could not get simulation parameters");
1385 // Converts number of electrons to fC
1386 const Double_t kEl2fC = 1.602e-19 * 1.0e15;
1389 Double_t coupling = simParam->GetPadCoupling()
1390 * simParam->GetTimeCoupling();
1391 // Electronics conversion factor
1392 Double_t convert = kEl2fC
1393 * simParam->GetChipGain();
1394 // ADC conversion factor
1395 Double_t adcConvert = simParam->GetADCoutRange()
1396 / simParam->GetADCinRange();
1397 // The electronics baseline in mV
1398 Double_t baseline = simParam->GetADCbaseline()
1400 // The electronics baseline in electrons
1401 //Double_t baselineEl = baseline
1404 // The gainfactor calibration objects
1405 //const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
1406 //AliTRDCalROC *calGainFactorROC = 0;
1407 //Float_t calGainFactorDetValue = 0.0;
1413 for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
1415 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1416 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1417 Int_t nTimeTotal = manDig->GetDigitsParam()->GetNTimeBins(det);
1419 // Get the calibration objects
1420 //calGainFactorROC = calibration->GetGainFactorROC(det);
1421 //calGainFactorDetValue = calGainFactorDet->GetValue(det);
1424 AliTRDarrayADC *digits = (AliTRDarrayADC *) manDig->GetDigits(det);
1426 if (!manSDig->HasSDigits()) {
1427 AliError("SDigits manager has no s-digits");
1431 AliTRDarraySignal *sdigits = (AliTRDarraySignal *) manSDig->GetSDigits(det);
1432 AliTRDarrayDictionary *tracks0 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,0);
1433 AliTRDarrayDictionary *tracks1 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,1);
1434 AliTRDarrayDictionary *tracks2 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,2);
1435 // Allocate memory space for the digits buffer
1436 sdigits->Allocate(nRowMax,nColMax,nTimeTotal);
1437 tracks0->Allocate(nRowMax,nColMax,nTimeTotal);
1438 tracks1->Allocate(nRowMax,nColMax,nTimeTotal);
1439 tracks2->Allocate(nRowMax,nColMax,nTimeTotal);
1441 // Keep the digits param
1442 manSDig->GetDigitsParam()->SetNTimeBinsAll(manDig->GetDigitsParam()->GetNTimeBins(0));
1443 manSDig->GetDigitsParam()->SetADCbaselineAll(manDig->GetDigitsParam()->GetADCbaseline(0));
1445 if (digits->HasData()) {
1449 // Create the sdigits for this chamber
1450 for (row = 0; row < nRowMax; row++ ) {
1451 for (col = 0; col < nColMax; col++ ) {
1454 //Float_t padgain = calGainFactorDetValue
1455 // * calGainFactorROC->GetValue(col,row);
1457 for (time = 0; time < nTimeTotal; time++) {
1459 Short_t adcVal = digits->GetData(row,col,time);
1460 Double_t signal = (Double_t) adcVal;
1461 // ADC -> signal in mV
1462 signal /= adcConvert;
1463 // Subtract baseline in mV
1465 // Signal in mV -> signal in #electrons
1468 //signal /= padgain; // Not needed for real data
1469 // Pad and time coupling
1472 sdigits->SetData(row,col,time,signal);
1473 tracks0->SetData(row,col,time,0);
1474 tracks1->SetData(row,col,time,0);
1475 tracks2->SetData(row,col,time,0);
1484 sdigits->Compress(0);
1485 tracks0->Compress();
1486 tracks1->Compress();
1487 tracks2->Compress();
1489 // No compress just remove
1490 manDig->RemoveDigits(det);
1491 manDig->RemoveDictionaries(det);
1499 //_____________________________________________________________________________
1500 Bool_t AliTRDdigitizer::SDigits2Digits()
1503 // Merges the input s-digits and converts them to normal digits
1506 if (!MergeSDigits()) {
1510 return ConvertSDigits();
1514 //_____________________________________________________________________________
1515 Bool_t AliTRDdigitizer::MergeSDigits()
1518 // Merges the input s-digits:
1519 // - The amplitude of the different inputs are summed up.
1520 // - Of the track IDs from the input dictionaries only one is
1521 // kept for each input. This works for maximal 3 different merged inputs.
1524 // Number of track dictionary arrays
1525 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1527 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1529 AliFatal("Could not get simulation parameters");
1533 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1535 AliFatal("Could not get calibration object");
1542 AliTRDarraySignal *digitsA;
1543 AliTRDarraySignal *digitsB;
1544 AliTRDarrayDictionary *dictionaryA[kNDict];
1545 AliTRDarrayDictionary *dictionaryB[kNDict];
1547 AliTRDdigitsManager *mergeSDigitsManager = 0x0;
1548 // Get the first s-digits
1549 fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First();
1550 if (!fSDigitsManager) {
1551 AliError("No SDigits manager");
1555 // Loop through the other sets of s-digits
1556 mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(fSDigitsManager);
1558 if (mergeSDigitsManager) {
1559 AliDebug(1,Form("Merge %d input files.",fSDigitsManagerList->GetSize()));
1562 AliDebug(1,"Only one input file.");
1567 while (mergeSDigitsManager) {
1571 // Loop through the detectors
1572 for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
1574 Int_t nTimeTotal = fSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet);
1575 if (mergeSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet) != nTimeTotal) {
1576 AliError(Form("Mismatch in the number of time bins [%d,%d] in detector %d"
1578 ,mergeSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet)
1583 Int_t nRowMax = fGeo->GetPadPlane(iDet)->GetNrows();
1584 Int_t nColMax = fGeo->GetPadPlane(iDet)->GetNcols();
1586 // Loop through the pixels of one detector and add the signals
1587 digitsA = (AliTRDarraySignal *) fSDigitsManager->GetSDigits(iDet);
1588 digitsB = (AliTRDarraySignal *) mergeSDigitsManager->GetSDigits(iDet);
1590 if (!digitsA->HasData()) continue;
1592 if (!digitsB->HasData()) continue;
1594 for (iDict = 0; iDict < kNDict; iDict++) {
1595 dictionaryA[iDict] = (AliTRDarrayDictionary *) fSDigitsManager->GetDictionary(iDet,iDict);
1596 dictionaryB[iDict] = (AliTRDarrayDictionary *) mergeSDigitsManager->GetDictionary(iDet,iDict);
1597 dictionaryA[iDict]->Expand();
1598 dictionaryB[iDict]->Expand();
1601 // Merge only detectors that contain a signal
1602 Bool_t doMerge = kTRUE;
1603 if (fMergeSignalOnly) {
1604 if (digitsA->GetOverThreshold(0) == 0) {
1611 AliDebug(1,Form("Merge detector %d of input no.%d",iDet,iMerge+1));
1613 for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) {
1614 for (Int_t iCol = 0; iCol < nColMax; iCol++ ) {
1615 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
1617 // Add the amplitudes of the summable digits
1618 Float_t ampA = digitsA->GetData(iRow,iCol,iTime);
1619 Float_t ampB = digitsB->GetData(iRow,iCol,iTime);
1621 digitsA->SetData(iRow,iCol,iTime,ampA);
1623 // Add the mask to the track id if defined.
1624 for (iDict = 0; iDict < kNDict; iDict++) {
1625 Int_t trackB = dictionaryB[iDict]->GetData(iRow,iCol,iTime);
1626 if ((fMasks) && (trackB > 0)) {
1627 for (jDict = 0; jDict < kNDict; jDict++) {
1628 Int_t trackA = dictionaryA[iDict]->GetData(iRow,iCol,iTime);
1630 trackA = trackB + fMasks[iMerge];
1631 dictionaryA[iDict]->SetData(iRow,iCol,iTime,trackA);
1632 } // if: track A == 0
1634 } // if: fMasks and trackB > 0
1643 mergeSDigitsManager->RemoveDigits(iDet);
1644 mergeSDigitsManager->RemoveDictionaries(iDet);
1647 digitsA->Compress(0);
1648 for (iDict = 0; iDict < kNDict; iDict++) {
1649 dictionaryA[iDict]->Compress();
1655 // The next set of s-digits
1656 mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(mergeSDigitsManager);
1658 } // while: mergeDigitsManagers
1664 //_____________________________________________________________________________
1665 Bool_t AliTRDdigitizer::ConvertSDigits()
1668 // Converts s-digits to normal digits
1671 AliTRDarraySignal *digitsIn = 0x0;
1673 if (!fSDigitsManager->HasSDigits()) {
1674 AliError("No s-digits in digits manager");
1678 // Loop through the detectors
1679 for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
1681 // Get the merged s-digits (signals)
1682 digitsIn = (AliTRDarraySignal *) fSDigitsManager->GetSDigits(det);
1683 if (!digitsIn->HasData()) {
1684 AliDebug(2,Form("No digits for det=%d",det));
1688 // Convert the merged sdigits to digits
1689 if (!Signal2ADC(det,digitsIn)) {
1693 // Copy the dictionary information to the output array
1694 if (!CopyDictionary(det)) {
1699 fSDigitsManager->RemoveDigits(det);
1700 fSDigitsManager->RemoveDictionaries(det);
1702 // Run digital processing
1703 RunDigitalProcessing(det);
1705 // Compress the arrays
1706 CompressOutputArrays(det);
1708 } // for: detector numbers
1710 if (AliDataLoader *trklLoader = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")) {
1711 if (trklLoader->Tree())
1712 trklLoader->WriteData("OVERWRITE");
1715 // Save the values for the raw data headers
1716 fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
1717 fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
1723 //_____________________________________________________________________________
1724 Bool_t AliTRDdigitizer::CopyDictionary(Int_t det)
1727 // Copies the dictionary information from the s-digits arrays
1728 // to the output arrays
1731 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1733 AliFatal("Could not get calibration object");
1737 AliDebug(1,Form("Start copying dictionaries for detector=%d",det));
1739 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1740 AliTRDarrayDictionary *dictionaryIn[kNDict];
1741 AliTRDarrayDictionary *dictionaryOut[kNDict];
1743 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1744 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1745 Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
1752 for (dict = 0; dict < kNDict; dict++) {
1754 dictionaryIn[dict] = (AliTRDarrayDictionary *) fSDigitsManager->GetDictionary(det,dict);
1755 dictionaryIn[dict]->Expand();
1756 dictionaryOut[dict] = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
1757 dictionaryOut[dict]->Allocate(nRowMax,nColMax,nTimeTotal);
1759 for (row = 0; row < nRowMax; row++) {
1760 for (col = 0; col < nColMax; col++) {
1761 for (time = 0; time < nTimeTotal; time++) {
1762 Int_t track = dictionaryIn[dict]->GetData(row,col,time);
1763 dictionaryOut[dict]->SetData(row,col,time,track);
1768 } // for: dictionaries
1774 //_____________________________________________________________________________
1775 void AliTRDdigitizer::CompressOutputArrays(Int_t det)
1778 // Compress the output arrays
1781 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1782 AliTRDarrayDictionary *dictionary = 0x0;
1787 AliTRDarrayADC *digits = 0x0;
1788 digits = (AliTRDarrayADC *) fDigitsManager->GetDigits(det);
1793 AliTRDarraySignal *digits = 0x0;
1794 digits = (AliTRDarraySignal *) fDigitsManager->GetSDigits(det);
1795 digits->Compress(0);
1798 for (Int_t dict = 0; dict < kNDict; dict++) {
1799 dictionary = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
1800 dictionary->Compress();
1807 //_____________________________________________________________________________
1808 Bool_t AliTRDdigitizer::WriteDigits() const
1811 // Writes out the TRD-digits and the dictionaries
1815 fRunLoader->CdGAFile();
1817 // Store the digits and the dictionary in the tree
1818 return fDigitsManager->WriteDigits();
1822 //_____________________________________________________________________________
1823 void AliTRDdigitizer::InitOutput(Int_t iEvent)
1826 // Initializes the output branches
1832 AliError("Run Loader is NULL");
1836 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
1838 AliError("Can not get TRD loader from Run Loader");
1845 // If we produce SDigits
1846 tree = loader->TreeS();
1848 loader->MakeTree("S");
1849 tree = loader->TreeS();
1853 // If we produce Digits
1854 tree = loader->TreeD();
1856 loader->MakeTree("D");
1857 tree = loader->TreeD();
1860 fDigitsManager->SetEvent(iEvent);
1861 fDigitsManager->MakeBranch(tree);
1865 //_____________________________________________________________________________
1866 Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
1867 , Double_t &lRow, Double_t &lCol, Double_t &lTime)
1870 // Applies the diffusion smearing to the position of a single electron.
1871 // Depends on absolute drift length.
1874 Float_t diffL = 0.0;
1875 Float_t diffT = 0.0;
1877 if (AliTRDCommonParam::Instance()->GetDiffCoeff(diffL,diffT,vdrift)) {
1879 Float_t driftSqrt = TMath::Sqrt(absdriftlength);
1880 Float_t sigmaT = driftSqrt * diffT;
1881 Float_t sigmaL = driftSqrt * diffL;
1882 lRow = gRandom->Gaus(lRow ,sigmaT);
1883 lCol = gRandom->Gaus(lCol ,sigmaT * GetLorentzFactor(vdrift));
1884 lTime = gRandom->Gaus(lTime,sigmaL * GetLorentzFactor(vdrift));
1897 //_____________________________________________________________________________
1898 Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd)
1901 // Returns the Lorentz factor
1904 Double_t omegaTau = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
1905 Double_t lorentzFactor = 1.0;
1906 if (AliTRDCommonParam::Instance()->ExBOn()) {
1907 lorentzFactor = 1.0 / (1.0 + omegaTau*omegaTau);
1910 return lorentzFactor;
1914 //_____________________________________________________________________________
1915 Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t &lCol)
1918 // Applies E x B effects to the position of a single electron.
1919 // Depends on signed drift length.
1923 + AliTRDCommonParam::Instance()->GetOmegaTau(vdrift)
1930 //_____________________________________________________________________________
1931 void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
1934 // Run the digital processing in the TRAP
1937 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
1939 AliTRDarrayADC *digits = fDigitsManager->GetDigits(det);
1943 //Call the methods in the mcm class using the temporary array as input
1944 for(Int_t rob = 0; rob < digits->GetNrow() / 2; rob++)
1946 for(Int_t mcm = 0; mcm < 16; mcm++)
1948 fMcmSim->Init(det, rob, mcm);
1949 fMcmSim->SetDataByPad(digits, fDigitsManager);
1951 if (feeParam->GetTracklet()) {
1952 fMcmSim->Tracklet();
1953 fMcmSim->StoreTracklets();
1955 fMcmSim->ZSMapping();
1956 fMcmSim->WriteData(digits);