]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROTriggerMask.cxx
c4c9d49a100d588d8f601dec144470409760c538
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTriggerMask.cxx
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 //-------------------------------------------
18 // Class : AliVZEROTriggerMask
19 //
20 // Fill up the trigger mask word.
21 //
22
23 #include <Riostream.h>
24 #include <TGeoManager.h>
25 #include <TGeoMatrix.h>
26 #include <TGeoPhysicalNode.h>
27 #include <TTree.h>
28 #include <TClonesArray.h>
29
30 #include <AliGeomManager.h>
31 #include "AliCDBManager.h"
32 #include "AliCDBStorage.h"
33 #include "AliCDBEntry.h"
34 #include "AliLog.h"
35 #include "AliVZEROTriggerMask.h"
36 #include "AliVZEROdigit.h"
37
38 //______________________________________________________________________
39 ClassImp(AliVZEROTriggerMask)
40
41 //______________________________________________________________________
42
43 AliVZEROTriggerMask::AliVZEROTriggerMask()
44   :TObject(),
45    fAdcThresHold(0.0),
46    fTimeWindowWidthBBA(50.0),
47    fTimeWindowWidthBGA(20.0),
48    fTimeWindowWidthBBC(50.0),
49    fTimeWindowWidthBGC(20.0),
50    fBBtriggerV0A(0),
51    fBGtriggerV0A(0),
52    fBBtriggerV0C(0),
53    fBGtriggerV0C(0)
54    
55 {
56    SetAdcThreshold();
57 }
58
59 //________________________________________________________________________________
60 Double_t AliVZEROTriggerMask::GetZPosition(const char* symname){
61 // Get the global z coordinate of the given V0 alignable volume
62 //
63   Double_t *tr;
64   TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname);
65   if (!pne) return 0;
66
67
68   TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
69   if(pnode){
70           TGeoHMatrix* hm = pnode->GetMatrix();
71            tr = hm->GetTranslation();
72   }else{
73           const char* path = pne->GetTitle();
74           if(!gGeoManager->cd(path)){
75                   AliErrorClass(Form("Volume path %s not valid!",path));
76                   return 0;
77           }
78          tr = gGeoManager->GetCurrentMatrix()->GetTranslation();
79   }
80   return tr[2];
81
82 }
83
84 //________________________________________________________________________________
85
86
87 void AliVZEROTriggerMask::FillMasks(TTree* vzeroDigitsTree,
88                                 TClonesArray* const vzeroDigits)
89 {
90 // Fill up the trigger mask word using the TDC 
91
92   const Double_t lightSpeed = 2.9979245800; // cm/100 ps
93   Float_t zV0A = TMath::Abs(GetZPosition("VZERO/V0A"));
94   Float_t zV0C = TMath::Abs(GetZPosition("VZERO/V0C"));
95
96   // distance in time units from nominal vertex to V0
97   Float_t v0aDist = zV0A/lightSpeed; // 100 of picoseconds
98   Float_t v0cDist = zV0C/lightSpeed; // 100 of picoseconds
99   Float_t bunchSeparation = 1000.0; // 100 of picoseconds
100
101   // mask
102   UInt_t one=1;
103  
104   // loop over vzero entries
105   Int_t nEntries = (Int_t)vzeroDigitsTree->GetEntries();
106   for (Int_t e=0; e<nEntries; e++) {
107     vzeroDigitsTree->GetEvent(e);
108
109     Int_t nDigits = vzeroDigits->GetEntriesFast();
110     
111     for (Int_t d=0; d<nDigits; d++) {
112       //      vzeroDigitsTree->GetEvent(d);
113       AliVZEROdigit* digit = (AliVZEROdigit*)vzeroDigits->At(d);
114       
115       Int_t   pmNumber   = digit->PMNumber();
116       Float_t adc        = digit->ADC();
117       Float_t tdc        = digit->Time()*10.0; // in 100 of picoseconds
118
119       if (adc>fAdcThresHold) {
120         if (pmNumber<32) { // in V0C
121           if (tdc>(v0cDist-fTimeWindowWidthBBC/2.0) &&
122               tdc<(v0cDist+fTimeWindowWidthBBC/2.0))
123             fBBtriggerV0C+=(one<<pmNumber);
124           if (tdc>(bunchSeparation-v0cDist-fTimeWindowWidthBGC/2.0) &&
125               tdc<(bunchSeparation-v0cDist+fTimeWindowWidthBGC/2.0))
126            fBGtriggerV0C+=(one<<pmNumber); 
127         }
128         if (pmNumber>31) { // in V0A
129           Int_t shift = pmNumber-32;
130           if (tdc>(v0aDist-fTimeWindowWidthBBA/2.0) &&
131               tdc<(v0aDist+fTimeWindowWidthBBA/2.0)) 
132             fBBtriggerV0A+=(one<<shift);
133           if (tdc>(bunchSeparation-v0aDist-fTimeWindowWidthBGA/2.0) &&
134               tdc<(bunchSeparation-v0aDist+fTimeWindowWidthBGA/2.0))
135             fBGtriggerV0A+=(one<<shift); 
136         }
137       }
138     } // end of loop over digits
139   } // end of loop over events in digits tree
140 }