Extension to L0 and L1 trigger classes
[u/mrichter/AliRoot.git] / TRD / AliTRDTriggerL1.cxx
CommitLineData
e58e15dc 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/* $Id: AliTRDTriggerL1.cxx 31904 2009-04-08 16:42:03Z cblume $ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// TRD trigger L1 (GTU) simulation steering //
21// currently the Trigger() method calls the GTU tracking simulation and //
22// runs two example triggers, namely on a single high pt particle and //
23// on a jet. //
24// //
25///////////////////////////////////////////////////////////////////////////////
26
27
28#include "TObjArray.h"
29
30#include "AliLog.h"
31#include "AliTriggerInput.h"
32#include "AliRunLoader.h"
33#include "AliLoader.h"
34
35#include "AliTRDTriggerL1.h"
36#include "AliTRDgtuSim.h"
37#include "AliTRDtrackGTU.h"
38
39AliTRDTriggerL1::AliTRDTriggerL1()
40{
41 SetName("TRD");
42}
43
44AliTRDTriggerL1::~AliTRDTriggerL1()
45{
46
47}
48
49void AliTRDTriggerL1::CreateInputs()
50{
51 if (fInputs.GetEntriesFast() > 0)
52 return;
53
54 fInputs.AddLast(new AliTriggerInput("TRD_HIGHPT_L1", "TRD", 1));
55 fInputs.AddLast(new AliTriggerInput("TRD_JET_L1", "TRD", 1));
56}
57
58void AliTRDTriggerL1::Trigger()
59{
60 AliRunLoader *runLoader = AliRunLoader::Instance();
61 if (!runLoader)
62 return;
63 AliLoader *trdLoader = runLoader->GetLoader("TRDLoader");
64 if (!trdLoader)
65 return;
66
67 // now running the GTU tracking;
68 AliTRDgtuSim *gtusim = new AliTRDgtuSim();
69 gtusim->RunGTU(trdLoader, 0x0);
70 gtusim->WriteTracksToLoader();
71
72 TTree *trackTree = trdLoader->GetDataLoader("gtutracks")->Tree();
73 if (!trackTree) {
74 AliDebug(1,"Did not find track tree");
75 return;
76 }
77 TBranch *branch = trackTree->GetBranch("TRDtrackGTU");
78 AliDebug(1,Form("TRD trigger: found %i tracks", trackTree->GetEntriesFast()));
79
80 // trigger thresholds should go elsewhere
81 Float_t ptThreshold1 = 2;
82 Float_t ptThreshold2 = 9.9;
83 Int_t trackThreshold1 = 6;
84 Int_t trackThreshold2 = 2;
85
86 // trigger algorithms to come, e.g.
87 Bool_t triggered_highpt = kFALSE;
88 Bool_t triggered_jet = kFALSE;
89
90 if (branch) {
91 AliTRDtrackGTU *trk = 0x0;
92 branch->SetAddress(&trk);
93
94 // high pt trigger
95 for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
96 trackTree->GetEntry(iTrack);
97 if (TMath::Abs(trk->GetPt()) > 3.0) {
98 AliDebug(1, Form("Found track in sector %2i, stack %i with pt = %3.1f, triggered",
99 trk->GetSector(), trk->GetStack(), trk->GetPt()));
100 triggered_highpt = kTRUE;
101 }
102 }
103
104 // jet trigger
105 Int_t nTracks1[90]; // tracks above lower pt threshold
106 Int_t nTracks2[90]; // tracks above higher pt threshold
107 for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
108 trackTree->GetEntry(iTrack);
109 if (TMath::Abs(trk->GetPt()) > ptThreshold1)
110 nTracks1[5*trk->GetSector() + trk->GetStack()]++;
111 if (TMath::Abs(trk->GetPt()) > ptThreshold2)
112 nTracks2[5*trk->GetSector() + trk->GetStack()]++;
113 }
114 for (Int_t iStack = 0; iStack < 90; iStack++) {
115 if ((nTracks1[iStack] >= trackThreshold1) || (nTracks2[iStack] >= trackThreshold2))
116 triggered_jet = kTRUE;
117 }
118 }
119 else {
120 AliWarning("GTU Branch not found");
121 }
122
123 if (triggered_highpt) {
124 AliInfo("Fired high-pt trigger");
125 SetInput("TRD_HIGHPT_L1");
126 }
127
128 if (triggered_jet) {
129 AliInfo("Fired jet trigger");
130 SetInput("TRD_JET_L1");
131 }
132
133 // cleaning up
134 delete gtusim;
135}