Renaming of methods (Yuri)
[u/mrichter/AliRoot.git] / TRD / AliTRDTriggerL1.cxx
CommitLineData
e3b2b5e5 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16///////////////////////////////////////////////////////
17// //
18// //
19// TRD main trigger class for L1 //
20// //
21// //
22///////////////////////////////////////////////////////
23
24#include <TMath.h>
25
26#include "AliRun.h"
27#include "AliTriggerInput.h"
28
29#include "AliTRDTriggerL1.h"
30#include "AliTRDtrigParam.h"
31#include "AliTRDtrigger.h"
32#include "AliTRDgtuTrack.h"
33#include "AliTRDgeometry.h"
34
35ClassImp(AliTRDTriggerL1)
36
37//_____________________________________________________________________________
38AliTRDTriggerL1::AliTRDTriggerL1():AliTriggerDetector()
39{
c202a357 40 //
41 // Default constructor
42 //
e3b2b5e5 43
44 SetName("TRD");
45
46}
47
48//_____________________________________________________________________________
49void AliTRDTriggerL1::CreateInputs()
50{
c202a357 51 //
6d50f529 52 // See TRIGGER/DAQ/HLT/DCS Techical Design Report,
53 // p. 58, Table 4.1 for the proposed inputs
c202a357 54 //
55
6d50f529 56 fInputs.AddLast(new AliTriggerInput("TRD_Unlike_EPair_L1"
57 ,"Unlike electron pair"
58 ,0x01 ));
59 fInputs.AddLast(new AliTriggerInput("TRD_Like_EPair_L1"
60 ,"Like electron pair"
61 ,0x02 ));
62 fInputs.AddLast(new AliTriggerInput("TRD_Jet_LPt_L1"
63 ,"Jet low pt"
64 ,0x04 ));
65 fInputs.AddLast(new AliTriggerInput("TRD_Jet_HPt_L1"
66 ,"Jet high pt"
67 ,0x08 ));
68 fInputs.AddLast(new AliTriggerInput("TRD_Electron_L1"
69 ,"Single electron"
70 ,0x10 ));
71 fInputs.AddLast(new AliTriggerInput("TRD_HadrLPt_L1"
72 ,"Single hadron low pt "
73 ,0x20 ));
74 fInputs.AddLast(new AliTriggerInput("TRD_HadrHPt_L1"
75 ,"Single hadron high pt"
76 ,0x40 ));
e3b2b5e5 77
78}
79
80//_____________________________________________________________________________
81void AliTRDTriggerL1::Trigger()
82{
c202a357 83 //
84 // Run the online tracking and trigger
85 //
e3b2b5e5 86
87 AliRunLoader* runLoader = gAlice->GetRunLoader();
88
89 AliLoader *loader=runLoader->GetLoader("TRDLoader");
90
e3b2b5e5 91 // Trigger (tracklets, LTU)
92
93 AliTRDgeometry *geo = AliTRDgeometry::GetGeometry(runLoader);
94
95 AliTRDtrigger trdTrigger("Trigger","Trigger class");
96
97 AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters");
98
e3b2b5e5 99 Double_t x[3] = { 0.0, 0.0, 0.0 };
100 Double_t b[3];
101 gAlice->Field(x,b); // b[] is in kilo Gauss
102 Float_t field = b[2] * 0.1; // Tesla
103 Info("Trigger","Trigger set for magnetic field = %f Tesla \n",field);
104
105 trigp->SetField(field);
106 trigp->Init();
107
108 trdTrigger.SetParameter(trigp);
109 trdTrigger.SetRunLoader(runLoader);
110 trdTrigger.Init();
111
c202a357 112 trdTrigger.Open(runLoader->GetFileName(), runLoader->GetEventNumber());
113 trdTrigger.ReadDigits();
114 trdTrigger.MakeTracklets(kTRUE);
115 trdTrigger.WriteTracklets(-1);
e3b2b5e5 116
117 // Trigger (tracks, GTU)
118
6d50f529 119 Float_t highPt = trigp->GetHighPt();
c202a357 120 Float_t jetLowPt = trigp->GetJetLowPt();
121 Float_t jetHighPt = trigp->GetJetHighPt();
e3b2b5e5 122
123 Float_t pid, pt;
124 Int_t det, sec;
125 Bool_t isElectron;
126
127 const Int_t maxEle = 1000;
128
129 Int_t electronPlus, electronMinus;
130 Int_t sectorElePlus[maxEle], sectorEleMinus[maxEle];
131 Float_t ptElePlus[maxEle], ptEleMinus[maxEle];
0f20e40c 132 Int_t hadronLowPt, hadronHighPt;
c202a357 133 Int_t hadronJetLowPt, hadronJetHighPt;
134
135 hadronJetLowPt = 0;
136 hadronJetHighPt = 0;
0f20e40c 137
138 hadronLowPt = 0;
139 hadronHighPt = 0;
e3b2b5e5 140
141 electronPlus = 0;
142 electronMinus = 0;
143
144 AliTRDgtuTrack *gtuTrack;
145 Int_t nTracks = trdTrigger.GetNumberOfTracks();
146 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
147
148 gtuTrack = trdTrigger.GetTrack(iTrack);
149
150 pid = gtuTrack->GetPID();
151 isElectron = gtuTrack->IsElectron();
152 pt = gtuTrack->GetPt();
153 det = gtuTrack->GetDetector();
154
155 sec = geo->GetSector(det);
156
157 if (isElectron) {
158
159 if (pt < 0.0) {
160 sectorEleMinus[electronMinus] = sec;
161 ptEleMinus[electronMinus] = pt;
162 electronMinus++;
163 } else {
164 sectorElePlus[electronPlus] = sec;
165 ptElePlus[electronPlus] = pt;
166 electronPlus++;
167 }
168
169 } else {
170
171 if (TMath::Abs(pt) < highPt) {
172 hadronLowPt++;
173 } else {
174 hadronHighPt++;
175 }
176
c202a357 177 if (TMath::Abs(pt) > jetLowPt ) hadronJetLowPt++;
178 if (TMath::Abs(pt) > jetHighPt) hadronJetHighPt++;
179
e3b2b5e5 180 }
181
182 }
183
184 loader->UnloadTracks();
185
186 // hadrons
187
188 if (hadronLowPt) SetInput("TRD_Hadr_LPt_L1");
189 if (hadronHighPt) SetInput("TRD_Hadr_HPt_L1");
190
c202a357 191 // hadrons from jets
192
193 if (hadronJetLowPt >= trigp->GetNPartJetLow() ) SetInput("TRD_Jet_LPt_L1");
194 if (hadronJetHighPt >= trigp->GetNPartJetHigh()) SetInput("TRD_Jet_HPt_L1");
195
e3b2b5e5 196 // electron-positron pairs (open angle > 80 deg)
197
198 Int_t secPlus, secMinus, secDiff;
199 Bool_t electronUnlikePair = kFALSE;
200 Bool_t electronUnlikePairHPt = kFALSE;
201
202 if (electronMinus > 0 && electronPlus > 0) {
203 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
204 secPlus = sectorElePlus[iPlus];
205 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
206 secMinus = sectorEleMinus[iMinus];
207 secDiff = TMath::Abs(secPlus-secMinus);
208 if (secDiff > 9) secDiff = 18 - secDiff;
209 if (secDiff >= 5) {
210 electronUnlikePair = kTRUE;
211 if (TMath::Abs(ptElePlus[iPlus]) > highPt && TMath::Abs(ptEleMinus[iMinus]) > highPt) {
212 electronUnlikePairHPt = kTRUE;
213 }
214 }
215 }
216 }
217 }
218
219 if (electronUnlikePair) SetInput("TRD_Unlike_EPair_L1");
c202a357 220 //if (electronUnlikePairHPt) SetInput("TRD_Unlike_EPair_HPt_L1");
e3b2b5e5 221
222 // like electron/positron pairs
223
224 Bool_t ele1, ele1HPt;
225 Bool_t ele2, ele2HPt;
226
227 // positive
228
229 ele1 = kFALSE;
230 ele2 = kFALSE;
231 ele1HPt = kFALSE;
232 ele2HPt = kFALSE;
233 if (electronPlus > 1) {
234 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
235 if (!ele1) {
236 ele1 = kTRUE;
237 } else if (!ele2) {
238 ele2 = kTRUE;
239 }
240 if (TMath::Abs(ptElePlus[iPlus]) > highPt) {
241 if (!ele1HPt) {
242 ele1HPt = kTRUE;
243 } else if (!ele2HPt) {
244 ele2HPt = kTRUE;
245 }
246 }
247 }
248 }
249
250 if (ele1 && ele2 ) SetInput("TRD_Like_EPair_L1");
c202a357 251 //if (ele1HPt && ele2HPt) SetInput("TRD_Like_EPair_HPt_L1");
e3b2b5e5 252
253 // negative
254
255 ele1 = kFALSE;
256 ele2 = kFALSE;
257 ele1HPt = kFALSE;
258 ele2HPt = kFALSE;
259 if (electronMinus > 1) {
260 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
261 if (!ele1) {
262 ele1 = kTRUE;
263 } else if (!ele2) {
264 ele2 = kTRUE;
265 }
266 if (TMath::Abs(ptEleMinus[iMinus]) > highPt) {
267 if (!ele1HPt) {
268 ele1HPt = kTRUE;
269 } else if (!ele2HPt) {
270 ele2HPt = kTRUE;
271 }
272 }
273 }
274 }
275
276 if (ele1 && ele2 ) SetInput("TRD_Like_EPair_L1");
c202a357 277 //if (ele1HPt && ele2HPt) SetInput("TRD_Like_EPair_HPt_L1");
e3b2b5e5 278
279 // single electron/positron
280
281 if (electronPlus > 0 || electronMinus > 0) {
282 SetInput("TRD_Electron_L1");
c202a357 283 /*
e3b2b5e5 284 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
285 if (TMath::Abs(ptElePlus[iPlus]) > highPt) SetInput("TRD_Electron_HPt_L1");
286 break;
287 }
288 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
289 if (TMath::Abs(ptEleMinus[iMinus]) > highPt) SetInput("TRD_Electron_HPt_L1");
290 break;
291 }
c202a357 292 */
e3b2b5e5 293 }
294
295}
296