track number corrected
[u/mrichter/AliRoot.git] / MUON / AliMUONTrigger.cxx
CommitLineData
3b2353d8 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$ */
17
445096c0 18#include "AliMUONTrigger.h"
7ca4655f 19
3b2353d8 20#include "AliLog.h"
445096c0 21#include "AliMUONGlobalTrigger.h"
22#include "AliMUONVTriggerStore.h"
3b2353d8 23#include "AliRun.h"
24#include "AliRunLoader.h"
25#include "AliTriggerInput.h"
26
d133db99 27
28//-----------------------------------------------------------------------------
85fec35d 29/// \class AliMUONTrigger
30///
31/// Implementation of AliTriggerDetector for MUON detector
32///
33/// So far, the inputs are taken from AliMUONTriggerDecision object
f57d136a 34/// April 06, E.L.T.
35/// May 06, taken info from Global Trigger branch (Ch.F)
d133db99 36///
37/// \author E. Lopez Torres
38//-----------------------------------------------------------------------------
85fec35d 39
3b2353d8 40//----------------------------------------------------------------------
71a2d3aa 41/// \cond CLASSIMP
3b2353d8 42ClassImp(AliMUONTrigger)
71a2d3aa 43/// \endcond
3b2353d8 44
45//----------------------------------------------------------------------
46AliMUONTrigger::AliMUONTrigger()
445096c0 47 : AliTriggerDetector(), fTriggerStore(0x0)
3b2353d8 48{
71a2d3aa 49/// Default constructor
50
3b2353d8 51 SetName("MUON");
52 CreateInputs();
53}
54
55//----------------------------------------------------------------------
71a2d3aa 56AliMUONTrigger::~AliMUONTrigger()
57{
445096c0 58 /// Destructor
59 delete fTriggerStore;
71a2d3aa 60}
61
62//----------------------------------------------------------------------
3b2353d8 63void AliMUONTrigger::CreateInputs()
64{
71a2d3aa 65 /// inputs
3b2353d8 66
67 // Do not create inputs again!!
68 if( fInputs.GetEntriesFast() > 0 ) return;
69
572b6f20 70 fInputs.AddLast( new AliTriggerInput( "MUON_Single_LPt_L0", "MUONTRG", 0 ) );
71 fInputs.AddLast( new AliTriggerInput( "MUON_Single_HPt_L0", "MUONTRG", 0 ) );
3b2353d8 72
572b6f20 73 fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_LPt_L0", "MUONTRG", 0 ) );
74 fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_HPt_L0", "MUONTRG", 0 ) );
3b2353d8 75
572b6f20 76 fInputs.AddLast( new AliTriggerInput( "MUON_Like_LPt_L0", "MUONTRG", 0 ) );
77 fInputs.AddLast( new AliTriggerInput( "MUON_Like_HPt_L0", "MUONTRG", 0 ) );
3b2353d8 78}
79
80//----------------------------------------------------------------------
81void AliMUONTrigger::Trigger()
82{
71a2d3aa 83 /// sets the trigger inputs
84
d3b3a3b2 85 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
445096c0 86
87 AliLoader * muonLoader = runLoader->GetDetectorLoader("MUON");
84aac932 88 muonLoader->LoadDigits("READ");
f57d136a 89
445096c0 90 TTree* treeD = muonLoader->TreeD();
91
92 if (!treeD)
93 {
94 AliError("No TreeD available. Cannot make trigger");
698b2e52 95 return;
96 }
445096c0 97
98 if (!fTriggerStore)
99 {
100 fTriggerStore = AliMUONVTriggerStore::Create(*treeD);
101 if (!fTriggerStore)
102 {
103 AliError("Could not create triggerStore from treeD");
104 return;
105 }
106 }
f57d136a 107
445096c0 108 Bool_t ok = fTriggerStore->Connect(*treeD,kTRUE);
109
110 if (!ok)
111 {
112 AliError("Could not read trigger from TreeD !");
f57d136a 113 return;
114 }
3b2353d8 115
445096c0 116 treeD->GetEvent(0);
3b2353d8 117
445096c0 118 AliMUONGlobalTrigger* globalTrigger = fTriggerStore->Global();
119 if (globalTrigger == 0x0)
120 {
121 AliWarning("No Global Trigger available");
122 }
123 else
124 {
125 // set CTP
126 if (globalTrigger->SingleLpt()) SetInput("MUON_Single_LPt_L0");
127 if (globalTrigger->SingleHpt()) SetInput("MUON_Single_HPt_L0");
128
129 if (globalTrigger->PairUnlikeLpt()) SetInput("MUON_Unlike_LPt_L0");
130 if (globalTrigger->PairUnlikeHpt()) SetInput("MUON_Unlike_HPt_L0");
131
132 if (globalTrigger->PairLikeLpt()) SetInput("MUON_Like_LPt_L0");
133 if (globalTrigger->PairLikeHpt()) SetInput("MUON_Like_HPt_L0");
134 }
f57d136a 135 muonLoader->UnloadDigits();
445096c0 136 fTriggerStore->Clear();
3b2353d8 137}