]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigitizerv2.cxx
remove calls to AliMUONTriggerDecision
[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
38169520 31#include "AliMUON.h"
30178c30 32#include "AliMUONData.h"
33#include "AliMUONLoader.h"
34#include "AliMUONConstants.h"
38169520 35#include "AliMUONChamber.h"
30178c30 36#include "AliMUONDigit.h"
37#include "AliMUONDigitizerv2.h"
38#include "AliMUONTransientDigit.h"
8c343c7c 39#include "AliLog.h"
30178c30 40
d1775029 41ClassImp(AliMUONDigitizerv2)
42
43//___________________________________________
38169520 44AliMUONDigitizerv2::AliMUONDigitizerv2() : AliMUONDigitizer()
d1775029 45{
d19b6003 46/// Default ctor - don't use it
d1775029 47}
48
49//___________________________________________
38169520 50AliMUONDigitizerv2::AliMUONDigitizerv2(AliRunDigitizer* manager) : AliMUONDigitizer(manager)
d1775029 51{
d19b6003 52/// ctor which should be used
d1775029 53}
54
8789635b 55//___________________________________________
56AliMUONDigitizerv2::~AliMUONDigitizerv2()
57{
d19b6003 58/// Destructor
8789635b 59}
60
cf286af7 61//-----------------------------------------------------------------------
62void AliMUONDigitizerv2::GenerateTransientDigits()
d1775029 63{
d19b6003 64/// Loop over all chambers and s-digits in the input stream and create
65/// AliMUONTransientDigit objects from them. These are then added to fTDList.
d1775029 66
8c343c7c 67 AliDebug(2,"Generating transient digits using treeH = 0x%X");
cf286af7 68 //
69 // Loop over SDigits
70 Int_t ndig, k;
71 AliMUONDigit* sDigit;
72 TClonesArray* muonSDigits;
73 for (Int_t ich = 0; ich < AliMUONConstants::NCh(); ich++) // loop over chamber
74 {
30178c30 75 fMUONData->ResetSDigits();
935b9895 76 fMUONData->GetSDigits();
30178c30 77 muonSDigits = fMUONData->SDigits(ich);
cf286af7 78 ndig = muonSDigits->GetEntriesFast();
79 for (k = 0; k < ndig; k++)
80 {
81 sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
82 MakeTransientDigitFromSDigit(ich,sDigit);
83 }
935b9895 84// fMUONData->ResetSDigits();
85// fMUONData->GetCathodeS(1);
86// muonSDigits = fMUONData->SDigits(ich);
87// ndig=muonSDigits->GetEntriesFast();
88// for (k = 0; k < ndig; k++)
89// {
90// sDigit = (AliMUONDigit*) muonSDigits->UncheckedAt(k);
91// MakeTransientDigitFromSDigit(ich,sDigit);
92// }
cf286af7 93 } // SDigits loop, end loop over chamber
925e6570 94}
d1775029 95
96//------------------------------------------------------------------------
cf286af7 97void AliMUONDigitizerv2::MakeTransientDigitFromSDigit(Int_t iChamber, AliMUONDigit* sDigit)
d1775029 98{
d19b6003 99/// Makes a transient digit from the specified s-digit from the specified chamber.
100/// Once the digit is created it is added to the fTDList.
d1775029 101
8c343c7c 102 AliDebug(4,Form("Making transient digit from s-digit for chamber %d.", iChamber));
a713db22 103 Int_t digits[7];
cf286af7 104 //
105 // Creating a new TransientDigits from SDigit
106 digits[0] = sDigit->PadX(); // Padx of the Digit
107 digits[1] = sDigit->PadY(); // Pady of the Digit
108 digits[2] = sDigit->Cathode()+1; // Cathode plane
109 digits[3] = sDigit->Signal(); // Induced charge in the Pad
110 if (fSignal)
111 digits[4] = sDigit->Signal();
112 else
113 digits[4] = 0;
114
115 digits[5] = sDigit->Hit(); // Hit number in the list
002920d1 116 digits[6] = sDigit->DetElemId();
a713db22 117
118 AliDebug(5,Form("Made digit from sDigit 0x%X: PadX %d\tPadY %d\tPlane %d\tCharge %d\tHit %d\tidDE %d",
119 (void*)sDigit, digits[0], digits[1], digits[2], digits[3], digits[5], digits[6]));
cf286af7 120
cf286af7 121
122 AliMUONTransientDigit* mTD = new AliMUONTransientDigit(iChamber, digits);
123 // Copy list of tracks and trackcharge
64aa908b 124 for(Int_t itrack = 0; itrack < sDigit->Ntracks(); ++itrack)
cf286af7 125 {
126 Int_t track = sDigit->Track(itrack);
127 if (track < 0) break; // Check if we reached the end of the track list.
128 mTD->AddToTrackList( track + fMask, sDigit->TrackCharge(itrack) );
925e6570 129 }
cf286af7 130
131 OnCreateTransientDigit(mTD, sDigit);
132 AddOrUpdateTransientDigit(mTD);
925e6570 133}
d1775029 134
135//------------------------------------------------------------------------
a713db22 136void AliMUONDigitizerv2::AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7])
d1775029 137{
d19b6003 138/// Override to add new digits to the digits tree TreeD.
30178c30 139 fMUONData->AddDigit(chamber, tracks, charges, digits);
925e6570 140}
d1775029 141
38169520 142//------------------------------------------------------------------------
143Int_t AliMUONDigitizerv2::GetSignalFrom(AliMUONTransientDigit* td)
144{
d19b6003 145/// Derived to apply the chamber response model to the digit.
146/// Using AliMUONChamber::ResponseModel() for this.
38169520 147
148 AliDebug(4, "Applying response of chamber to TransientDigit signal.");
149 //
150 // Digit Response (noise, threshold, saturation, ...)
151 Int_t q = td->Signal();
152 AliMUONChamber& chamber = fMUON->Chamber(td->Chamber());
153 AliMUONResponse* response = chamber.ResponseModel();
154 q = response->DigitResponse(q, td);
c0d7bac8 155 if ( q >= response->Saturation() )
156 {
157 td->Saturated(kTRUE);
158 }
38169520 159 return q;
160}
161
cf286af7 162//------------------------------------------------------------------------
163Bool_t AliMUONDigitizerv2::InitInputData(AliMUONLoader* muonloader)
d1775029 164{
d19b6003 165/// Overridden to initialize fMUONData to read from the s-digits tree TreeS.
166/// If the s-digits are not loaded then the muon loader is used to load the
167/// s-digits into memory.
d1775029 168
8c343c7c 169 AliDebug(3,"Loading s-digits in READ mode and setting the tree address.");
30178c30 170 fMUONData->SetLoader(muonloader);
d1775029 171
cf286af7 172 if (muonloader->TreeS() == NULL)
173 {
174 muonloader->LoadSDigits("READ");
175 if (muonloader->TreeS() == NULL)
176 {
8c343c7c 177 AliError("Can not load the s-digits tree.");
cf286af7 178 return kFALSE;
925e6570 179 }
180 }
be42eafc 181
30178c30 182 fMUONData->SetTreeAddress("S");
cf286af7 183 return kTRUE;
925e6570 184}
cf286af7 185
d1775029 186//------------------------------------------------------------------------
cf286af7 187void AliMUONDigitizerv2::CleanupInputData(AliMUONLoader* muonloader)
d1775029 188{
d19b6003 189/// Overridden to release and unload s-digits from memory.
cf286af7 190
8c343c7c 191 AliDebug(3,"Releasing loaded s-digits.");
30178c30 192 fMUONData->ResetSDigits();
cf286af7 193 muonloader->UnloadSDigits();
925e6570 194}
38169520 195
196//------------------------------------------------------------------------
197Bool_t AliMUONDigitizerv2::InitOutputData(AliMUONLoader* muonloader)
198{
d19b6003 199/// Derived to initialize the output digits tree TreeD, create it if necessary
200/// and sets the fMUONData tree address to treeD.
38169520 201
202 AliDebug(3, "Creating digits branch and setting the tree address.");
203
204 fMUONData->SetLoader(muonloader);
205
206 // New branch per chamber for MUON digit in the tree of digits
207 if (muonloader->TreeD() == NULL)
208 {
209 muonloader->MakeDigitsContainer();
210 if (muonloader->TreeD() == NULL)
211 {
212 AliError("Could not create TreeD.");
213 return kFALSE;
214 }
215 }
216
217 fMUONData->MakeBranch("D");
218 fMUONData->SetTreeAddress("D");
219
220 return kTRUE;
221}
222
223//------------------------------------------------------------------------
224void AliMUONDigitizerv2::FillOutputData()
225{
d19b6003 226/// Derived to fill TreeD and resets the digit array in fMUONData.
38169520 227
228 AliDebug(3, "Filling trees with digits.");
229 fMUONData->Fill("D");
230 fMUONData->ResetDigits();
231}
232
233//------------------------------------------------------------------------
234void AliMUONDigitizerv2::CleanupOutputData(AliMUONLoader* muonloader)
235{
d19b6003 236/// Derived to write the digits tree and then unload the digits tree once written.
38169520 237
238 AliDebug(3, "Writing digits and releasing pointers.");
239 muonloader->WriteDigits("OVERWRITE");
240 muonloader->UnloadDigits();
241}
242
38169520 243