Classes for trigger processing in simulation
[u/mrichter/AliRoot.git] / ZDC / AliZDCTriggerProcessor.cxx
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
14 ClassImp(AliZDCTriggerProcessor)
15
16 //______________________________________________________________________________________________
17 AliZDCTriggerProcessor::AliZDCTriggerProcessor() :
18   fSignal(0x0),
19   fTriggerParam(0x0)
20 {
21   // default constructor
22 }
23
24 //______________________________________________________________________________________________
25 AliZDCTriggerProcessor::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 //______________________________________________________________________________________________
34 AliZDCTriggerProcessor::AliZDCTriggerProcessor(Float_t* signal, AliZDCTriggerParameters* ocdbParam) :
35   fSignal(signal),
36   fTriggerParam(ocdbParam)
37 {
38   // standard constructor II
39 }
40
41 //______________________________________________________________________________________________
42 AliZDCTriggerProcessor::AliZDCTriggerProcessor(const AliZDCTriggerProcessor& trigg) :
43   fSignal(trigg.fSignal),
44   fTriggerParam(trigg.fTriggerParam)
45 {
46   // copy constructor
47 }
48
49 //______________________________________________________________________________________________
50 AliZDCTriggerProcessor::~AliZDCTriggerProcessor()
51 {
52   // destructor
53 }
54
55 //______________________________________________________________________________________________
56 UInt_t AliZDCTriggerProcessor::ProcessEvent()
57 {
58   // process ZDC signals in order to determine the trigger output
59   UInt_t ctpInput = 0;
60   //
61   if(MBTrigger() == kTRUE) ctpInput = 0x1;
62   if(CentralTrigger() == kTRUE) ctpInput = 0x1 << 1;
63   if(SemicentralTrigger() == kTRUE) ctpInput = 0x1 << 2;
64   if(EMDTrigger() == kTRUE) ctpInput = 0x1 << 3;
65 }
66
67 //______________________________________________________________________________________________
68 Bool_t AliZDCTriggerProcessor::MBTrigger()
69 {
70   // is the processed event a MB A-A event?
71   
72   Float_t mbTrheshold = fTriggerParam->GetADCMBThreshold();
73   // check whether ZDC signal > mbTrheshold
74   if((fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) > mbTrheshold)
75        return kTRUE;
76   else return kFALSE;
77   
78 }
79
80 //______________________________________________________________________________________________
81 Bool_t AliZDCTriggerProcessor::CentralTrigger()
82 {
83   // is the processed event a central A-A event?
84   
85   Float_t zemThr = fTriggerParam->GetADCZDCCentralityThr();
86   const Float_t* centralWin = fTriggerParam->GetADCCentralWindow();
87   // 
88   if((fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) > centralWin[0]
89      && 
90      (fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) < centralWin[1]
91      &&
92      fSignal[2] > zemThr)
93         return kTRUE;
94   else return kFALSE;
95 }
96
97 //______________________________________________________________________________________________
98 Bool_t AliZDCTriggerProcessor::SemicentralTrigger()
99 {
100   // is the processed event a semicentral A-A event?
101   
102   Float_t zemThr =  fTriggerParam->GetADCZDCCentralityThr();
103   const Float_t* semicentralWin =   fTriggerParam->GetADCSemicentralWindow();
104   //
105   if((fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) > semicentralWin[0]
106      && 
107      (fSignal[0]+fSignal[1]+fSignal[3]+fSignal[4]) < semicentralWin[1]
108      &&
109      fSignal[2] > zemThr)
110         return kTRUE;
111   else return kFALSE;
112 }
113
114 //______________________________________________________________________________________________
115 Bool_t AliZDCTriggerProcessor::EMDTrigger()
116 {
117   // is the processed an EMD event?
118   
119   const Float_t* emdWin =   fTriggerParam->GetADCEMDWindow();
120   // check whether ZNA AND ZNC signals fall into the 
121   // 2 distinct windows defined for EMD trigger
122   if(fSignal[0] > emdWin[0] && fSignal[0] < emdWin[1]
123      &&
124      fSignal[3] > emdWin[2] && fSignal[3] < emdWin[3])
125         return kTRUE;
126   else return kFALSE;
127 }
128
129 //______________________________________________________________________________________________
130 AliZDCTriggerParameters* AliZDCTriggerProcessor::GetTriggerParamFromOCDB() const
131 {
132   // retrieving trigger parameter configuration form OCDB
133   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("ZDC/Trigger/");
134   if(!entry) AliFatal("No calibration data loaded!");  
135
136   AliZDCTriggerParameters *trigParam = dynamic_cast<AliZDCTriggerParameters*>  (entry->GetObject());
137   if(!trigParam)  AliFatal("Wrong calibration object in calibration  file!");
138
139   return trigParam;
140   
141 }