Add the number of local boards
[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");
93 AliTRDgeometry *geo = AliTRDgeometry::GetGeometry(runLoader);
94 AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters");
e3b2b5e5 95
96 AliTRDtrigger trdTrigger("Trigger","Trigger class");
97
c965eab1 98 Float_t field = AliTracker::GetBz() * 0.1; // Tesla
99 AliInfo(Form("Trigger set for magnetic field = %f Tesla \n",field));
e3b2b5e5 100
101 trigp->SetField(field);
102 trigp->Init();
103
104 trdTrigger.SetParameter(trigp);
105 trdTrigger.SetRunLoader(runLoader);
106 trdTrigger.Init();
107
c202a357 108 trdTrigger.Open(runLoader->GetFileName(), runLoader->GetEventNumber());
109 trdTrigger.ReadDigits();
110 trdTrigger.MakeTracklets(kTRUE);
111 trdTrigger.WriteTracklets(-1);
e3b2b5e5 112
113 // Trigger (tracks, GTU)
114
6d50f529 115 Float_t highPt = trigp->GetHighPt();
c202a357 116 Float_t jetLowPt = trigp->GetJetLowPt();
117 Float_t jetHighPt = trigp->GetJetHighPt();
e3b2b5e5 118
c965eab1 119 Float_t pid;
120 Float_t pt;
121 Int_t det;
122 Int_t sec;
e3b2b5e5 123 Bool_t isElectron;
124
125 const Int_t maxEle = 1000;
126
c965eab1 127 Int_t electronPlus;
128 Int_t electronMinus;
129 Int_t sectorElePlus[maxEle];
130 Int_t sectorEleMinus[maxEle];
131 Float_t ptElePlus[maxEle];
132 Float_t ptEleMinus[maxEle];
133 Int_t hadronLowPt;
134 Int_t hadronHighPt;
135 Int_t hadronJetLowPt;
136 Int_t hadronJetHighPt;
c202a357 137
138 hadronJetLowPt = 0;
139 hadronJetHighPt = 0;
0f20e40c 140
c965eab1 141 hadronLowPt = 0;
142 hadronHighPt = 0;
e3b2b5e5 143
c965eab1 144 electronPlus = 0;
145 electronMinus = 0;
e3b2b5e5 146
147 AliTRDgtuTrack *gtuTrack;
148 Int_t nTracks = trdTrigger.GetNumberOfTracks();
149 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
150
151 gtuTrack = trdTrigger.GetTrack(iTrack);
152
153 pid = gtuTrack->GetPID();
154 isElectron = gtuTrack->IsElectron();
155 pt = gtuTrack->GetPt();
156 det = gtuTrack->GetDetector();
e3b2b5e5 157 sec = geo->GetSector(det);
158
159 if (isElectron) {
160
161 if (pt < 0.0) {
162 sectorEleMinus[electronMinus] = sec;
163 ptEleMinus[electronMinus] = pt;
164 electronMinus++;
c965eab1 165 }
166 else {
167 sectorElePlus[electronPlus] = sec;
168 ptElePlus[electronPlus] = pt;
e3b2b5e5 169 electronPlus++;
170 }
171
c965eab1 172 }
173 else {
e3b2b5e5 174
175 if (TMath::Abs(pt) < highPt) {
176 hadronLowPt++;
c965eab1 177 }
178 else {
e3b2b5e5 179 hadronHighPt++;
180 }
181
c965eab1 182 if (TMath::Abs(pt) > jetLowPt ) {
183 hadronJetLowPt++;
184 }
185 if (TMath::Abs(pt) > jetHighPt) {
186 hadronJetHighPt++;
187 }
c202a357 188
e3b2b5e5 189 }
190
191 }
192
193 loader->UnloadTracks();
194
c965eab1 195 // Hadrons
196 if (hadronLowPt) {
197 SetInput("TRD_Hadr_LPt_L1");
198 }
199 if (hadronHighPt) {
200 SetInput("TRD_Hadr_HPt_L1");
201 }
c202a357 202
c965eab1 203 // Hadrons from jets
204 if (hadronJetLowPt >= trigp->GetNPartJetLow() ) {
205 SetInput("TRD_Jet_LPt_L1");
206 }
207 if (hadronJetHighPt >= trigp->GetNPartJetHigh()) {
208 SetInput("TRD_Jet_HPt_L1");
209 }
e3b2b5e5 210
c965eab1 211 // Electron-positron pairs (open angle > 80 deg)
212 Int_t secPlus;
213 Int_t secMinus;
214 Int_t secDiff;
e3b2b5e5 215 Bool_t electronUnlikePair = kFALSE;
216 Bool_t electronUnlikePairHPt = kFALSE;
217
c965eab1 218 if ((electronMinus > 0) &&
219 (electronPlus > 0)) {
e3b2b5e5 220 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
221 secPlus = sectorElePlus[iPlus];
222 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
223 secMinus = sectorEleMinus[iMinus];
c965eab1 224 secDiff = TMath::Abs(secPlus-secMinus);
225 if (secDiff > 9) {
226 secDiff = 18 - secDiff;
227 }
e3b2b5e5 228 if (secDiff >= 5) {
229 electronUnlikePair = kTRUE;
c965eab1 230 if ((TMath::Abs(ptElePlus[iPlus]) > highPt) &&
231 (TMath::Abs(ptEleMinus[iMinus]) > highPt)) {
e3b2b5e5 232 electronUnlikePairHPt = kTRUE;
233 }
234 }
235 }
236 }
237 }
238
c965eab1 239 if (electronUnlikePair) {
240 SetInput("TRD_Unlike_EPair_L1");
241 }
242 //if (electronUnlikePairHPt) {
243 // SetInput("TRD_Unlike_EPair_HPt_L1");
244 //}
e3b2b5e5 245
c965eab1 246 // Like electron/positron pairs
247 Bool_t ele1;
248 Bool_t ele1HPt;
249 Bool_t ele2;
250 Bool_t ele2HPt;
e3b2b5e5 251
c965eab1 252 // Positive
e3b2b5e5 253 ele1 = kFALSE;
254 ele2 = kFALSE;
255 ele1HPt = kFALSE;
256 ele2HPt = kFALSE;
257 if (electronPlus > 1) {
258 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
c965eab1 259 if (!ele1) {
e3b2b5e5 260 ele1 = kTRUE;
c965eab1 261 }
262 else if (!ele2) {
e3b2b5e5 263 ele2 = kTRUE;
264 }
265 if (TMath::Abs(ptElePlus[iPlus]) > highPt) {
c965eab1 266 if (!ele1HPt) {
e3b2b5e5 267 ele1HPt = kTRUE;
c965eab1 268 }
269 else if (!ele2HPt) {
e3b2b5e5 270 ele2HPt = kTRUE;
271 }
272 }
273 }
274 }
275
c965eab1 276 if (ele1 && ele2 ) {
277 SetInput("TRD_Like_EPair_L1");
278 }
279 //if (ele1HPt && ele2HPt) {
280 // SetInput("TRD_Like_EPair_HPt_L1");
281 //}
e3b2b5e5 282
c965eab1 283 // Negative
e3b2b5e5 284 ele1 = kFALSE;
285 ele2 = kFALSE;
286 ele1HPt = kFALSE;
287 ele2HPt = kFALSE;
288 if (electronMinus > 1) {
289 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
c965eab1 290 if (!ele1) {
e3b2b5e5 291 ele1 = kTRUE;
c965eab1 292 }
293 else if (!ele2) {
e3b2b5e5 294 ele2 = kTRUE;
295 }
296 if (TMath::Abs(ptEleMinus[iMinus]) > highPt) {
c965eab1 297 if (!ele1HPt) {
e3b2b5e5 298 ele1HPt = kTRUE;
c965eab1 299 }
300 else if (!ele2HPt) {
e3b2b5e5 301 ele2HPt = kTRUE;
302 }
303 }
304 }
305 }
306
c965eab1 307 if (ele1 && ele2 ) {
308 SetInput("TRD_Like_EPair_L1");
309 }
310 //if (ele1HPt && ele2HPt) {
311 // SetInput("TRD_Like_EPair_HPt_L1");
312 //}
e3b2b5e5 313
c965eab1 314 // Single electron/positron
e3b2b5e5 315
c965eab1 316 if ((electronPlus > 0) ||
317 (electronMinus > 0)) {
e3b2b5e5 318 SetInput("TRD_Electron_L1");
c202a357 319 /*
e3b2b5e5 320 for (Int_t iPlus = 0; iPlus < electronPlus; iPlus++) {
321 if (TMath::Abs(ptElePlus[iPlus]) > highPt) SetInput("TRD_Electron_HPt_L1");
322 break;
323 }
324 for (Int_t iMinus = 0; iMinus < electronMinus; iMinus++) {
325 if (TMath::Abs(ptEleMinus[iMinus]) > highPt) SetInput("TRD_Electron_HPt_L1");
326 break;
327 }
c202a357 328 */
e3b2b5e5 329 }
330
331}
332