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];
119 for (Int_t i=0; i<64; i++){
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);
130 Int_t nDigits = digitsArray->GetEntriesFast();
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
142 for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);
143 fESDVZERO->SetMultiplicity(Multiplicity);
145 // now get the trigger mask
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);
155 fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
156 fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
157 fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
158 fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
161 AliDebug(1, Form("Writing VZERO data to ESD tree"));
162 esd->SetVZEROData(fESDVZERO);
166 //_____________________________________________________________________________
167 AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
171 Bool_t deleteManager = kFALSE;
173 AliCDBManager *manager = AliCDBManager::Instance();
174 AliCDBStorage *defstorage = manager->GetDefaultStorage();
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;
182 AliCDBStorage *storage = manager->GetDefaultStorage();
185 AliCDBManager::Instance()->UnsetDefaultStorage();
186 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
192 //_____________________________________________________________________________
193 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
195 // Gets calibration object for VZERO set
197 AliCDBManager *man = AliCDBManager::Instance();
199 AliCDBEntry *entry=0;
201 entry = man->Get("VZERO/Calib/Data");
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);
212 // Retrieval of data in directory VZERO/Calib/Data:
214 AliVZEROCalibData *calibdata = 0;
216 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
217 if (!calibdata) AliFatal("No calibration data from calibration database !");