]>
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$ */ | |
cf286af7 | 17 | |
18 | ///////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // AliMUONDigitizerv1 implements a full digitizer to digitize digits directly | |
21 | // from hits. It also performs merging over several input streams. | |
22 | // The first input stream is assumed to be the signal and all other input | |
23 | // streams are assumed to be background. SDigits are never generated by this | |
24 | // digitizer and one should use the AliMUONSDigitizerv1 for that task. | |
25 | // | |
26 | // NOTE: This digitizer will become depricated in the future in favour of | |
27 | // AliMUONSDigitizerv1 and AliMUONDigitizerv2. | |
28 | // | |
29 | ///////////////////////////////////////////////////////////////////////////////// | |
8dbbc4e3 | 30 | |
30178c30 | 31 | #include <TTree.h> |
32 | ||
33 | #include "AliMUON.h" | |
34 | #include "AliMUONData.h" | |
35 | #include "AliMUONLoader.h" | |
36 | #include "AliMUONChamber.h" | |
37 | #include "AliMUONConstants.h" | |
38 | #include "AliMUONDigitizerv1.h" | |
39 | #include "AliMUONHit.h" | |
40 | #include "AliMUONTransientDigit.h" | |
41 | ||
8dbbc4e3 | 42 | ClassImp(AliMUONDigitizerv1) |
43 | ||
44 | //___________________________________________ | |
cf286af7 | 45 | AliMUONDigitizerv1::AliMUONDigitizerv1() : AliMUONDigitizer() |
8dbbc4e3 | 46 | { |
cf286af7 | 47 | // Default ctor - don't use it |
8dbbc4e3 | 48 | } |
49 | ||
50 | //___________________________________________ | |
cf286af7 | 51 | AliMUONDigitizerv1::AliMUONDigitizerv1(AliRunDigitizer* manager) : AliMUONDigitizer(manager) |
8dbbc4e3 | 52 | { |
cf286af7 | 53 | // ctor which should be used |
8dbbc4e3 | 54 | } |
55 | ||
8789635b | 56 | //___________________________________________ |
57 | AliMUONDigitizerv1::~AliMUONDigitizerv1() | |
58 | { | |
59 | // Destructor | |
60 | } | |
61 | ||
cf286af7 | 62 | //----------------------------------------------------------------------- |
63 | void AliMUONDigitizerv1::GenerateTransientDigits() | |
64 | { | |
65 | // Loops over all tracks and hits in the current selected event and calls | |
66 | // MakeTransientDigitsFromHit for each hit. | |
67 | // Note: Charge correlation is applied to the tracking chambers. | |
68 | ||
30178c30 | 69 | TTree* treeH = fGime->TreeH(); |
cf286af7 | 70 | if (GetDebug() > 1) |
71 | Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X" | |
72 | , (void*)treeH); | |
73 | // | |
74 | // Loop over tracks | |
75 | Int_t ntracks = (Int_t) treeH->GetEntries(); | |
76 | for (Int_t itrack = 0; itrack < ntracks; itrack++) | |
77 | { | |
78 | if (GetDebug() > 2) Info("GenerateTransientDigits", "Processing track %d...", itrack); | |
30178c30 | 79 | fMUONData->ResetHits(); |
cf286af7 | 80 | treeH->GetEvent(itrack); |
81 | // | |
82 | // Loop over hits | |
30178c30 | 83 | TClonesArray* hits = fMUONData->Hits(); |
cf286af7 | 84 | for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++) |
85 | { | |
86 | AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) ); | |
87 | Int_t ichamber = mHit->Chamber()-1; // chamber number | |
88 | if (ichamber > AliMUONConstants::NCh()-1) | |
89 | { | |
90 | Error("GenerateTransientDigits", | |
91 | "Hit 0x%X has a invalid chamber number: %d", ichamber); | |
92 | continue; | |
93 | } | |
94 | // | |
95 | //Dumping Hit content: | |
96 | if (GetDebug() > 2) | |
97 | { | |
98 | Info("GenerateTransientDigits", | |
99 | "Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f", | |
100 | ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss() | |
101 | ); | |
102 | } | |
103 | // | |
104 | // Inititializing Correlation | |
30178c30 | 105 | AliMUONChamber& chamber = fMUON->Chamber(ichamber); |
cf286af7 | 106 | chamber.ChargeCorrelationInit(); |
107 | if (ichamber < AliMUONConstants::NTrackingCh()) | |
108 | { | |
109 | // Tracking Chamber | |
110 | // Initialize hit position (cursor) in the segmentation model | |
111 | chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z()); | |
112 | }; // else do nothing for Trigger Chambers | |
113 | ||
114 | MakeTransientDigitsFromHit(itrack, ihit, mHit); | |
115 | } // hit loop | |
116 | } // track loop | |
117 | }; | |
118 | ||
119 | //-------------------------------------------------------------------------- | |
120 | void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit) | |
121 | { | |
122 | // This method is called for every hit in an event to generate AliMUONTransientDigits | |
123 | // from the hit and add these to fTDList. | |
124 | // The AliMUONChamber::DisIntegration method us used to figure out which pads are | |
125 | // fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit | |
126 | // for each pad. | |
127 | ||
128 | if (GetDebug() > 3) | |
129 | Info("MakeTransientDigitsFromHit", "Making transient digit for hit number %d.", iHit); | |
130 | ||
131 | // | |
132 | // Calls the charge disintegration method of the current chamber | |
133 | if (GetDebug() > 4) | |
134 | Info("MakeTransientDigitsFromHit", "Calling AliMUONChamber::DisIngtegration..."); | |
135 | ||
136 | Float_t newdigit[6][500]; // Pad information | |
137 | Int_t nnew=0; // Number of touched Pads per hit | |
138 | Int_t ichamber = mHit->Chamber()-1; | |
30178c30 | 139 | AliMUONChamber& chamber = fMUON->Chamber(ichamber); |
cf286af7 | 140 | chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit); |
141 | ||
142 | // Creating new TransientDigits from hit | |
143 | for(Int_t iTD = 0; iTD < nnew; iTD++) | |
144 | { | |
145 | Int_t charge; | |
146 | Int_t digits[6]; | |
147 | ||
148 | digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit | |
149 | digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit | |
150 | digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane | |
151 | digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad | |
152 | if (fSignal) | |
153 | { | |
154 | charge = digits[3]; | |
155 | digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics | |
156 | } | |
157 | else | |
158 | { | |
159 | charge = digits[3] + fMask; | |
160 | digits[4] = 0; // No signal due to physics since this is now background. | |
161 | }; | |
162 | digits[5] = iHit+fMask; // Hit number in the list | |
163 | ||
164 | if (GetDebug() > 4) | |
165 | Info("MakeTransientDigitsFromHit", | |
166 | "DisIntegration result %d: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d", | |
167 | iTD, digits[0], digits[1], digits[2], digits[3], digits[5]); | |
168 | ||
169 | AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits); | |
170 | mTD->AddToTrackList(track + fMask, charge); | |
171 | ||
172 | OnCreateTransientDigit(mTD, mHit); | |
173 | AddOrUpdateTransientDigit(mTD); | |
174 | }; | |
175 | }; | |
176 | ||
8dbbc4e3 | 177 | //------------------------------------------------------------------------ |
cf286af7 | 178 | void AliMUONDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6]) |
8dbbc4e3 | 179 | { |
cf286af7 | 180 | // Derived to add digits to TreeD. |
30178c30 | 181 | fMUONData->AddDigit(chamber, tracks, charges, digits); |
cf286af7 | 182 | }; |
8dbbc4e3 | 183 | |
184 | //------------------------------------------------------------------------ | |
cf286af7 | 185 | Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td) |
8dbbc4e3 | 186 | { |
cf286af7 | 187 | // Derived to apply the chamber response model to the digit. |
188 | // Using AliMUONChamber::ResponseModel() for this. | |
189 | ||
190 | if (GetDebug() > 3) | |
191 | Info("GetSignalFrom", "Applying response of chamber to TransientDigit signal."); | |
192 | // | |
193 | // Digit Response (noise, threshold, saturation, ...) | |
194 | Int_t q = td->Signal(); | |
30178c30 | 195 | AliMUONChamber& chamber = fMUON->Chamber(td->Chamber()); |
cf286af7 | 196 | AliMUONResponse* response = chamber.ResponseModel(); |
197 | q = response->DigitResponse(q, td); | |
198 | return q; | |
199 | }; | |
8dbbc4e3 | 200 | |
201 | //------------------------------------------------------------------------ | |
cf286af7 | 202 | Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader) |
8dbbc4e3 | 203 | { |
cf286af7 | 204 | // Derived to initialize the output digits tree TreeD, create it if necessary |
30178c30 | 205 | // and sets the fMUONData tree address to treeD. |
cf286af7 | 206 | |
207 | if (GetDebug() > 2) | |
208 | Info("InitOutputData", "Creating digits branch and setting the tree address."); | |
209 | ||
30178c30 | 210 | fMUONData->SetLoader(muonloader); |
cf286af7 | 211 | |
212 | // New branch per chamber for MUON digit in the tree of digits | |
213 | if (muonloader->TreeD() == NULL) | |
214 | { | |
215 | muonloader->MakeDigitsContainer(); | |
216 | if (muonloader->TreeD() == NULL) | |
217 | { | |
218 | Error("InitOutputData", "Could not create TreeD."); | |
219 | return kFALSE; | |
220 | }; | |
221 | }; | |
222 | ||
30178c30 | 223 | fMUONData->MakeBranch("D"); |
224 | fMUONData->SetTreeAddress("D"); | |
cf286af7 | 225 | |
226 | return kTRUE; | |
227 | }; | |
8dbbc4e3 | 228 | |
229 | //------------------------------------------------------------------------ | |
cf286af7 | 230 | void AliMUONDigitizerv1::FillOutputData() |
8dbbc4e3 | 231 | { |
30178c30 | 232 | // Derived to fill TreeD and resets the digit array in fMUONData. |
1391e633 | 233 | |
cf286af7 | 234 | if (GetDebug() > 2) Info("FillOutputData", "Filling trees with digits."); |
30178c30 | 235 | fMUONData->Fill("D"); |
236 | fMUONData->ResetDigits(); | |
cf286af7 | 237 | }; |
8dbbc4e3 | 238 | |
239 | //------------------------------------------------------------------------ | |
cf286af7 | 240 | void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader) |
8dbbc4e3 | 241 | { |
cf286af7 | 242 | // Derived to write the digits tree and then unload the digits tree once written. |
8dbbc4e3 | 243 | |
cf286af7 | 244 | if (GetDebug() > 2) Info("CleanupOutputData", "Writing digits and releasing pointers."); |
245 | muonloader->WriteDigits("OVERWRITE"); | |
246 | muonloader->UnloadDigits(); | |
247 | }; | |
8dbbc4e3 | 248 | |
cf286af7 | 249 | |
250 | //------------------------------------------------------------------------ | |
251 | Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader) | |
8dbbc4e3 | 252 | { |
cf286af7 | 253 | // Derived to initialise the input to read from TreeH the hits tree. |
254 | // If the hits are not loaded then we load the hits using the muon loader. | |
255 | ||
256 | if (GetDebug() > 2) | |
257 | Info("InitInputData", "Loading hits in READ mode and setting the tree address."); | |
258 | ||
30178c30 | 259 | fMUONData->SetLoader(muonloader); |
cf286af7 | 260 | |
261 | if (muonloader->TreeH() == NULL) | |
262 | { | |
263 | muonloader->LoadHits("READ"); | |
264 | if (muonloader->TreeH() == NULL) | |
265 | { | |
266 | Error("InitInputData", "Can not load the hits tree."); | |
267 | return kFALSE; | |
268 | }; | |
269 | }; | |
270 | ||
30178c30 | 271 | fMUONData->SetTreeAddress("H"); |
cf286af7 | 272 | return kTRUE; |
273 | }; | |
274 | ||
8dbbc4e3 | 275 | //------------------------------------------------------------------------ |
cf286af7 | 276 | void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader) |
8dbbc4e3 | 277 | { |
cf286af7 | 278 | // Derived to release the loaded hits and unload them. |
279 | ||
280 | if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded hits."); | |
30178c30 | 281 | fMUONData->ResetHits(); |
cf286af7 | 282 | muonloader->UnloadHits(); |
283 | }; | |
284 |