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 **************************************************************************/
16 /* $Id: AliADReconstructor.cxx 20956 2007-09-26 14:22:18Z mrodrigu $ */
17 //////////////////////////////////////////////////////////////////////////////
19 // Class for AD reconstruction //
20 //////////////////////////////////////////////////////////////////////////////
21 #include <TParameter.h>
23 #include "AliRawReader.h"
24 #include "AliGRPObject.h"
25 #include "AliCDBManager.h"
26 #include "AliCDBStorage.h"
27 #include "AliCDBEntry.h"
28 #include "AliESDEvent.h"
30 #include "AliADReconstructor.h"
31 #include "AliADdigit.h"
33 #include "AliADConst.h"
34 #include "AliADCalibData.h"
35 #include "AliADRawStream.h"
37 ClassImp(AliADReconstructor)
38 //_____________________________________________________________________________
39 AliADReconstructor:: AliADReconstructor():
46 fCalibData = GetCalibData();
47 // Default constructor
48 // Get calibration data
52 //_____________________________________________________________________________
53 AliADReconstructor& AliADReconstructor::operator =
54 (const AliADReconstructor& /*reconstructor*/)
56 // assignment operator
58 Fatal("operator =", "assignment operator not implemented");
62 //_____________________________________________________________________________
63 AliADReconstructor::~AliADReconstructor()
70 //_____________________________________________________________________________
71 void AliADReconstructor::Init()
74 fESDAD = new AliESDAD;
77 //_____________________________________________________________________________
78 void AliADReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
80 // converts RAW to digits
83 AliError("No digits tree!");
88 fDigitsArray = new TClonesArray("AliADdigit", 16);
89 digitsTree->Branch("ADDigit", &fDigitsArray);
93 AliADRawStream rawStream(rawReader);
94 if (rawStream.Next()) {
96 for(Int_t iChannel=0; iChannel < 16; ++iChannel) {
97 Int_t offlineCh = rawStream.GetOfflineChannel(iChannel);
99 Short_t chargeADC[kNClocks];
100 for(Int_t iClock=0; iClock < kNClocks; ++iClock) {
101 chargeADC[iClock] = rawStream.GetPedestal(iChannel,iClock);
104 Bool_t integrator = rawStream.GetIntegratorFlag(iChannel,kNClocks/2);
105 Bool_t BBflag = rawStream.GetBBFlag(iChannel,kNClocks/2);
106 Bool_t BGflag = rawStream.GetBGFlag(iChannel,kNClocks/2);
108 // HPTDC data (leading time and width)
109 Int_t board = AliADCalibData::GetBoardNumber(offlineCh);
110 Float_t time = rawStream.GetTime(iChannel)*fCalibData->GetTimeResolution(board);
111 Float_t width = rawStream.GetWidth(iChannel)*fCalibData->GetWidthResolution(board);
113 if(!fCalibData->IsChannelDead(iChannel)){
114 new ((*fDigitsArray)[fDigitsArray->GetEntriesFast()]) AliADdigit(offlineCh, time, width,integrator, chargeADC, BBflag, BGflag);
121 fDigitsArray->Clear();
125 //_____________________________________________________________________________
126 void AliADReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,AliESDEvent* esd) const
129 printf("Running AD Reconstruction \n");
131 // fills ESD with AD Digits
135 AliError("No digits tree!");
139 TBranch* digitBranch = digitsTree->GetBranch("ADdigit");
141 AliError("No AD digits branch found!");
144 digitBranch->SetAddress(&fDigitsArray);
146 digitsTree->GetEvent(0);
149 for(Int_t i = 0; i < 16; i++) { ADHits[i] = kFALSE; }
151 Int_t nDigits = fDigitsArray->GetEntriesFast();
153 for (Int_t d=0; d<nDigits; d++) {
154 AliADdigit* digit = (AliADdigit*) fDigitsArray->At(d);
155 Int_t module = digit->PMNumber();
156 // printf("AD Module: %d\n",module);
157 ADHits[module] = kTRUE;
160 AliError("NO AD ESD branch found!");
163 fESDAD->SetADBitCell(ADHits);
167 AliDebug(1, Form("Writing AD data to ESD Tree"));
168 esd->SetADData(fESDAD);
171 fDigitsArray->Clear();
174 //_____________________________________________________________________________
175 AliADCalibData* AliADReconstructor::GetCalibData() const
177 AliCDBManager *man = AliCDBManager::Instance();
179 AliCDBEntry *entry=0;
181 //entry = man->Get("AD/Calib/Data");
183 //AliWarning("Load of calibration data from default storage failed!");
184 //AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
186 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
188 entry = man->Get("AD/Calib/Data");
190 // Retrieval of data in directory AD/Calib/Data:
192 AliADCalibData *calibdata = 0;
194 if (entry) calibdata = (AliADCalibData*) entry->GetObject();
195 if (!calibdata) AliFatal("No calibration data from calibration database !");