Replacing - by . in the AliRoot versions used in the spec file
[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"
c93255fe 29#include <TTree.h>
e58e15dc 30
31#include "AliLog.h"
32#include "AliTriggerInput.h"
33#include "AliRunLoader.h"
34#include "AliLoader.h"
35
36#include "AliTRDTriggerL1.h"
37#include "AliTRDgtuSim.h"
38#include "AliTRDtrackGTU.h"
39
40AliTRDTriggerL1::AliTRDTriggerL1()
41{
42 SetName("TRD");
43}
44
45AliTRDTriggerL1::~AliTRDTriggerL1()
46{
47
48}
49
50void AliTRDTriggerL1::CreateInputs()
51{
36dc3337 52 // create the trigger inputs for TRD
53
e58e15dc 54 if (fInputs.GetEntriesFast() > 0)
55 return;
56
e43b478f 57 fInputs.AddLast(new AliTriggerInput("1HSH", "TRD", 1));
58 fInputs.AddLast(new AliTriggerInput("1HJT", "TRD", 1));
e58e15dc 59}
60
61void AliTRDTriggerL1::Trigger()
62{
36dc3337 63 // run the trigger algorithms
64
e58e15dc 65 AliRunLoader *runLoader = AliRunLoader::Instance();
66 if (!runLoader)
67 return;
68 AliLoader *trdLoader = runLoader->GetLoader("TRDLoader");
69 if (!trdLoader)
70 return;
5f006bd7 71
e58e15dc 72 // now running the GTU tracking;
73 AliTRDgtuSim *gtusim = new AliTRDgtuSim();
74 gtusim->RunGTU(trdLoader, 0x0);
5f006bd7 75
e58e15dc 76 TTree *trackTree = trdLoader->GetDataLoader("gtutracks")->Tree();
77 if (!trackTree) {
78 AliDebug(1,"Did not find track tree");
79 return;
80 }
81 TBranch *branch = trackTree->GetBranch("TRDtrackGTU");
20a6e9c2 82 AliDebug(1,Form("TRD trigger: found %lld tracks", trackTree->GetEntriesFast()));
5f006bd7 83
e58e15dc 84 // trigger thresholds should go elsewhere
85 Float_t ptThreshold1 = 2;
86 Float_t ptThreshold2 = 9.9;
87 Int_t trackThreshold1 = 6;
88 Int_t trackThreshold2 = 2;
5f006bd7 89
e58e15dc 90 // trigger algorithms to come, e.g.
36dc3337 91 Bool_t triggeredHighPt = kFALSE;
92 Bool_t triggeredJet = kFALSE;
5f006bd7 93
e58e15dc 94 if (branch) {
95 AliTRDtrackGTU *trk = 0x0;
96 branch->SetAddress(&trk);
97
98 // high pt trigger
99 for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
100 trackTree->GetEntry(iTrack);
101 if (TMath::Abs(trk->GetPt()) > 3.0) {
5f006bd7 102 AliDebug(1, Form("Found track in sector %2i, stack %i with pt = %3.1f, triggered",
e58e15dc 103 trk->GetSector(), trk->GetStack(), trk->GetPt()));
36dc3337 104 triggeredHighPt = kTRUE;
e58e15dc 105 }
106 }
107
108 // jet trigger
109 Int_t nTracks1[90]; // tracks above lower pt threshold
110 Int_t nTracks2[90]; // tracks above higher pt threshold
2f9bdd85 111 memset(nTracks1,0,sizeof(Int_t)*90);
112 memset(nTracks2,0,sizeof(Int_t)*90);
e58e15dc 113 for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
114 trackTree->GetEntry(iTrack);
115 if (TMath::Abs(trk->GetPt()) > ptThreshold1)
116 nTracks1[5*trk->GetSector() + trk->GetStack()]++;
117 if (TMath::Abs(trk->GetPt()) > ptThreshold2)
118 nTracks2[5*trk->GetSector() + trk->GetStack()]++;
119 }
120 for (Int_t iStack = 0; iStack < 90; iStack++) {
121 if ((nTracks1[iStack] >= trackThreshold1) || (nTracks2[iStack] >= trackThreshold2))
36dc3337 122 triggeredJet = kTRUE;
e58e15dc 123 }
124 }
125 else {
126 AliWarning("GTU Branch not found");
127 }
128
5f006bd7 129 if (triggeredHighPt) {
e58e15dc 130 AliInfo("Fired high-pt trigger");
e43b478f 131 SetInput("1HSH");
e58e15dc 132 }
133
36dc3337 134 if (triggeredJet) {
e58e15dc 135 AliInfo("Fired jet trigger");
e43b478f 136 SetInput("1HJT");
e58e15dc 137 }
138
139 // cleaning up
140 delete gtusim;
141}