Correction of additional compilation errors from the first compilation trial.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTriggerData.cxx
1 \r
2 /**************************************************************************\r
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
4  *                                                                        *\r
5  * Author: The ALICE Off-line Project.                                    *\r
6  * Contributors are mentioned in the code where appropriate.              *\r
7  *                                                                        *\r
8  * Permission to use, copy, modify and distribute this software and its   *\r
9  * documentation strictly for non-commercial purposes is hereby granted   *\r
10  * without fee, provided that the above copyright notice appears in all   *\r
11  * copies and that both the copyright notice and this permission notice   *\r
12  * appear in the supporting documentation. The authors make no claims     *\r
13  * about the suitability of this software for any purpose. It is          *\r
14  * provided "as is" without express or implied warranty.                  *\r
15  **************************************************************************/\r
16 \r
17 // Class AliVZEROTriggerData\r
18 // -------------------------\r
19 // Retrieves and hold the FEE parameters\r
20 // The parameters are recieved from the shuttle \r
21 // AliVZEROTriggerData is then used in the AliVZEROTriggerSimulator\r
22 //\r
23 \r
24 #include <TObjString.h>\r
25 #include <TMap.h>\r
26 \r
27 #include "AliLog.h"\r
28 #include "AliDCSValue.h"\r
29 #include "AliVZEROTriggerData.h"\r
30 \r
31 ClassImp(AliVZEROTriggerData)\r
32 //________________________________________________________________\r
33 \r
34 AliVZEROTriggerData::AliVZEROTriggerData() :\r
35         TNamed(),\r
36         fBBAThreshold(0),\r
37         fBBCThreshold(0) ,  \r
38         fBGAThreshold(0) ,  \r
39         fBGCThreshold(0) ,  \r
40         fBBAForBGThreshold(0) ,  \r
41         fBBCForBGThreshold(0) ,  \r
42         fCentralityVOAThrLow(0) ,  \r
43         fCentralityVOAThrHigh(0) , \r
44         fCentralityVOCThrLow(0) ,  \r
45         fCentralityVOCThrHigh(0) , \r
46         fMultV0AThrLow(0) ,  \r
47         fMultV0AThrHigh(0) , \r
48         fMultV0CThrLow(0) ,  \r
49         fMultV0CThrHigh(0),\r
50         fRun(0),\r
51         fStartTime(0),\r
52         fEndTime(0),\r
53         fIsProcessed(kFALSE)    \r
54 \r
55 {\r
56         // default constructor\r
57         for(int i=0; i<kNCIUBoards ;i++) {\r
58                 fClk1Win1[i] = fClk1Win2[i] = 0;\r
59                 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;\r
60                 fClk2Win1[i] = fClk2Win2[i] = 0;\r
61                 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;\r
62                 fLatchWin1[i] = fLatchWin2[i] = 0;\r
63                 fResetWin1[i] = fResetWin2[i] = 0;\r
64                 fPedestalSubtraction[i] = kFALSE;\r
65                 for(Int_t j = 0; j < kNChannels; ++j) {\r
66                   fEnableCharge[i][j] = fEnableTiming[i][j] = kFALSE;\r
67                   fDiscriThr[i][j] = fDelayHit[i][j] = 0;\r
68                   fPedestalOdd[i][j] = fPedestalEven[i][j] = 0;\r
69                   fPedestalCutOdd[i][j] = fPedestalCutEven[i][j] = 0;\r
70                 }\r
71         }\r
72         for(Int_t i = 0; i < kNTriggerOutputs; ++i) fTriggerSelected[i] = 0;\r
73 }\r
74 //________________________________________________________________\r
75 AliVZEROTriggerData::AliVZEROTriggerData(Int_t nRun, UInt_t startTime, UInt_t endTime) :\r
76         TNamed(),\r
77         fBBAThreshold(0),\r
78         fBBCThreshold(0) ,  \r
79         fBGAThreshold(0) ,  \r
80         fBGCThreshold(0) ,  \r
81         fBBAForBGThreshold(0) ,  \r
82         fBBCForBGThreshold(0) ,  \r
83         fCentralityVOAThrLow(0) ,  \r
84         fCentralityVOAThrHigh(0) , \r
85         fCentralityVOCThrLow(0) ,  \r
86         fCentralityVOCThrHigh(0) , \r
87         fMultV0AThrLow(0) ,  \r
88         fMultV0AThrHigh(0) , \r
89         fMultV0CThrLow(0) ,  \r
90         fMultV0CThrHigh(0),\r
91         fRun(nRun),\r
92         fStartTime(startTime),\r
93         fEndTime(endTime),\r
94         fIsProcessed(kFALSE)\r
95 {\r
96         // Constructor\r
97         for(int i=0; i<kNCIUBoards ;i++) {\r
98                 fClk1Win1[i] = fClk1Win2[i] = 0;\r
99                 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;\r
100                 fClk2Win1[i] = fClk2Win2[i] = 0;\r
101                 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;\r
102                 fLatchWin1[i] = fLatchWin2[i] = 0;\r
103                 fResetWin1[i] = fResetWin2[i] = 0;\r
104                 fPedestalSubtraction[i] = kFALSE;\r
105                 for(Int_t j = 0; j < kNChannels; ++j) {\r
106                   fEnableCharge[i][j] = fEnableTiming[i][j] = kFALSE;\r
107                   fDiscriThr[i][j] = fDelayHit[i][j] = 0;\r
108                   fPedestalOdd[i][j] = fPedestalEven[i][j] = 0;\r
109                   fPedestalCutOdd[i][j] = fPedestalCutEven[i][j] = 0;\r
110                 }\r
111         }\r
112         for(Int_t i = 0; i < kNTriggerOutputs; ++i) fTriggerSelected[i] = 0;\r
113 \r
114         TString namst = "VZERO_Trigger_FEE";\r
115         SetName(namst.Data());\r
116         SetTitle(namst.Data());\r
117         \r
118 }\r
119 \r
120 //________________________________________________________________\r
121 AliVZEROTriggerData::~AliVZEROTriggerData(){\r
122         // destructor\r
123 }\r
124 //_____________________________________________________________________________\r
125 void AliVZEROTriggerData::FillData(AliVZERODataFEE * data){\r
126         // Set all parameters from the data get by the shuttle\r
127         TMap * params = data->GetParameters();\r
128         TIter iter(params);     \r
129         TObjString* aliasName;\r
130         \r
131         while ((  aliasName = (TObjString*) iter.Next() ))  {\r
132                 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);\r
133                 Int_t val;\r
134                 if(aValue) {\r
135                         val = aValue->GetUInt();\r
136                         AliInfo(Form("%s : %d",aliasName->String().Data(), val));\r
137                         SetParameter(aliasName->String(),val);\r
138                 }\r
139         }       \r
140 }\r
141 \r
142 //_____________________________________________________________________________\r
143 void AliVZEROTriggerData::SetParameter(TString name, Int_t val){\r
144         // Set given parameter\r
145         \r
146         Int_t iBoard = -1;\r
147         Int_t iChannel = -1;\r
148 \r
149         TSeqCollection* nameSplit = name.Tokenize("/");\r
150         TObjString * boardName = (TObjString *)nameSplit->At(2);\r
151         if(!boardName->String().Contains("CCIU")) sscanf(boardName->String().Data(),"CIU%d",&iBoard);\r
152         \r
153         TString paramName = ((TObjString *)nameSplit->At(3))->String();\r
154         Char_t channel[2] ; channel[1] = '\0';\r
155         channel[0] = paramName[paramName.Sizeof()-2];\r
156         sscanf(channel,"%d",&iChannel);\r
157         \r
158         if(name.Contains("DelayClk1Win1")) SetDelayClk1Win1((UShort_t) val,iBoard);\r
159         else if(name.Contains("Clk1Win1")) SetClk1Win1((UShort_t) val,iBoard);\r
160         else if(name.Contains("DelayClk1Win2")) SetDelayClk1Win2((UShort_t) val,iBoard);\r
161         else if(name.Contains("Clk1Win2")) SetClk1Win2((UShort_t) val,iBoard);\r
162         else if(name.Contains("DelayClk2Win1")) SetDelayClk2Win1((UShort_t) val,iBoard);\r
163         else if(name.Contains("Clk2Win1")) SetClk2Win1((UShort_t) val,iBoard);\r
164         else if(name.Contains("DelayClk2Win2")) SetDelayClk2Win2((UShort_t) val,iBoard);\r
165         else if(name.Contains("Clk2Win2")) SetClk2Win2((UShort_t) val,iBoard);\r
166         else if(name.Contains("LatchWin1")) SetLatchWin1((UShort_t) val,iBoard);\r
167         else if(name.Contains("LatchWin2")) SetLatchWin2((UShort_t) val,iBoard);\r
168         else if(name.Contains("ResetWin1")) SetResetWin1((UShort_t) val,iBoard);\r
169         else if(name.Contains("ResetWin2")) SetResetWin2((UShort_t) val,iBoard);\r
170         else if(name.Contains("PedestalSubtraction")) SetPedestalSubtraction((Bool_t) val,iBoard);\r
171         else if(name.Contains("BBAThreshold")) SetBBAThreshold((UShort_t) val);\r
172         else if(name.Contains("BBCThreshold")) SetBBCThreshold((UShort_t) val);\r
173         else if(name.Contains("BGAThreshold")) SetBGAThreshold((UShort_t) val);\r
174         else if(name.Contains("BGCThreshold")) SetBGCThreshold((UShort_t) val);\r
175         else if(name.Contains("BBAForBGThreshold")) SetBBAForBGThreshold((UShort_t) val);\r
176         else if(name.Contains("BBCForBGThreshold")) SetBBCForBGThreshold((UShort_t) val);\r
177         else if(name.Contains("CentralityV0AThrLow")) SetCentralityV0AThrLow((UShort_t) val);\r
178         else if(name.Contains("CentralityV0AThrHigh")) SetCentralityV0AThrHigh((UShort_t) val);\r
179         else if(name.Contains("CentralityV0CThrLow")) SetCentralityV0CThrLow((UShort_t) val);\r
180         else if(name.Contains("CentralityV0CThrHigh")) SetCentralityV0CThrHigh((UShort_t) val);\r
181         else if(name.Contains("MultV0AThrLow")) SetMultV0AThrLow((UShort_t) val);\r
182         else if(name.Contains("MultV0AThrHigh")) SetMultV0AThrHigh((UShort_t) val);\r
183         else if(name.Contains("MultV0CThrLow")) SetMultV0CThrLow((UShort_t) val);\r
184         else if(name.Contains("MultV0CThrHigh")) SetMultV0CThrHigh((UShort_t) val);\r
185         else if(name.Contains("TriggerSelect")) SetTriggerSelected((UShort_t) val, iChannel-1 );\r
186         else if(name.Contains("EnableCharge")) SetEnableCharge((Bool_t) val, iBoard , iChannel-1);\r
187         else if(name.Contains("EnableTiming")) SetEnableTiming((Bool_t) val, iBoard , iChannel-1);\r
188         else if(name.Contains("DiscriThr")) SetDiscriThr((UShort_t) val, iBoard, iChannel-1);\r
189         else if(name.Contains("DelayHit")) SetDelayHit((UShort_t) val, iBoard, iChannel-1);\r
190         else if(name.Contains("PedOdd")) SetPedestal((UShort_t) val, 1, iBoard, iChannel-1);\r
191         else if(name.Contains("PedEven")) SetPedestal((UShort_t) val, 0, iBoard, iChannel-1);\r
192         else if(name.Contains("PedCutOdd")) SetPedestalCut((UShort_t) val, 1, iBoard, iChannel-1);\r
193         else if(name.Contains("PedCutEven")) SetPedestalCut((UShort_t) val, 0, iBoard, iChannel-1);\r
194         else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));\r
195 }\r
196 //________________________________________________________________\r
197 void AliVZEROTriggerData::SetPedestalCut(UShort_t val,Int_t integrator, Int_t board, Int_t channel)\r
198 {\r
199         // Set Pedestal Cut of individual channel \r
200         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
201                 if(integrator) fPedestalCutOdd[board][channel] = val;\r
202                 else fPedestalCutEven[board][channel] = val;\r
203         } else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
204 }\r
205 //________________________________________________________________\r
206 UShort_t AliVZEROTriggerData::GetPedestalCut(Int_t integrator, Int_t board, Int_t channel)\r
207 {\r
208         // Get Pedestal Cut of individual channel \r
209         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
210                 if(integrator) return(fPedestalCutOdd[board][channel]);\r
211                 else return(fPedestalCutEven[board][channel]);\r
212         }else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
213         return 0;\r
214 }\r
215 //________________________________________________________________\r
216 void AliVZEROTriggerData::SetPedestal(UShort_t val, Int_t integrator, Int_t board, Int_t channel)\r
217 {\r
218         // Set Pedestal of individual channel \r
219         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
220                 if(integrator) fPedestalOdd[board][channel] = val;\r
221                 else fPedestalEven[board][channel] = val;\r
222         } else AliError(Form("Impossible to write at : Board %d ; Channel %d ; Integrator %d ",board,channel,integrator));\r
223 }\r
224 //________________________________________________________________\r
225 UShort_t AliVZEROTriggerData::GetPedestal(Int_t integrator, Int_t board, Int_t channel)\r
226 {\r
227         // Get Pedestal of individual channel \r
228         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
229                 if(integrator) return(fPedestalOdd[board][channel]);\r
230                 else return(fPedestalEven[board][channel]);\r
231         } else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
232         return 0;\r
233 }\r
234 //________________________________________________________________\r
235 void AliVZEROTriggerData::SetDelayHit(UShort_t val,Int_t board, Int_t channel)\r
236 {\r
237         // Set Delay of individual channel \r
238         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fDelayHit[board][channel] = val;\r
239         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
240 }\r
241 //________________________________________________________________\r
242 UShort_t AliVZEROTriggerData::GetDelayHit(Int_t board, Int_t channel)\r
243 {\r
244         // Get Delay of individual channel \r
245         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fDelayHit[board][channel]);\r
246         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
247         return 0;\r
248 }\r
249 //________________________________________________________________\r
250 void AliVZEROTriggerData::SetDiscriThr(UShort_t val,Int_t board, Int_t channel)\r
251 {\r
252         // Set discriminator threshold\r
253         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fDiscriThr[board][channel] = val;\r
254         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
255 }\r
256 //________________________________________________________________\r
257 UShort_t AliVZEROTriggerData::GetDiscriThr(Int_t board, Int_t channel)\r
258 {\r
259         // Get discriminator threshold\r
260         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fDiscriThr[board][channel]);\r
261         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
262         return 0;\r
263 }\r
264 //________________________________________________________________\r
265 void AliVZEROTriggerData::SetEnableCharge(Bool_t val,Int_t board, Int_t channel)\r
266 {\r
267         // Set the channels enabled for Charge triggers\r
268         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fEnableCharge[board][channel] = val;\r
269         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
270 }\r
271 //________________________________________________________________\r
272 Bool_t AliVZEROTriggerData::GetEnableCharge(Int_t board, Int_t channel)\r
273 {\r
274         // Get the channels enabled for Charge triggers\r
275         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fEnableCharge[board][channel]);\r
276         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
277         return kFALSE;\r
278 }\r
279 //________________________________________________________________\r
280 void AliVZEROTriggerData::SetEnableTiming(Bool_t val,Int_t board, Int_t channel)\r
281 {\r
282         // Set the channels enabled for Timing triggers\r
283         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fEnableTiming[board][channel] = val;\r
284         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
285 }\r
286 //________________________________________________________________\r
287 Bool_t AliVZEROTriggerData::GetEnableTiming(Int_t board, Int_t channel)\r
288 {\r
289         // Get the channels enabled for Timing triggers\r
290         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fEnableTiming[board][channel]);\r
291         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
292         return kFALSE;\r
293 }\r
294 //________________________________________________________________\r
295 void AliVZEROTriggerData::SetTriggerSelected(UShort_t trigger, Int_t output)\r
296 {\r
297         // Set the trigger selected on the outputs to CTP\r
298         if(output>=0 && output<kNTriggerOutputs) fTriggerSelected[output] = trigger;\r
299         else AliError(Form("Trigger output number %d not valid",output));\r
300 }\r
301 \r
302 //________________________________________________________________\r
303 void AliVZEROTriggerData::SetClk1Win1(UShort_t* clks)\r
304 {\r
305         // Set Win clock of BB\r
306         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win1(clks[t],t);\r
307         else AliError("Profil Clock1 Win1 Not defined.");\r
308 }\r
309 //________________________________________________________________\r
310 void AliVZEROTriggerData::SetClk2Win1(UShort_t* clks)\r
311 {\r
312         // Set Win clock of BB\r
313         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win1(clks[t],t);\r
314         else AliError("Profil Clock2 Win1 Not defined.");\r
315 }\r
316 //________________________________________________________________\r
317 void AliVZEROTriggerData::SetClk1Win1(UShort_t clk, Int_t board)\r
318 {\r
319         // Set Win clock of BB\r
320         if((board>=0) && (board<kNCIUBoards)) {\r
321                 fClk1Win1[board] = clk;\r
322                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win1 of board %d is not valid : %d",board,clk));\r
323         }else {\r
324                 AliError(Form("Impossible to Write at Board %d",board));\r
325         }\r
326 }\r
327 //________________________________________________________________\r
328 void AliVZEROTriggerData::SetClk2Win1(UShort_t clk, Int_t board)\r
329 {\r
330         // Set Win clock of BB\r
331         if((board>=0) && (board<kNCIUBoards)) {\r
332                 fClk2Win1[board] = clk;\r
333                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win1 of board %d is not valid : %d",board,clk));\r
334         }else {\r
335                 AliError(Form("Impossible to Write at Board %d",board));\r
336         }\r
337 }\r
338 //________________________________________________________________\r
339 void AliVZEROTriggerData::SetClk1Win2(UShort_t* clks)\r
340 {\r
341         // Set Win clock of BG\r
342         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win2(clks[t],t);\r
343         else AliError("Profil Clock1 Win2 Not defined.");\r
344 }\r
345 //________________________________________________________________\r
346 void AliVZEROTriggerData::SetClk2Win2(UShort_t* clks)\r
347 {\r
348         // Set Win clock of BG\r
349         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win2(clks[t],t);\r
350         else AliError("Profil Clock2 Win2 Not defined.");\r
351 }\r
352 //________________________________________________________________\r
353 void AliVZEROTriggerData::SetClk1Win2(UShort_t clk, Int_t board)\r
354 {\r
355         // Set Win clock of BG\r
356         if((board>=0) && (board<kNCIUBoards)) {\r
357                 fClk1Win2[board] = clk;\r
358                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win2 of board %d is not valid : %d",board,clk));\r
359         }else {\r
360                 AliError(Form("Impossible to Write at Board %d",board));\r
361         }\r
362 }\r
363 //________________________________________________________________\r
364 void AliVZEROTriggerData::SetClk2Win2(UShort_t clk, Int_t board)\r
365 {\r
366         // Set Win clock of BG\r
367         if((board>=0) && (board<kNCIUBoards)) {\r
368                 fClk2Win2[board] = clk;\r
369                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win2 of board %d is not valid : %d",board,clk));\r
370         }else {\r
371                 AliError(Form("Impossible to Write at Board %d",board));\r
372         }\r
373 }\r
374 //________________________________________________________________\r
375 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t* delays)\r
376 {\r
377         // Set Delay for Win clock of BB\r
378         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win1(delays[t],t);\r
379         else AliError("Profil Clock1 Win1 Delays Not defined.");\r
380 }\r
381 //________________________________________________________________\r
382 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t delay, Int_t board)\r
383 {\r
384         // Set Delay for Win clock of BB\r
385         if(delay>1023){\r
386                 AliWarning(Form("Profil Clock1 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));\r
387                 delay = delay & 0x3FF;\r
388         }\r
389         if((board>=0) && (board<kNCIUBoards))   fDelayClk1Win1[board] = delay;\r
390         else AliError(Form("Trying to write out of the array Board = %d",board));\r
391 }\r
392 //________________________________________________________________\r
393 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t* delays)\r
394 {\r
395         // Set Delay for Win clock of BB\r
396         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win1(delays[t],t);\r
397         else AliError("Profil Clock2 Win1 Delays Not defined.");\r
398 }\r
399 //________________________________________________________________\r
400 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t delay, Int_t board)\r
401 {\r
402         // Set Delay for Win clock of BB\r
403         if(delay>1023){\r
404                 AliWarning(Form("Profil Clock2 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));\r
405                 delay = delay & 0x3FF;\r
406         }\r
407         if((board>=0) && (board<kNCIUBoards))   fDelayClk2Win1[board] = delay;\r
408         else AliError(Form("Trying to write out of the array Board = %d",board));\r
409 }\r
410 //________________________________________________________________\r
411 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t* delays)\r
412 {\r
413         // Set Delay for Win clock of BG\r
414         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win2(delays[t],t);\r
415         else AliError("Profil Clock1 Win2 Delays Not defined.");\r
416 }\r
417 //________________________________________________________________\r
418 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t delay, Int_t board)\r
419 {\r
420         // Set Delay for Win clock of BG\r
421         if(delay>1023){\r
422                 AliWarning(Form("Profil Clock1 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));\r
423                 delay = delay & 0x3FF;\r
424         }\r
425         if((board>=0) && (board<kNCIUBoards))   fDelayClk1Win2[board] = delay;\r
426         else AliError(Form("Trying to write out of the array Board = %d",board));\r
427 }\r
428 //________________________________________________________________\r
429 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t* delays)\r
430 {\r
431         // Set Delay for Win clock of BG\r
432         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win2(delays[t],t);\r
433         else AliError("Profil Clock2 Win2 Delays Not defined.");\r
434 }\r
435 //________________________________________________________________\r
436 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t delay, Int_t board)\r
437 {\r
438         // Set Delay for Win clock of BG\r
439         if(delay>1023){\r
440                 AliWarning(Form("Profil Clock2 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));\r
441                 delay = delay & 0x3FF;\r
442         }\r
443         if((board>=0) && (board<kNCIUBoards))   fDelayClk2Win2[board] = delay;\r
444         else AliError(Form("Trying to write out of the array Board = %d",board));\r
445 }\r
446 //________________________________________________________________\r
447 void AliVZEROTriggerData::SetLatchWin1(UShort_t *latchs){\r
448         // Set Latch Win clock for BB\r
449         if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin1(latchs[t],t);\r
450         else AliError("Latch Win1 profil Not defined.");\r
451 }\r
452 //________________________________________________________________\r
453 void AliVZEROTriggerData::SetLatchWin1(UShort_t latch, Int_t board)\r
454 {\r
455         // Set Latch Win clock for BB\r
456         if((board>=0) && (board<kNCIUBoards)) {\r
457                 fLatchWin1[board] = latch;\r
458                 if(!IsClkValid(latch)) AliWarning(Form("Latch Win1 of board %d is not valid : %d",board,latch));\r
459         }else {\r
460                 AliError(Form("Impossible to Write at Board %d",board));\r
461         }\r
462 }\r
463 //________________________________________________________________\r
464 void AliVZEROTriggerData::SetLatchWin2(UShort_t *latchs){\r
465         // Set Latch Win clock for BG\r
466         if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin2(latchs[t],t);\r
467         else AliError("Latch Win2 profil Not defined.");\r
468 }\r
469 //________________________________________________________________\r
470 void AliVZEROTriggerData::SetLatchWin2(UShort_t latch, Int_t board)\r
471 {\r
472         // Set Latch Win clock for BG\r
473         if((board>=0) && (board<kNCIUBoards)) {\r
474                 fLatchWin2[board] = latch;\r
475                 if(!IsClkValid(latch)) AliWarning(Form("Latch Win2 of board %d is not valid : %d",board,latch));\r
476         }else {\r
477                 AliError(Form("Impossible to Write at Board %d",board));\r
478         }\r
479 }\r
480 //________________________________________________________________\r
481 void AliVZEROTriggerData::SetResetWin1(UShort_t *resets){\r
482         // Set Reset Win clock for BB\r
483         if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin1(resets[t],t);\r
484         else AliError("Reset Win1 profil Not defined.");\r
485 }\r
486 //________________________________________________________________\r
487 void AliVZEROTriggerData::SetResetWin1(UShort_t reset, Int_t board)\r
488 {\r
489         // Set Reset Win clock for BB\r
490         if((board>=0) && (board<kNCIUBoards)) {\r
491                 fResetWin1[board] = reset;\r
492                 if(!IsClkValid(reset)) AliWarning(Form("Reset Win1 of board %d is not valid : %d",board,reset));\r
493         }else {\r
494                 AliError(Form("Impossible to Write at Board %d",board));\r
495         }\r
496 }\r
497 //________________________________________________________________\r
498 void AliVZEROTriggerData::SetResetWin2(UShort_t *resets){\r
499         // Set Reset Win clock for BG\r
500         if(resets)  for(int t=0; t<kNCIUBoards; t++) SetResetWin2(resets[t],t);\r
501         else AliError("Reset Win2 profil Not defined.");\r
502 }\r
503 //________________________________________________________________\r
504 void AliVZEROTriggerData::SetResetWin2(UShort_t reset, Int_t board)\r
505 {\r
506         // Set Reset Win clock for BG\r
507         if((board>=0) && (board<kNCIUBoards)) {\r
508                 fResetWin2[board] = reset;\r
509                 if(!IsClkValid(reset)) AliWarning(Form("Reset Win2 of board %d is not valid : %d",board,reset));\r
510         }else {\r
511                 AliError(Form("Impossible to Write at Board %d",board));\r
512         }\r
513 }\r
514 //________________________________________________________________\r
515 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t *peds){\r
516         // Set Pedestal Subtraction Parameter\r
517         if(peds)  for(int t=0; t<kNCIUBoards; t++) SetPedestalSubtraction(peds[t],t);\r
518         else AliError("Pedestal Subtraction Not defined.");\r
519         \r
520 }\r
521 //________________________________________________________________\r
522 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t ped, Int_t board)\r
523 {\r
524         // Set Pedestal Subtraction Parameter\r
525         if((board>=0) && (board<kNCIUBoards)) fPedestalSubtraction[board] = ped;\r
526         else AliError(Form("Board %d is not valid",board));\r
527 }\r
528 \r
529 //________________________________________________________________\r
530 Bool_t  AliVZEROTriggerData::IsClkValid(UShort_t clock) const {\r
531         // Check if the given clock has a valid profil.\r
532         Bool_t word[5];\r
533         Bool_t isValid = kTRUE;\r
534         Short_t risingEdge = 0;\r
535         Short_t fallingEdge = 0;\r
536         for(int i=0 ; i<5 ; i++) word[i] = (clock >> i) & 0x1;\r
537         \r
538         if(word[0] != word[4]){\r
539                 if(word[4]) fallingEdge++;\r
540                 else risingEdge++;\r
541         }       \r
542         for(int i=1 ; i<5 ; i++){\r
543                 if(word[i] != word[i-1]) {\r
544                         if(word[i-1]) fallingEdge++;\r
545                         else risingEdge++;\r
546                 }\r
547         }\r
548         if((fallingEdge>1)||(risingEdge>1)) isValid = kFALSE;\r
549         if(((risingEdge==0)&&(fallingEdge==0)) &&(!word[0]))  isValid = kFALSE;\r
550         return isValid;\r
551 }\r
552 \r
553 \r
554 \r