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 // 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.
26 // NOTE: This digitizer will become depricated in the future in favour of
27 // AliMUONSDigitizerv1 and AliMUONDigitizerv2.
29 /////////////////////////////////////////////////////////////////////////////////
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 #include "AliMUONTriggerDecision.h"
43 ClassImp(AliMUONDigitizerv1)
45 //___________________________________________
46 AliMUONDigitizerv1::AliMUONDigitizerv1() : AliMUONDigitizer()
48 // Default ctor - don't use it
51 //___________________________________________
52 AliMUONDigitizerv1::AliMUONDigitizerv1(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
54 // ctor which should be used
58 //___________________________________________
59 AliMUONDigitizerv1::~AliMUONDigitizerv1()
63 //-----------------------------------------------------------------------
65 void AliMUONDigitizerv1::CleanupTriggerArrays()
67 fTrigDec->ClearDigits();
70 //-----------------------------------------------------------------------
71 void AliMUONDigitizerv1::GenerateTransientDigits()
73 // Loops over all tracks and hits in the current selected event and calls
74 // MakeTransientDigitsFromHit for each hit.
75 // Note: Charge correlation is applied to the tracking chambers.
77 TTree* treeH = fGime->TreeH();
79 Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X"
83 Int_t ntracks = (Int_t) treeH->GetEntries();
84 for (Int_t itrack = 0; itrack < ntracks; itrack++)
86 if (GetDebug() > 2) Info("GenerateTransientDigits", "Processing track %d...", itrack);
87 fMUONData->ResetHits();
88 treeH->GetEvent(itrack);
91 TClonesArray* hits = fMUONData->Hits();
92 for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++)
94 AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) );
95 Int_t ichamber = mHit->Chamber()-1; // chamber number
96 if (ichamber > AliMUONConstants::NCh()-1)
98 Error("GenerateTransientDigits",
99 "Hit 0x%X has a invalid chamber number: %d", ichamber);
103 //Dumping Hit content:
106 Info("GenerateTransientDigits",
107 "Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f",
108 ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss()
112 // Inititializing Correlation
113 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
114 chamber.ChargeCorrelationInit();
115 if (ichamber < AliMUONConstants::NTrackingCh())
118 // Initialize hit position (cursor) in the segmentation model
119 chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z());
120 }; // else do nothing for Trigger Chambers
122 MakeTransientDigitsFromHit(itrack, ihit, mHit);
127 //--------------------------------------------------------------------------
128 void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
130 // This method is called for every hit in an event to generate AliMUONTransientDigits
131 // from the hit and add these to fTDList.
132 // The AliMUONChamber::DisIntegration method us used to figure out which pads are
133 // fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit
137 Info("MakeTransientDigitsFromHit", "Making transient digit for hit number %d.", iHit);
140 // Calls the charge disintegration method of the current chamber
142 Info("MakeTransientDigitsFromHit", "Calling AliMUONChamber::DisIngtegration...");
144 Float_t newdigit[6][500]; // Pad information
145 Int_t nnew=0; // Number of touched Pads per hit
146 Int_t ichamber = mHit->Chamber()-1;
147 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
148 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
150 // Creating new TransientDigits from hit
151 for(Int_t iTD = 0; iTD < nnew; iTD++)
156 digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit
157 digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit
158 digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane
159 digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad
163 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
167 charge = digits[3] + fMask;
168 digits[4] = 0; // No signal due to physics since this is now background.
170 digits[5] = iHit+fMask; // Hit number in the list
173 Info("MakeTransientDigitsFromHit",
174 "DisIntegration result %d: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d",
175 iTD, digits[0], digits[1], digits[2], digits[3], digits[5]);
177 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits);
178 mTD->AddToTrackList(track + fMask, charge);
180 OnCreateTransientDigit(mTD, mHit);
181 AddOrUpdateTransientDigit(mTD);
185 //------------------------------------------------------------------------
186 void AliMUONDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
188 // Derived to add digits to TreeD.
189 fMUONData->AddDigit(chamber, tracks, charges, digits);
192 //------------------------------------------------------------------------
193 void AliMUONDigitizerv1::AddDigitTrigger(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
195 // Derived to add digits to TreeD for trigger.
196 fTrigDec->AddDigit(chamber, tracks, charges, digits);
199 //------------------------------------------------------------------------
200 void AliMUONDigitizerv1::FillTriggerOutput()
202 // Derived to fill TreeD and resets the trigger array in fMUONData.
204 if (GetDebug() > 2) Info("FillTriggerOutput", "Filling trees with trigger.");
205 fMUONData->Fill("GLT");
206 fMUONData->ResetTrigger();
209 //------------------------------------------------------------------------
210 void AliMUONDigitizerv1::CreateTrigger()
212 fMUONData->MakeBranch("GLT");
213 fMUONData->SetTreeAddress("GLT");
214 fTrigDec->Digits2Trigger();
219 //------------------------------------------------------------------------
220 Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
222 // Derived to apply the chamber response model to the digit.
223 // Using AliMUONChamber::ResponseModel() for this.
226 Info("GetSignalFrom", "Applying response of chamber to TransientDigit signal.");
228 // Digit Response (noise, threshold, saturation, ...)
229 Int_t q = td->Signal();
230 AliMUONChamber& chamber = fMUON->Chamber(td->Chamber());
231 AliMUONResponse* response = chamber.ResponseModel();
232 q = response->DigitResponse(q, td);
236 //------------------------------------------------------------------------
237 Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
239 // Derived to initialize the output digits tree TreeD, create it if necessary
240 // and sets the fMUONData tree address to treeD.
243 Info("InitOutputData", "Creating digits branch and setting the tree address.");
245 fMUONData->SetLoader(muonloader);
247 // New branch per chamber for MUON digit in the tree of digits
248 if (muonloader->TreeD() == NULL)
250 muonloader->MakeDigitsContainer();
251 if (muonloader->TreeD() == NULL)
253 Error("InitOutputData", "Could not create TreeD.");
258 fMUONData->MakeBranch("D");
259 fMUONData->SetTreeAddress("D");
264 //------------------------------------------------------------------------
265 void AliMUONDigitizerv1::FillOutputData()
267 // Derived to fill TreeD and resets the digit array in fMUONData.
269 if (GetDebug() > 2) Info("FillOutputData", "Filling trees with digits.");
270 fMUONData->Fill("D");
271 fMUONData->ResetDigits();
274 //------------------------------------------------------------------------
275 void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
277 // Derived to write the digits tree and then unload the digits tree once written.
279 if (GetDebug() > 2) Info("CleanupOutputData", "Writing digits and releasing pointers.");
280 muonloader->WriteDigits("OVERWRITE");
281 muonloader->UnloadDigits();
285 //------------------------------------------------------------------------
286 Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader)
288 // Derived to initialise the input to read from TreeH the hits tree.
289 // If the hits are not loaded then we load the hits using the muon loader.
292 Info("InitInputData", "Loading hits in READ mode and setting the tree address.");
294 fMUONData->SetLoader(muonloader);
296 if (muonloader->TreeH() == NULL)
298 muonloader->LoadHits("READ");
299 if (muonloader->TreeH() == NULL)
301 Error("InitInputData", "Can not load the hits tree.");
306 fMUONData->SetTreeAddress("H");
310 //------------------------------------------------------------------------
311 void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
313 // Derived to release the loaded hits and unload them.
315 if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded hits.");
316 fMUONData->ResetHits();
317 muonloader->UnloadHits();