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"
44 ClassImp(AliMUONDigitizerv1)
46 //___________________________________________
47 AliMUONDigitizerv1::AliMUONDigitizerv1() : AliMUONDigitizer()
49 // Default ctor - don't use it
52 //___________________________________________
53 AliMUONDigitizerv1::AliMUONDigitizerv1(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
55 // ctor which should be used
59 //___________________________________________
60 AliMUONDigitizerv1::~AliMUONDigitizerv1()
64 //-----------------------------------------------------------------------
66 void AliMUONDigitizerv1::CleanupTriggerArrays()
68 fTrigDec->ClearDigits();
71 //-----------------------------------------------------------------------
72 void AliMUONDigitizerv1::GenerateTransientDigits()
74 // Loops over all tracks and hits in the current selected event and calls
75 // MakeTransientDigitsFromHit for each hit.
76 // Note: Charge correlation is applied to the tracking chambers.
78 TTree* treeH = fGime->TreeH();
79 AliDebug(2, Form("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 AliDebug(3, Form("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 AliError(Form("Hit 0x%X has a invalid chamber number: %d", ichamber));
102 //Dumping Hit content:
103 AliDebug(3,Form("Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f",
104 ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss()
107 // Inititializing Correlation
108 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
109 chamber.ChargeCorrelationInit();
110 if (ichamber < AliMUONConstants::NTrackingCh())
113 // Initialize hit position (cursor) in the segmentation model
114 chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z());
115 } // else do nothing for Trigger Chambers
117 MakeTransientDigitsFromHit(itrack, ihit, mHit);
122 //--------------------------------------------------------------------------
123 void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
125 // This method is called for every hit in an event to generate AliMUONTransientDigits
126 // from the hit and add these to fTDList.
127 // The AliMUONChamber::DisIntegration method us used to figure out which pads are
128 // fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit
131 AliDebug(4,Form("Making transient digit for hit number %d.", iHit));
134 // Calls the charge disintegration method of the current chamber
135 AliDebug(5,"Calling AliMUONChamber::DisIngtegration...");
137 Float_t newdigit[6][500]; // Pad information
138 Int_t nnew=0; // Number of touched Pads per hit
139 Int_t ichamber = mHit->Chamber()-1;
140 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
141 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
143 // Creating new TransientDigits from hit
144 for(Int_t iTD = 0; iTD < nnew; iTD++)
149 digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit
150 digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit
151 digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane
152 digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad
156 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
160 charge = digits[3] + fMask;
161 digits[4] = 0; // No signal due to physics since this is now background.
163 digits[5] = iHit+fMask; // Hit number in the list
165 AliDebug(5,Form("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]));
169 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits);
170 mTD->AddToTrackList(track + fMask, charge);
172 OnCreateTransientDigit(mTD, mHit);
173 AddOrUpdateTransientDigit(mTD);
177 //------------------------------------------------------------------------
178 void AliMUONDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
180 // Derived to add digits to TreeD.
181 fMUONData->AddDigit(chamber, tracks, charges, digits);
184 //------------------------------------------------------------------------
185 void AliMUONDigitizerv1::AddDigitTrigger(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
187 // Derived to add digits to TreeD for trigger.
188 fTrigDec->AddDigit(chamber, tracks, charges, digits);
191 //------------------------------------------------------------------------
192 void AliMUONDigitizerv1::FillTriggerOutput()
194 // Derived to fill TreeD and resets the trigger array in fMUONData.
196 AliDebug(3,"Filling trees with trigger.");
197 fMUONData->Fill("GLT");
198 fMUONData->ResetTrigger();
201 //------------------------------------------------------------------------
202 void AliMUONDigitizerv1::CreateTrigger()
204 fMUONData->MakeBranch("GLT");
205 fMUONData->SetTreeAddress("GLT");
206 fTrigDec->Digits2Trigger();
211 //------------------------------------------------------------------------
212 Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
214 // Derived to apply the chamber response model to the digit.
215 // Using AliMUONChamber::ResponseModel() for this.
217 AliDebug(4, "Applying response of chamber to TransientDigit signal.");
219 // Digit Response (noise, threshold, saturation, ...)
220 Int_t q = td->Signal();
221 AliMUONChamber& chamber = fMUON->Chamber(td->Chamber());
222 AliMUONResponse* response = chamber.ResponseModel();
223 q = response->DigitResponse(q, td);
227 //------------------------------------------------------------------------
228 Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
230 // Derived to initialize the output digits tree TreeD, create it if necessary
231 // and sets the fMUONData tree address to treeD.
233 AliDebug(3, "Creating digits branch and setting the tree address.");
235 fMUONData->SetLoader(muonloader);
237 // New branch per chamber for MUON digit in the tree of digits
238 if (muonloader->TreeD() == NULL)
240 muonloader->MakeDigitsContainer();
241 if (muonloader->TreeD() == NULL)
243 AliError("Could not create TreeD.");
248 fMUONData->MakeBranch("D");
249 fMUONData->SetTreeAddress("D");
254 //------------------------------------------------------------------------
255 void AliMUONDigitizerv1::FillOutputData()
257 // Derived to fill TreeD and resets the digit array in fMUONData.
259 AliDebug(3, "Filling trees with digits.");
260 fMUONData->Fill("D");
261 fMUONData->ResetDigits();
264 //------------------------------------------------------------------------
265 void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
267 // Derived to write the digits tree and then unload the digits tree once written.
269 AliDebug(3, "Writing digits and releasing pointers.");
270 muonloader->WriteDigits("OVERWRITE");
271 muonloader->UnloadDigits();
275 //------------------------------------------------------------------------
276 Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader)
278 // Derived to initialise the input to read from TreeH the hits tree.
279 // If the hits are not loaded then we load the hits using the muon loader.
281 AliDebug(3, "Loading hits in READ mode and setting the tree address.");
283 fMUONData->SetLoader(muonloader);
285 if (muonloader->TreeH() == NULL)
287 muonloader->LoadHits("READ");
288 if (muonloader->TreeH() == NULL)
290 AliError("Can not load the hits tree.");
295 fMUONData->SetTreeAddress("H");
299 //------------------------------------------------------------------------
300 void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
302 // Derived to release the loaded hits and unload them.
304 AliDebug(3, "Releasing loaded hits.");
305 fMUONData->ResetHits();
306 muonloader->UnloadHits();