]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDTriggerL1.cxx
- fix warnings in TRD online track matching
[u/mrichter/AliRoot.git] / TRD / AliTRDTriggerL1.cxx
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 #include <TTree.h>
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 #include "AliTRDcalibDB.h"
40 #include "AliTRDCalDCSGTU.h"
41
42 AliTRDTriggerL1::AliTRDTriggerL1() :
43   AliTriggerDetector(),
44   fPtThresholdA(3.),
45   fPtThresholdB(5.),
46   fPidThresholdA(0),
47   fPidThresholdB(185),
48   fNoThreshold(1),
49   fNoThresholdA(3),
50   fNoThresholdB(200),
51   fNoThresholdJetA(3),
52   fNoThresholdJetB(200),
53   fNoThresholdElA(1),
54   fNoThresholdElB(1)
55 {
56   // ctor
57
58   SetName("TRD");
59 }
60
61 AliTRDTriggerL1::~AliTRDTriggerL1()
62 {
63   // dtor
64 }
65
66 void AliTRDTriggerL1::CreateInputs()
67 {
68   // create the trigger inputs for TRD
69
70   if (fInputs.GetEntriesFast() > 0)
71     return;
72
73   fInputs.AddLast(new AliTriggerInput("1HCO", "TRD", 1));
74   fInputs.AddLast(new AliTriggerInput("1HJT", "TRD", 1));
75   fInputs.AddLast(new AliTriggerInput("1HSE", "TRD", 1));
76 }
77
78 void AliTRDTriggerL1::Trigger()
79 {
80   // run the trigger algorithms
81
82   AliRunLoader *runLoader = AliRunLoader::Instance();
83   if (!runLoader)
84     return;
85   AliLoader *trdLoader = runLoader->GetLoader("TRDLoader");
86   if (!trdLoader)
87     return;
88
89   // now running the GTU tracking;
90   AliTRDgtuSim *gtusim = new AliTRDgtuSim();
91   gtusim->RunGTU(trdLoader, 0x0);
92
93   TTree *trackTree = trdLoader->GetDataLoader("gtutracks")->Tree();
94   if (!trackTree) {
95     AliDebug(1,"Did not find track tree");
96     return;
97   }
98   TBranch *branch = trackTree->GetBranch("TRDtrackGTU");
99   AliDebug(1,Form("TRD trigger: found %lld tracks", trackTree->GetEntriesFast()));
100
101   // trigger algorithms to come, e.g.
102   Bool_t triggered1HCO    = kFALSE;
103   Bool_t triggered1HJT    = kFALSE;
104   Bool_t triggered1HSE    = kFALSE;
105
106   if (branch) {
107     AliTRDtrackGTU *trk = 0x0;
108     branch->SetAddress(&trk);
109
110     Int_t nTracks[90]      = { 0 }; // number of tracks
111     Int_t nTracksA[90]     = { 0 }; // number of tracks above pt threshold A
112     Int_t nTracksB[90]     = { 0 }; // number of tracks above pt threshold B
113     Int_t nTracksElA[90]   = { 0 }; // number of tracks above pt threshold A and PID threshold A
114     Int_t nTracksElB[90]   = { 0 }; // number of tracks above pt threshold B and PID threshold B
115
116     for (Int_t iTrack = 0; iTrack < trackTree->GetEntriesFast(); iTrack++) {
117       trackTree->GetEntry(iTrack);
118
119       nTracks[5*trk->GetSector() + trk->GetStack()]++;
120
121       if (TMath::Abs(trk->GetPt()) > fPtThresholdA) {
122         nTracksA[5*trk->GetSector() + trk->GetStack()]++;
123         if (trk->GetPID() > fPidThresholdA)
124           nTracksElA[5*trk->GetSector() + trk->GetStack()]++;
125       }
126
127       if (TMath::Abs(trk->GetPt()) > fPtThresholdB) {
128         nTracksB[5*trk->GetSector() + trk->GetStack()]++;
129         if (trk->GetPID() > fPidThresholdB)
130           nTracksElB[5*trk->GetSector() + trk->GetStack()]++;
131       }
132     }
133
134     for (Int_t iStack = 0; iStack < 90; iStack++) {
135       if ((nTracksA[iStack] >= fNoThresholdJetA) || (nTracksB[iStack] >= fNoThresholdJetB))
136         triggered1HJT = kTRUE;
137
138       if ((nTracksElA[iStack] >= fNoThresholdElA))
139         triggered1HCO = kTRUE;
140
141       if ((nTracksElB[iStack] >= fNoThresholdElB))
142         triggered1HSE = kTRUE;
143     }
144   }
145   else {
146     AliWarning("GTU Branch not found");
147   }
148
149   if (triggered1HCO) {
150     AliDebug(1, "Fired cosmic trigger");
151     SetInput("1HCO");
152   }
153
154   if (triggered1HJT) {
155     AliDebug(1, "Fired jet trigger");
156     SetInput("1HJT");
157   }
158
159   if (triggered1HSE) {
160     AliDebug(1, "Fired single electron trigger");
161     SetInput("1HSE");
162   }
163
164   // cleaning up
165   delete gtusim;
166 }