]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDTrigger.cxx
List of Changes:
[u/mrichter/AliRoot.git] / TRD / AliTRDTrigger.cxx
CommitLineData
c8b1590d 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: AliTRDTrigger.cxx 31904 2009-04-08 16:42:03Z cblume $ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// TRD trigger interface class to CTP //
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#include "TClonesArray.h"
28
29#include "AliLog.h"
30#include "AliTriggerInput.h"
31#include "AliRunLoader.h"
32#include "AliLoader.h"
33
34#include "AliTRDgtuSim.h"
35#include "AliTRDtrackGTU.h"
36#include "AliTRDTrigger.h"
37
38AliTRDTrigger::AliTRDTrigger()
39{
40 // defautl constructor
41
42 SetName("TRD");
43}
44
45AliTRDTrigger::~AliTRDTrigger()
46{
47 // destructor
48}
49
50void AliTRDTrigger::CreateInputs()
51{
52 // Create the inputs to CTP for the TRD
53
54 // if inputs already created return
55 if (fInputs.GetEntriesFast() > 0)
56 return;
57
58 AliInfo("Creating TRD trigger inputs");
59 fInputs.AddLast(new AliTriggerInput("TRD_HIGHPT_L1", "TRD", 1));
60 fInputs.AddLast(new AliTriggerInput("TRD_JET_L1", "TRD", 1));
61}
62
63void AliTRDTrigger::Trigger()
64{
65 // TRD trigger steering
66 // currently the L1 trigger is directly put here
67 // lateron can be separated such that from here the
68 // pretrigger (generating an L0) and L1 can be called
69
70 AliRunLoader *runLoader = AliRunLoader::Instance();
71 if (!runLoader)
72 return;
73 AliLoader *trdLoader = runLoader->GetLoader("TRDLoader");
74 if (!trdLoader)
75 return;
76
77 // now running the GTU tracking;
78 AliTRDgtuSim *gtusim = new AliTRDgtuSim();
79 gtusim->RunGTU(trdLoader, 0x0);
80 gtusim->WriteTracksToLoader();
81
82 TTree *trackTree = trdLoader->GetDataLoader("gtutracks")->Tree();
83 if (!trackTree) {
84 AliDebug(1,"Did not find track tree");
85 return;
86 }
87 TBranch *branch = trackTree->GetBranch("TRDtrackGTU");
88 AliDebug(1,Form("TRD trigger: found %i tracks", trackTree->GetEntriesFast()));
89
90 // trigger thresholds should go elsewhere
91 Float_t ptThreshold1 = 2;
92 Float_t ptThreshold2 = 9.9;
93 Int_t trackThreshold1 = 6;
94 Int_t trackThreshold2 = 2;
95
96 // trigger algorithms to come, e.g.
97 Bool_t triggered_highpt = kFALSE;
98 Bool_t triggered_jet = kFALSE;
99
100 if (branch) {
101 AliTRDtrackGTU *trk = 0x0;
102 branch->SetAddress(&trk);
103
104 // high pt trigger
105 for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
106 trackTree->GetEntry(iTrack);
107 if (TMath::Abs(trk->GetPt()) > 3.0) {
108 AliInfo(Form("Found track in sector %2i, stack %i with pt = %3.1f, triggered",
109 trk->GetSector(), trk->GetStack(), trk->GetPt()));
110 triggered_highpt = kTRUE;
111 }
112 }
113
114 // jet trigger
115 Int_t nTracks1[90]; // tracks above lower pt threshold
116 Int_t nTracks2[90]; // tracks above higher pt threshold
117 for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
118 trackTree->GetEntry(iTrack);
119 if (TMath::Abs(trk->GetPt()) > ptThreshold1)
120 nTracks1[5*trk->GetSector() + trk->GetStack()]++;
121 if (TMath::Abs(trk->GetPt()) > ptThreshold2)
122 nTracks2[5*trk->GetSector() + trk->GetStack()]++;
123 }
124 for (Int_t iStack = 0; iStack < 90; iStack++) {
125 if ((nTracks1[iStack] >= trackThreshold1) || (nTracks2[iStack] >= trackThreshold2))
126 triggered_jet = kTRUE;
127 }
128 }
129 else {
130 AliWarning("GTU Branch not found");
131 }
132
133 if (triggered_highpt) {
134 AliInfo("Fired high-pt trigger");
135 SetInput("TRD_HIGHPT_L1");
136 }
137
138 if (triggered_jet) {
139 AliInfo("Fired jet trigger");
140 SetInput("TRD_JET_L1");
141 }
142
143 // cleaning up
144 delete gtusim;
145}