]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigitizerv2.cxx
In stand-allone mode, pass stack to entries.
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizerv2.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$ */
d1775029 17
18// Do the Digitization (Digit) from summable Digits (SDigit)
19// Allow the merging of signal file with background file(s).
20
cf286af7 21/////////////////////////////////////////////////////////////////////////////////
22//
23// AliMUONDigitizerv2 digitizes digits from s-digits.
24// Merging is allowed from multiple input streams. The first input stream is
25// assumed to be the signal and all other input streams as assumed to be
26// background.
27// Chamber response is applied to the digits identically to AliMUONDigitizerv1.
28//
29/////////////////////////////////////////////////////////////////////////////////
30
30178c30 31#include "AliMUONData.h"
32#include "AliMUONLoader.h"
33#include "AliMUONConstants.h"
34#include "AliMUONDigit.h"
35#include "AliMUONDigitizerv2.h"
36#include "AliMUONTransientDigit.h"
37
d1775029 38ClassImp(AliMUONDigitizerv2)
39
40//___________________________________________
cf286af7 41AliMUONDigitizerv2::AliMUONDigitizerv2() : AliMUONDigitizerv1()
d1775029 42{
cf286af7 43 // Default ctor - don't use it
d1775029 44}
45
46//___________________________________________
cf286af7 47AliMUONDigitizerv2::AliMUONDigitizerv2(AliRunDigitizer* manager) : AliMUONDigitizerv1(manager)
d1775029 48{
cf286af7 49 // ctor which should be used
d1775029 50}
51
8789635b 52//___________________________________________
53AliMUONDigitizerv2::~AliMUONDigitizerv2()
54{
55 // Destructor
56}
57
cf286af7 58//-----------------------------------------------------------------------
59void AliMUONDigitizerv2::GenerateTransientDigits()
d1775029 60{
cf286af7 61// Loop over all chambers and s-digits in the input stream and create
62// AliMUONTransientDigit objects from them. These are then added to fTDList.
d1775029 63
cf286af7 64 if (GetDebug() > 1)
65 Info("GenerateTransientDigits", "Generating transient digits using treeH = 0x%X");
d1775029 66
cf286af7 67 //
68 // Loop over SDigits
69 Int_t ndig, k;
70 AliMUONDigit* sDigit;
71 TClonesArray* muonSDigits;
72 for (Int_t ich = 0; ich < AliMUONConstants::NCh(); ich++) // loop over chamber
73 {
30178c30 74 fMUONData->ResetSDigits();
75 fMUONData->GetCathodeS(0);
76 muonSDigits = fMUONData->SDigits(ich);
cf286af7 77 ndig = muonSDigits->GetEntriesFast();
78 for (k = 0; k < ndig; k++)
79 {
80 sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
81 MakeTransientDigitFromSDigit(ich,sDigit);
82 }
30178c30 83 fMUONData->ResetSDigits();
84 fMUONData->GetCathodeS(1);
85 muonSDigits = fMUONData->SDigits(ich);
cf286af7 86 ndig=muonSDigits->GetEntriesFast();
87 for (k = 0; k < ndig; k++)
88 {
89 sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
90 MakeTransientDigitFromSDigit(ich,sDigit);
91 };
92 } // SDigits loop, end loop over chamber
93};
d1775029 94
95//------------------------------------------------------------------------
cf286af7 96void AliMUONDigitizerv2::MakeTransientDigitFromSDigit(Int_t iChamber, AliMUONDigit* sDigit)
d1775029 97{
cf286af7 98// Makes a transient digit from the specified s-digit from the specified chamber.
99// Once the digit is created it is added to the fTDList.
d1775029 100
cf286af7 101 if (GetDebug() > 3)
102 Info("MakeTransientDigitFromSDigit",
103 "Making transient digit from s-digit for chamber %d.", iChamber);
104
105 Int_t digits[6];
106 //
107 // Creating a new TransientDigits from SDigit
108 digits[0] = sDigit->PadX(); // Padx of the Digit
109 digits[1] = sDigit->PadY(); // Pady of the Digit
110 digits[2] = sDigit->Cathode()+1; // Cathode plane
111 digits[3] = sDigit->Signal(); // Induced charge in the Pad
112 if (fSignal)
113 digits[4] = sDigit->Signal();
114 else
115 digits[4] = 0;
116
117 digits[5] = sDigit->Hit(); // Hit number in the list
118
119 if (GetDebug() > 4)
120 Info("MakeTransientDigitFromSDigit",
121 "Made digit from sDigit 0x%X: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d",
122 (void*)sDigit, digits[0], digits[1], digits[2], digits[3], digits[5]);
123
124 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(iChamber, digits);
125 // Copy list of tracks and trackcharge
126 for(Int_t itrack = 0; itrack < kMAXTRACKS; itrack++)
127 {
128 Int_t track = sDigit->Track(itrack);
129 if (track < 0) break; // Check if we reached the end of the track list.
130 mTD->AddToTrackList( track + fMask, sDigit->TrackCharge(itrack) );
131 };
132
133 OnCreateTransientDigit(mTD, sDigit);
134 AddOrUpdateTransientDigit(mTD);
135};
d1775029 136
137//------------------------------------------------------------------------
cf286af7 138void AliMUONDigitizerv2::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6])
d1775029 139{
cf286af7 140// Override to add new digits to the digits tree TreeD.
30178c30 141 fMUONData->AddDigit(chamber, tracks, charges, digits);
cf286af7 142};
d1775029 143
cf286af7 144//------------------------------------------------------------------------
145Bool_t AliMUONDigitizerv2::InitInputData(AliMUONLoader* muonloader)
d1775029 146{
30178c30 147// Overridden to initialize fMUONData to read from the s-digits tree TreeS.
cf286af7 148// If the s-digits are not loaded then the muon loader is used to load the
149// s-digits into memory.
d1775029 150
cf286af7 151 if (GetDebug() > 2)
152 Info("InitInputData", "Loading s-digits in READ mode and setting the tree address.");
d1775029 153
30178c30 154 fMUONData->SetLoader(muonloader);
d1775029 155
cf286af7 156 if (muonloader->TreeS() == NULL)
157 {
158 muonloader->LoadSDigits("READ");
159 if (muonloader->TreeS() == NULL)
160 {
161 Error("InitInputData", "Can not load the s-digits tree.");
162 return kFALSE;
163 };
164 };
be42eafc 165
30178c30 166 fMUONData->SetTreeAddress("S");
cf286af7 167 return kTRUE;
168};
169
d1775029 170//------------------------------------------------------------------------
cf286af7 171void AliMUONDigitizerv2::CleanupInputData(AliMUONLoader* muonloader)
d1775029 172{
cf286af7 173// Overridden to release and unload s-digits from memory.
174
175 if (GetDebug() > 2) Info("CleanupInputData", "Releasing loaded s-digits.");
30178c30 176 fMUONData->ResetSDigits();
cf286af7 177 muonloader->UnloadSDigits();
178};