]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROTriggerData.cxx
Implementation of Trigger simulation (Raphael Tieulent)
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTriggerData.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
7  *                                                                        *
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  **************************************************************************/
16
17
18 //  
19 // 
20 // 
21 #include <TObjString.h>
22
23 #include "AliLog.h"
24 #include "AliDCSValue.h"
25 #include "AliVZEROTriggerData.h"
26
27 ClassImp(AliVZEROTriggerData)
28 //________________________________________________________________
29
30 AliVZEROTriggerData::AliVZEROTriggerData() :
31         TNamed(),
32         fBBAThreshold(0),
33         fBBCThreshold(0) ,  
34         fBGAThreshold(0) ,  
35         fBGCThreshold(0) ,  
36         fBBAForBGThreshold(0) ,  
37         fBBCForBGThreshold(0) ,  
38         fCentralityVOAThrLow(0) ,  
39         fCentralityVOAThrHigh(0) , 
40         fCentralityVOCThrLow(0) ,  
41         fCentralityVOCThrHigh(0) , 
42         fMultV0AThrLow(0) ,  
43         fMultV0AThrHigh(0) , 
44         fMultV0CThrLow(0) ,  
45         fMultV0CThrHigh(0),
46         fRun(0),
47         fStartTime(0),
48         fEndTime(0),
49         fIsProcessed(kFALSE)    
50
51 {
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;
60         }
61 }
62 //________________________________________________________________
63 AliVZEROTriggerData::AliVZEROTriggerData(Int_t nRun, UInt_t startTime, UInt_t endTime) :
64         TNamed(),
65         fBBAThreshold(0),
66         fBBCThreshold(0) ,  
67         fBGAThreshold(0) ,  
68         fBGCThreshold(0) ,  
69         fBBAForBGThreshold(0) ,  
70         fBBCForBGThreshold(0) ,  
71         fCentralityVOAThrLow(0) ,  
72         fCentralityVOAThrHigh(0) , 
73         fCentralityVOCThrLow(0) ,  
74         fCentralityVOCThrHigh(0) , 
75         fMultV0AThrLow(0) ,  
76         fMultV0AThrHigh(0) , 
77         fMultV0CThrLow(0) ,  
78         fMultV0CThrHigh(0),
79         fRun(nRun),
80         fStartTime(startTime),
81         fEndTime(endTime),
82         fIsProcessed(kFALSE)
83 {
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;
92         }
93         TString namst = "Trigger_FEE";
94         SetName(namst.Data());
95         SetTitle(namst.Data());
96         
97 }
98
99 //________________________________________________________________
100 AliVZEROTriggerData::~AliVZEROTriggerData(){
101 }
102 //_____________________________________________________________________________
103 void AliVZEROTriggerData::FillData(AliVZERODataFEE * data){
104         TMap * params = data->GetParameters();
105         TIter iter(params);     
106         TObjString* aliasName;
107         
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);
113         
114         }       
115 }
116
117 //_____________________________________________________________________________
118 void AliVZEROTriggerData::SetParameter(TString name, Float_t val){
119         Int_t iBoard = -1;
120         Int_t iChannel = -1;
121
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);
125         
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);
130         
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()));
168 }
169 //________________________________________________________________
170 void AliVZEROTriggerData::SetPedestalCut(UShort_t val,Int_t integrator, Int_t board, Int_t channel)
171 {
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));
176 }
177 //________________________________________________________________
178 UShort_t AliVZEROTriggerData::GetPedestalCut(Int_t integrator, Int_t board, Int_t channel)
179 {
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));
184         return 0;
185 }
186 //________________________________________________________________
187 void AliVZEROTriggerData::SetPedestal(UShort_t val, Int_t integrator, Int_t board, Int_t channel)
188 {
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));
193 }
194 //________________________________________________________________
195 UShort_t AliVZEROTriggerData::GetPedestal(Int_t integrator, Int_t board, Int_t channel)
196 {
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));
201         return 0;
202 }
203 //________________________________________________________________
204 void AliVZEROTriggerData::SetDelayHit(UShort_t val,Int_t board, Int_t channel)
205 {
206         if(board<kNCIUBoards && channel<kNChannels) fDelayHit[board][channel] = val;
207         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
208 }
209 //________________________________________________________________
210 UShort_t AliVZEROTriggerData::GetDelayHit(Int_t board, Int_t channel)
211 {
212         if(board<kNCIUBoards && channel<kNChannels) return(fDelayHit[board][channel]);
213         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
214         return 0;
215 }
216 //________________________________________________________________
217 void AliVZEROTriggerData::SetDiscriThr(UShort_t val,Int_t board, Int_t channel)
218 {
219         if(board<kNCIUBoards && channel<kNChannels) fDiscriThr[board][channel] = val;
220         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
221 }
222 //________________________________________________________________
223 UShort_t AliVZEROTriggerData::GetDiscriThr(Int_t board, Int_t channel)
224 {
225         if(board<kNCIUBoards && channel<kNChannels) return(fDiscriThr[board][channel]);
226         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
227         return 0;
228 }
229 //________________________________________________________________
230 void AliVZEROTriggerData::SetEnableCharge(Bool_t val,Int_t board, Int_t channel)
231 {
232         if(board<kNCIUBoards && channel<kNChannels) fEnableCharge[board][channel] = val;
233         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
234 }
235 //________________________________________________________________
236 Bool_t AliVZEROTriggerData::GetEnableCharge(Int_t board, Int_t channel)
237 {
238         if(board<kNCIUBoards && channel<kNChannels) return(fEnableCharge[board][channel]);
239         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
240         return kFALSE;
241 }
242 //________________________________________________________________
243 void AliVZEROTriggerData::SetEnableTiming(Bool_t val,Int_t board, Int_t channel)
244 {
245         if(board<kNCIUBoards && channel<kNChannels) fEnableTiming[board][channel] = val;
246         else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
247 }
248 //________________________________________________________________
249 Bool_t AliVZEROTriggerData::GetEnableTiming(Int_t board, Int_t channel)
250 {
251         if(board<kNCIUBoards && channel<kNChannels) return(fEnableTiming[board][channel]);
252         else AliError(Form("Impossible to read at : Board %d ; Channel %d",board,channel));
253         return kFALSE;
254 }
255 //________________________________________________________________
256 void AliVZEROTriggerData::SetTriggerSelected(UShort_t trigger, Int_t output)
257 {
258         if(output<kNTriggerOutputs) fTriggerSelected[output] = trigger;
259         else AliError(Form("Trigger output number %d not valid",output));
260 }
261
262 //________________________________________________________________
263 void AliVZEROTriggerData::SetClk1Win1(UShort_t* clks)
264 {
265         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win1(clks[t],t);
266         else AliFatal("Profil Clock1 Win1 Not defined.");
267 }
268 //________________________________________________________________
269 void AliVZEROTriggerData::SetClk2Win1(UShort_t* clks)
270 {
271         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win1(clks[t],t);
272         else AliFatal("Profil Clock2 Win1 Not defined.");
273 }
274 //________________________________________________________________
275 void AliVZEROTriggerData::SetClk1Win1(UShort_t clk, Int_t board)
276 {
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));
279 }
280 //________________________________________________________________
281 void AliVZEROTriggerData::SetClk2Win1(UShort_t clk, Int_t board)
282 {
283         if(IsClkValid(clk) && (board<kNCIUBoards)) fClk2Win1[board] = clk;
284         else AliError(Form("Profil Clock2 Win1 of board %d is not valid",board));
285 }
286 //________________________________________________________________
287 void AliVZEROTriggerData::SetClk1Win2(UShort_t* clks)
288 {
289         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win2(clks[t],t);
290         else AliFatal("Profil Clock1 Win2 Not defined.");
291 }
292 //________________________________________________________________
293 void AliVZEROTriggerData::SetClk2Win2(UShort_t* clks)
294 {
295         if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win2(clks[t],t);
296         else AliFatal("Profil Clock2 Win2 Not defined.");
297 }
298 //________________________________________________________________
299 void AliVZEROTriggerData::SetClk1Win2(UShort_t clk, Int_t board)
300 {
301         if(IsClkValid(clk) && (board<kNCIUBoards)) fClk1Win2[board] = clk;
302         else AliError(Form("Profil Clock1 Win2 of board %d is not valid",board));
303 }
304 //________________________________________________________________
305 void AliVZEROTriggerData::SetClk2Win2(UShort_t clk, Int_t board)
306 {
307         if(IsClkValid(clk) && (board<kNCIUBoards)) fClk2Win2[board] = clk;
308         else AliError(Form("Profil Clock2 Win2 of board %d is not valid",board));
309 }
310 //________________________________________________________________
311 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t* delays)
312 {
313         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win1(delays[t],t);
314         else AliFatal("Profil Clock1 Win1 Delays Not defined.");
315 }
316 //________________________________________________________________
317 void AliVZEROTriggerData::SetDelayClk1Win1(UShort_t delay, Int_t board)
318 {
319         if(delay>1023){
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;
322         }
323         if(board<kNCIUBoards)   fDelayClk1Win1[board] = delay;
324         else AliError("Trying to write out of the array");
325 }
326 //________________________________________________________________
327 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t* delays)
328 {
329         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win1(delays[t],t);
330         else AliFatal("Profil Clock2 Win1 Delays Not defined.");
331 }
332 //________________________________________________________________
333 void AliVZEROTriggerData::SetDelayClk2Win1(UShort_t delay, Int_t board)
334 {
335         if(delay>1023){
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;
338         }
339         if(board<kNCIUBoards)   fDelayClk2Win1[board] = delay;
340         else AliError("Trying to write out of the array");
341 }
342 //________________________________________________________________
343 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t* delays)
344 {
345         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win2(delays[t],t);
346         else AliFatal("Profil Clock1 Win2 Delays Not defined.");
347 }
348 //________________________________________________________________
349 void AliVZEROTriggerData::SetDelayClk1Win2(UShort_t delay, Int_t board)
350 {
351         if(delay>1023){
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;
354         }
355         if(board<kNCIUBoards)   fDelayClk1Win2[board] = delay;
356         else AliError("Trying to write out of the array");
357 }
358 //________________________________________________________________
359 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t* delays)
360 {
361         if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win2(delays[t],t);
362         else AliFatal("Profil Clock2 Win2 Delays Not defined.");
363 }
364 //________________________________________________________________
365 void AliVZEROTriggerData::SetDelayClk2Win2(UShort_t delay, Int_t board)
366 {
367         if(delay>1023){
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;
370         }
371         if(board<kNCIUBoards)   fDelayClk2Win2[board] = delay;
372         else AliError("Trying to write out of the array");
373 }
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.");
378 }
379 //________________________________________________________________
380 void AliVZEROTriggerData::SetLatchWin1(UShort_t latch, Int_t board)
381 {
382         if(IsClkValid(latch) && (board<kNCIUBoards)) fLatchWin1[board] = latch;
383         else AliError(Form("Latch Win1 profil of board %d is not valid",board));
384 }
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.");
389 }
390 //________________________________________________________________
391 void AliVZEROTriggerData::SetLatchWin2(UShort_t latch, Int_t board)
392 {
393         if(IsClkValid(latch) && (board<kNCIUBoards)) fLatchWin2[board] = latch;
394         else AliError(Form("Latch Win2 profil of board %d is not valid",board));
395 }
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.");
400 }
401 //________________________________________________________________
402 void AliVZEROTriggerData::SetResetWin1(UShort_t reset, Int_t board)
403 {
404         if(IsClkValid(reset) && (board<kNCIUBoards)) fResetWin1[board] = reset;
405         else AliError(Form("Reset Win1 profil of board %d is not valid",board));
406 }
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.");
411 }
412 //________________________________________________________________
413 void AliVZEROTriggerData::SetResetWin2(UShort_t reset, Int_t board)
414 {
415         if(IsClkValid(reset) && (board<kNCIUBoards)) fResetWin2[board] = reset;
416         else AliError(Form("Reset Win2 profil of board %d is not valid",board));
417 }
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.");
422         
423 }
424 //________________________________________________________________
425 void AliVZEROTriggerData::SetPedestalSubtraction(Bool_t ped, Int_t board)
426 {
427         if((board<kNCIUBoards)) fPedestalSubtraction[board] = ped;
428         else AliError(Form("Board %d is not valid",board));
429 }
430
431 //________________________________________________________________
432 Bool_t  AliVZEROTriggerData::IsClkValid(UShort_t clock){
433         Bool_t word[5];
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;
438         
439         if(word[0] != word[4]){
440                 if(word[4]) FallingEdge++;
441                 else RisingEdge++;
442         }       
443         for(int i=1 ; i<5 ; i++){
444                 if(word[i] != word[i-1]) {
445                         if(word[i-1]) FallingEdge++;
446                         else RisingEdge++;
447                 }
448         }
449         if((FallingEdge>1)||(RisingEdge>1)) isValid = kFALSE;
450         if(((RisingEdge==0)&&(FallingEdge==0)) &&(!word[0]))  isValid = kFALSE;
451         return isValid;
452 }