]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROTriggerMask.cxx
New more precise light yields from Raphael. It is time to put them as an object in...
[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
46f94ab3 117 const Float_t p1 = 2.50; // photostatistics term in the time resolution
118 const Float_t p2 = 3.00; // slewing related term in the time resolution
b44c933e 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))*
dc34b140 133 TMath::Power(adc/cal->GetDiscriThr(i),2.*(slewing->GetParameter(1)-1.))/
134 (cal->GetDiscriThr(i)*cal->GetDiscriThr(i)));
b44c933e 135
136 if (i < 32) { // in V0C
137 ntimeC++;
138 timeCW += tdc/(timeErr*timeErr);
139 weightC += 1.0/(timeErr*timeErr);
140
141 if (tdc > (fV0CDist + fTimeWindowBBCLow) &&
142 tdc < (fV0CDist + fTimeWindowBBCUp))
143 aBBtriggerV0C |= (1 << i);
144 if (tdc > (-fV0CDist + fTimeWindowBGCLow) &&
145 tdc < (-fV0CDist + fTimeWindowBGCUp))
146 aBGtriggerV0C |= (1 << i);
a055ee24 147 }
b44c933e 148 else { // in V0A
149 ntimeA++;
150 timeAW += tdc/(timeErr*timeErr);
151 weightA += 1.0/(timeErr*timeErr);
152
153 Int_t shift = i - 32;
154 if (tdc > (fV0ADist + fTimeWindowBBALow) &&
155 tdc < (fV0ADist + fTimeWindowBBAUp))
156 aBBtriggerV0A |= (1 << shift);
157 if (tdc > (-fV0ADist + fTimeWindowBGALow) &&
158 tdc < (-fV0ADist + fTimeWindowBGAUp))
159 aBGtriggerV0A |= (1 << shift);
a055ee24 160 }
161 }
b44c933e 162 }
163 } // end of loop over channels
164
165 esdV0->SetBBtriggerV0A(aBBtriggerV0A);
166 esdV0->SetBGtriggerV0A(aBGtriggerV0A);
167 esdV0->SetBBtriggerV0C(aBBtriggerV0C);
168 esdV0->SetBGtriggerV0C(aBGtriggerV0C);
169
170 if (weightA > 0) timeAW = timeAW/weightA;
171 else timeAW = AliVZEROReconstructor::kInvalidTime;
172
173 if (weightC > 0) timeCW = timeCW/weightC;
174 else timeCW = AliVZEROReconstructor::kInvalidTime;
175
176 esdV0->SetV0ATime(timeAW);
177 esdV0->SetV0CTime(timeCW);
178 esdV0->SetV0ATimeError((weightA > 0) ? (1./TMath::Sqrt(weightA)) : 0);
78b795e7 179 esdV0->SetV0CTimeError((weightC > 0) ? (1./TMath::Sqrt(weightC)) : 0);
b44c933e 180
181 esdV0->SetV0ADecision(AliESDVZERO::kV0Empty);
182 esdV0->SetV0CDecision(AliESDVZERO::kV0Empty);
183
184 if (timeAW > (fV0ADist + fTimeWindowBBALow) &&
185 timeAW < (fV0ADist + fTimeWindowBBAUp))
186 esdV0->SetV0ADecision(AliESDVZERO::kV0BB);
187 else if (timeAW > (-fV0ADist + fTimeWindowBGALow) &&
188 timeAW < (-fV0ADist + fTimeWindowBGAUp))
189 esdV0->SetV0ADecision(AliESDVZERO::kV0BG);
190 else if (timeAW > (fV0ADist + fTimeWindowFakeALow) &&
191 timeAW < (fV0ADist + fTimeWindowFakeAUp))
192 esdV0->SetV0ADecision(AliESDVZERO::kV0Fake);
193
194 if (timeCW > (fV0CDist + fTimeWindowBBCLow) &&
195 timeCW < (fV0CDist + fTimeWindowBBCUp))
196 esdV0->SetV0CDecision(AliESDVZERO::kV0BB);
197 else if (timeCW > (-fV0CDist + fTimeWindowBGCLow) &&
198 timeCW < (-fV0CDist + fTimeWindowBGCUp))
199 esdV0->SetV0CDecision(AliESDVZERO::kV0BG);
200 else if (timeCW > (fV0CDist + fTimeWindowFakeCLow) &&
201 timeCW < (fV0CDist + fTimeWindowFakeCUp))
202 esdV0->SetV0CDecision(AliESDVZERO::kV0Fake);
203
a055ee24 204}