]>
Commit | Line | Data |
---|---|---|
e1aec4f9 | 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 | //This class produces PHOS trigger digits of one event. | |
16 | //Authors: Henrik Qvigstad, Boris Polishchuk. | |
17 | ||
18 | #include "AliPHOSTriggerRawDigiProducer.h" | |
19 | #include "AliPHOSTriggerRawReader.h" | |
20 | #include "AliPHOSTRURawReader.h" | |
21 | #include "AliPHOSTriggerParameters.h" | |
22 | #include "AliPHOSTriggerRawDigit.h" | |
23 | #include "AliPHOSGeometry.h" | |
24 | #include "AliRawReader.h" | |
25 | #include "AliCaloRawStreamV3.h" | |
26 | ||
27 | #include "TH1I.h" | |
28 | #include "TH2I.h" | |
29 | ||
30 | #include <iostream> | |
31 | using namespace std; | |
32 | ||
33 | ClassImp(AliPHOSTriggerRawDigiProducer) | |
34 | ||
35 | AliPHOSTriggerRawDigiProducer::AliPHOSTriggerRawDigiProducer() | |
36 | :fModules(kNMods, false), | |
37 | fSaturationThreshold(950), | |
38 | fParameters(0), | |
39 | fRawReader(0), | |
40 | fRawStream(0), | |
41 | fTriggerReader(0) | |
42 | {} | |
43 | ||
44 | AliPHOSTriggerRawDigiProducer::AliPHOSTriggerRawDigiProducer(AliRawReader *rawReader) | |
45 | :fModules(kNMods, false), | |
46 | fSaturationThreshold(950), | |
47 | fParameters(0), | |
48 | fRawReader(rawReader), | |
49 | fRawStream(0), | |
50 | fTriggerReader(new AliPHOSTriggerRawReader) | |
51 | { | |
52 | SetAnalyseModule(2); | |
53 | SetAnalyseModule(3); | |
54 | SetAnalyseModule(4); | |
55 | ||
56 | fRawStream = new AliCaloRawStreamV3(rawReader,"PHOS"); | |
57 | } | |
58 | ||
59 | AliPHOSTriggerRawDigiProducer::~AliPHOSTriggerRawDigiProducer() | |
60 | { | |
61 | delete fRawStream; | |
1cdbc516 | 62 | delete fTriggerReader; |
e1aec4f9 | 63 | } |
64 | ||
65 | void AliPHOSTriggerRawDigiProducer::ProcessEvent(TClonesArray* tdigits) | |
66 | { | |
67 | ||
68 | fTriggerReader->Reset(); | |
69 | ||
70 | tdigits->Clear(); | |
71 | Int_t iDigit=0 ; | |
72 | ||
73 | while (fRawStream->NextDDL()) { | |
74 | while (fRawStream->NextChannel()) { | |
75 | ||
76 | if (fRawStream->IsTRUData()) { | |
77 | fTriggerReader->ReadFromStream(fRawStream); | |
78 | }// IsTRUData | |
79 | }// NextChannel | |
80 | }//NextDDL | |
81 | ||
82 | // Loop over modules | |
83 | for(unsigned int mod = 0; mod < fModules.size(); ++mod) { | |
84 | if( fModules[mod] ) { | |
85 | ||
86 | // Loop over 4x4 cells | |
87 | for(int TRURow = 0; TRURow < kNTRURows; ++TRURow) { | |
88 | for(int branch = 0; branch < kNBranches; ++branch) { | |
89 | ||
90 | AliPHOSTRURawReader* truReader = fTriggerReader->GetTRU(mod, TRURow, branch); | |
91 | if( truReader->IsActive() ) { | |
92 | ||
93 | for(int xIdx = 0; xIdx < kN4x4XPrTRURow; ++xIdx) { | |
94 | for(int zIdx = 0; zIdx < kN4x4ZPrBranch; ++zIdx) { | |
95 | ||
96 | // Determin if Trigger is flagged for any timeBin | |
97 | bool triggered = false; | |
98 | ||
99 | for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin){ | |
100 | if(truReader->IsActive(timeBin)) { | |
101 | if( fTriggerReader->GetTRU(mod, TRURow, branch)->GetTriggerFlag(xIdx, zIdx, timeBin) ){ | |
102 | triggered = true; | |
103 | } // end "if TriggerBit" | |
104 | } | |
105 | }// end TimeBin loop | |
106 | ||
7a7fa4eb | 107 | if( triggered ){ |
e1aec4f9 | 108 | // Get peak values |
109 | const int TSmax = Get4x4Max(fTriggerReader, fParameters, mod, TRURow, branch, xIdx, zIdx); | |
110 | new((*tdigits)[iDigit]) AliPHOSTriggerRawDigit(mod,xIdx,zIdx,TRURow,branch,TSmax); | |
111 | iDigit++; | |
112 | }// end "if triggered" | |
113 | ||
114 | } // end zIdx loop | |
115 | } // end xIdx loop | |
116 | } // truReader->IsActive | |
117 | } // end branch loop | |
118 | } // end tru loop | |
119 | } // end "if module" | |
120 | } // end mod loop | |
121 | ||
122 | } | |
123 | ||
124 | int AliPHOSTriggerRawDigiProducer::Get2x2Max(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int xIdx, int zIdx) | |
125 | { | |
126 | int max = 0; | |
127 | for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) { | |
128 | const int signal = Get2x2Signal(reader, params, mod, xIdx, zIdx, timeBin); | |
129 | if( max < signal ){ | |
130 | max = signal; | |
131 | } | |
132 | } | |
133 | return max; | |
134 | } | |
135 | ||
136 | ||
137 | int AliPHOSTriggerRawDigiProducer::Get2x2Signal(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* parameters, int mod, int xIdx, int zIdx, int timeBin) | |
138 | { | |
139 | const int TRURow = xIdx / kN2x2XPrTRURow; | |
140 | const int branch = zIdx / kN2x2ZPrBranch; | |
141 | const int TRUX = xIdx % kN2x2XPrTRURow; // 2x2 coordinates | |
142 | const int TRUZ = zIdx % kN2x2ZPrBranch; // 2x2 coordinates | |
143 | ||
7a7fa4eb | 144 | if( reader->GetTRU(mod, TRURow, branch)->IsActive() ){ |
e1aec4f9 | 145 | const int signal = reader->GetTRU(mod, TRURow, branch)->GetTriggerSignal( TRUX, TRUZ, timeBin); |
146 | if( parameters ) | |
147 | return signal - parameters->GetTRUPedestal(mod, TRURow, branch, TRUX, TRUZ); | |
148 | else | |
149 | return signal - AliPHOSTRURawReader::kDefaultSignalValue; | |
150 | } | |
151 | else | |
152 | return 0; | |
153 | } | |
154 | ||
155 | int AliPHOSTriggerRawDigiProducer::Get4x4Max(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int TRURow, int branch, int xIdx, int zIdx) | |
156 | { | |
157 | int max = 0; | |
158 | for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) { | |
159 | const int signal = Get4x4Signal(reader, params, mod, TRURow, branch, xIdx, zIdx, timeBin); | |
160 | if( max < signal ){ | |
161 | max = signal; | |
162 | } | |
163 | } | |
164 | return max; | |
165 | } | |
166 | ||
167 | ||
168 | int AliPHOSTriggerRawDigiProducer::Get4x4Signal(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int TRURow, int branch, int xIdx, int zIdx, int timeBin) | |
169 | { | |
170 | const int modX = xIdx + TRURow * kN2x2XPrTRURow; | |
171 | const int modZ = zIdx + branch * kN2x2ZPrBranch; | |
172 | ||
173 | const int signal | |
174 | = Get2x2Signal(reader, params, mod, modX , modZ , timeBin) | |
175 | + Get2x2Signal(reader, params, mod, modX+1, modZ , timeBin) | |
176 | + Get2x2Signal(reader, params, mod, modX , modZ+1, timeBin) | |
177 | + Get2x2Signal(reader, params, mod, modX+1, modZ+1, timeBin); | |
178 | return signal; | |
179 | } | |
180 | ||
181 | bool AliPHOSTriggerRawDigiProducer::Is2x2Active(AliPHOSTriggerRawReader* reader, int mod, int xIdx, int zIdx) | |
182 | { | |
183 | const int TRURow = xIdx / kN2x2XPrTRURow; | |
184 | const int branch = zIdx / kN2x2ZPrBranch; | |
185 | ||
186 | return reader->GetTRU(mod, TRURow, branch)->IsActive(); | |
187 | } | |
188 | ||
189 | bool AliPHOSTriggerRawDigiProducer::Is2x2Active(AliPHOSTriggerRawReader* reader, int mod, int xIdx, int zIdx, int timeBin) | |
190 | { | |
191 | const int TRURow = xIdx / kN2x2XPrTRURow; | |
192 | const int branch = zIdx / kN2x2ZPrBranch; | |
193 | ||
194 | return reader->GetTRU(mod, TRURow, branch)->IsActive(timeBin); | |
195 | } | |
196 | ||
197 |