...also histos are now correctly booked
[u/mrichter/AliRoot.git] / ZDC / AliZDCTriggerProcessor.cxx
CommitLineData
3288dac3 1#include "AliZDCTriggerProcessor.h"
2#include "AliCDBManager.h"
3#include "AliCDBEntry.h"
4#include "AliCDBMetaData.h"
5#include "AliLog.h"
6#include "AliZDCTriggerParameters.h"
7
8/////////////////////////////////////////////////////////////////////
9// //
10// Class implementing ZDC trigger processor. //
11// //
12/////////////////////////////////////////////////////////////////////
13
14ClassImp(AliZDCTriggerProcessor)
15
16//______________________________________________________________________________________________
17AliZDCTriggerProcessor::AliZDCTriggerProcessor() :
18 fSignal(0x0),
19 fTriggerParam(0x0)
20{
21 // default constructor
22}
23
24//______________________________________________________________________________________________
25AliZDCTriggerProcessor::AliZDCTriggerProcessor(Float_t* signal) :
26 fSignal(signal),
27 fTriggerParam(GetTriggerParamFromOCDB())
28{
29 // standard constructor I
30 // gets the trigger parameters directly from OCDB
31}
32
33//______________________________________________________________________________________________
34AliZDCTriggerProcessor::AliZDCTriggerProcessor(Float_t* signal, AliZDCTriggerParameters* ocdbParam) :
35 fSignal(signal),
36 fTriggerParam(ocdbParam)
37{
38 // standard constructor II
39}
40
db0907f4 41//_____________________________________________________________________________
42AliZDCTriggerProcessor &AliZDCTriggerProcessor::operator =(const AliZDCTriggerProcessor &trig)
43{
213a7d34 44 // Equal operator.
45 this->~AliZDCTriggerProcessor();
46 new(this) AliZDCTriggerProcessor(trig);
47 return *this;
db0907f4 48
49}
50
3288dac3 51//______________________________________________________________________________________________
52AliZDCTriggerProcessor::AliZDCTriggerProcessor(const AliZDCTriggerProcessor& trigg) :
db0907f4 53 TObject(),
3288dac3 54 fSignal(trigg.fSignal),
55 fTriggerParam(trigg.fTriggerParam)
56{
57 // copy constructor
58}
59
60//______________________________________________________________________________________________
61AliZDCTriggerProcessor::~AliZDCTriggerProcessor()
62{
63 // destructor
64}
65
66//______________________________________________________________________________________________
67UInt_t AliZDCTriggerProcessor::ProcessEvent()
68{
69 // process ZDC signals in order to determine the trigger output
70 UInt_t ctpInput = 0;
71 //
db0907f4 72 Bool_t mbTriggered = MBTrigger();
73 if(mbTriggered == kTRUE) ctpInput = 0x1;
74 Bool_t cenTriggered = CentralTrigger();
75 if(cenTriggered == kTRUE) ctpInput = 0x1 << 1;
76 Bool_t semicenTriggered = SemicentralTrigger();
77 if(semicenTriggered == kTRUE) ctpInput = 0x1 << 2;
78 Bool_t emdTriggered = EMDTrigger();
79 if(emdTriggered == kTRUE) ctpInput = 0x1 << 3;
80
81 if((mbTriggered == kTRUE) || (cenTriggered == kTRUE) ||
82 (semicenTriggered == kTRUE) || (emdTriggered == kTRUE)){
83 return 1;
84 }
85 else{
86 return 0;
87 }
3288dac3 88}
89
90//______________________________________________________________________________________________
91Bool_t AliZDCTriggerProcessor::MBTrigger()
92{
93 // is the processed event a MB A-A event?
94
95 Float_t mbTrheshold = fTriggerParam->GetADCMBThreshold();
96 // check whether ZDC signal > mbTrheshold
97 if((fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) > mbTrheshold)
98 return kTRUE;
99 else return kFALSE;
100
101}
102
103//______________________________________________________________________________________________
104Bool_t AliZDCTriggerProcessor::CentralTrigger()
105{
106 // is the processed event a central A-A event?
107
108 Float_t zemThr = fTriggerParam->GetADCZDCCentralityThr();
109 const Float_t* centralWin = fTriggerParam->GetADCCentralWindow();
110 //
111 if((fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) > centralWin[0]
112 &&
113 (fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) < centralWin[1]
114 &&
115 fSignal[2] > zemThr)
116 return kTRUE;
117 else return kFALSE;
118}
119
120//______________________________________________________________________________________________
121Bool_t AliZDCTriggerProcessor::SemicentralTrigger()
122{
123 // is the processed event a semicentral A-A event?
124
125 Float_t zemThr = fTriggerParam->GetADCZDCCentralityThr();
126 const Float_t* semicentralWin = fTriggerParam->GetADCSemicentralWindow();
127 //
128 if((fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) > semicentralWin[0]
129 &&
130 (fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) < semicentralWin[1]
131 &&
132 fSignal[2] > zemThr)
133 return kTRUE;
134 else return kFALSE;
135}
136
137//______________________________________________________________________________________________
138Bool_t AliZDCTriggerProcessor::EMDTrigger()
139{
140 // is the processed an EMD event?
141
142 const Float_t* emdWin = fTriggerParam->GetADCEMDWindow();
143 // check whether ZNA AND ZNC signals fall into the
144 // 2 distinct windows defined for EMD trigger
145 if(fSignal[0] > emdWin[0] && fSignal[0] < emdWin[1]
146 &&
147 fSignal[3] > emdWin[2] && fSignal[3] < emdWin[3])
148 return kTRUE;
149 else return kFALSE;
150}
151
152//______________________________________________________________________________________________
153AliZDCTriggerParameters* AliZDCTriggerProcessor::GetTriggerParamFromOCDB() const
154{
155 // retrieving trigger parameter configuration form OCDB
156 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Trigger/");
157 if(!entry) AliFatal("No calibration data loaded!");
158
159 AliZDCTriggerParameters *trigParam = dynamic_cast<AliZDCTriggerParameters*> (entry->GetObject());
160 if(!trigParam) AliFatal("Wrong calibration object in calibration file!");
161
162 return trigParam;
163
164}