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 void AliMUONDigitizerv1::GenerateTransientDigits()
55 // Loops over all tracks and hits in the current selected event and calls
56 // MakeTransientDigitsFromHit for each hit.
57 // Note: Charge correlation is applied to the tracking chambers.
59 TTree* treeH = gime->TreeH();
61 Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X"
65 Int_t ntracks = (Int_t) treeH->GetEntries();
66 for (Int_t itrack = 0; itrack < ntracks; itrack++)
68 if (GetDebug() > 2) Info("GenerateTransientDigits", "Processing track %d...", itrack);
69 muondata->ResetHits();
70 treeH->GetEvent(itrack);
73 TClonesArray* hits = muondata->Hits();
74 for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++)
76 AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) );
77 Int_t ichamber = mHit->Chamber()-1; // chamber number
78 if (ichamber > AliMUONConstants::NCh()-1)
80 Error("GenerateTransientDigits",
81 "Hit 0x%X has a invalid chamber number: %d", ichamber);
85 //Dumping Hit content:
88 Info("GenerateTransientDigits",
89 "Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f",
90 ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss()
94 // Inititializing Correlation
95 AliMUONChamber& chamber = pMUON->Chamber(ichamber);
96 chamber.ChargeCorrelationInit();
97 if (ichamber < AliMUONConstants::NTrackingCh())
100 // Initialize hit position (cursor) in the segmentation model
101 chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z());
102 }; // else do nothing for Trigger Chambers
104 MakeTransientDigitsFromHit(itrack, ihit, mHit);
109 //--------------------------------------------------------------------------
110 void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
112 // This method is called for every hit in an event to generate AliMUONTransientDigits
113 // from the hit and add these to fTDList.
114 // The AliMUONChamber::DisIntegration method us used to figure out which pads are
115 // fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit
119 Info("MakeTransientDigitsFromHit", "Making transient digit for hit number %d.", iHit);
122 // Calls the charge disintegration method of the current chamber
124 Info("MakeTransientDigitsFromHit", "Calling AliMUONChamber::DisIngtegration...");
126 Float_t newdigit[6][500]; // Pad information
127 Int_t nnew=0; // Number of touched Pads per hit
128 Int_t ichamber = mHit->Chamber()-1;
129 AliMUONChamber& chamber = pMUON->Chamber(ichamber);
130 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
132 // Creating new TransientDigits from hit
133 for(Int_t iTD = 0; iTD < nnew; iTD++)
138 digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit
139 digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit
140 digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane
141 digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad
145 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
149 charge = digits[3] + fMask;
150 digits[4] = 0; // No signal due to physics since this is now background.
152 digits[5] = iHit+fMask; // Hit number in the list
155 Info("MakeTransientDigitsFromHit",
156 "DisIntegration result %d: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d",
157 iTD, digits[0], digits[1], digits[2], digits[3], digits[5]);
159 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits);
160 mTD->AddToTrackList(track + fMask, charge);
162 OnCreateTransientDigit(mTD, mHit);
163 AddOrUpdateTransientDigit(mTD);
167 //------------------------------------------------------------------------
168 void AliMUONDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
170 // Derived to add digits to TreeD.
171 muondata->AddDigit(chamber, tracks, charges, digits);
174 //------------------------------------------------------------------------
175 Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
177 // Derived to apply the chamber response model to the digit.
178 // Using AliMUONChamber::ResponseModel() for this.
181 Info("GetSignalFrom", "Applying response of chamber to TransientDigit signal.");
183 // Digit Response (noise, threshold, saturation, ...)
184 Int_t q = td->Signal();
185 AliMUONChamber& chamber = pMUON->Chamber(td->Chamber());
186 AliMUONResponse* response = chamber.ResponseModel();
187 q = response->DigitResponse(q, td);
191 //------------------------------------------------------------------------
192 Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
194 // Derived to initialize the output digits tree TreeD, create it if necessary
195 // and sets the muondata tree address to treeD.
198 Info("InitOutputData", "Creating digits branch and setting the tree address.");
200 muondata->SetLoader(muonloader);
202 // New branch per chamber for MUON digit in the tree of digits
203 if (muonloader->TreeD() == NULL)
205 muonloader->MakeDigitsContainer();
206 if (muonloader->TreeD() == NULL)
208 Error("InitOutputData", "Could not create TreeD.");
213 muondata->MakeBranch("D");
214 muondata->SetTreeAddress("D");
219 //------------------------------------------------------------------------
220 void AliMUONDigitizerv1::FillOutputData()
222 // Derived to fill TreeD and resets the digit array in muondata.
224 if (GetDebug() > 2) Info("FillOutputData", "Filling trees with digits.");
226 muondata->ResetDigits();
229 //------------------------------------------------------------------------
230 void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
232 // Derived to write the digits tree and then unload the digits tree once written.
234 if (GetDebug() > 2) Info("CleanupOutputData", "Writing digits and releasing pointers.");
235 muonloader->WriteDigits("OVERWRITE");
236 muonloader->UnloadDigits();
240 //------------------------------------------------------------------------
241 Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader)
243 // Derived to initialise the input to read from TreeH the hits tree.
244 // If the hits are not loaded then we load the hits using the muon loader.
247 Info("InitInputData", "Loading hits in READ mode and setting the tree address.");
249 muondata->SetLoader(muonloader);
251 if (muonloader->TreeH() == NULL)
253 muonloader->LoadHits("READ");
254 if (muonloader->TreeH() == NULL)
256 Error("InitInputData", "Can not load the hits tree.");
261 muondata->SetTreeAddress("H");
265 //------------------------------------------------------------------------
266 void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
268 // Derived to release the loaded hits and unload them.
270 if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded hits.");
271 muondata->ResetHits();
272 muonloader->UnloadHits();