DPs retrieved as UInts instead of Ints
[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         }\r
66 }\r
67 //________________________________________________________________\r
68 AliVZEROTriggerData::AliVZEROTriggerData(Int_t nRun, UInt_t startTime, UInt_t endTime) :\r
69         TNamed(),\r
70         fBBAThreshold(0),\r
71         fBBCThreshold(0) ,  \r
72         fBGAThreshold(0) ,  \r
73         fBGCThreshold(0) ,  \r
74         fBBAForBGThreshold(0) ,  \r
75         fBBCForBGThreshold(0) ,  \r
76         fCentralityVOAThrLow(0) ,  \r
77         fCentralityVOAThrHigh(0) , \r
78         fCentralityVOCThrLow(0) ,  \r
79         fCentralityVOCThrHigh(0) , \r
80         fMultV0AThrLow(0) ,  \r
81         fMultV0AThrHigh(0) , \r
82         fMultV0CThrLow(0) ,  \r
83         fMultV0CThrHigh(0),\r
84         fRun(nRun),\r
85         fStartTime(startTime),\r
86         fEndTime(endTime),\r
87         fIsProcessed(kFALSE)\r
88 {\r
89         // Constructor\r
90         for(int i=0; i<kNCIUBoards ;i++) {\r
91                 fClk1Win1[i] = fClk1Win2[i] = 0;\r
92                 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;\r
93                 fClk2Win1[i] = fClk2Win2[i] = 0;\r
94                 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;\r
95                 fLatchWin1[i] = fLatchWin2[i] = 0;\r
96                 fResetWin1[i] = fResetWin2[i] = 0;\r
97                 fPedestalSubtraction[i] = kFALSE;\r
98         }\r
99         TString namst = "VZERO_Trigger_FEE";\r
100         SetName(namst.Data());\r
101         SetTitle(namst.Data());\r
102         \r
103 }\r
104 \r
105 //________________________________________________________________\r
106 AliVZEROTriggerData::~AliVZEROTriggerData(){\r
107         // destructor\r
108 }\r
109 //_____________________________________________________________________________\r
110 void AliVZEROTriggerData::FillData(AliVZERODataFEE * data){\r
111         // Set all parameters from the data get by the shuttle\r
112         TMap * params = data->GetParameters();\r
113         TIter iter(params);     \r
114         TObjString* aliasName;\r
115         \r
116         while ((  aliasName = (TObjString*) iter.Next() ))  {\r
117                 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);\r
118                 Int_t val;\r
119                 if(aValue) {\r
120                         val = aValue->GetUInt();\r
121                         AliInfo(Form("%s : %d",aliasName->String().Data(), val));\r
122                         SetParameter(aliasName->String(),val);\r
123                 }\r
124         }       \r
125 }\r
126 \r
127 //_____________________________________________________________________________\r
128 void AliVZEROTriggerData::SetParameter(TString name, Int_t val){\r
129         // Set given parameter\r
130         \r
131         Int_t iBoard = -1;\r
132         Int_t iChannel = -1;\r
133 \r
134         TSeqCollection* nameSplit = name.Tokenize("/");\r
135         TObjString * boardName = (TObjString *)nameSplit->At(2);\r
136         if(!boardName->String().Contains("CCIU")) sscanf(boardName->String().Data(),"CIU%d",&iBoard);\r
137         \r
138         TString paramName = ((TObjString *)nameSplit->At(3))->String();\r
139         Char_t channel[2] ; channel[1] = '\0';\r
140         channel[0] = paramName[paramName.Sizeof()-2];\r
141         sscanf(channel,"%d",&iChannel);\r
142         \r
143         if(name.Contains("DelayClk1Win1")) SetDelayClk1Win1((UShort_t) val,iBoard);\r
144         else if(name.Contains("Clk1Win1")) SetClk1Win1((UShort_t) val,iBoard);\r
145         else if(name.Contains("DelayClk1Win2")) SetDelayClk1Win2((UShort_t) val,iBoard);\r
146         else if(name.Contains("Clk1Win2")) SetClk1Win2((UShort_t) val,iBoard);\r
147         else if(name.Contains("DelayClk2Win1")) SetDelayClk2Win1((UShort_t) val,iBoard);\r
148         else if(name.Contains("Clk2Win1")) SetClk2Win1((UShort_t) val,iBoard);\r
149         else if(name.Contains("DelayClk2Win2")) SetDelayClk2Win2((UShort_t) val,iBoard);\r
150         else if(name.Contains("Clk2Win2")) SetClk2Win2((UShort_t) val,iBoard);\r
151         else if(name.Contains("LatchWin1")) SetLatchWin1((UShort_t) val,iBoard);\r
152         else if(name.Contains("LatchWin2")) SetLatchWin2((UShort_t) val,iBoard);\r
153         else if(name.Contains("ResetWin1")) SetResetWin1((UShort_t) val,iBoard);\r
154         else if(name.Contains("ResetWin2")) SetResetWin2((UShort_t) val,iBoard);\r
155         else if(name.Contains("PedestalSubtraction")) SetPedestalSubtraction((Bool_t) val,iBoard);\r
156         else if(name.Contains("BBAThreshold")) SetBBAThreshold((UShort_t) val);\r
157         else if(name.Contains("BBCThreshold")) SetBBCThreshold((UShort_t) val);\r
158         else if(name.Contains("BGAThreshold")) SetBGAThreshold((UShort_t) val);\r
159         else if(name.Contains("BGCThreshold")) SetBGCThreshold((UShort_t) val);\r
160         else if(name.Contains("BBAForBGThreshold")) SetBBAForBGThreshold((UShort_t) val);\r
161         else if(name.Contains("BBCForBGThreshold")) SetBBCForBGThreshold((UShort_t) val);\r
162         else if(name.Contains("CentralityV0AThrLow")) SetCentralityV0AThrLow((UShort_t) val);\r
163         else if(name.Contains("CentralityV0AThrHigh")) SetCentralityV0AThrHigh((UShort_t) val);\r
164         else if(name.Contains("CentralityV0CThrLow")) SetCentralityV0CThrLow((UShort_t) val);\r
165         else if(name.Contains("CentralityV0CThrHigh")) SetCentralityV0CThrHigh((UShort_t) val);\r
166         else if(name.Contains("MultV0AThrLow")) SetMultV0AThrLow((UShort_t) val);\r
167         else if(name.Contains("MultV0AThrHigh")) SetMultV0AThrHigh((UShort_t) val);\r
168         else if(name.Contains("MultV0CThrLow")) SetMultV0CThrLow((UShort_t) val);\r
169         else if(name.Contains("MultV0CThrHigh")) SetMultV0CThrHigh((UShort_t) val);\r
170         else if(name.Contains("TriggerSelect")) SetTriggerSelected((UShort_t) val, iChannel-1 );\r
171         else if(name.Contains("EnableCharge")) SetEnableCharge((Bool_t) val, iBoard , iChannel-1);\r
172         else if(name.Contains("EnableTiming")) SetEnableTiming((Bool_t) val, iBoard , iChannel-1);\r
173         else if(name.Contains("DiscriThr")) SetDiscriThr((UShort_t) val, iBoard, iChannel-1);\r
174         else if(name.Contains("DelayHit")) SetDelayHit((UShort_t) val, iBoard, iChannel-1);\r
175         else if(name.Contains("PedOdd")) SetPedestal((UShort_t) val, 1, iBoard, iChannel-1);\r
176         else if(name.Contains("PedEven")) SetPedestal((UShort_t) val, 0, iBoard, iChannel-1);\r
177         else if(name.Contains("PedCutOdd")) SetPedestalCut((UShort_t) val, 1, iBoard, iChannel-1);\r
178         else if(name.Contains("PedCutEven")) SetPedestalCut((UShort_t) val, 0, iBoard, iChannel-1);\r
179         else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));\r
180 }\r
181 //________________________________________________________________\r
182 void AliVZEROTriggerData::SetPedestalCut(UShort_t val,Int_t integrator, Int_t board, Int_t channel)\r
183 {\r
184         // Set Pedestal Cut of individual channel \r
185         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
186                 if(integrator) fPedestalCutOdd[board][channel] = val;\r
187                 else fPedestalCutEven[board][channel] = val;\r
188         } else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
189 }\r
190 //________________________________________________________________\r
191 UShort_t AliVZEROTriggerData::GetPedestalCut(Int_t integrator, Int_t board, Int_t channel)\r
192 {\r
193         // Get Pedestal Cut of individual channel \r
194         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
195                 if(integrator) return(fPedestalCutOdd[board][channel]);\r
196                 else return(fPedestalCutEven[board][channel]);\r
197         }else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
198         return 0;\r
199 }\r
200 //________________________________________________________________\r
201 void AliVZEROTriggerData::SetPedestal(UShort_t val, Int_t integrator, Int_t board, Int_t channel)\r
202 {\r
203         // Set Pedestal of individual channel \r
204         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
205                 if(integrator) fPedestalOdd[board][channel] = val;\r
206                 else fPedestalEven[board][channel] = val;\r
207         } else AliError(Form("Impossible to write at : Board %d ; Channel %d ; Integrator %d ",board,channel,integrator));\r
208 }\r
209 //________________________________________________________________\r
210 UShort_t AliVZEROTriggerData::GetPedestal(Int_t integrator, Int_t board, Int_t channel)\r
211 {\r
212         // Get Pedestal of individual channel \r
213         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) {\r
214                 if(integrator) return(fPedestalOdd[board][channel]);\r
215                 else return(fPedestalEven[board][channel]);\r
216         } else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
217         return 0;\r
218 }\r
219 //________________________________________________________________\r
220 void AliVZEROTriggerData::SetDelayHit(UShort_t val,Int_t board, Int_t channel)\r
221 {\r
222         // Set Delay of individual channel \r
223         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fDelayHit[board][channel] = val;\r
224         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
225 }\r
226 //________________________________________________________________\r
227 UShort_t AliVZEROTriggerData::GetDelayHit(Int_t board, Int_t channel)\r
228 {\r
229         // Get Delay of individual channel \r
230         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fDelayHit[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::SetDiscriThr(UShort_t val,Int_t board, Int_t channel)\r
236 {\r
237         // Set discriminator threshold\r
238         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fDiscriThr[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::GetDiscriThr(Int_t board, Int_t channel)\r
243 {\r
244         // Get discriminator threshold\r
245         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fDiscriThr[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::SetEnableCharge(Bool_t val,Int_t board, Int_t channel)\r
251 {\r
252         // Set the channels enabled for Charge triggers\r
253         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fEnableCharge[board][channel] = val;\r
254         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));\r
255 }\r
256 //________________________________________________________________\r
257 Bool_t AliVZEROTriggerData::GetEnableCharge(Int_t board, Int_t channel)\r
258 {\r
259         // Get the channels enabled for Charge triggers\r
260         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fEnableCharge[board][channel]);\r
261         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));\r
262         return kFALSE;\r
263 }\r
264 //________________________________________________________________\r
265 void AliVZEROTriggerData::SetEnableTiming(Bool_t val,Int_t board, Int_t channel)\r
266 {\r
267         // Set the channels enabled for Timing triggers\r
268         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) fEnableTiming[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::GetEnableTiming(Int_t board, Int_t channel)\r
273 {\r
274         // Get the channels enabled for Timing triggers\r
275         if((board>=0 && board<kNCIUBoards) && (channel>=0 && channel<kNChannels)) return(fEnableTiming[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::SetTriggerSelected(UShort_t trigger, Int_t output)\r
281 {\r
282         // Set the trigger selected on the outputs to CTP\r
283         if(output>=0 && output<kNTriggerOutputs) fTriggerSelected[output] = trigger;\r
284         else AliError(Form("Trigger output number %d not valid",output));\r
285 }\r
286 \r
287 //________________________________________________________________\r
288 void AliVZEROTriggerData::SetClk1Win1(UShort_t* clks)\r
289 {\r
290         // Set Win clock of BB\r
291         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win1(clks[t],t);\r
292         else AliError("Profil Clock1 Win1 Not defined.");\r
293 }\r
294 //________________________________________________________________\r
295 void AliVZEROTriggerData::SetClk2Win1(UShort_t* clks)\r
296 {\r
297         // Set Win clock of BB\r
298         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win1(clks[t],t);\r
299         else AliError("Profil Clock2 Win1 Not defined.");\r
300 }\r
301 //________________________________________________________________\r
302 void AliVZEROTriggerData::SetClk1Win1(UShort_t clk, Int_t board)\r
303 {\r
304         // Set Win clock of BB\r
305         if((board>=0) && (board<kNCIUBoards)) {\r
306                 fClk1Win1[board] = clk;\r
307                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win1 of board %d is not valid : %d",board,clk));\r
308         }else {\r
309                 AliError(Form("Impossible to Write at Board %d",board));\r
310         }\r
311 }\r
312 //________________________________________________________________\r
313 void AliVZEROTriggerData::SetClk2Win1(UShort_t clk, Int_t board)\r
314 {\r
315         // Set Win clock of BB\r
316         if((board>=0) && (board<kNCIUBoards)) {\r
317                 fClk2Win1[board] = clk;\r
318                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win1 of board %d is not valid : %d",board,clk));\r
319         }else {\r
320                 AliError(Form("Impossible to Write at Board %d",board));\r
321         }\r
322 }\r
323 //________________________________________________________________\r
324 void AliVZEROTriggerData::SetClk1Win2(UShort_t* clks)\r
325 {\r
326         // Set Win clock of BG\r
327         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win2(clks[t],t);\r
328         else AliError("Profil Clock1 Win2 Not defined.");\r
329 }\r
330 //________________________________________________________________\r
331 void AliVZEROTriggerData::SetClk2Win2(UShort_t* clks)\r
332 {\r
333         // Set Win clock of BG\r
334         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win2(clks[t],t);\r
335         else AliError("Profil Clock2 Win2 Not defined.");\r
336 }\r
337 //________________________________________________________________\r
338 void AliVZEROTriggerData::SetClk1Win2(UShort_t clk, Int_t board)\r
339 {\r
340         // Set Win clock of BG\r
341         if((board>=0) && (board<kNCIUBoards)) {\r
342                 fClk1Win2[board] = clk;\r
343                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win2 of board %d is not valid : %d",board,clk));\r
344         }else {\r
345                 AliError(Form("Impossible to Write at Board %d",board));\r
346         }\r
347 }\r
348 //________________________________________________________________\r
349 void AliVZEROTriggerData::SetClk2Win2(UShort_t clk, Int_t board)\r
350 {\r
351         // Set Win clock of BG\r
352         if((board>=0) && (board<kNCIUBoards)) {\r
353                 fClk2Win2[board] = clk;\r
354                 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win2 of board %d is not valid : %d",board,clk));\r
355         }else {\r
356                 AliError(Form("Impossible to Write at Board %d",board));\r
357         }\r
358 }\r
359 //________________________________________________________________\r
360 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t* delays)\r
361 {\r
362         // Set Delay for Win clock of BB\r
363         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win1(delays[t],t);\r
364         else AliError("Profil Clock1 Win1 Delays Not defined.");\r
365 }\r
366 //________________________________________________________________\r
367 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t delay, Int_t board)\r
368 {\r
369         // Set Delay for Win clock of BB\r
370         if(delay>1023){\r
371                 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
372                 delay = delay & 0x3FF;\r
373         }\r
374         if((board>=0) && (board<kNCIUBoards))   fDelayClk1Win1[board] = delay;\r
375         else AliError(Form("Trying to write out of the array Board = %d",board));\r
376 }\r
377 //________________________________________________________________\r
378 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t* delays)\r
379 {\r
380         // Set Delay for Win clock of BB\r
381         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win1(delays[t],t);\r
382         else AliError("Profil Clock2 Win1 Delays Not defined.");\r
383 }\r
384 //________________________________________________________________\r
385 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t delay, Int_t board)\r
386 {\r
387         // Set Delay for Win clock of BB\r
388         if(delay>1023){\r
389                 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
390                 delay = delay & 0x3FF;\r
391         }\r
392         if((board>=0) && (board<kNCIUBoards))   fDelayClk2Win1[board] = delay;\r
393         else AliError(Form("Trying to write out of the array Board = %d",board));\r
394 }\r
395 //________________________________________________________________\r
396 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t* delays)\r
397 {\r
398         // Set Delay for Win clock of BG\r
399         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win2(delays[t],t);\r
400         else AliError("Profil Clock1 Win2 Delays Not defined.");\r
401 }\r
402 //________________________________________________________________\r
403 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t delay, Int_t board)\r
404 {\r
405         // Set Delay for Win clock of BG\r
406         if(delay>1023){\r
407                 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
408                 delay = delay & 0x3FF;\r
409         }\r
410         if((board>=0) && (board<kNCIUBoards))   fDelayClk1Win2[board] = delay;\r
411         else AliError(Form("Trying to write out of the array Board = %d",board));\r
412 }\r
413 //________________________________________________________________\r
414 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t* delays)\r
415 {\r
416         // Set Delay for Win clock of BG\r
417         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win2(delays[t],t);\r
418         else AliError("Profil Clock2 Win2 Delays Not defined.");\r
419 }\r
420 //________________________________________________________________\r
421 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t delay, Int_t board)\r
422 {\r
423         // Set Delay for Win clock of BG\r
424         if(delay>1023){\r
425                 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
426                 delay = delay & 0x3FF;\r
427         }\r
428         if((board>=0) && (board<kNCIUBoards))   fDelayClk2Win2[board] = delay;\r
429         else AliError(Form("Trying to write out of the array Board = %d",board));\r
430 }\r
431 //________________________________________________________________\r
432 void AliVZEROTriggerData::SetLatchWin1(UShort_t *latchs){\r
433         // Set Latch Win clock for BB\r
434         if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin1(latchs[t],t);\r
435         else AliError("Latch Win1 profil Not defined.");\r
436 }\r
437 //________________________________________________________________\r
438 void AliVZEROTriggerData::SetLatchWin1(UShort_t latch, Int_t board)\r
439 {\r
440         // Set Latch Win clock for BB\r
441         if((board>=0) && (board<kNCIUBoards)) {\r
442                 fLatchWin1[board] = latch;\r
443                 if(!IsClkValid(latch)) AliWarning(Form("Latch Win1 of board %d is not valid : %d",board,latch));\r
444         }else {\r
445                 AliError(Form("Impossible to Write at Board %d",board));\r
446         }\r
447 }\r
448 //________________________________________________________________\r
449 void AliVZEROTriggerData::SetLatchWin2(UShort_t *latchs){\r
450         // Set Latch Win clock for BG\r
451         if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin2(latchs[t],t);\r
452         else AliError("Latch Win2 profil Not defined.");\r
453 }\r
454 //________________________________________________________________\r
455 void AliVZEROTriggerData::SetLatchWin2(UShort_t latch, Int_t board)\r
456 {\r
457         // Set Latch Win clock for BG\r
458         if((board>=0) && (board<kNCIUBoards)) {\r
459                 fLatchWin2[board] = latch;\r
460                 if(!IsClkValid(latch)) AliWarning(Form("Latch Win2 of board %d is not valid : %d",board,latch));\r
461         }else {\r
462                 AliError(Form("Impossible to Write at Board %d",board));\r
463         }\r
464 }\r
465 //________________________________________________________________\r
466 void AliVZEROTriggerData::SetResetWin1(UShort_t *resets){\r
467         // Set Reset Win clock for BB\r
468         if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin1(resets[t],t);\r
469         else AliError("Reset Win1 profil Not defined.");\r
470 }\r
471 //________________________________________________________________\r
472 void AliVZEROTriggerData::SetResetWin1(UShort_t reset, Int_t board)\r
473 {\r
474         // Set Reset Win clock for BB\r
475         if((board>=0) && (board<kNCIUBoards)) {\r
476                 fResetWin1[board] = reset;\r
477                 if(!IsClkValid(reset)) AliWarning(Form("Reset Win1 of board %d is not valid : %d",board,reset));\r
478         }else {\r
479                 AliError(Form("Impossible to Write at Board %d",board));\r
480         }\r
481 }\r
482 //________________________________________________________________\r
483 void AliVZEROTriggerData::SetResetWin2(UShort_t *resets){\r
484         // Set Reset Win clock for BG\r
485         if(resets)  for(int t=0; t<kNCIUBoards; t++) SetResetWin2(resets[t],t);\r
486         else AliError("Reset Win2 profil Not defined.");\r
487 }\r
488 //________________________________________________________________\r
489 void AliVZEROTriggerData::SetResetWin2(UShort_t reset, Int_t board)\r
490 {\r
491         // Set Reset Win clock for BG\r
492         if((board>=0) && (board<kNCIUBoards)) {\r
493                 fResetWin2[board] = reset;\r
494                 if(!IsClkValid(reset)) AliWarning(Form("Reset Win2 of board %d is not valid : %d",board,reset));\r
495         }else {\r
496                 AliError(Form("Impossible to Write at Board %d",board));\r
497         }\r
498 }\r
499 //________________________________________________________________\r
500 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t *peds){\r
501         // Set Pedestal Subtraction Parameter\r
502         if(peds)  for(int t=0; t<kNCIUBoards; t++) SetPedestalSubtraction(peds[t],t);\r
503         else AliError("Pedestal Subtraction Not defined.");\r
504         \r
505 }\r
506 //________________________________________________________________\r
507 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t ped, Int_t board)\r
508 {\r
509         // Set Pedestal Subtraction Parameter\r
510         if((board>=0) && (board<kNCIUBoards)) fPedestalSubtraction[board] = ped;\r
511         else AliError(Form("Board %d is not valid",board));\r
512 }\r
513 \r
514 //________________________________________________________________\r
515 Bool_t  AliVZEROTriggerData::IsClkValid(UShort_t clock) const {\r
516         // Check if the given clock has a valid profil.\r
517         Bool_t word[5];\r
518         Bool_t isValid = kTRUE;\r
519         Short_t risingEdge = 0;\r
520         Short_t fallingEdge = 0;\r
521         for(int i=0 ; i<5 ; i++) word[i] = (clock >> i) & 0x1;\r
522         \r
523         if(word[0] != word[4]){\r
524                 if(word[4]) fallingEdge++;\r
525                 else risingEdge++;\r
526         }       \r
527         for(int i=1 ; i<5 ; i++){\r
528                 if(word[i] != word[i-1]) {\r
529                         if(word[i-1]) fallingEdge++;\r
530                         else risingEdge++;\r
531                 }\r
532         }\r
533         if((fallingEdge>1)||(risingEdge>1)) isValid = kFALSE;\r
534         if(((risingEdge==0)&&(fallingEdge==0)) &&(!word[0]))  isValid = kFALSE;\r
535         return isValid;\r
536 }\r
537 \r
538 \r
539 \r