]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROReconstructor.cxx
Trigger bit mask and multiplicity per PMT in the VZERO ESD. Related changes and class...
[u/mrichter/AliRoot.git] / VZERO / AliVZEROReconstructor.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 ///////////////////////////////////////////////////////////////////////////////
19 ///                                                                          //
20 /// class for VZERO reconstruction                                           //
21 ///                                                                          //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include "AliRunLoader.h"
25 #include "AliRawReader.h"
26 #include "AliVZEROReconstructor.h"
27 #include "AliVZERORawStream.h"
28 #include "AliESDEvent.h"
29 #include "AliVZEROTriggerMask.h"
30
31 ClassImp(AliVZEROReconstructor)
32
33 //_____________________________________________________________________________
34 AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
35    fESDVZERO(0x0),
36    fESD(0x0),
37    fCalibData(GetCalibData())
38 {
39   // Default constructor  
40   // Get calibration data
41   
42   // fCalibData = GetCalibData(); 
43 }
44
45
46 //_____________________________________________________________________________
47 AliVZEROReconstructor& AliVZEROReconstructor::operator = 
48   (const AliVZEROReconstructor& /*reconstructor*/)
49 {
50 // assignment operator
51
52   Fatal("operator =", "assignment operator not implemented");
53   return *this;
54 }
55
56 //_____________________________________________________________________________
57 AliVZEROReconstructor::~AliVZEROReconstructor()
58 {
59 // destructor
60    delete fESDVZERO; 
61    
62 }
63
64 //_____________________________________________________________________________
65 void AliVZEROReconstructor::Init()
66 {
67 // initializer
68
69   fESDVZERO  = new AliESDVZERO;
70 }
71
72 //______________________________________________________________________
73 void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
74 {
75 // converts to digits
76
77   if (!digitsTree) {
78     AliError("No digits tree!");
79     return;
80   }
81
82   TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit");
83   digitsTree->Branch("VZERODigit", &digitsArray);
84
85   rawReader->Reset();
86   AliVZERORawStream rawStream(rawReader);
87   if (rawStream.Next()) {
88     for(Int_t iChannel = 0; iChannel < 64; iChannel++) {
89     Int_t adc = rawStream.GetADC(iChannel);  
90     Int_t time = rawStream.GetTime(iChannel);
91     new ((*digitsArray)[digitsArray->GetEntriesFast()])
92       AliVZEROdigit(iChannel,adc,time);
93     }
94   }
95
96   digitsTree->Fill();
97 }
98
99 //______________________________________________________________________
100 void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
101                                     AliESDEvent* esd) const
102 {
103 // fills multiplicities to the ESD
104
105   if (!digitsTree) {
106     AliError("No digits tree!");
107     return;
108   }
109
110   TClonesArray* digitsArray = NULL;
111   TBranch* digitBranch = digitsTree->GetBranch("VZERODigit");
112   digitBranch->SetAddress(&digitsArray);
113
114   const Float_t mip0=110.0;
115   Short_t Multiplicity[64];
116   Float_t mult[64];  
117   Int_t   adc[64]; 
118   Float_t mip[64];
119   for (Int_t i=0; i<64; i++){
120        adc[i] = 0;
121        mip[i] = mip0;
122        mult[i]= 0.0;
123   }
124      
125   // loop over VZERO entries to get multiplicity
126   Int_t nEntries = (Int_t)digitsTree->GetEntries();
127   for (Int_t e=0; e<nEntries; e++) {
128     digitsTree->GetEvent(e);
129
130     Int_t nDigits = digitsArray->GetEntriesFast();
131     
132     for (Int_t d=0; d<nDigits; d++) {    
133       AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d);      
134       Int_t  pmNumber      = digit->PMNumber();  
135       adc[pmNumber] = digit->ADC(); 
136       // cut of ADC at MIP/2
137       if  (adc[pmNumber] > (mip[pmNumber]/2)) 
138         mult[pmNumber] += float(adc[pmNumber])/mip[pmNumber];
139     } // end of loop over digits
140   } // end of loop over events in digits tree
141   
142   for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);       
143   fESDVZERO->SetMultiplicity(Multiplicity);
144
145   // now get the trigger mask
146
147   AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
148   TriggerMask->SetAdcThreshold(mip0/2.0);
149   TriggerMask->SetTimeWindowWidthBBA(50);
150   TriggerMask->SetTimeWindowWidthBGA(20);
151   TriggerMask->SetTimeWindowWidthBBC(50);
152   TriggerMask->SetTimeWindowWidthBGC(20);
153   TriggerMask->FillMasks(digitsTree,digitsArray);
154
155   fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
156   fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
157   fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
158   fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
159   
160   if (esd) { 
161     AliDebug(1, Form("Writing VZERO data to ESD tree"));
162     esd->SetVZEROData(fESDVZERO);
163   }
164 }
165
166 //_____________________________________________________________________________
167 AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri) 
168 {
169 // Sets the storage  
170
171   Bool_t deleteManager = kFALSE;
172   
173   AliCDBManager *manager = AliCDBManager::Instance();
174   AliCDBStorage *defstorage = manager->GetDefaultStorage();
175   
176   if(!defstorage || !(defstorage->Contains("VZERO"))){ 
177      AliWarning("No default storage set or default storage doesn't contain VZERO!");
178      manager->SetDefaultStorage(uri);
179      deleteManager = kTRUE;
180   }
181  
182   AliCDBStorage *storage = manager->GetDefaultStorage();
183
184   if(deleteManager){
185     AliCDBManager::Instance()->UnsetDefaultStorage();
186     defstorage = 0;   // the storage is killed by AliCDBManager::Instance()->Destroy()
187   }
188
189   return storage; 
190 }
191
192 //_____________________________________________________________________________
193 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
194 {
195   // Gets calibration object for VZERO set
196
197   AliCDBManager *man = AliCDBManager::Instance();
198
199   AliCDBEntry *entry=0;
200
201   entry = man->Get("VZERO/Calib/Data");
202
203 //   if(!entry){
204 //     AliWarning("Load of calibration data from default storage failed!");
205 //     AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
206 //     Int_t runNumber = man->GetRun();
207 //     entry = man->GetStorage("local://$ALICE_ROOT")
208 //       ->Get("VZERO/Calib/Data",runNumber);
209 //      
210 //   }
211
212   // Retrieval of data in directory VZERO/Calib/Data:
213
214   AliVZEROCalibData *calibdata = 0;
215
216   if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
217   if (!calibdata)  AliFatal("No calibration data from calibration database !");
218
219   return calibdata;
220 }