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 // Do the Digitization (Digit) from summable Digits (SDigit)
19 // Allow the merging of signal file with background file(s).
21 /////////////////////////////////////////////////////////////////////////////////
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
27 // Chamber response is applied to the digits identically to AliMUONDigitizerv1.
29 /////////////////////////////////////////////////////////////////////////////////
32 #include "AliMUONData.h"
33 #include "AliMUONLoader.h"
34 #include "AliMUONConstants.h"
35 #include "AliMUONChamber.h"
36 #include "AliMUONDigit.h"
37 #include "AliMUONDigitizerv2.h"
38 #include "AliMUONTransientDigit.h"
39 #include "AliMUONTriggerDecision.h"
42 ClassImp(AliMUONDigitizerv2)
44 //___________________________________________
45 AliMUONDigitizerv2::AliMUONDigitizerv2() : AliMUONDigitizer()
47 // Default ctor - don't use it
50 //___________________________________________
51 AliMUONDigitizerv2::AliMUONDigitizerv2(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
53 // ctor which should be used
56 //___________________________________________
57 AliMUONDigitizerv2::~AliMUONDigitizerv2()
62 //-----------------------------------------------------------------------
63 void AliMUONDigitizerv2::GenerateTransientDigits()
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.
68 AliDebug(2,"Generating transient digits using treeH = 0x%X");
73 TClonesArray* muonSDigits;
74 for (Int_t ich = 0; ich < AliMUONConstants::NCh(); ich++) // loop over chamber
76 fMUONData->ResetSDigits();
77 fMUONData->GetSDigits();
78 muonSDigits = fMUONData->SDigits(ich);
79 ndig = muonSDigits->GetEntriesFast();
80 for (k = 0; k < ndig; k++)
82 sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
83 MakeTransientDigitFromSDigit(ich,sDigit);
85 // fMUONData->ResetSDigits();
86 // fMUONData->GetCathodeS(1);
87 // muonSDigits = fMUONData->SDigits(ich);
88 // ndig=muonSDigits->GetEntriesFast();
89 // for (k = 0; k < ndig; k++)
91 // sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
92 // MakeTransientDigitFromSDigit(ich,sDigit);
94 } // SDigits loop, end loop over chamber
97 //------------------------------------------------------------------------
98 void AliMUONDigitizerv2::MakeTransientDigitFromSDigit(Int_t iChamber, AliMUONDigit* sDigit)
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.
103 AliDebug(4,Form("Making transient digit from s-digit for chamber %d.", iChamber));
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
112 digits[4] = sDigit->Signal();
116 digits[5] = sDigit->Hit(); // Hit number in the list
117 digits[6] = sDigit->DetElemId();
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]));
123 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(iChamber, digits);
124 // Copy list of tracks and trackcharge
125 for(Int_t itrack = 0; itrack < kMAXTRACKS; itrack++)
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) );
132 OnCreateTransientDigit(mTD, sDigit);
133 AddOrUpdateTransientDigit(mTD);
136 //------------------------------------------------------------------------
137 void AliMUONDigitizerv2::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7])
139 // Override to add new digits to the digits tree TreeD.
140 fMUONData->AddDigit(chamber, tracks, charges, digits);
143 //------------------------------------------------------------------------
144 Int_t AliMUONDigitizerv2::GetSignalFrom(AliMUONTransientDigit* td)
146 // Derived to apply the chamber response model to the digit.
147 // Using AliMUONChamber::ResponseModel() for this.
149 AliDebug(4, "Applying response of chamber to TransientDigit signal.");
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);
159 //------------------------------------------------------------------------
160 Bool_t AliMUONDigitizerv2::InitInputData(AliMUONLoader* muonloader)
162 // Overridden to initialize fMUONData to read from the s-digits tree TreeS.
163 // If the s-digits are not loaded then the muon loader is used to load the
164 // s-digits into memory.
166 AliDebug(3,"Loading s-digits in READ mode and setting the tree address.");
167 fMUONData->SetLoader(muonloader);
169 if (muonloader->TreeS() == NULL)
171 muonloader->LoadSDigits("READ");
172 if (muonloader->TreeS() == NULL)
174 AliError("Can not load the s-digits tree.");
179 fMUONData->SetTreeAddress("S");
183 //------------------------------------------------------------------------
184 void AliMUONDigitizerv2::CleanupInputData(AliMUONLoader* muonloader)
186 // Overridden to release and unload s-digits from memory.
188 AliDebug(3,"Releasing loaded s-digits.");
189 fMUONData->ResetSDigits();
190 muonloader->UnloadSDigits();
193 //------------------------------------------------------------------------
194 Bool_t AliMUONDigitizerv2::InitOutputData(AliMUONLoader* muonloader)
196 // Derived to initialize the output digits tree TreeD, create it if necessary
197 // and sets the fMUONData tree address to treeD.
199 AliDebug(3, "Creating digits branch and setting the tree address.");
201 fMUONData->SetLoader(muonloader);
203 // New branch per chamber for MUON digit in the tree of digits
204 if (muonloader->TreeD() == NULL)
206 muonloader->MakeDigitsContainer();
207 if (muonloader->TreeD() == NULL)
209 AliError("Could not create TreeD.");
214 fMUONData->MakeBranch("D");
215 fMUONData->SetTreeAddress("D");
220 //------------------------------------------------------------------------
221 void AliMUONDigitizerv2::FillOutputData()
223 // Derived to fill TreeD and resets the digit array in fMUONData.
225 AliDebug(3, "Filling trees with digits.");
226 fMUONData->Fill("D");
227 fMUONData->ResetDigits();
230 //------------------------------------------------------------------------
231 void AliMUONDigitizerv2::CleanupOutputData(AliMUONLoader* muonloader)
233 // Derived to write the digits tree and then unload the digits tree once written.
235 AliDebug(3, "Writing digits and releasing pointers.");
236 muonloader->WriteDigits("OVERWRITE");
237 muonloader->UnloadDigits();
240 //-----------------------------------------------------------------------
242 void AliMUONDigitizerv2::CleanupTriggerArrays()
244 fTrigDec->ClearDigits();
247 //------------------------------------------------------------------------
248 void AliMUONDigitizerv2::AddDigitTrigger(
249 Int_t chamber, Int_t tracks[kMAXTRACKS],
250 Int_t charges[kMAXTRACKS], Int_t digits[7],
251 const Int_t digitindex
254 // Derived to add digits to TreeD for trigger.
255 fTrigDec->AddDigit(chamber, tracks, charges, digits, digitindex);
258 //------------------------------------------------------------------------
259 void AliMUONDigitizerv2::FillTriggerOutput()
261 // Derived to fill TreeD and resets the trigger array in fMUONData.
263 AliDebug(3,"Filling trees with trigger.");
264 fMUONData->Fill("GLT");
265 fMUONData->ResetTrigger();
268 //------------------------------------------------------------------------
269 void AliMUONDigitizerv2::CreateTrigger()
271 fMUONData->MakeBranch("GLT");
272 fMUONData->SetTreeAddress("GLT");
273 fTrigDec->Digits2Trigger();