2 // Do the Digitization (Digit) from summable Digits (SDigit)
3 // Allow the merging of signal file with background file(s).
6 #include <TDirectory.h>
14 #include "AliMUONChamber.h"
15 #include "AliMUONConstants.h"
16 #include "AliMUONDigit.h"
17 #include "AliMUONDigitizerv2.h"
18 #include "AliMUONHit.h"
19 #include "AliMUONHitMapA1.h"
20 #include "AliMUONPadHit.h"
21 #include "AliMUONTransientDigit.h"
23 #include "AliRunDigitizer.h"
24 #include "AliRunLoader.h"
25 #include "AliLoader.h"
27 /////////////////////////////////////////////////////////////////////////////////
29 // AliMUONDigitizerv2 digitizes digits from s-digits.
30 // Merging is allowed from multiple input streams. The first input stream is
31 // assumed to be the signal and all other input streams as assumed to be
33 // Chamber response is applied to the digits identically to AliMUONDigitizerv1.
35 /////////////////////////////////////////////////////////////////////////////////
37 ClassImp(AliMUONDigitizerv2)
39 //___________________________________________
40 AliMUONDigitizerv2::AliMUONDigitizerv2() : AliMUONDigitizerv1()
42 // Default ctor - don't use it
45 //___________________________________________
46 AliMUONDigitizerv2::AliMUONDigitizerv2(AliRunDigitizer* manager) : AliMUONDigitizerv1(manager)
48 // ctor which should be used
51 //-----------------------------------------------------------------------
52 void AliMUONDigitizerv2::GenerateTransientDigits()
54 // Loop over all chambers and s-digits in the input stream and create
55 // AliMUONTransientDigit objects from them. These are then added to fTDList.
58 Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X");
64 TClonesArray* muonSDigits;
65 for (Int_t ich = 0; ich < AliMUONConstants::NCh(); ich++) // loop over chamber
67 muondata->ResetSDigits();
68 muondata->GetCathodeS(0);
69 muonSDigits = muondata->SDigits(ich);
70 ndig = muonSDigits->GetEntriesFast();
71 for (k = 0; k < ndig; k++)
73 sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
74 MakeTransientDigitFromSDigit(ich,sDigit);
76 muondata->ResetSDigits();
77 muondata->GetCathodeS(1);
78 muonSDigits = muondata->SDigits(ich);
79 ndig=muonSDigits->GetEntriesFast();
80 for (k = 0; k < ndig; k++)
82 sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
83 MakeTransientDigitFromSDigit(ich,sDigit);
85 } // SDigits loop, end loop over chamber
88 //------------------------------------------------------------------------
89 void AliMUONDigitizerv2::MakeTransientDigitFromSDigit(Int_t iChamber, AliMUONDigit* sDigit)
91 // Makes a transient digit from the specified s-digit from the specified chamber.
92 // Once the digit is created it is added to the fTDList.
95 Info("MakeTransientDigitFromSDigit",
96 "Making transient digit from s-digit for chamber %d.", iChamber);
100 // Creating a new TransientDigits from SDigit
101 digits[0] = sDigit->PadX(); // Padx of the Digit
102 digits[1] = sDigit->PadY(); // Pady of the Digit
103 digits[2] = sDigit->Cathode()+1; // Cathode plane
104 digits[3] = sDigit->Signal(); // Induced charge in the Pad
106 digits[4] = sDigit->Signal();
110 digits[5] = sDigit->Hit(); // Hit number in the list
113 Info("MakeTransientDigitFromSDigit",
114 "Made digit from sDigit 0x%X: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d",
115 (void*)sDigit, digits[0], digits[1], digits[2], digits[3], digits[5]);
117 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(iChamber, digits);
118 // Copy list of tracks and trackcharge
119 for(Int_t itrack = 0; itrack < kMAXTRACKS; itrack++)
121 Int_t track = sDigit->Track(itrack);
122 if (track < 0) break; // Check if we reached the end of the track list.
123 mTD->AddToTrackList( track + fMask, sDigit->TrackCharge(itrack) );
126 OnCreateTransientDigit(mTD, sDigit);
127 AddOrUpdateTransientDigit(mTD);
130 //------------------------------------------------------------------------
131 void AliMUONDigitizerv2::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
133 // Override to add new digits to the digits tree TreeD.
134 muondata->AddDigit(chamber, tracks, charges, digits);
137 //------------------------------------------------------------------------
138 Bool_t AliMUONDigitizerv2::InitInputData(AliMUONLoader* muonloader)
140 // Overridden to initialize muondata to read from the s-digits tree TreeS.
141 // If the s-digits are not loaded then the muon loader is used to load the
142 // s-digits into memory.
145 Info("InitInputData", "Loading s-digits in READ mode and setting the tree address.");
147 muondata->SetLoader(muonloader);
149 if (muonloader->TreeS() == NULL)
151 muonloader->LoadSDigits("READ");
152 if (muonloader->TreeS() == NULL)
154 Error("InitInputData", "Can not load the s-digits tree.");
159 muondata->SetTreeAddress("S");
163 //------------------------------------------------------------------------
164 void AliMUONDigitizerv2::CleanupInputData(AliMUONLoader* muonloader)
166 // Overridden to release and unload s-digits from memory.
168 if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded s-digits.");
169 muondata->ResetSDigits();
170 muonloader->UnloadSDigits();