Classes moved to STEERBase.
[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
c965eab1 26#include "AliRunLoader.h"
27#include "AliConfig.h"
28#include "AliTracker.h"
e3b2b5e5 29#include "AliTriggerInput.h"
30
31#include "AliTRDTriggerL1.h"
32#include "AliTRDtrigParam.h"
33#include "AliTRDtrigger.h"
34#include "AliTRDgtuTrack.h"
35#include "AliTRDgeometry.h"
36
37ClassImp(AliTRDTriggerL1)
38
39//_____________________________________________________________________________
c965eab1 40AliTRDTriggerL1::AliTRDTriggerL1()
41 :AliTriggerDetector()
e3b2b5e5 42{
c202a357 43 //
44 // Default constructor
45 //
e3b2b5e5 46
47 SetName("TRD");
48
49}
50
51//_____________________________________________________________________________
52void AliTRDTriggerL1::CreateInputs()
53{
c202a357 54 //
6d50f529 55 // See TRIGGER/DAQ/HLT/DCS Techical Design Report,
56 // p. 58, Table 4.1 for the proposed inputs
c202a357 57 //
58
6d50f529 59 fInputs.AddLast(new AliTriggerInput("TRD_Unlike_EPair_L1"
60 ,"Unlike electron pair"
61 ,0x01 ));
62 fInputs.AddLast(new AliTriggerInput("TRD_Like_EPair_L1"
63 ,"Like electron pair"
64 ,0x02 ));
65 fInputs.AddLast(new AliTriggerInput("TRD_Jet_LPt_L1"
66 ,"Jet low pt"
67 ,0x04 ));
68 fInputs.AddLast(new AliTriggerInput("TRD_Jet_HPt_L1"
69 ,"Jet high pt"
70 ,0x08 ));
71 fInputs.AddLast(new AliTriggerInput("TRD_Electron_L1"
72 ,"Single electron"
73 ,0x10 ));
74 fInputs.AddLast(new AliTriggerInput("TRD_HadrLPt_L1"
75 ,"Single hadron low pt "
76 ,0x20 ));
77 fInputs.AddLast(new AliTriggerInput("TRD_HadrHPt_L1"
78 ,"Single hadron high pt"
79 ,0x40 ));
e3b2b5e5 80
81}
82
83//_____________________________________________________________________________
84void AliTRDTriggerL1::Trigger()
85{
c202a357 86 //
87 // Run the online tracking and trigger
88 //
e3b2b5e5 89
c965eab1 90 TString evfoldname = AliConfig::GetDefaultEventFolderName();
91 AliRunLoader *runLoader = AliRunLoader::GetRunLoader(evfoldname);
92 AliLoader *loader = runLoader->GetLoader("TRDLoader");
f162af62 93 AliTRDgeometry geo;
e3b2b5e5 94
95 AliTRDtrigger trdTrigger("Trigger","Trigger class");
96
c965eab1 97 Float_t field = AliTracker::GetBz() * 0.1; // Tesla
98 AliInfo(Form("Trigger set for magnetic field = %f Tesla \n",field));
e3b2b5e5 99
e3b2b5e5 100 trdTrigger.SetRunLoader(runLoader);
101 trdTrigger.Init();
102
c202a357 103 trdTrigger.Open(runLoader->GetFileName(), runLoader->GetEventNumber());
104 trdTrigger.ReadDigits();
105 trdTrigger.MakeTracklets(kTRUE);
106 trdTrigger.WriteTracklets(-1);
e3b2b5e5 107
108 // Trigger (tracks, GTU)
109
f162af62 110 Float_t highPt = AliTRDtrigParam::Instance()->GetHighPt();
111 Float_t jetLowPt = AliTRDtrigParam::Instance()->GetJetLowPt();
112 Float_t jetHighPt = AliTRDtrigParam::Instance()->GetJetHighPt();
e3b2b5e5 113
c965eab1 114 Float_t pid;
115 Float_t pt;
116 Int_t det;
117 Int_t sec;
e3b2b5e5 118 Bool_t isElectron;
119
120 const Int_t maxEle = 1000;
121
c965eab1 122 Int_t electronPlus;
123 Int_t electronMinus;
124 Int_t sectorElePlus[maxEle];
125 Int_t sectorEleMinus[maxEle];
126 Float_t ptElePlus[maxEle];
127 Float_t ptEleMinus[maxEle];
128 Int_t hadronLowPt;
129 Int_t hadronHighPt;
130 Int_t hadronJetLowPt;
131 Int_t hadronJetHighPt;
c202a357 132
133 hadronJetLowPt = 0;
134 hadronJetHighPt = 0;
0f20e40c 135
c965eab1 136 hadronLowPt = 0;
137 hadronHighPt = 0;
e3b2b5e5 138
c965eab1 139 electronPlus = 0;
140 electronMinus = 0;
e3b2b5e5 141
142 AliTRDgtuTrack *gtuTrack;
143 Int_t nTracks = trdTrigger.GetNumberOfTracks();
144 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
145
146 gtuTrack = trdTrigger.GetTrack(iTrack);
147
148 pid = gtuTrack->GetPID();
149 isElectron = gtuTrack->IsElectron();
150 pt = gtuTrack->GetPt();
151 det = gtuTrack->GetDetector();
f162af62 152 sec = geo.GetSector(det);
e3b2b5e5 153
154 if (isElectron) {
155
156 if (pt < 0.0) {
157 sectorEleMinus[electronMinus] = sec;
158 ptEleMinus[electronMinus] = pt;
159 electronMinus++;
c965eab1 160 }
161 else {
162 sectorElePlus[electronPlus] = sec;
163 ptElePlus[electronPlus] = pt;
e3b2b5e5 164 electronPlus++;
165 }
166
c965eab1 167 }
168 else {
e3b2b5e5 169
170 if (TMath::Abs(pt) < highPt) {
171 hadronLowPt++;
c965eab1 172 }
173 else {
e3b2b5e5 174 hadronHighPt++;
175 }
176
c965eab1 177 if (TMath::Abs(pt) > jetLowPt ) {
178 hadronJetLowPt++;
179 }
180 if (TMath::Abs(pt) > jetHighPt) {
181 hadronJetHighPt++;
182 }
c202a357 183
e3b2b5e5 184 }
185
186 }
187
188 loader->UnloadTracks();
189
c965eab1 190 // Hadrons
191 if (hadronLowPt) {
192 SetInput("TRD_Hadr_LPt_L1");
193 }
194 if (hadronHighPt) {
195 SetInput("TRD_Hadr_HPt_L1");
196 }
c202a357 197
c965eab1 198 // Hadrons from jets
f162af62 199 if (hadronJetLowPt >= AliTRDtrigParam::Instance()->GetNPartJetLow() ) {
c965eab1 200 SetInput("TRD_Jet_LPt_L1");
201 }
f162af62 202 if (hadronJetHighPt >= AliTRDtrigParam::Instance()->GetNPartJetHigh()) {
c965eab1 203 SetInput("TRD_Jet_HPt_L1");
204 }
e3b2b5e5 205
c965eab1 206 // Electron-positron pairs (open angle > 80 deg)
207 Int_t secPlus;
208 Int_t secMinus;
209 Int_t secDiff;
e3b2b5e5 210 Bool_t electronUnlikePair = kFALSE;
211 Bool_t electronUnlikePairHPt = kFALSE;
212
c965eab1 213 if ((electronMinus > 0) &&
214 (electronPlus > 0)) {
e3b2b5e5 215 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
216 secPlus = sectorElePlus[iPlus];
217 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
218 secMinus = sectorEleMinus[iMinus];
c965eab1 219 secDiff = TMath::Abs(secPlus-secMinus);
220 if (secDiff > 9) {
221 secDiff = 18 - secDiff;
222 }
e3b2b5e5 223 if (secDiff >= 5) {
224 electronUnlikePair = kTRUE;
c965eab1 225 if ((TMath::Abs(ptElePlus[iPlus]) > highPt) &&
226 (TMath::Abs(ptEleMinus[iMinus]) > highPt)) {
e3b2b5e5 227 electronUnlikePairHPt = kTRUE;
228 }
229 }
230 }
231 }
232 }
233
c965eab1 234 if (electronUnlikePair) {
235 SetInput("TRD_Unlike_EPair_L1");
236 }
237 //if (electronUnlikePairHPt) {
238 // SetInput("TRD_Unlike_EPair_HPt_L1");
239 //}
e3b2b5e5 240
c965eab1 241 // Like electron/positron pairs
242 Bool_t ele1;
243 Bool_t ele1HPt;
244 Bool_t ele2;
245 Bool_t ele2HPt;
e3b2b5e5 246
c965eab1 247 // Positive
e3b2b5e5 248 ele1 = kFALSE;
249 ele2 = kFALSE;
250 ele1HPt = kFALSE;
251 ele2HPt = kFALSE;
252 if (electronPlus > 1) {
253 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
c965eab1 254 if (!ele1) {
e3b2b5e5 255 ele1 = kTRUE;
c965eab1 256 }
257 else if (!ele2) {
e3b2b5e5 258 ele2 = kTRUE;
259 }
260 if (TMath::Abs(ptElePlus[iPlus]) > highPt) {
c965eab1 261 if (!ele1HPt) {
e3b2b5e5 262 ele1HPt = kTRUE;
c965eab1 263 }
264 else if (!ele2HPt) {
e3b2b5e5 265 ele2HPt = kTRUE;
266 }
267 }
268 }
269 }
270
c965eab1 271 if (ele1 && ele2 ) {
272 SetInput("TRD_Like_EPair_L1");
273 }
274 //if (ele1HPt && ele2HPt) {
275 // SetInput("TRD_Like_EPair_HPt_L1");
276 //}
e3b2b5e5 277
c965eab1 278 // Negative
e3b2b5e5 279 ele1 = kFALSE;
280 ele2 = kFALSE;
281 ele1HPt = kFALSE;
282 ele2HPt = kFALSE;
283 if (electronMinus > 1) {
284 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
c965eab1 285 if (!ele1) {
e3b2b5e5 286 ele1 = kTRUE;
c965eab1 287 }
288 else if (!ele2) {
e3b2b5e5 289 ele2 = kTRUE;
290 }
291 if (TMath::Abs(ptEleMinus[iMinus]) > highPt) {
c965eab1 292 if (!ele1HPt) {
e3b2b5e5 293 ele1HPt = kTRUE;
c965eab1 294 }
295 else if (!ele2HPt) {
e3b2b5e5 296 ele2HPt = kTRUE;
297 }
298 }
299 }
300 }
301
c965eab1 302 if (ele1 && ele2 ) {
303 SetInput("TRD_Like_EPair_L1");
304 }
305 //if (ele1HPt && ele2HPt) {
306 // SetInput("TRD_Like_EPair_HPt_L1");
307 //}
e3b2b5e5 308
c965eab1 309 // Single electron/positron
e3b2b5e5 310
c965eab1 311 if ((electronPlus > 0) ||
312 (electronMinus > 0)) {
e3b2b5e5 313 SetInput("TRD_Electron_L1");
c202a357 314 /*
e3b2b5e5 315 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
316 if (TMath::Abs(ptElePlus[iPlus]) > highPt) SetInput("TRD_Electron_HPt_L1");
317 break;
318 }
319 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
320 if (TMath::Abs(ptEleMinus[iMinus]) > highPt) SetInput("TRD_Electron_HPt_L1");
321 break;
322 }
c202a357 323 */
e3b2b5e5 324 }
325
326}
327