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