]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSDigitizerv1.cxx
remove obsolete flange (Pascal)
[u/mrichter/AliRoot.git] / MUON / AliMUONSDigitizerv1.cxx
CommitLineData
30178c30 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
cf286af7 17
18/////////////////////////////////////////////////////////////////////////////////
19//
20// AliMUONSDigitizerv1 digitizes hits from the input stream into s-digits.
21// The s-digits are written to the s-digit tree TreeS.
22// The same algorithm is implemented as for AliMUONDigitizerv1 however the
23// chamber response is not applied to the s-digits and we write to TreeS and
24// not TreeD.
25//
26/////////////////////////////////////////////////////////////////////////////////
d1775029 27
30178c30 28#include "AliMUONSDigitizerv1.h"
38169520 29#include "AliMUON.h"
30178c30 30#include "AliMUONLoader.h"
38169520 31#include "AliMUONConstants.h"
32#include "AliMUONChamber.h"
30178c30 33#include "AliMUONData.h"
34#include "AliMUONDigit.h"
38169520 35#include "AliMUONHit.h"
30178c30 36#include "AliMUONTransientDigit.h"
8c343c7c 37#include "AliLog.h"
30178c30 38
d1775029 39ClassImp(AliMUONSDigitizerv1)
40
41//___________________________________________
30178c30 42AliMUONSDigitizerv1::AliMUONSDigitizerv1()
38169520 43 : AliMUONDigitizer()
d1775029 44{
cf286af7 45 // Default ctor - don't use it
d1775029 46}
47
cf286af7 48//___________________________________________
30178c30 49AliMUONSDigitizerv1::AliMUONSDigitizerv1(AliRunDigitizer* manager)
38169520 50 : AliMUONDigitizer(manager)
d1775029 51{
cf286af7 52 // ctor which should be used
d1775029 53}
54
8789635b 55//___________________________________________
56AliMUONSDigitizerv1::~AliMUONSDigitizerv1()
57{
58 // Destructor
59}
60
38169520 61//-----------------------------------------------------------------------
62void AliMUONSDigitizerv1::GenerateTransientDigits()
63{
64// Loops over all tracks and hits in the current selected event and calls
65// MakeTransientDigitsFromHit for each hit.
66// Note: Charge correlation is applied to the tracking chambers.
67
68 TTree* treeH = fGime->TreeH();
69 AliDebug(2, Form("Generating transient digits using treeH = 0x%X"
70 , (void*)treeH));
71 //
72 // Loop over tracks
73 Int_t ntracks = (Int_t) treeH->GetEntries();
74 for (Int_t itrack = 0; itrack < ntracks; itrack++)
75 {
76 AliDebug(3, Form("Processing track %d...", itrack));
77 fMUONData->ResetHits();
78 treeH->GetEvent(itrack);
79 //
80 // Loop over hits
81 TClonesArray* hits = fMUONData->Hits();
82 for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++)
83 {
84 AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) );
85 Int_t ichamber = mHit->Chamber()-1; // chamber number
86 if (ichamber > AliMUONConstants::NCh()-1)
87 {
88 AliError(Form("Hit 0x%X has a invalid chamber number: %d", ichamber));
89 continue;
90 }
91 //
92 //Dumping Hit content:
93 AliDebug(3,Form("Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f",
94 ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss()
95 ));
96 //
97 // Inititializing Correlation
98 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
99 chamber.ChargeCorrelationInit();
100 if (ichamber < AliMUONConstants::NTrackingCh())
101 {
102 // Tracking Chamber
103 // Initialize hit position (cursor) in the segmentation model
104 if (GetSegmentation() == 1) // old segmentation
105 chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z());
106 else
107 chamber.SigGenInit(mHit);
108
109 } // else do nothing for Trigger Chambers
110
111 MakeTransientDigitsFromHit(itrack, ihit, mHit);
112 } // hit loop
113 } // track loop
114}
115
116//--------------------------------------------------------------------------
117void AliMUONSDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
118{
119// This method is called for every hit in an event to generate AliMUONTransientDigits
120// from the hit and add these to fTDList.
121// The AliMUONChamber::DisIntegration method us used to figure out which pads are
122// fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit
123// for each pad.
124
125 AliDebug(4,Form("Making transient digit for hit number %d.", iHit));
126
127 //
128 // Calls the charge disintegration method of the current chamber
129 AliDebug(5,"Calling AliMUONChamber::DisIngtegration...");
130
131 Float_t newdigit[6][500]; // Pad information
132 Int_t nnew=0; // Number of touched Pads per hit
133 Int_t ichamber = mHit->Chamber()-1;
134 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
135 if (GetSegmentation() == 1)
136 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
137 else
138 chamber.DisIntegration(mHit, nnew, newdigit);
139
140 // Creating new TransientDigits from hit
141 for(Int_t iTD = 0; iTD < nnew; iTD++)
142 {
143 Int_t charge;
144 Int_t digits[7];
145
146 digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit
147 digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit
148 digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane
149 digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad
150 if (fSignal)
151 {
152 charge = digits[3];
153 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
154 }
155 else
156 {
157 charge = digits[3] + fMask;
158 digits[4] = 0; // No signal due to physics since this is now background.
159 }
160 digits[5] = iHit+fMask; // Hit number in the list
161 if (GetSegmentation() == 1)
162 digits[6] = 0;
163 else
164 digits[6] = mHit->DetElemId();
165
166 AliDebug(5,Form("MakeTransientDigitsFromHit",
167 "DisIntegration result %d: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d\tidDE %d",
168 iTD, digits[0], digits[1], digits[2], digits[3], digits[5], digits[6]));
169
170 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits);
171 mTD->AddToTrackList(track + fMask, charge);
172
173 OnCreateTransientDigit(mTD, mHit);
174 AddOrUpdateTransientDigit(mTD);
175 }
176}
177
d1775029 178//------------------------------------------------------------------------
a713db22 179void AliMUONSDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7])
d1775029 180{
cf286af7 181// Derived to write to the s-digit tree TreeS.
d1775029 182
30178c30 183 fMUONData->AddSDigit(chamber, tracks, charges, digits);
925e6570 184}
d1775029 185
186//------------------------------------------------------------------------
cf286af7 187Int_t AliMUONSDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
d1775029 188{
cf286af7 189// Returns the transient digit signal as is without applying the chamber response.
8c343c7c 190 AliDebug(4,"Returning TransientDigit signal.");
cf286af7 191 return td->Signal();
925e6570 192}
d1775029 193
194//------------------------------------------------------------------------
cf286af7 195Bool_t AliMUONSDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
d1775029 196{
cf286af7 197// Overridden to initialise the output tree to be TreeS rather than TreeD.
8c343c7c 198 AliDebug(3,"Creating s-digits branch and setting the tree address.");
cf286af7 199
30178c30 200 fMUONData->SetLoader(muonloader);
cf286af7 201
202 // New branch per chamber for MUON digit in the tree of digits
203 if (muonloader->TreeS() == NULL)
204 {
205 muonloader->MakeSDigitsContainer();
206 if (muonloader->TreeS() == NULL)
207 {
8c343c7c 208 AliError("Could not create TreeS.");
cf286af7 209 return kFALSE;
925e6570 210 }
211 }
cf286af7 212
30178c30 213 fMUONData->MakeBranch("S");
214 fMUONData->SetTreeAddress("S");
d1775029 215
cf286af7 216 return kTRUE;
925e6570 217}
d1775029 218
cf286af7 219//------------------------------------------------------------------------
220void AliMUONSDigitizerv1::FillOutputData()
221{
222// Overridden to fill TreeS rather than TreeD.
d1775029 223
8c343c7c 224 AliDebug(3,"Filling trees with s-digits.");
30178c30 225 fMUONData->Fill("S");
226 fMUONData->ResetSDigits();
925e6570 227}
d1775029 228
d1775029 229//------------------------------------------------------------------------
cf286af7 230void AliMUONSDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
d1775029 231{
cf286af7 232// Overridden to write and then cleanup TreeS that was initialised in InitOutputData.
8c343c7c 233 AliDebug(3,"Writing s-digits and releasing pointers.");
cf286af7 234 muonloader->WriteSDigits("OVERWRITE");
30178c30 235 fMUONData->ResetSDigits();
cf286af7 236 muonloader->UnloadSDigits();
925e6570 237}
38169520 238
239//------------------------------------------------------------------------
240Bool_t AliMUONSDigitizerv1::InitInputData(AliMUONLoader* muonloader)
241{
242// Derived to initialise the input to read from TreeH the hits tree.
243// If the hits are not loaded then we load the hits using the muon loader.
244
245 AliDebug(3, "Loading hits in READ mode and setting the tree address.");
246
247 fMUONData->SetLoader(muonloader);
248
249 if (muonloader->TreeH() == NULL)
250 {
251 muonloader->LoadHits("READ");
252 if (muonloader->TreeH() == NULL)
253 {
254 AliError("Can not load the hits tree.");
255 return kFALSE;
256 }
257 }
258
259 fMUONData->SetTreeAddress("H");
260 return kTRUE;
261}
262
263//------------------------------------------------------------------------
264void AliMUONSDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
265{
266// Derived to release the loaded hits and unload them.
267
268 AliDebug(3, "Releasing loaded hits.");
269 fMUONData->ResetHits();
270 muonloader->UnloadHits();
271}
272