]>
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; | |
62 | } | |
63 | ||
64 | void AliPHOSTriggerRawDigiProducer::ProcessEvent(TClonesArray* tdigits) | |
65 | { | |
66 | ||
67 | fTriggerReader->Reset(); | |
68 | ||
69 | tdigits->Clear(); | |
70 | Int_t iDigit=0 ; | |
71 | ||
72 | while (fRawStream->NextDDL()) { | |
73 | while (fRawStream->NextChannel()) { | |
74 | ||
75 | if (fRawStream->IsTRUData()) { | |
76 | fTriggerReader->ReadFromStream(fRawStream); | |
77 | }// IsTRUData | |
78 | }// NextChannel | |
79 | }//NextDDL | |
80 | ||
81 | // Loop over modules | |
82 | for(unsigned int mod = 0; mod < fModules.size(); ++mod) { | |
83 | if( fModules[mod] ) { | |
84 | ||
85 | // Loop over 4x4 cells | |
86 | for(int TRURow = 0; TRURow < kNTRURows; ++TRURow) { | |
87 | for(int branch = 0; branch < kNBranches; ++branch) { | |
88 | ||
89 | AliPHOSTRURawReader* truReader = fTriggerReader->GetTRU(mod, TRURow, branch); | |
90 | if( truReader->IsActive() ) { | |
91 | ||
92 | for(int xIdx = 0; xIdx < kN4x4XPrTRURow; ++xIdx) { | |
93 | for(int zIdx = 0; zIdx < kN4x4ZPrBranch; ++zIdx) { | |
94 | ||
95 | // Determin if Trigger is flagged for any timeBin | |
96 | bool triggered = false; | |
97 | ||
98 | for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin){ | |
99 | if(truReader->IsActive(timeBin)) { | |
100 | if( fTriggerReader->GetTRU(mod, TRURow, branch)->GetTriggerFlag(xIdx, zIdx, timeBin) ){ | |
101 | triggered = true; | |
102 | } // end "if TriggerBit" | |
103 | } | |
104 | }// end TimeBin loop | |
105 | ||
106 | if( triggered ){ | |
107 | // Get peak values | |
108 | const int TSmax = Get4x4Max(fTriggerReader, fParameters, mod, TRURow, branch, xIdx, zIdx); | |
109 | new((*tdigits)[iDigit]) AliPHOSTriggerRawDigit(mod,xIdx,zIdx,TRURow,branch,TSmax); | |
110 | iDigit++; | |
111 | }// end "if triggered" | |
112 | ||
113 | } // end zIdx loop | |
114 | } // end xIdx loop | |
115 | } // truReader->IsActive | |
116 | } // end branch loop | |
117 | } // end tru loop | |
118 | } // end "if module" | |
119 | } // end mod loop | |
120 | ||
121 | } | |
122 | ||
123 | int AliPHOSTriggerRawDigiProducer::Get2x2Max(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int xIdx, int zIdx) | |
124 | { | |
125 | int max = 0; | |
126 | for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) { | |
127 | const int signal = Get2x2Signal(reader, params, mod, xIdx, zIdx, timeBin); | |
128 | if( max < signal ){ | |
129 | max = signal; | |
130 | } | |
131 | } | |
132 | return max; | |
133 | } | |
134 | ||
135 | ||
136 | int AliPHOSTriggerRawDigiProducer::Get2x2Signal(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* parameters, int mod, int xIdx, int zIdx, int timeBin) | |
137 | { | |
138 | const int TRURow = xIdx / kN2x2XPrTRURow; | |
139 | const int branch = zIdx / kN2x2ZPrBranch; | |
140 | const int TRUX = xIdx % kN2x2XPrTRURow; // 2x2 coordinates | |
141 | const int TRUZ = zIdx % kN2x2ZPrBranch; // 2x2 coordinates | |
142 | ||
143 | if( reader->GetTRU(mod, TRURow, branch)->IsActive() ){ | |
144 | const int signal = reader->GetTRU(mod, TRURow, branch)->GetTriggerSignal( TRUX, TRUZ, timeBin); | |
145 | if( parameters ) | |
146 | return signal - parameters->GetTRUPedestal(mod, TRURow, branch, TRUX, TRUZ); | |
147 | else | |
148 | return signal - AliPHOSTRURawReader::kDefaultSignalValue; | |
149 | } | |
150 | else | |
151 | return 0; | |
152 | } | |
153 | ||
154 | int AliPHOSTriggerRawDigiProducer::Get4x4Max(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int TRURow, int branch, int xIdx, int zIdx) | |
155 | { | |
156 | int max = 0; | |
157 | for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) { | |
158 | const int signal = Get4x4Signal(reader, params, mod, TRURow, branch, xIdx, zIdx, timeBin); | |
159 | if( max < signal ){ | |
160 | max = signal; | |
161 | } | |
162 | } | |
163 | return max; | |
164 | } | |
165 | ||
166 | ||
167 | int AliPHOSTriggerRawDigiProducer::Get4x4Signal(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int TRURow, int branch, int xIdx, int zIdx, int timeBin) | |
168 | { | |
169 | const int modX = xIdx + TRURow * kN2x2XPrTRURow; | |
170 | const int modZ = zIdx + branch * kN2x2ZPrBranch; | |
171 | ||
172 | const int signal | |
173 | = Get2x2Signal(reader, params, mod, modX , modZ , timeBin) | |
174 | + Get2x2Signal(reader, params, mod, modX+1, modZ , timeBin) | |
175 | + Get2x2Signal(reader, params, mod, modX , modZ+1, timeBin) | |
176 | + Get2x2Signal(reader, params, mod, modX+1, modZ+1, timeBin); | |
177 | return signal; | |
178 | } | |
179 | ||
180 | bool AliPHOSTriggerRawDigiProducer::Is2x2Active(AliPHOSTriggerRawReader* reader, int mod, int xIdx, int zIdx) | |
181 | { | |
182 | const int TRURow = xIdx / kN2x2XPrTRURow; | |
183 | const int branch = zIdx / kN2x2ZPrBranch; | |
184 | ||
185 | return reader->GetTRU(mod, TRURow, branch)->IsActive(); | |
186 | } | |
187 | ||
188 | bool AliPHOSTriggerRawDigiProducer::Is2x2Active(AliPHOSTriggerRawReader* reader, int mod, int xIdx, int zIdx, int timeBin) | |
189 | { | |
190 | const int TRURow = xIdx / kN2x2XPrTRURow; | |
191 | const int branch = zIdx / kN2x2ZPrBranch; | |
192 | ||
193 | return reader->GetTRU(mod, TRURow, branch)->IsActive(timeBin); | |
194 | } | |
195 | ||
196 |