Rename classes to read raw data 2004
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawStream.cxx
CommitLineData
65792ca0 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/// This class provides access to PHOS digits in raw data.
21///
22/// It loops over all PHOS digits in the raw data given by the AliRawReader.
23/// The Next method goes to the next digit. If there are no digits left
24/// it returns kFALSE.
25/// Several getters provide information about the current digit.
b7f3cbac 26/// usage:
27/// root > AliRawReaderFile rawReader ;
28/// root > AliPHOSRawStream input(&rawReader) ;
29/// root > while (input.Next()) .....
65792ca0 30///////////////////////////////////////////////////////////////////////////////
31
c2b19535 32#include "TClonesArray.h"
33#include "TClass.h"
34
35
36
65792ca0 37#include "AliPHOSRawStream.h"
38#include "AliRawReader.h"
8040246b 39#include "AliRawEventHeaderBase.h"
c2b19535 40#include "AliPHOSConTableDB.h"
41#include "AliPHOSDigit.h"
65792ca0 42
3255d660 43#define EVENT_TYPE_MASK ((UInt_t)0x0000FFFF)
65792ca0 44
c2b19535 45ClassImp(AliPHOSRawStream)
65792ca0 46
47//_____________________________________________________________________________
c2b19535 48AliPHOSRawStream::AliPHOSRawStream(AliRawReader* rawReader) : TObject()
65792ca0 49{
c2b19535 50 fRawReader = rawReader ;
51 fctdb = 0 ;
52}
53//_____________________________________________________________________________
54Bool_t AliPHOSRawStream::ReadDigits(TClonesArray * digits){
55
56 Bool_t isOK = kFALSE ;
57 if(!fctdb){
58 Error("ReadDigits","Connection table not set") ;
59 return kFALSE ;
60 }
65792ca0 61
c2b19535 62 if(!digits){
63 Error("ReadDigits","Output array not created") ;
64 return kFALSE ;
65 }
66
67 if(!(digits->GetClass()->InheritsFrom("AliPHOSDigit"))){
68 Error("ReadDigits","Digits contanier made for %s, not AliPHOSDigits",digits->GetClass()->GetName()) ;
69 return kFALSE ;
70 }
71
72 digits->Clear() ;
73
74 //Check, if current event - PHYSICS event
8040246b 75 if(!((fRawReader->GetType() & EVENT_TYPE_MASK)==AliRawEventHeaderBase::kPhysicsEvent)){
c2b19535 76 return kFALSE ;
77 }
78
79 //Scan subevents until subevent with digits
80 while(fRawReader->ReadNextData(fData)){
81 switch (fRawReader->GetEquipmentType()){
82 case kPattUnitMarker:
83 if(fRawReader->GetEquipmentId() == kPattUnitEquipId){ //Read PHOS trigger
84 Int_t * patt = (Int_t *)fData;
85 if(fRawReader->GetEquipmentSize() >= (Int_t)sizeof(Int_t))
86 fTrig = patt[0];
87 else
88 fTrig = 0 ;
89 }
90 break;
91 case kPhosAdcMarker:
92 if(fRawReader->GetEquipmentId() == kPhosAdcEquipId){
93 Int_t ndigits = fRawReader->GetEquipmentSize()/sizeof(Int_t);
94 digits->Expand(ndigits) ;
95 for(Int_t i=0; i<ndigits; i++){
96 Int_t * amps = (Int_t *)fData ;
97 Int_t absID = fctdb->Raw2AbsId(i) ;
98 Int_t time = 0;
99 if(absID>0) //Only real digits are filled, last ADC numbers (if any) are scipped
100 new((*digits)[i]) AliPHOSDigit( -1, absID, amps[i], time) ;
101 }
102 digits->Sort() ;
103 digits->Compress() ;
104 digits->Expand(digits->GetEntriesFast()) ;
105
106 //Set indexes in list of digits and make true digitization of the energy
107 for (Int_t id = 0 ; id < digits->GetEntriesFast() ; id++) {
108 AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit*>( digits->At(id) ) ;
109 digit->SetIndexInList(id) ;
110 }
111
112 isOK = kTRUE ;
113 }
114 break;
115 case kTdcMarker:
116 if(fRawReader->GetEquipmentId() == kTdcEquipId){
117 // Probably sometime we will need to handle these data
118 }
119 break;
120 case kChargeAdcMarker:
121 if(fRawReader->GetEquipmentId() == kChargeAdcEquipId){
122 //Probably sometime we will need to handle these data
123 }
124 break;
125 case kScalerMarker:
126 if(fRawReader->GetEquipmentId() == kScalerEquipId){
127 //Probably sometime we will need to handle these data
128 }
129 break;
130 default:
131 break;
132 }
133 }
134 return isOK ;
65792ca0 135}
c2b19535 136