1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 /// class for VZERO reconstruction //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliRunLoader.h"
25 #include "AliRawReader.h"
26 #include "AliVZEROReconstructor.h"
27 #include "AliVZERORawStream.h"
28 #include "AliESDEvent.h"
29 #include "AliVZEROTriggerMask.h"
31 ClassImp(AliVZEROReconstructor)
33 //_____________________________________________________________________________
34 AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
37 fCalibData(GetCalibData())
39 // Default constructor
40 // Get calibration data
42 // fCalibData = GetCalibData();
46 //_____________________________________________________________________________
47 AliVZEROReconstructor& AliVZEROReconstructor::operator =
48 (const AliVZEROReconstructor& /*reconstructor*/)
50 // assignment operator
52 Fatal("operator =", "assignment operator not implemented");
56 //_____________________________________________________________________________
57 AliVZEROReconstructor::~AliVZEROReconstructor()
64 //_____________________________________________________________________________
65 void AliVZEROReconstructor::Init()
69 fESDVZERO = new AliESDVZERO;
72 //______________________________________________________________________
73 void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
78 AliError("No digits tree!");
82 TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit");
83 digitsTree->Branch("VZERODigit", &digitsArray);
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);
99 //______________________________________________________________________
100 void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
101 AliESDEvent* esd) const
103 // fills multiplicities to the ESD
106 AliError("No digits tree!");
110 TClonesArray* digitsArray = NULL;
111 TBranch* digitBranch = digitsTree->GetBranch("VZERODigit");
112 digitBranch->SetAddress(&digitsArray);
114 const Float_t mip0=110.0;
115 Short_t Multiplicity[64];
120 for (Int_t i=0; i<64; i++){
126 // loop over VZERO entries to get multiplicity
127 Int_t nEntries = (Int_t)digitsTree->GetEntries();
128 for (Int_t e=0; e<nEntries; e++) {
129 digitsTree->GetEvent(e);
131 Int_t nDigits = digitsArray->GetEntriesFast();
133 for (Int_t d=0; d<nDigits; d++) {
134 AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d);
135 Int_t pmNumber = digit->PMNumber();
136 adc[pmNumber] = (Short_t) digit->ADC();
137 time[pmNumber] = (Short_t) digit->Time();
138 // cut of ADC at MIP/2
139 if (adc[pmNumber] > (mip[pmNumber]/2))
140 mult[pmNumber] += float(adc[pmNumber])/mip[pmNumber];
141 } // end of loop over digits
142 } // end of loop over events in digits tree
144 for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);
145 fESDVZERO->SetMultiplicity(Multiplicity);
146 fESDVZERO->SetADC(adc);
147 fESDVZERO->SetTime(time);
149 // now get the trigger mask
151 AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
152 TriggerMask->SetAdcThreshold(mip0/2.0);
153 TriggerMask->SetTimeWindowWidthBBA(50);
154 TriggerMask->SetTimeWindowWidthBGA(20);
155 TriggerMask->SetTimeWindowWidthBBC(50);
156 TriggerMask->SetTimeWindowWidthBGC(20);
157 TriggerMask->FillMasks(digitsTree,digitsArray);
159 fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
160 fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
161 fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
162 fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
165 AliDebug(1, Form("Writing VZERO data to ESD tree"));
166 esd->SetVZEROData(fESDVZERO);
170 //_____________________________________________________________________________
171 AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
175 Bool_t deleteManager = kFALSE;
177 AliCDBManager *manager = AliCDBManager::Instance();
178 AliCDBStorage *defstorage = manager->GetDefaultStorage();
180 if(!defstorage || !(defstorage->Contains("VZERO"))){
181 AliWarning("No default storage set or default storage doesn't contain VZERO!");
182 manager->SetDefaultStorage(uri);
183 deleteManager = kTRUE;
186 AliCDBStorage *storage = manager->GetDefaultStorage();
189 AliCDBManager::Instance()->UnsetDefaultStorage();
190 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
196 //_____________________________________________________________________________
197 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
199 // Gets calibration object for VZERO set
201 AliCDBManager *man = AliCDBManager::Instance();
203 AliCDBEntry *entry=0;
205 entry = man->Get("VZERO/Calib/Data");
208 // AliWarning("Load of calibration data from default storage failed!");
209 // AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
210 // Int_t runNumber = man->GetRun();
211 // entry = man->GetStorage("local://$ALICE_ROOT")
212 // ->Get("VZERO/Calib/Data",runNumber);
216 // Retrieval of data in directory VZERO/Calib/Data:
218 AliVZEROCalibData *calibdata = 0;
220 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
221 if (!calibdata) AliFatal("No calibration data from calibration database !");