]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROTriggerSimulator.cxx
Updated ITS alignment data filter (run with alien plugin)
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTriggerSimulator.cxx
CommitLineData
a08520b8 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
e370cdfe 15// \r
16// Class AliVZEROTriggerSimulator\r
17// ------------------------------\r
a08520b8 18// Simulate the VZERO Trigger response\r
19// Use FEE parameters stored in Database\r
20// Can work on real data or in simulation\r
e370cdfe 21//\r
22\r
23#include <TTree.h>\r
24#include <TClonesArray.h>\r
a08520b8 25\r
26#include "AliLog.h"\r
27#include "AliCDBManager.h"\r
28#include "AliCDBEntry.h"\r
29#include "AliCDBStorage.h"\r
30#include "AliCDBId.h"\r
31#include "AliVZEROTriggerData.h"\r
32#include "AliVZEROLogicalSignal.h"\r
33#include "AliVZEROTriggerSimulator.h"\r
34#include "AliVZEROdigit.h"\r
35\r
36ClassImp(AliVZEROTriggerSimulator)\r
37\r
a08520b8 38//_____________________________________________________________________________\r
39AliVZEROTriggerSimulator::AliVZEROTriggerSimulator(TTree * digitsTree, TClonesArray* digits) : \r
90c0f772 40TObject(),fTriggerData(NULL),fDigitsTree(digitsTree),fDigits(digits),fTriggerWord(0)\r
a08520b8 41{\r
e370cdfe 42 // constructor\r
90c0f772 43 fTriggerData = LoadTriggerData();\r
44 \r
a08520b8 45 for(int i=0;i<64;i++) {\r
46 fBBFlags[i] = fBGFlags[i] = kFALSE;\r
47 fCharges[i] = 0;\r
48 }\r
49 GenerateBBWindows();\r
50 GenerateBGWindows();\r
51 for (int i=0; i<AliVZEROTriggerData::kNCIUBoards; i++) {\r
52 fBBLatch[i] = new AliVZEROLogicalSignal(fTriggerData->GetLatchWin1(i),0); \r
53 fBGLatch[i] = new AliVZEROLogicalSignal(fTriggerData->GetLatchWin2(i),0); \r
54 fBBReset[i] = new AliVZEROLogicalSignal(fTriggerData->GetResetWin1(i),0);\r
55 fBGReset[i] = new AliVZEROLogicalSignal(fTriggerData->GetResetWin2(i),0); \r
56 }\r
57}\r
58//_____________________________________________________________________________\r
59AliVZEROTriggerSimulator::AliVZEROTriggerSimulator() : \r
90c0f772 60TObject(),fTriggerData(NULL),fDigitsTree(NULL),fDigits(NULL),fTriggerWord(0)\r
a08520b8 61{\r
e370cdfe 62 // Default constructor\r
90c0f772 63 fTriggerData = LoadTriggerData();\r
64\r
a08520b8 65 for(int i=0;i<64;i++) {\r
66 fBBFlags[i] = fBGFlags[i] = kFALSE;\r
67 fCharges[i] = 0;\r
68 }\r
69 GenerateBBWindows();\r
70 GenerateBGWindows();\r
71 for (int i=0; i<AliVZEROTriggerData::kNCIUBoards; i++) {\r
72 fBBLatch[i] = new AliVZEROLogicalSignal(fTriggerData->GetLatchWin1(i),0); \r
73 fBGLatch[i] = new AliVZEROLogicalSignal(fTriggerData->GetLatchWin2(i),0); \r
74 fBBReset[i] = new AliVZEROLogicalSignal(fTriggerData->GetResetWin1(i),0);\r
75 fBGReset[i] = new AliVZEROLogicalSignal(fTriggerData->GetResetWin2(i),0); \r
76 }\r
77}\r
78\r
79//_____________________________________________________________________________\r
80AliVZEROTriggerSimulator::~AliVZEROTriggerSimulator(){\r
e370cdfe 81// Destructor\r
a08520b8 82 if(fBBGate) delete [] fBBGate;\r
83 if(fBGGate) delete [] fBGGate;\r
84 if(fBBLatch) delete [] fBBLatch;\r
85 if(fBBReset) delete [] fBBReset;\r
86 if(fBGLatch) delete [] fBGLatch;\r
87 if(fBGReset) delete [] fBGReset;\r
88}\r
89\r
90//_____________________________________________________________________________\r
91void AliVZEROTriggerSimulator::GenerateBBWindows() \r
92{\r
e370cdfe 93 // Generates the BB observation window\r
a08520b8 94 for (int i=0; i<AliVZEROTriggerData::kNCIUBoards; i++) {\r
e370cdfe 95 AliVZEROLogicalSignal clk1BB(fTriggerData->GetClk1Win1(i),fTriggerData->GetDelayClk1Win1(i));\r
96 AliVZEROLogicalSignal clk2BB(fTriggerData->GetClk2Win1(i),fTriggerData->GetDelayClk2Win1(i));\r
97 fBBGate[i] = new AliVZEROLogicalSignal(clk1BB & clk2BB);\r
a08520b8 98 }\r
99}\r
100//_____________________________________________________________________________\r
101void AliVZEROTriggerSimulator::GenerateBGWindows() \r
102{\r
e370cdfe 103 // Generates the BG observation window\r
a08520b8 104 for (int i=0; i<AliVZEROTriggerData::kNCIUBoards; i++) {\r
e370cdfe 105 AliVZEROLogicalSignal clk1BG(fTriggerData->GetClk1Win2(i),fTriggerData->GetDelayClk1Win2(i));\r
106 AliVZEROLogicalSignal clk2BG(fTriggerData->GetClk2Win2(i),fTriggerData->GetDelayClk2Win2(i));\r
107 fBGGate[i] = new AliVZEROLogicalSignal(clk1BG & clk2BG);\r
a08520b8 108 }\r
109}\r
110\r
111//_____________________________________________________________________________\r
112AliVZEROTriggerData * AliVZEROTriggerSimulator::LoadTriggerData() const \r
113{\r
114 // Gets Trigger object for VZERO set\r
115 AliInfo("Loading Trigger parameters");\r
116 AliCDBManager *man = AliCDBManager::Instance();\r
117 \r
118 \r
119 AliCDBEntry *entry=0;\r
120 \r
121 entry = man->Get("VZERO/Trigger/Data");\r
122 if(!entry){\r
123 AliWarning("Load of calibration data from default storage failed!");\r
124 AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");\r
125 \r
126 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");\r
127 entry = man->Get("VZERO/Trigger/Data",0);\r
128 }\r
129 \r
130 // Retrieval of data in directory VZERO/Calib/Trigger:\r
131 \r
132 AliVZEROTriggerData *triggerData = NULL;\r
133 \r
134 if (entry) triggerData = (AliVZEROTriggerData*) entry->GetObject();\r
135 if (!triggerData) AliError("No Trigger data from database !");\r
136 \r
137 return triggerData;\r
138}\r
139\r
140//_____________________________________________________________________________\r
141void AliVZEROTriggerSimulator::Run() {\r
142 //AliInfo("Generating VZERO Triggers");\r
143 \r
144 // Loop over VZERO entries\r
145 Int_t nEntries = (Int_t)fDigitsTree->GetEntries();\r
146 for (Int_t ievt=0; ievt<nEntries; ievt++) {\r
147 fDigitsTree->GetEvent(ievt);\r
148 \r
149 Int_t nDigits = fDigits->GetEntriesFast();\r
150 \r
151 for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {\r
152 AliVZEROdigit* digit = (AliVZEROdigit*)fDigits->At(iDigit);\r
153 \r
154 Int_t integrator = digit->Integrator();\r
155 Int_t pmNumber = digit->PMNumber();\r
156 Int_t board = pmNumber / 8;\r
157 Int_t channel = pmNumber % 8;\r
158 \r
159 if(fTriggerData->GetEnableCharge(board,channel)) {\r
160 fCharges[pmNumber] = digit->ADC();\r
e370cdfe 161 if(fTriggerData->GetPedestalSubtraction(board)) {\r
a08520b8 162 if(fCharges[pmNumber]>=fTriggerData->GetPedestalCut(integrator,board,channel)){ \r
163 fCharges[pmNumber] -= fTriggerData->GetPedestal(integrator,board,channel);\r
164 } else {\r
165 fCharges[pmNumber] = 0;\r
166 }\r
e370cdfe 167 }\r
a08520b8 168 } else {\r
169 fCharges[pmNumber] = 0;\r
170 }\r
171 \r
172 Float_t time = (Float_t)digit->Time() / 10.; // digit->Time() in bin of 100 picoseconds. Divide by 10 to have it in nanoseconds\r
173 time += fTriggerData->GetDelayHit(board,channel);\r
174 \r
e370cdfe 175 //AliInfo(Form(" PM nb : %d ; ADC= %d ; TDC= %f Enable Time %d charge %d",pmNumber,digit->ADC(),time,fTriggerData->GetEnableTiming(board,channel),fTriggerData->GetEnableCharge(board,channel)));\r
a08520b8 176 fBBFlags[pmNumber] = fTriggerData->GetEnableTiming(board,channel) && fBBGate[board]->IsInCoincidence(time);\r
177 fBGFlags[pmNumber] = fTriggerData->GetEnableTiming(board,channel) && fBGGate[board]->IsInCoincidence(time);\r
178 \r
179 } // end of loop over digits\r
180 } // end of loop over events in digits tree\r
181 \r
182 Int_t nBBflagsV0A = 0;\r
183 Int_t nBBflagsV0C = 0;\r
184 Int_t nBGflagsV0A = 0;\r
185 Int_t nBGflagsV0C = 0;\r
186 Int_t chargeV0A = 0;\r
187 Int_t chargeV0C = 0;\r
188\r
189 for(int i=0;i<64;i++) {\r
190 if(i<32) {\r
191 nBBflagsV0C += fBBFlags[i]; \r
192 nBGflagsV0C += fBGFlags[i];\r
193 chargeV0C += fCharges[i];\r
194 } else {\r
195 nBBflagsV0A += fBBFlags[i]; \r
196 nBGflagsV0A += fBGFlags[i];\r
197 chargeV0A += fCharges[i];\r
198 }\r
199 //AliInfo(Form("Ch %d BB=%d BG=%d",i,fBBFlags[i],fBGFlags[i] )); \r
200 }\r
201 \r
202 // BBA\r
203 if(nBBflagsV0A>=fTriggerData->GetBBAThreshold()) SetBBA();\r
204 \r
205 // BBC\r
206 if(nBBflagsV0C>=fTriggerData->GetBBCThreshold()) SetBBC();\r
207\r
208 // BBA_AND_BBC\r
209 if(GetBBA() && GetBBC()) SetBBAandBBC();\r
210 \r
211 // BBA_OR_BBC\r
212 if(GetBBA() || GetBBC()) SetBBAorBBC();\r
213\r
214 // BGA\r
215 if(nBGflagsV0A>=fTriggerData->GetBGAThreshold()) SetBGA();\r
216\r
217 // BGC\r
218 if(nBGflagsV0C>=fTriggerData->GetBGCThreshold()) SetBGC();\r
219 \r
220 // BGA_AND_BBC (Beam Gas from RB24 side)\r
221 if(nBBflagsV0C>=fTriggerData->GetBBCForBGThreshold() && GetBGA()) SetBGAandBBC();\r
222 \r
223 // BGC_AND_BBA (Beam Gas from RB26 side)\r
224 if(nBBflagsV0A>=fTriggerData->GetBBAForBGThreshold() && GetBGC()) SetBGCandBBA();\r
225\r
226 // CTA1_AND_CTC1 (Centrality trigger 1)\r
227 if(chargeV0A>=fTriggerData->GetCentralityV0AThrLow() && chargeV0C>=fTriggerData->GetCentralityV0CThrLow()) SetCTA1andCTC1();\r
228\r
229 // CTA1_OR_CTC1 (Centrality trigger 1)\r
230 if(chargeV0A>=fTriggerData->GetCentralityV0AThrLow() || chargeV0C>=fTriggerData->GetCentralityV0CThrLow()) SetCTA1orCTC1();\r
231 \r
232 // CTA2_AND_CTC2 (Centrality trigger 2)\r
233 if(chargeV0A>=fTriggerData->GetCentralityV0AThrHigh() && chargeV0C>=fTriggerData->GetCentralityV0CThrHigh()) SetCTA2andCTC2();\r
234 \r
235 // CTA2_OR_CTC2 (Centrality trigger 2)\r
236 if(chargeV0A>=fTriggerData->GetCentralityV0AThrHigh() || chargeV0C>=fTriggerData->GetCentralityV0CThrHigh()) SetCTA2orCTC2();\r
237 \r
238 // MTA_AND_MTC (Multiplicity Trigger)\r
239 if((nBBflagsV0A<=fTriggerData->GetMultV0AThrHigh() && nBBflagsV0A>=fTriggerData->GetMultV0AThrLow())\r
240 && (nBBflagsV0C<=fTriggerData->GetMultV0CThrHigh() && nBBflagsV0C>=fTriggerData->GetMultV0CThrLow()) ) \r
241 SetMTAandMTC();\r
242 \r
243 // MTA_OR_MTC (Multiplicity Trigger)\r
244 if((nBBflagsV0A<=fTriggerData->GetMultV0AThrHigh() && nBBflagsV0A>=fTriggerData->GetMultV0AThrLow())\r
245 || (nBBflagsV0C<=fTriggerData->GetMultV0CThrHigh() && nBBflagsV0C>=fTriggerData->GetMultV0CThrLow()) ) \r
246 SetMTAorMTC();\r
247 \r
248 // BGA_OR_BGC\r
249 if(GetBGA() || GetBGC()) SetBGAorBGC();\r
250 \r
251 // (BGA and BBC) or (BGC and BBA) (Beam Gas from one of the two sides)\r
252 if(GetBGAandBBC() || GetBGCandBBA()) SetBeamGas();\r
253\r
e370cdfe 254// AliInfo(Form("BB Flags : V0A = %d V0C = %d ",nBBflagsV0A, nBBflagsV0C )); \r
255// AliInfo(Form("BG Flags : V0A = %d V0C = %d ",nBGflagsV0A, nBGflagsV0C )); \r
256// AliInfo(Form("Charges : V0A = %d V0C = %d ",chargeV0A, chargeV0C )); \r
a08520b8 257 \r
258}\r
259\r
90c0f772 260\r
e370cdfe 261\r