]>
Commit | Line | Data |
---|---|---|
30178c30 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
d1775029 | 17 | |
18 | // Do the Digitization (Digit) from summable Digits (SDigit) | |
19 | // Allow the merging of signal file with background file(s). | |
20 | ||
cf286af7 | 21 | ///////////////////////////////////////////////////////////////////////////////// |
22 | // | |
23 | // AliMUONDigitizerv2 digitizes digits from s-digits. | |
24 | // Merging is allowed from multiple input streams. The first input stream is | |
25 | // assumed to be the signal and all other input streams as assumed to be | |
26 | // background. | |
27 | // Chamber response is applied to the digits identically to AliMUONDigitizerv1. | |
28 | // | |
29 | ///////////////////////////////////////////////////////////////////////////////// | |
30 | ||
38169520 | 31 | #include "AliMUON.h" |
30178c30 | 32 | #include "AliMUONData.h" |
33 | #include "AliMUONLoader.h" | |
34 | #include "AliMUONConstants.h" | |
38169520 | 35 | #include "AliMUONChamber.h" |
30178c30 | 36 | #include "AliMUONDigit.h" |
37 | #include "AliMUONDigitizerv2.h" | |
38 | #include "AliMUONTransientDigit.h" | |
38169520 | 39 | #include "AliMUONTriggerDecision.h" |
8c343c7c | 40 | #include "AliLog.h" |
30178c30 | 41 | |
d1775029 | 42 | ClassImp(AliMUONDigitizerv2) |
43 | ||
44 | //___________________________________________ | |
38169520 | 45 | AliMUONDigitizerv2::AliMUONDigitizerv2() : AliMUONDigitizer() |
d1775029 | 46 | { |
d19b6003 | 47 | /// Default ctor - don't use it |
d1775029 | 48 | } |
49 | ||
50 | //___________________________________________ | |
38169520 | 51 | AliMUONDigitizerv2::AliMUONDigitizerv2(AliRunDigitizer* manager) : AliMUONDigitizer(manager) |
d1775029 | 52 | { |
d19b6003 | 53 | /// ctor which should be used |
d1775029 | 54 | } |
55 | ||
8789635b | 56 | //___________________________________________ |
57 | AliMUONDigitizerv2::~AliMUONDigitizerv2() | |
58 | { | |
d19b6003 | 59 | /// Destructor |
8789635b | 60 | } |
61 | ||
cf286af7 | 62 | //----------------------------------------------------------------------- |
63 | void AliMUONDigitizerv2::GenerateTransientDigits() | |
d1775029 | 64 | { |
d19b6003 | 65 | /// Loop over all chambers and s-digits in the input stream and create |
66 | /// AliMUONTransientDigit objects from them. These are then added to fTDList. | |
d1775029 | 67 | |
8c343c7c | 68 | AliDebug(2,"Generating transient digits using treeH = 0x%X"); |
cf286af7 | 69 | // |
70 | // Loop over SDigits | |
71 | Int_t ndig, k; | |
72 | AliMUONDigit* sDigit; | |
73 | TClonesArray* muonSDigits; | |
74 | for (Int_t ich = 0; ich < AliMUONConstants::NCh(); ich++) // loop over chamber | |
75 | { | |
30178c30 | 76 | fMUONData->ResetSDigits(); |
935b9895 | 77 | fMUONData->GetSDigits(); |
30178c30 | 78 | muonSDigits = fMUONData->SDigits(ich); |
cf286af7 | 79 | ndig = muonSDigits->GetEntriesFast(); |
80 | for (k = 0; k < ndig; k++) | |
81 | { | |
82 | sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k); | |
83 | MakeTransientDigitFromSDigit(ich,sDigit); | |
84 | } | |
935b9895 | 85 | // fMUONData->ResetSDigits(); |
86 | // fMUONData->GetCathodeS(1); | |
87 | // muonSDigits = fMUONData->SDigits(ich); | |
88 | // ndig=muonSDigits->GetEntriesFast(); | |
89 | // for (k = 0; k < ndig; k++) | |
90 | // { | |
91 | // sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k); | |
92 | // MakeTransientDigitFromSDigit(ich,sDigit); | |
93 | // } | |
cf286af7 | 94 | } // SDigits loop, end loop over chamber |
925e6570 | 95 | } |
d1775029 | 96 | |
97 | //------------------------------------------------------------------------ | |
cf286af7 | 98 | void AliMUONDigitizerv2::MakeTransientDigitFromSDigit(Int_t iChamber, AliMUONDigit* sDigit) |
d1775029 | 99 | { |
d19b6003 | 100 | /// Makes a transient digit from the specified s-digit from the specified chamber. |
101 | /// Once the digit is created it is added to the fTDList. | |
d1775029 | 102 | |
8c343c7c | 103 | AliDebug(4,Form("Making transient digit from s-digit for chamber %d.", iChamber)); |
a713db22 | 104 | Int_t digits[7]; |
cf286af7 | 105 | // |
106 | // Creating a new TransientDigits from SDigit | |
107 | digits[0] = sDigit->PadX(); // Padx of the Digit | |
108 | digits[1] = sDigit->PadY(); // Pady of the Digit | |
109 | digits[2] = sDigit->Cathode()+1; // Cathode plane | |
110 | digits[3] = sDigit->Signal(); // Induced charge in the Pad | |
111 | if (fSignal) | |
112 | digits[4] = sDigit->Signal(); | |
113 | else | |
114 | digits[4] = 0; | |
115 | ||
116 | digits[5] = sDigit->Hit(); // Hit number in the list | |
002920d1 | 117 | digits[6] = sDigit->DetElemId(); |
a713db22 | 118 | |
119 | AliDebug(5,Form("Made digit from sDigit 0x%X: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d\tidDE %d", | |
120 | (void*)sDigit, digits[0], digits[1], digits[2], digits[3], digits[5], digits[6])); | |
cf286af7 | 121 | |
cf286af7 | 122 | |
123 | AliMUONTransientDigit* mTD = new AliMUONTransientDigit(iChamber, digits); | |
124 | // Copy list of tracks and trackcharge | |
64aa908b | 125 | for(Int_t itrack = 0; itrack < sDigit->Ntracks(); ++itrack) |
cf286af7 | 126 | { |
127 | Int_t track = sDigit->Track(itrack); | |
128 | if (track < 0) break; // Check if we reached the end of the track list. | |
129 | mTD->AddToTrackList( track + fMask, sDigit->TrackCharge(itrack) ); | |
925e6570 | 130 | } |
cf286af7 | 131 | |
132 | OnCreateTransientDigit(mTD, sDigit); | |
133 | AddOrUpdateTransientDigit(mTD); | |
925e6570 | 134 | } |
d1775029 | 135 | |
136 | //------------------------------------------------------------------------ | |
a713db22 | 137 | void AliMUONDigitizerv2::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7]) |
d1775029 | 138 | { |
d19b6003 | 139 | /// Override to add new digits to the digits tree TreeD. |
30178c30 | 140 | fMUONData->AddDigit(chamber, tracks, charges, digits); |
925e6570 | 141 | } |
d1775029 | 142 | |
38169520 | 143 | //------------------------------------------------------------------------ |
144 | Int_t AliMUONDigitizerv2::GetSignalFrom(AliMUONTransientDigit* td) | |
145 | { | |
d19b6003 | 146 | /// Derived to apply the chamber response model to the digit. |
147 | /// Using AliMUONChamber::ResponseModel() for this. | |
38169520 | 148 | |
149 | AliDebug(4, "Applying response of chamber to TransientDigit signal."); | |
150 | // | |
151 | // Digit Response (noise, threshold, saturation, ...) | |
152 | Int_t q = td->Signal(); | |
153 | AliMUONChamber& chamber = fMUON->Chamber(td->Chamber()); | |
154 | AliMUONResponse* response = chamber.ResponseModel(); | |
155 | q = response->DigitResponse(q, td); | |
c0d7bac8 | 156 | if ( q >= response->Saturation() ) |
157 | { | |
158 | td->Saturated(kTRUE); | |
159 | } | |
38169520 | 160 | return q; |
161 | } | |
162 | ||
cf286af7 | 163 | //------------------------------------------------------------------------ |
164 | Bool_t AliMUONDigitizerv2::InitInputData(AliMUONLoader* muonloader) | |
d1775029 | 165 | { |
d19b6003 | 166 | /// Overridden to initialize fMUONData to read from the s-digits tree TreeS. |
167 | /// If the s-digits are not loaded then the muon loader is used to load the | |
168 | /// s-digits into memory. | |
d1775029 | 169 | |
8c343c7c | 170 | AliDebug(3,"Loading s-digits in READ mode and setting the tree address."); |
30178c30 | 171 | fMUONData->SetLoader(muonloader); |
d1775029 | 172 | |
cf286af7 | 173 | if (muonloader->TreeS() == NULL) |
174 | { | |
175 | muonloader->LoadSDigits("READ"); | |
176 | if (muonloader->TreeS() == NULL) | |
177 | { | |
8c343c7c | 178 | AliError("Can not load the s-digits tree."); |
cf286af7 | 179 | return kFALSE; |
925e6570 | 180 | } |
181 | } | |
be42eafc | 182 | |
30178c30 | 183 | fMUONData->SetTreeAddress("S"); |
cf286af7 | 184 | return kTRUE; |
925e6570 | 185 | } |
cf286af7 | 186 | |
d1775029 | 187 | //------------------------------------------------------------------------ |
cf286af7 | 188 | void AliMUONDigitizerv2::CleanupInputData(AliMUONLoader* muonloader) |
d1775029 | 189 | { |
d19b6003 | 190 | /// Overridden to release and unload s-digits from memory. |
cf286af7 | 191 | |
8c343c7c | 192 | AliDebug(3,"Releasing loaded s-digits."); |
30178c30 | 193 | fMUONData->ResetSDigits(); |
cf286af7 | 194 | muonloader->UnloadSDigits(); |
925e6570 | 195 | } |
38169520 | 196 | |
197 | //------------------------------------------------------------------------ | |
198 | Bool_t AliMUONDigitizerv2::InitOutputData(AliMUONLoader* muonloader) | |
199 | { | |
d19b6003 | 200 | /// Derived to initialize the output digits tree TreeD, create it if necessary |
201 | /// and sets the fMUONData tree address to treeD. | |
38169520 | 202 | |
203 | AliDebug(3, "Creating digits branch and setting the tree address."); | |
204 | ||
205 | fMUONData->SetLoader(muonloader); | |
206 | ||
207 | // New branch per chamber for MUON digit in the tree of digits | |
208 | if (muonloader->TreeD() == NULL) | |
209 | { | |
210 | muonloader->MakeDigitsContainer(); | |
211 | if (muonloader->TreeD() == NULL) | |
212 | { | |
213 | AliError("Could not create TreeD."); | |
214 | return kFALSE; | |
215 | } | |
216 | } | |
217 | ||
218 | fMUONData->MakeBranch("D"); | |
219 | fMUONData->SetTreeAddress("D"); | |
220 | ||
221 | return kTRUE; | |
222 | } | |
223 | ||
224 | //------------------------------------------------------------------------ | |
225 | void AliMUONDigitizerv2::FillOutputData() | |
226 | { | |
d19b6003 | 227 | /// Derived to fill TreeD and resets the digit array in fMUONData. |
38169520 | 228 | |
229 | AliDebug(3, "Filling trees with digits."); | |
230 | fMUONData->Fill("D"); | |
231 | fMUONData->ResetDigits(); | |
232 | } | |
233 | ||
234 | //------------------------------------------------------------------------ | |
235 | void AliMUONDigitizerv2::CleanupOutputData(AliMUONLoader* muonloader) | |
236 | { | |
d19b6003 | 237 | /// Derived to write the digits tree and then unload the digits tree once written. |
38169520 | 238 | |
239 | AliDebug(3, "Writing digits and releasing pointers."); | |
240 | muonloader->WriteDigits("OVERWRITE"); | |
241 | muonloader->UnloadDigits(); | |
242 | } | |
243 | ||
244 | //----------------------------------------------------------------------- | |
245 | ||
246 | void AliMUONDigitizerv2::CleanupTriggerArrays() | |
247 | { | |
d19b6003 | 248 | /// Cleanup trigger arrays |
249 | ||
38169520 | 250 | fTrigDec->ClearDigits(); |
251 | } | |
252 | ||
253 | //------------------------------------------------------------------------ | |
2be06f1e | 254 | void AliMUONDigitizerv2::AddDigitTrigger( |
255 | Int_t chamber, Int_t tracks[kMAXTRACKS], | |
256 | Int_t charges[kMAXTRACKS], Int_t digits[7], | |
b812d393 | 257 | Int_t digitindex |
2be06f1e | 258 | ) |
38169520 | 259 | { |
d19b6003 | 260 | /// Derived to add digits to TreeD for trigger. |
2be06f1e | 261 | fTrigDec->AddDigit(chamber, tracks, charges, digits, digitindex); |
38169520 | 262 | } |
263 | ||
264 | //------------------------------------------------------------------------ | |
265 | void AliMUONDigitizerv2::FillTriggerOutput() | |
266 | { | |
d19b6003 | 267 | /// Derived to fill TreeD and resets the trigger array in fMUONData. |
38169520 | 268 | |
269 | AliDebug(3,"Filling trees with trigger."); | |
270 | fMUONData->Fill("GLT"); | |
271 | fMUONData->ResetTrigger(); | |
272 | } | |
273 | ||
274 | //------------------------------------------------------------------------ | |
275 | void AliMUONDigitizerv2::CreateTrigger() | |
276 | { | |
d19b6003 | 277 | /// Create trigger data |
278 | ||
38169520 | 279 | fMUONData->MakeBranch("GLT"); |
280 | fMUONData->SetTreeAddress("GLT"); | |
281 | fTrigDec->Digits2Trigger(); | |
282 | FillTriggerOutput(); | |
283 | ||
284 | } |