1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTRDTrigger.cxx 31904 2009-04-08 16:42:03Z cblume $ */
18 ///////////////////////////////////////////////////////////////////////////////
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 //
25 ///////////////////////////////////////////////////////////////////////////////
27 #include "TClonesArray.h"
30 #include "AliTriggerInput.h"
31 #include "AliRunLoader.h"
32 #include "AliLoader.h"
34 #include "AliTRDgtuSim.h"
35 #include "AliTRDtrackGTU.h"
36 #include "AliTRDTrigger.h"
38 AliTRDTrigger::AliTRDTrigger()
40 // defautl constructor
45 AliTRDTrigger::~AliTRDTrigger()
50 void AliTRDTrigger::CreateInputs()
52 // Create the inputs to CTP for the TRD
54 // if inputs already created return
55 if (fInputs.GetEntriesFast() > 0)
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));
63 void AliTRDTrigger::Trigger()
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
70 AliRunLoader *runLoader = AliRunLoader::Instance();
73 AliLoader *trdLoader = runLoader->GetLoader("TRDLoader");
77 // now running the GTU tracking;
78 AliTRDgtuSim *gtusim = new AliTRDgtuSim();
79 gtusim->RunGTU(trdLoader, 0x0);
80 gtusim->WriteTracksToLoader();
82 TTree *trackTree = trdLoader->GetDataLoader("gtutracks")->Tree();
84 AliDebug(1,"Did not find track tree");
87 TBranch *branch = trackTree->GetBranch("TRDtrackGTU");
88 AliDebug(1,Form("TRD trigger: found %i tracks", trackTree->GetEntriesFast()));
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;
96 // trigger algorithms to come, e.g.
97 Bool_t triggered_highpt = kFALSE;
98 Bool_t triggered_jet = kFALSE;
101 AliTRDtrackGTU *trk = 0x0;
102 branch->SetAddress(&trk);
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;
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()]++;
124 for (Int_t iStack = 0; iStack < 90; iStack++) {
125 if ((nTracks1[iStack] >= trackThreshold1) || (nTracks2[iStack] >= trackThreshold2))
126 triggered_jet = kTRUE;
130 AliWarning("GTU Branch not found");
133 if (triggered_highpt) {
134 AliInfo("Fired high-pt trigger");
135 SetInput("TRD_HIGHPT_L1");
139 AliInfo("Fired jet trigger");
140 SetInput("TRD_JET_L1");