3 #include <TDirectory.h>
11 #include "AliRunDigitizer.h"
12 #include "AliRunLoader.h"
13 #include "AliLoader.h"
16 #include "AliMUONChamber.h"
17 #include "AliMUONConstants.h"
18 #include "AliMUONDigit.h"
19 #include "AliMUONDigitizerv1.h"
20 #include "AliMUONHit.h"
21 #include "AliMUONHitMapA1.h"
22 #include "AliMUONPadHit.h"
23 #include "AliMUONTransientDigit.h"
25 /////////////////////////////////////////////////////////////////////////////////
27 // AliMUONDigitizerv1 implements a full digitizer to digitize digits directly
28 // from hits. It also performs merging over several input streams.
29 // The first input stream is assumed to be the signal and all other input
30 // streams are assumed to be background. SDigits are never generated by this
31 // digitizer and one should use the AliMUONSDigitizerv1 for that task.
33 // NOTE: This digitizer will become depricated in the future in favour of
34 // AliMUONSDigitizerv1 and AliMUONDigitizerv2.
36 /////////////////////////////////////////////////////////////////////////////////
38 ClassImp(AliMUONDigitizerv1)
40 //___________________________________________
41 AliMUONDigitizerv1::AliMUONDigitizerv1() : AliMUONDigitizer()
43 // Default ctor - don't use it
46 //___________________________________________
47 AliMUONDigitizerv1::AliMUONDigitizerv1(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
49 // ctor which should be used
52 //___________________________________________
53 AliMUONDigitizerv1::~AliMUONDigitizerv1()
58 //-----------------------------------------------------------------------
59 void AliMUONDigitizerv1::GenerateTransientDigits()
61 // Loops over all tracks and hits in the current selected event and calls
62 // MakeTransientDigitsFromHit for each hit.
63 // Note: Charge correlation is applied to the tracking chambers.
65 TTree* treeH = gime->TreeH();
67 Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X"
71 Int_t ntracks = (Int_t) treeH->GetEntries();
72 for (Int_t itrack = 0; itrack < ntracks; itrack++)
74 if (GetDebug() > 2) Info("GenerateTransientDigits", "Processing track %d...", itrack);
75 muondata->ResetHits();
76 treeH->GetEvent(itrack);
79 TClonesArray* hits = muondata->Hits();
80 for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++)
82 AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) );
83 Int_t ichamber = mHit->Chamber()-1; // chamber number
84 if (ichamber > AliMUONConstants::NCh()-1)
86 Error("GenerateTransientDigits",
87 "Hit 0x%X has a invalid chamber number: %d", ichamber);
91 //Dumping Hit content:
94 Info("GenerateTransientDigits",
95 "Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f",
96 ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss()
100 // Inititializing Correlation
101 AliMUONChamber& chamber = pMUON->Chamber(ichamber);
102 chamber.ChargeCorrelationInit();
103 if (ichamber < AliMUONConstants::NTrackingCh())
106 // Initialize hit position (cursor) in the segmentation model
107 chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z());
108 }; // else do nothing for Trigger Chambers
110 MakeTransientDigitsFromHit(itrack, ihit, mHit);
115 //--------------------------------------------------------------------------
116 void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
118 // This method is called for every hit in an event to generate AliMUONTransientDigits
119 // from the hit and add these to fTDList.
120 // The AliMUONChamber::DisIntegration method us used to figure out which pads are
121 // fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit
125 Info("MakeTransientDigitsFromHit", "Making transient digit for hit number %d.", iHit);
128 // Calls the charge disintegration method of the current chamber
130 Info("MakeTransientDigitsFromHit", "Calling AliMUONChamber::DisIngtegration...");
132 Float_t newdigit[6][500]; // Pad information
133 Int_t nnew=0; // Number of touched Pads per hit
134 Int_t ichamber = mHit->Chamber()-1;
135 AliMUONChamber& chamber = pMUON->Chamber(ichamber);
136 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
138 // Creating new TransientDigits from hit
139 for(Int_t iTD = 0; iTD < nnew; iTD++)
144 digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit
145 digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit
146 digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane
147 digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad
151 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
155 charge = digits[3] + fMask;
156 digits[4] = 0; // No signal due to physics since this is now background.
158 digits[5] = iHit+fMask; // Hit number in the list
161 Info("MakeTransientDigitsFromHit",
162 "DisIntegration result %d: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d",
163 iTD, digits[0], digits[1], digits[2], digits[3], digits[5]);
165 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits);
166 mTD->AddToTrackList(track + fMask, charge);
168 OnCreateTransientDigit(mTD, mHit);
169 AddOrUpdateTransientDigit(mTD);
173 //------------------------------------------------------------------------
174 void AliMUONDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
176 // Derived to add digits to TreeD.
177 muondata->AddDigit(chamber, tracks, charges, digits);
180 //------------------------------------------------------------------------
181 Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
183 // Derived to apply the chamber response model to the digit.
184 // Using AliMUONChamber::ResponseModel() for this.
187 Info("GetSignalFrom", "Applying response of chamber to TransientDigit signal.");
189 // Digit Response (noise, threshold, saturation, ...)
190 Int_t q = td->Signal();
191 AliMUONChamber& chamber = pMUON->Chamber(td->Chamber());
192 AliMUONResponse* response = chamber.ResponseModel();
193 q = response->DigitResponse(q, td);
197 //------------------------------------------------------------------------
198 Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
200 // Derived to initialize the output digits tree TreeD, create it if necessary
201 // and sets the muondata tree address to treeD.
204 Info("InitOutputData", "Creating digits branch and setting the tree address.");
206 muondata->SetLoader(muonloader);
208 // New branch per chamber for MUON digit in the tree of digits
209 if (muonloader->TreeD() == NULL)
211 muonloader->MakeDigitsContainer();
212 if (muonloader->TreeD() == NULL)
214 Error("InitOutputData", "Could not create TreeD.");
219 muondata->MakeBranch("D");
220 muondata->SetTreeAddress("D");
225 //------------------------------------------------------------------------
226 void AliMUONDigitizerv1::FillOutputData()
228 // Derived to fill TreeD and resets the digit array in muondata.
230 if (GetDebug() > 2) Info("FillOutputData", "Filling trees with digits.");
232 muondata->ResetDigits();
235 //------------------------------------------------------------------------
236 void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
238 // Derived to write the digits tree and then unload the digits tree once written.
240 if (GetDebug() > 2) Info("CleanupOutputData", "Writing digits and releasing pointers.");
241 muonloader->WriteDigits("OVERWRITE");
242 muonloader->UnloadDigits();
246 //------------------------------------------------------------------------
247 Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader)
249 // Derived to initialise the input to read from TreeH the hits tree.
250 // If the hits are not loaded then we load the hits using the muon loader.
253 Info("InitInputData", "Loading hits in READ mode and setting the tree address.");
255 muondata->SetLoader(muonloader);
257 if (muonloader->TreeH() == NULL)
259 muonloader->LoadHits("READ");
260 if (muonloader->TreeH() == NULL)
262 Error("InitInputData", "Can not load the hits tree.");
267 muondata->SetTreeAddress("H");
271 //------------------------------------------------------------------------
272 void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
274 // Derived to release the loaded hits and unload them.
276 if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded hits.");
277 muondata->ResetHits();
278 muonloader->UnloadHits();