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"
42 ClassImp(AliMUONDigitizerv1)
44 //___________________________________________
45 AliMUONDigitizerv1::AliMUONDigitizerv1() : AliMUONDigitizer()
47 // Default ctor - don't use it
50 //___________________________________________
51 AliMUONDigitizerv1::AliMUONDigitizerv1(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
53 // ctor which should be used
56 //___________________________________________
57 AliMUONDigitizerv1::~AliMUONDigitizerv1()
62 //-----------------------------------------------------------------------
63 void AliMUONDigitizerv1::GenerateTransientDigits()
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.
69 TTree* treeH = fGime->TreeH();
71 Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X"
75 Int_t ntracks = (Int_t) treeH->GetEntries();
76 for (Int_t itrack = 0; itrack < ntracks; itrack++)
78 if (GetDebug() > 2) Info("GenerateTransientDigits", "Processing track %d...", itrack);
79 fMUONData->ResetHits();
80 treeH->GetEvent(itrack);
83 TClonesArray* hits = fMUONData->Hits();
84 for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++)
86 AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) );
87 Int_t ichamber = mHit->Chamber()-1; // chamber number
88 if (ichamber > AliMUONConstants::NCh()-1)
90 Error("GenerateTransientDigits",
91 "Hit 0x%X has a invalid chamber number: %d", ichamber);
95 //Dumping Hit content:
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()
104 // Inititializing Correlation
105 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
106 chamber.ChargeCorrelationInit();
107 if (ichamber < AliMUONConstants::NTrackingCh())
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
114 MakeTransientDigitsFromHit(itrack, ihit, mHit);
119 //--------------------------------------------------------------------------
120 void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
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
129 Info("MakeTransientDigitsFromHit", "Making transient digit for hit number %d.", iHit);
132 // Calls the charge disintegration method of the current chamber
134 Info("MakeTransientDigitsFromHit", "Calling AliMUONChamber::DisIngtegration...");
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;
139 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
140 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
142 // Creating new TransientDigits from hit
143 for(Int_t iTD = 0; iTD < nnew; iTD++)
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
155 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
159 charge = digits[3] + fMask;
160 digits[4] = 0; // No signal due to physics since this is now background.
162 digits[5] = iHit+fMask; // Hit number in the list
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]);
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 Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
187 // Derived to apply the chamber response model to the digit.
188 // Using AliMUONChamber::ResponseModel() for this.
191 Info("GetSignalFrom", "Applying response of chamber to TransientDigit signal.");
193 // Digit Response (noise, threshold, saturation, ...)
194 Int_t q = td->Signal();
195 AliMUONChamber& chamber = fMUON->Chamber(td->Chamber());
196 AliMUONResponse* response = chamber.ResponseModel();
197 q = response->DigitResponse(q, td);
201 //------------------------------------------------------------------------
202 Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
204 // Derived to initialize the output digits tree TreeD, create it if necessary
205 // and sets the fMUONData tree address to treeD.
208 Info("InitOutputData", "Creating digits branch and setting the tree address.");
210 fMUONData->SetLoader(muonloader);
212 // New branch per chamber for MUON digit in the tree of digits
213 if (muonloader->TreeD() == NULL)
215 muonloader->MakeDigitsContainer();
216 if (muonloader->TreeD() == NULL)
218 Error("InitOutputData", "Could not create TreeD.");
223 fMUONData->MakeBranch("D");
224 fMUONData->SetTreeAddress("D");
229 //------------------------------------------------------------------------
230 void AliMUONDigitizerv1::FillOutputData()
232 // Derived to fill TreeD and resets the digit array in fMUONData.
234 if (GetDebug() > 2) Info("FillOutputData", "Filling trees with digits.");
235 fMUONData->Fill("D");
236 fMUONData->ResetDigits();
239 //------------------------------------------------------------------------
240 void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
242 // Derived to write the digits tree and then unload the digits tree once written.
244 if (GetDebug() > 2) Info("CleanupOutputData", "Writing digits and releasing pointers.");
245 muonloader->WriteDigits("OVERWRITE");
246 muonloader->UnloadDigits();
250 //------------------------------------------------------------------------
251 Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader)
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.
257 Info("InitInputData", "Loading hits in READ mode and setting the tree address.");
259 fMUONData->SetLoader(muonloader);
261 if (muonloader->TreeH() == NULL)
263 muonloader->LoadHits("READ");
264 if (muonloader->TreeH() == NULL)
266 Error("InitInputData", "Can not load the hits tree.");
271 fMUONData->SetTreeAddress("H");
275 //------------------------------------------------------------------------
276 void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
278 // Derived to release the loaded hits and unload them.
280 if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded hits.");
281 fMUONData->ResetHits();
282 muonloader->UnloadHits();