]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROTriggerMask.cxx
only process physics and pedestals runs - no longer standalone runs
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTriggerMask.cxx
CommitLineData
a055ee24 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$ */
2647fc37 17//-------------------------------------------
18// Class : AliVZEROTriggerMask
19//
20// Fill up the trigger mask word.
21//
22
a055ee24 23#include <Riostream.h>
24#include <TGeoManager.h>
25#include <TGeoMatrix.h>
26#include <TGeoPhysicalNode.h>
b44c933e 27#include <TF1.h>
28#include <TMath.h>
2647fc37 29
a055ee24 30#include <AliGeomManager.h>
a055ee24 31#include "AliLog.h"
32#include "AliVZEROTriggerMask.h"
b44c933e 33#include "AliVZEROConst.h"
34#include "AliVZEROCalibData.h"
35#include "AliESDVZERO.h"
36#include "AliVZEROReconstructor.h"
a055ee24 37
38//______________________________________________________________________
39ClassImp(AliVZEROTriggerMask)
40
41//______________________________________________________________________
42
43AliVZEROTriggerMask::AliVZEROTriggerMask()
44 :TObject(),
45 fAdcThresHold(0.0),
b44c933e 46 fTimeWindowBBALow(-9.5),
47 fTimeWindowBBAUp(22.5),
48 fTimeWindowBGALow(-2.5),
49 fTimeWindowBGAUp(5.0),
50 fTimeWindowFakeALow(-17.5),
51 fTimeWindowFakeAUp(-9.5),
52 fTimeWindowBBCLow(-2.5),
53 fTimeWindowBBCUp(22.5),
54 fTimeWindowBGCLow(-2.5),
55 fTimeWindowBGCUp(2.5),
56 fTimeWindowFakeCLow(-22.5),
57 fTimeWindowFakeCUp(-8.5),
58 fV0ADist(0),
59 fV0CDist(0)
a055ee24 60{
b44c933e 61 // Default constructor
62 //
63 Float_t zV0A = TMath::Abs(GetZPosition("VZERO/V0A"));
64 Float_t zV0C = TMath::Abs(GetZPosition("VZERO/V0C"));
65
66 // distance in time units from nominal vertex to V0
67 fV0ADist = zV0A/TMath::Ccgs()*1e9;
68 fV0CDist = zV0C/TMath::Ccgs()*1e9;
a055ee24 69}
70
71//________________________________________________________________________________
72Double_t AliVZEROTriggerMask::GetZPosition(const char* symname){
73// Get the global z coordinate of the given V0 alignable volume
74//
75 Double_t *tr;
76 TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname);
b44c933e 77 if (!pne) {
78 AliFatalClass(Form("TGeoPNEntry with symbolic name %s does not exist!",symname));
79 return 0;
80 }
a055ee24 81
82 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
83 if(pnode){
84 TGeoHMatrix* hm = pnode->GetMatrix();
85 tr = hm->GetTranslation();
86 }else{
87 const char* path = pne->GetTitle();
88 if(!gGeoManager->cd(path)){
b44c933e 89 AliFatalClass(Form("Volume path %s not valid!",path));
a055ee24 90 return 0;
91 }
92 tr = gGeoManager->GetCurrentMatrix()->GetTranslation();
93 }
94 return tr[2];
95
96}
97
98//________________________________________________________________________________
99
100
b44c933e 101void AliVZEROTriggerMask::FillMasks(AliESDVZERO *esdV0,
102 AliVZEROCalibData *cal,
103 TF1 *slewing)
a055ee24 104{
b44c933e 105 // Fill up the trigger mask word
106 // using the TDC data (already corrected for
107 // slewing and misalignment between channels)
108
109 esdV0->SetBit(AliESDVZERO::kTriggerBitsFilled,kTRUE);
110 esdV0->SetBit(AliESDVZERO::kDecisionFilled,kTRUE);
111
112 UInt_t aBBtriggerV0A = 0; // bit mask for Beam-Beam trigger in V0A
113 UInt_t aBGtriggerV0A = 0; // bit mask for Beam-Gas trigger in V0A
114 UInt_t aBBtriggerV0C = 0; // bit mask for Beam-Beam trigger in V0C
115 UInt_t aBGtriggerV0C = 0; // bit mask for Beam-Gas trigger in V0C
116
117 const Float_t p1 = 2.19; // photostatistics term in the time resolution
118 const Float_t p2 = 1.31; // slewing related term in the time resolution
119
120 // loop over vzero channels
121 Float_t timeAW = 0,timeCW = 0;
122 Float_t weightA = 0,weightC = 0;
123 Int_t ntimeA = 0, ntimeC = 0;
124 for (Int_t i = 0; i < 64; ++i) {
125 Float_t adc = esdV0->GetAdc(i);
126 if (adc > fAdcThresHold) {
127 Float_t tdc = esdV0->GetTime(i);
128 if (tdc > (AliVZEROReconstructor::kInvalidTime + 1e-6)) {
129 Float_t nphe = adc*kChargePerADC/(cal->GetGain(i)*TMath::Qe());
130 Float_t timeErr = TMath::Sqrt(kIntTimeRes*kIntTimeRes+
131 p1*p1/nphe+
132 p2*p2*(slewing->GetParameter(0)*slewing->GetParameter(1))*(slewing->GetParameter(0)*slewing->GetParameter(1))*
133 TMath::Power(adc/cal->GetDiscriThr(i),2.*(slewing->GetParameter(1)-1.)));
134
135 if (i < 32) { // in V0C
136 ntimeC++;
137 timeCW += tdc/(timeErr*timeErr);
138 weightC += 1.0/(timeErr*timeErr);
139
140 if (tdc > (fV0CDist + fTimeWindowBBCLow) &&
141 tdc < (fV0CDist + fTimeWindowBBCUp))
142 aBBtriggerV0C |= (1 << i);
143 if (tdc > (-fV0CDist + fTimeWindowBGCLow) &&
144 tdc < (-fV0CDist + fTimeWindowBGCUp))
145 aBGtriggerV0C |= (1 << i);
a055ee24 146 }
b44c933e 147 else { // in V0A
148 ntimeA++;
149 timeAW += tdc/(timeErr*timeErr);
150 weightA += 1.0/(timeErr*timeErr);
151
152 Int_t shift = i - 32;
153 if (tdc > (fV0ADist + fTimeWindowBBALow) &&
154 tdc < (fV0ADist + fTimeWindowBBAUp))
155 aBBtriggerV0A |= (1 << shift);
156 if (tdc > (-fV0ADist + fTimeWindowBGALow) &&
157 tdc < (-fV0ADist + fTimeWindowBGAUp))
158 aBGtriggerV0A |= (1 << shift);
a055ee24 159 }
160 }
b44c933e 161 }
162 } // end of loop over channels
163
164 esdV0->SetBBtriggerV0A(aBBtriggerV0A);
165 esdV0->SetBGtriggerV0A(aBGtriggerV0A);
166 esdV0->SetBBtriggerV0C(aBBtriggerV0C);
167 esdV0->SetBGtriggerV0C(aBGtriggerV0C);
168
169 if (weightA > 0) timeAW = timeAW/weightA;
170 else timeAW = AliVZEROReconstructor::kInvalidTime;
171
172 if (weightC > 0) timeCW = timeCW/weightC;
173 else timeCW = AliVZEROReconstructor::kInvalidTime;
174
175 esdV0->SetV0ATime(timeAW);
176 esdV0->SetV0CTime(timeCW);
177 esdV0->SetV0ATimeError((weightA > 0) ? (1./TMath::Sqrt(weightA)) : 0);
178 esdV0->SetV0ATimeError((weightC > 0) ? (1./TMath::Sqrt(weightC)) : 0);
179
180 esdV0->SetV0ADecision(AliESDVZERO::kV0Empty);
181 esdV0->SetV0CDecision(AliESDVZERO::kV0Empty);
182
183 if (timeAW > (fV0ADist + fTimeWindowBBALow) &&
184 timeAW < (fV0ADist + fTimeWindowBBAUp))
185 esdV0->SetV0ADecision(AliESDVZERO::kV0BB);
186 else if (timeAW > (-fV0ADist + fTimeWindowBGALow) &&
187 timeAW < (-fV0ADist + fTimeWindowBGAUp))
188 esdV0->SetV0ADecision(AliESDVZERO::kV0BG);
189 else if (timeAW > (fV0ADist + fTimeWindowFakeALow) &&
190 timeAW < (fV0ADist + fTimeWindowFakeAUp))
191 esdV0->SetV0ADecision(AliESDVZERO::kV0Fake);
192
193 if (timeCW > (fV0CDist + fTimeWindowBBCLow) &&
194 timeCW < (fV0CDist + fTimeWindowBBCUp))
195 esdV0->SetV0CDecision(AliESDVZERO::kV0BB);
196 else if (timeCW > (-fV0CDist + fTimeWindowBGCLow) &&
197 timeCW < (-fV0CDist + fTimeWindowBGCUp))
198 esdV0->SetV0CDecision(AliESDVZERO::kV0BG);
199 else if (timeCW > (fV0CDist + fTimeWindowFakeCLow) &&
200 timeCW < (fV0CDist + fTimeWindowFakeCUp))
201 esdV0->SetV0CDecision(AliESDVZERO::kV0Fake);
202
a055ee24 203}