]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigitizerv1.cxx
restore destructor
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizerv1.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// 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.
25//
26// NOTE: This digitizer will become depricated in the future in favour of
27// AliMUONSDigitizerv1 and AliMUONDigitizerv2.
28//
29/////////////////////////////////////////////////////////////////////////////////
8dbbc4e3 30
30178c30 31#include <TTree.h>
32
33#include "AliMUON.h"
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"
ce3e25a8 41#include "AliMUONTriggerDecision.h"
8c343c7c 42#include "AliLog.h"
30178c30 43
8dbbc4e3 44ClassImp(AliMUONDigitizerv1)
45
46//___________________________________________
cf286af7 47AliMUONDigitizerv1::AliMUONDigitizerv1() : AliMUONDigitizer()
8dbbc4e3 48{
cf286af7 49 // Default ctor - don't use it
8dbbc4e3 50}
51
52//___________________________________________
cf286af7 53AliMUONDigitizerv1::AliMUONDigitizerv1(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
8dbbc4e3 54{
cf286af7 55 // ctor which should be used
ce3e25a8 56
8dbbc4e3 57}
58
8789635b 59//___________________________________________
60AliMUONDigitizerv1::~AliMUONDigitizerv1()
61{
ce3e25a8 62 // dtor
63}
64//-----------------------------------------------------------------------
65
66void AliMUONDigitizerv1::CleanupTriggerArrays()
67{
68 fTrigDec->ClearDigits();
8789635b 69}
70
cf286af7 71//-----------------------------------------------------------------------
72void AliMUONDigitizerv1::GenerateTransientDigits()
73{
74// Loops over all tracks and hits in the current selected event and calls
75// MakeTransientDigitsFromHit for each hit.
76// Note: Charge correlation is applied to the tracking chambers.
77
30178c30 78 TTree* treeH = fGime->TreeH();
8c343c7c 79 AliDebug(2, Form("Generating transient digits using treeH = 0x%X"
80 , (void*)treeH));
cf286af7 81 //
82 // Loop over tracks
83 Int_t ntracks = (Int_t) treeH->GetEntries();
84 for (Int_t itrack = 0; itrack < ntracks; itrack++)
85 {
8c343c7c 86 AliDebug(3, Form("Processing track %d...", itrack));
30178c30 87 fMUONData->ResetHits();
cf286af7 88 treeH->GetEvent(itrack);
89 //
90 // Loop over hits
30178c30 91 TClonesArray* hits = fMUONData->Hits();
cf286af7 92 for (Int_t ihit = 0; ihit < hits->GetEntriesFast(); ihit++)
93 {
94 AliMUONHit* mHit = static_cast<AliMUONHit*>( hits->At(ihit) );
95 Int_t ichamber = mHit->Chamber()-1; // chamber number
96 if (ichamber > AliMUONConstants::NCh()-1)
97 {
8c343c7c 98 AliError(Form("Hit 0x%X has a invalid chamber number: %d", ichamber));
cf286af7 99 continue;
100 }
101 //
102 //Dumping Hit content:
8c343c7c 103 AliDebug(3,Form("Hit %d: chamber = %d\tX = %f\tY = %f\tZ = %f\teloss = %f",
cf286af7 104 ihit, mHit->Chamber(), mHit->X(), mHit->Y(), mHit->Z(), mHit->Eloss()
8c343c7c 105 ));
cf286af7 106 //
107 // Inititializing Correlation
30178c30 108 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
cf286af7 109 chamber.ChargeCorrelationInit();
110 if (ichamber < AliMUONConstants::NTrackingCh())
111 {
112 // Tracking Chamber
113 // Initialize hit position (cursor) in the segmentation model
a713db22 114 if (GetSegmentation() == 1) // old segmentation
115 chamber.SigGenInit(mHit->X(), mHit->Y(), mHit->Z());
116 else
117 chamber.SigGenInit(mHit);
118
925e6570 119 } // else do nothing for Trigger Chambers
cf286af7 120
121 MakeTransientDigitsFromHit(itrack, ihit, mHit);
122 } // hit loop
123 } // track loop
925e6570 124}
cf286af7 125
126//--------------------------------------------------------------------------
127void AliMUONDigitizerv1::MakeTransientDigitsFromHit(Int_t track, Int_t iHit, AliMUONHit * mHit)
128{
129// This method is called for every hit in an event to generate AliMUONTransientDigits
130// from the hit and add these to fTDList.
131// The AliMUONChamber::DisIntegration method us used to figure out which pads are
132// fired for a given hit. We then loop over the fired pads and add an AliMUONTransientDigit
133// for each pad.
134
8c343c7c 135 AliDebug(4,Form("Making transient digit for hit number %d.", iHit));
cf286af7 136
137 //
138 // Calls the charge disintegration method of the current chamber
8c343c7c 139 AliDebug(5,"Calling AliMUONChamber::DisIngtegration...");
cf286af7 140
141 Float_t newdigit[6][500]; // Pad information
142 Int_t nnew=0; // Number of touched Pads per hit
143 Int_t ichamber = mHit->Chamber()-1;
30178c30 144 AliMUONChamber& chamber = fMUON->Chamber(ichamber);
a713db22 145 if (GetSegmentation() == 1)
146 chamber.DisIntegration(mHit->Eloss(), mHit->Age(), mHit->X(), mHit->Y(), mHit->Z(), nnew, newdigit);
147 else
148 chamber.DisIntegration(mHit, nnew, newdigit);
cf286af7 149
150 // Creating new TransientDigits from hit
151 for(Int_t iTD = 0; iTD < nnew; iTD++)
152 {
153 Int_t charge;
a713db22 154 Int_t digits[7];
cf286af7 155
156 digits[0] = Int_t(newdigit[1][iTD]); // Padx of the Digit
157 digits[1] = Int_t(newdigit[2][iTD]); // Pady of the Digit
158 digits[2] = Int_t(newdigit[5][iTD]); // Cathode plane
159 digits[3] = Int_t(newdigit[3][iTD]); // Induced charge in the Pad
160 if (fSignal)
161 {
162 charge = digits[3];
163 digits[4] = Int_t(newdigit[3][iTD]); // Signal due to physics
164 }
165 else
166 {
167 charge = digits[3] + fMask;
168 digits[4] = 0; // No signal due to physics since this is now background.
925e6570 169 }
cf286af7 170 digits[5] = iHit+fMask; // Hit number in the list
a713db22 171 if (GetSegmentation() == 1)
172 digits[6] = 0;
173 else
174 digits[6] = mHit->DetElemId();
cf286af7 175
8c343c7c 176 AliDebug(5,Form("MakeTransientDigitsFromHit",
a713db22 177 "DisIntegration result %d: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d\tidDE %d",
178 iTD, digits[0], digits[1], digits[2], digits[3], digits[5], digits[6]));
cf286af7 179
180 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(ichamber, digits);
181 mTD->AddToTrackList(track + fMask, charge);
182
183 OnCreateTransientDigit(mTD, mHit);
184 AddOrUpdateTransientDigit(mTD);
925e6570 185 }
186}
cf286af7 187
8dbbc4e3 188//------------------------------------------------------------------------
a713db22 189void AliMUONDigitizerv1::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7])
8dbbc4e3 190{
cf286af7 191// Derived to add digits to TreeD.
ce3e25a8 192 fMUONData->AddDigit(chamber, tracks, charges, digits);
925e6570 193}
ce3e25a8 194
195//------------------------------------------------------------------------
a713db22 196void AliMUONDigitizerv1::AddDigitTrigger(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7])
ce3e25a8 197{
198// Derived to add digits to TreeD for trigger.
199 fTrigDec->AddDigit(chamber, tracks, charges, digits);
925e6570 200}
ce3e25a8 201
202//------------------------------------------------------------------------
203void AliMUONDigitizerv1::FillTriggerOutput()
204{
205// Derived to fill TreeD and resets the trigger array in fMUONData.
206
8c343c7c 207 AliDebug(3,"Filling trees with trigger.");
ce3e25a8 208 fMUONData->Fill("GLT");
209 fMUONData->ResetTrigger();
925e6570 210}
ce3e25a8 211
212//------------------------------------------------------------------------
213void AliMUONDigitizerv1::CreateTrigger()
214{
215 fMUONData->MakeBranch("GLT");
216 fMUONData->SetTreeAddress("GLT");
217 fTrigDec->Digits2Trigger();
218 FillTriggerOutput();
219
925e6570 220}
8dbbc4e3 221
222//------------------------------------------------------------------------
cf286af7 223Int_t AliMUONDigitizerv1::GetSignalFrom(AliMUONTransientDigit* td)
8dbbc4e3 224{
cf286af7 225// Derived to apply the chamber response model to the digit.
226// Using AliMUONChamber::ResponseModel() for this.
227
8c343c7c 228 AliDebug(4, "Applying response of chamber to TransientDigit signal.");
cf286af7 229 //
230 // Digit Response (noise, threshold, saturation, ...)
231 Int_t q = td->Signal();
30178c30 232 AliMUONChamber& chamber = fMUON->Chamber(td->Chamber());
cf286af7 233 AliMUONResponse* response = chamber.ResponseModel();
234 q = response->DigitResponse(q, td);
235 return q;
925e6570 236}
8dbbc4e3 237
238//------------------------------------------------------------------------
cf286af7 239Bool_t AliMUONDigitizerv1::InitOutputData(AliMUONLoader* muonloader)
8dbbc4e3 240{
cf286af7 241// Derived to initialize the output digits tree TreeD, create it if necessary
30178c30 242// and sets the fMUONData tree address to treeD.
cf286af7 243
8c343c7c 244 AliDebug(3, "Creating digits branch and setting the tree address.");
cf286af7 245
30178c30 246 fMUONData->SetLoader(muonloader);
cf286af7 247
248 // New branch per chamber for MUON digit in the tree of digits
249 if (muonloader->TreeD() == NULL)
250 {
251 muonloader->MakeDigitsContainer();
252 if (muonloader->TreeD() == NULL)
253 {
8c343c7c 254 AliError("Could not create TreeD.");
cf286af7 255 return kFALSE;
925e6570 256 }
257 }
cf286af7 258
30178c30 259 fMUONData->MakeBranch("D");
260 fMUONData->SetTreeAddress("D");
cf286af7 261
262 return kTRUE;
925e6570 263}
8dbbc4e3 264
265//------------------------------------------------------------------------
cf286af7 266void AliMUONDigitizerv1::FillOutputData()
8dbbc4e3 267{
30178c30 268// Derived to fill TreeD and resets the digit array in fMUONData.
1391e633 269
8c343c7c 270 AliDebug(3, "Filling trees with digits.");
30178c30 271 fMUONData->Fill("D");
272 fMUONData->ResetDigits();
925e6570 273}
8dbbc4e3 274
275//------------------------------------------------------------------------
cf286af7 276void AliMUONDigitizerv1::CleanupOutputData(AliMUONLoader* muonloader)
8dbbc4e3 277{
cf286af7 278// Derived to write the digits tree and then unload the digits tree once written.
8dbbc4e3 279
8c343c7c 280 AliDebug(3, "Writing digits and releasing pointers.");
cf286af7 281 muonloader->WriteDigits("OVERWRITE");
282 muonloader->UnloadDigits();
925e6570 283}
8dbbc4e3 284
cf286af7 285
286//------------------------------------------------------------------------
287Bool_t AliMUONDigitizerv1::InitInputData(AliMUONLoader* muonloader)
8dbbc4e3 288{
cf286af7 289// Derived to initialise the input to read from TreeH the hits tree.
290// If the hits are not loaded then we load the hits using the muon loader.
291
8c343c7c 292 AliDebug(3, "Loading hits in READ mode and setting the tree address.");
cf286af7 293
30178c30 294 fMUONData->SetLoader(muonloader);
cf286af7 295
296 if (muonloader->TreeH() == NULL)
297 {
298 muonloader->LoadHits("READ");
299 if (muonloader->TreeH() == NULL)
300 {
8c343c7c 301 AliError("Can not load the hits tree.");
cf286af7 302 return kFALSE;
925e6570 303 }
304 }
cf286af7 305
30178c30 306 fMUONData->SetTreeAddress("H");
cf286af7 307 return kTRUE;
925e6570 308}
cf286af7 309
8dbbc4e3 310//------------------------------------------------------------------------
cf286af7 311void AliMUONDigitizerv1::CleanupInputData(AliMUONLoader* muonloader)
8dbbc4e3 312{
cf286af7 313// Derived to release the loaded hits and unload them.
314
8c343c7c 315 AliDebug(3, "Releasing loaded hits.");
30178c30 316 fMUONData->ResetHits();
cf286af7 317 muonloader->UnloadHits();
925e6570 318}
cf286af7 319