2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
21 #include <TObjString.h>
24 #include "AliDCSValue.h"
25 #include "AliVZEROTriggerData.h"
27 ClassImp(AliVZEROTriggerData)
28 //________________________________________________________________
30 AliVZEROTriggerData::AliVZEROTriggerData() :
36 fBBAForBGThreshold(0) ,
37 fBBCForBGThreshold(0) ,
38 fCentralityVOAThrLow(0) ,
39 fCentralityVOAThrHigh(0) ,
40 fCentralityVOCThrLow(0) ,
41 fCentralityVOCThrHigh(0) ,
52 for(int i=0; i<kNCIUBoards ;i++) {
53 fClk1Win1[i] = fClk1Win2[i] = 0;
54 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;
55 fClk2Win1[i] = fClk2Win2[i] = 0;
56 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;
57 fLatchWin1[i] = fLatchWin2[i] = 0;
58 fResetWin1[i] = fResetWin2[i] = 0;
59 fPedestalSubtraction[i] = kFALSE;
62 //________________________________________________________________
63 AliVZEROTriggerData::AliVZEROTriggerData(Int_t nRun, UInt_t startTime, UInt_t endTime) :
69 fBBAForBGThreshold(0) ,
70 fBBCForBGThreshold(0) ,
71 fCentralityVOAThrLow(0) ,
72 fCentralityVOAThrHigh(0) ,
73 fCentralityVOCThrLow(0) ,
74 fCentralityVOCThrHigh(0) ,
80 fStartTime(startTime),
84 for(int i=0; i<kNCIUBoards ;i++) {
85 fClk1Win1[i] = fClk1Win2[i] = 0;
86 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;
87 fClk2Win1[i] = fClk2Win2[i] = 0;
88 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;
89 fLatchWin1[i] = fLatchWin2[i] = 0;
90 fResetWin1[i] = fResetWin2[i] = 0;
91 fPedestalSubtraction[i] = kFALSE;
93 TString namst = "Trigger_FEE";
94 SetName(namst.Data());
95 SetTitle(namst.Data());
99 //________________________________________________________________
100 AliVZEROTriggerData::~AliVZEROTriggerData(){
102 //_____________________________________________________________________________
103 void AliVZEROTriggerData::FillData(AliVZERODataFEE * data){
104 TMap * params = data->GetParameters();
106 TObjString* aliasName;
108 while (( aliasName = (TObjString*) iter.Next() )) {
109 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
110 Float_t val = aValue->GetFloat();
111 //AliInfo(Form("%s : %f",aliasName->String().Data(), val));
112 SetParameter(aliasName->String(),val);
117 //_____________________________________________________________________________
118 void AliVZEROTriggerData::SetParameter(TString name, Float_t val){
122 TSeqCollection* nameSplit = name.Tokenize("/");
123 TObjString * boardName = (TObjString *)nameSplit->At(2);
124 if(!boardName->String().Contains("CCIU")) sscanf(boardName->String().Data(),"CIU%d",&iBoard);
126 TString paramName = ((TObjString *)nameSplit->At(3))->String();
127 Char_t channel[2] ; channel[1] = '\0';
128 channel[0] = paramName[paramName.Sizeof()-2];
129 sscanf(channel,"%d",&iChannel);
131 if(name.Contains("DelayClk1Win1")) SetDelayClk1Win1((UShort_t) val,iBoard-1);
132 else if(name.Contains("Clk1Win1")) SetClk1Win1((UShort_t) val,iBoard-1);
133 else if(name.Contains("DelayClk1Win2")) SetDelayClk1Win2((UShort_t) val,iBoard-1);
134 else if(name.Contains("Clk1Win2")) SetClk1Win2((UShort_t) val,iBoard-1);
135 else if(name.Contains("DelayClk2Win1")) SetDelayClk2Win1((UShort_t) val,iBoard-1);
136 else if(name.Contains("Clk2Win1")) SetClk2Win1((UShort_t) val,iBoard-1);
137 else if(name.Contains("DelayClk2Win2")) SetDelayClk2Win2((UShort_t) val,iBoard-1);
138 else if(name.Contains("Clk2Win2")) SetClk2Win2((UShort_t) val,iBoard-1);
139 else if(name.Contains("LatchWin1")) SetLatchWin1((UShort_t) val,iBoard-1);
140 else if(name.Contains("LatchWin2")) SetLatchWin2((UShort_t) val,iBoard-1);
141 else if(name.Contains("ResetWin1")) SetResetWin1((UShort_t) val,iBoard-1);
142 else if(name.Contains("ResetWin2")) SetResetWin2((UShort_t) val,iBoard-1);
143 else if(name.Contains("PedestalSubtraction")) SetPedestalSubtraction((Bool_t) val,iBoard-1);
144 else if(name.Contains("BBAThreshold")) SetBBAThreshold((UShort_t) val);
145 else if(name.Contains("BBCThreshold")) SetBBCThreshold((UShort_t) val);
146 else if(name.Contains("BGAThreshold")) SetBGAThreshold((UShort_t) val);
147 else if(name.Contains("BGCThreshold")) SetBGCThreshold((UShort_t) val);
148 else if(name.Contains("BBAForBGThreshold")) SetBBAForBGThreshold((UShort_t) val);
149 else if(name.Contains("BBCForBGThreshold")) SetBBCForBGThreshold((UShort_t) val);
150 else if(name.Contains("CentralityV0AThrLow")) SetCentralityV0AThrLow((UShort_t) val);
151 else if(name.Contains("CentralityV0AThrHigh")) SetCentralityV0AThrHigh((UShort_t) val);
152 else if(name.Contains("CentralityV0CThrLow")) SetCentralityV0CThrLow((UShort_t) val);
153 else if(name.Contains("CentralityV0CThrHigh")) SetCentralityV0CThrHigh((UShort_t) val);
154 else if(name.Contains("MultV0AThrLow")) SetMultV0AThrLow((UShort_t) val);
155 else if(name.Contains("MultV0AThrHigh")) SetMultV0AThrHigh((UShort_t) val);
156 else if(name.Contains("MultV0CThrLow")) SetMultV0CThrLow((UShort_t) val);
157 else if(name.Contains("MultV0CThrHigh")) SetMultV0CThrHigh((UShort_t) val);
158 else if(name.Contains("TriggerSelect")) SetTriggerSelected((UShort_t) val, iBoard -1);
159 else if(name.Contains("EnableCharge")) SetEnableCharge((Bool_t) val, iBoard -1, iChannel-1);
160 else if(name.Contains("EnableTiming")) SetEnableTiming((Bool_t) val, iBoard -1, iChannel-1);
161 else if(name.Contains("DiscriThr")) SetDiscriThr((UShort_t) val, iBoard -1, iChannel-1);
162 else if(name.Contains("DelayHit")) SetDelayHit((UShort_t) val, iBoard -1, iChannel-1);
163 else if(name.Contains("PedOdd")) SetPedestal((UShort_t) val, 1, iBoard -1, iChannel-1);
164 else if(name.Contains("PedEven")) SetPedestal((UShort_t) val, 0, iBoard -1, iChannel-1);
165 else if(name.Contains("PedCutOdd")) SetPedestalCut((UShort_t) val, 1, iBoard -1, iChannel-1);
166 else if(name.Contains("PedCutEven")) SetPedestalCut((UShort_t) val, 0, iBoard -1, iChannel-1);
167 else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
169 //________________________________________________________________
170 void AliVZEROTriggerData::SetPedestalCut(UShort_t val,Int_t integrator, Int_t board, Int_t channel)
172 if(board<kNCIUBoards && channel<kNChannels) {
173 if(integrator) fPedestalCutOdd[board][channel] = val;
174 else fPedestalCutEven[board][channel] = val;
175 } else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
177 //________________________________________________________________
178 UShort_t AliVZEROTriggerData::GetPedestalCut(Int_t integrator, Int_t board, Int_t channel)
180 if(board<kNCIUBoards && channel<kNChannels) {
181 if(integrator) return(fPedestalCutOdd[board][channel]);
182 else return(fPedestalCutEven[board][channel]);
183 }else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
186 //________________________________________________________________
187 void AliVZEROTriggerData::SetPedestal(UShort_t val, Int_t integrator, Int_t board, Int_t channel)
189 if(board<kNCIUBoards && channel<kNChannels) {
190 if(integrator) fPedestalOdd[board][channel] = val;
191 else fPedestalEven[board][channel] = val;
192 } else AliError(Form("Impossible to write at : Board %d ; Channel %d ; Integrator %d ",board,channel,integrator));
194 //________________________________________________________________
195 UShort_t AliVZEROTriggerData::GetPedestal(Int_t integrator, Int_t board, Int_t channel)
197 if(board<kNCIUBoards && channel<kNChannels) {
198 if(integrator) return(fPedestalOdd[board][channel]);
199 else return(fPedestalEven[board][channel]);
200 } else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
203 //________________________________________________________________
204 void AliVZEROTriggerData::SetDelayHit(UShort_t val,Int_t board, Int_t channel)
206 if(board<kNCIUBoards && channel<kNChannels) fDelayHit[board][channel] = val;
207 else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
209 //________________________________________________________________
210 UShort_t AliVZEROTriggerData::GetDelayHit(Int_t board, Int_t channel)
212 if(board<kNCIUBoards && channel<kNChannels) return(fDelayHit[board][channel]);
213 else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
216 //________________________________________________________________
217 void AliVZEROTriggerData::SetDiscriThr(UShort_t val,Int_t board, Int_t channel)
219 if(board<kNCIUBoards && channel<kNChannels) fDiscriThr[board][channel] = val;
220 else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
222 //________________________________________________________________
223 UShort_t AliVZEROTriggerData::GetDiscriThr(Int_t board, Int_t channel)
225 if(board<kNCIUBoards && channel<kNChannels) return(fDiscriThr[board][channel]);
226 else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
229 //________________________________________________________________
230 void AliVZEROTriggerData::SetEnableCharge(Bool_t val,Int_t board, Int_t channel)
232 if(board<kNCIUBoards && channel<kNChannels) fEnableCharge[board][channel] = val;
233 else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
235 //________________________________________________________________
236 Bool_t AliVZEROTriggerData::GetEnableCharge(Int_t board, Int_t channel)
238 if(board<kNCIUBoards && channel<kNChannels) return(fEnableCharge[board][channel]);
239 else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
242 //________________________________________________________________
243 void AliVZEROTriggerData::SetEnableTiming(Bool_t val,Int_t board, Int_t channel)
245 if(board<kNCIUBoards && channel<kNChannels) fEnableTiming[board][channel] = val;
246 else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
248 //________________________________________________________________
249 Bool_t AliVZEROTriggerData::GetEnableTiming(Int_t board, Int_t channel)
251 if(board<kNCIUBoards && channel<kNChannels) return(fEnableTiming[board][channel]);
252 else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
255 //________________________________________________________________
256 void AliVZEROTriggerData::SetTriggerSelected(UShort_t trigger, Int_t output)
258 if(output<kNTriggerOutputs) fTriggerSelected[output] = trigger;
259 else AliError(Form("Trigger output number %d not valid",output));
262 //________________________________________________________________
263 void AliVZEROTriggerData::SetClk1Win1(UShort_t* clks)
265 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win1(clks[t],t);
266 else AliFatal("Profil Clock1 Win1 Not defined.");
268 //________________________________________________________________
269 void AliVZEROTriggerData::SetClk2Win1(UShort_t* clks)
271 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win1(clks[t],t);
272 else AliFatal("Profil Clock2 Win1 Not defined.");
274 //________________________________________________________________
275 void AliVZEROTriggerData::SetClk1Win1(UShort_t clk, Int_t board)
277 if(IsClkValid(clk) && (board<kNCIUBoards)) fClk1Win1[board] = clk;
278 else AliError(Form("Profil Clock1 Win1 of board %d is not valid : %d",board,clk));
280 //________________________________________________________________
281 void AliVZEROTriggerData::SetClk2Win1(UShort_t clk, Int_t board)
283 if(IsClkValid(clk) && (board<kNCIUBoards)) fClk2Win1[board] = clk;
284 else AliError(Form("Profil Clock2 Win1 of board %d is not valid",board));
286 //________________________________________________________________
287 void AliVZEROTriggerData::SetClk1Win2(UShort_t* clks)
289 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win2(clks[t],t);
290 else AliFatal("Profil Clock1 Win2 Not defined.");
292 //________________________________________________________________
293 void AliVZEROTriggerData::SetClk2Win2(UShort_t* clks)
295 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win2(clks[t],t);
296 else AliFatal("Profil Clock2 Win2 Not defined.");
298 //________________________________________________________________
299 void AliVZEROTriggerData::SetClk1Win2(UShort_t clk, Int_t board)
301 if(IsClkValid(clk) && (board<kNCIUBoards)) fClk1Win2[board] = clk;
302 else AliError(Form("Profil Clock1 Win2 of board %d is not valid",board));
304 //________________________________________________________________
305 void AliVZEROTriggerData::SetClk2Win2(UShort_t clk, Int_t board)
307 if(IsClkValid(clk) && (board<kNCIUBoards)) fClk2Win2[board] = clk;
308 else AliError(Form("Profil Clock2 Win2 of board %d is not valid",board));
310 //________________________________________________________________
311 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t* delays)
313 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win1(delays[t],t);
314 else AliFatal("Profil Clock1 Win1 Delays Not defined.");
316 //________________________________________________________________
317 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t delay, Int_t board)
320 AliWarning(Form("Profil Clock1 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
321 delay = delay & 0x3FF;
323 if(board<kNCIUBoards) fDelayClk1Win1[board] = delay;
324 else AliError("Trying to write out of the array");
326 //________________________________________________________________
327 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t* delays)
329 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win1(delays[t],t);
330 else AliFatal("Profil Clock2 Win1 Delays Not defined.");
332 //________________________________________________________________
333 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t delay, Int_t board)
336 AliWarning(Form("Profil Clock2 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
337 delay = delay & 0x3FF;
339 if(board<kNCIUBoards) fDelayClk2Win1[board] = delay;
340 else AliError("Trying to write out of the array");
342 //________________________________________________________________
343 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t* delays)
345 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win2(delays[t],t);
346 else AliFatal("Profil Clock1 Win2 Delays Not defined.");
348 //________________________________________________________________
349 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t delay, Int_t board)
352 AliWarning(Form("Profil Clock1 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
353 delay = delay & 0x3FF;
355 if(board<kNCIUBoards) fDelayClk1Win2[board] = delay;
356 else AliError("Trying to write out of the array");
358 //________________________________________________________________
359 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t* delays)
361 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win2(delays[t],t);
362 else AliFatal("Profil Clock2 Win2 Delays Not defined.");
364 //________________________________________________________________
365 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t delay, Int_t board)
368 AliWarning(Form("Profil Clock2 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
369 delay = delay & 0x3FF;
371 if(board<kNCIUBoards) fDelayClk2Win2[board] = delay;
372 else AliError("Trying to write out of the array");
374 //________________________________________________________________
375 void AliVZEROTriggerData::SetLatchWin1(UShort_t *latchs){
376 if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin1(latchs[t],t);
377 else AliFatal("Latch Win1 profil Not defined.");
379 //________________________________________________________________
380 void AliVZEROTriggerData::SetLatchWin1(UShort_t latch, Int_t board)
382 if(IsClkValid(latch) && (board<kNCIUBoards)) fLatchWin1[board] = latch;
383 else AliError(Form("Latch Win1 profil of board %d is not valid",board));
385 //________________________________________________________________
386 void AliVZEROTriggerData::SetLatchWin2(UShort_t *latchs){
387 if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin2(latchs[t],t);
388 else AliFatal("Latch Win2 profil Not defined.");
390 //________________________________________________________________
391 void AliVZEROTriggerData::SetLatchWin2(UShort_t latch, Int_t board)
393 if(IsClkValid(latch) && (board<kNCIUBoards)) fLatchWin2[board] = latch;
394 else AliError(Form("Latch Win2 profil of board %d is not valid",board));
396 //________________________________________________________________
397 void AliVZEROTriggerData::SetResetWin1(UShort_t *resets){
398 if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin1(resets[t],t);
399 else AliFatal("Reset Win1 profil Not defined.");
401 //________________________________________________________________
402 void AliVZEROTriggerData::SetResetWin1(UShort_t reset, Int_t board)
404 if(IsClkValid(reset) && (board<kNCIUBoards)) fResetWin1[board] = reset;
405 else AliError(Form("Reset Win1 profil of board %d is not valid",board));
407 //________________________________________________________________
408 void AliVZEROTriggerData::SetResetWin2(UShort_t *resets){
409 if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin2(resets[t],t);
410 else AliFatal("Reset Win2 profil Not defined.");
412 //________________________________________________________________
413 void AliVZEROTriggerData::SetResetWin2(UShort_t reset, Int_t board)
415 if(IsClkValid(reset) && (board<kNCIUBoards)) fResetWin2[board] = reset;
416 else AliError(Form("Reset Win2 profil of board %d is not valid",board));
418 //________________________________________________________________
419 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t *peds){
420 if(peds) for(int t=0; t<kNCIUBoards; t++) SetPedestalSubtraction(peds[t],t);
421 else AliFatal("Pedestal Subtraction Not defined.");
424 //________________________________________________________________
425 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t ped, Int_t board)
427 if((board<kNCIUBoards)) fPedestalSubtraction[board] = ped;
428 else AliError(Form("Board %d is not valid",board));
431 //________________________________________________________________
432 Bool_t AliVZEROTriggerData::IsClkValid(UShort_t clock){
434 Bool_t isValid = kTRUE;
435 Short_t RisingEdge = 0;
436 Short_t FallingEdge = 0;
437 for(int i=0 ; i<5 ; i++) word[i] = (clock >> i) & 0x1;
439 if(word[0] != word[4]){
440 if(word[4]) FallingEdge++;
443 for(int i=1 ; i<5 ; i++){
444 if(word[i] != word[i-1]) {
445 if(word[i-1]) FallingEdge++;
449 if((FallingEdge>1)||(RisingEdge>1)) isValid = kFALSE;
450 if(((RisingEdge==0)&&(FallingEdge==0)) &&(!word[0])) isValid = kFALSE;