Make separate, specialized geometries for RPhi and RhoZ views.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawStream2004.cxx
CommitLineData
45e334f8 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.
26/// usage:
27/// root > AliRawReaderFile rawReader ;
28/// root > AliPHOSRawStream2004 input(&rawReader) ;
29/// root > while (input.Next()) .....
30///////////////////////////////////////////////////////////////////////////////
31
32#include "TClonesArray.h"
33#include "TClass.h"
34
45e334f8 35#include "AliPHOSRawStream2004.h"
36#include "AliRawReader.h"
37#include "AliRawEventHeaderBase.h"
38#include "AliPHOSConTableDB.h"
39#include "AliPHOSDigit.h"
40
41#define EVENT_TYPE_MASK ((UInt_t)0x0000FFFF)
42
43ClassImp(AliPHOSRawStream2004)
44
45//_____________________________________________________________________________
3f7dbdb7 46AliPHOSRawStream2004::AliPHOSRawStream2004(AliRawReader* rawReader) :
47 fRawReader(rawReader),
48 fData(0),
49 fctdb(0),
50 fTrig(0)
51{
52 //Ctor
53}
54
55//_____________________________________________________________________________
56AliPHOSRawStream2004::AliPHOSRawStream2004(const AliPHOSRawStream2004 & rhs) :
57 TObject(rhs),
58 fRawReader(rhs.fRawReader),
59 fData(rhs.fData),
60 fctdb(rhs.fctdb),
61 fTrig(rhs.fTrig)
45e334f8 62{
3f7dbdb7 63 //Copy ctor
45e334f8 64}
3f7dbdb7 65
66//_____________________________________________________________________________
67AliPHOSRawStream2004 & AliPHOSRawStream2004::operator = (const AliPHOSRawStream2004 &rhs)
68{
69 TObject::operator = (rhs);
70 fRawReader = rhs.fRawReader;
71 fData = rhs.fData;
72 fctdb = rhs.fctdb;
73 fTrig = rhs.fTrig;
74
75 return *this;
76}
77
45e334f8 78//_____________________________________________________________________________
79Bool_t AliPHOSRawStream2004::ReadDigits(TClonesArray * digits){
80
81 Bool_t isOK = kFALSE ;
82 if(!fctdb){
83 Error("ReadDigits","Connection table not set") ;
84 return kFALSE ;
85 }
86
87 if(!digits){
88 Error("ReadDigits","Output array not created") ;
89 return kFALSE ;
90 }
91
92 if(!(digits->GetClass()->InheritsFrom("AliPHOSDigit"))){
93 Error("ReadDigits","Digits contanier made for %s, not AliPHOSDigits",digits->GetClass()->GetName()) ;
94 return kFALSE ;
95 }
96
97 digits->Clear() ;
98
99 //Check, if current event - PHYSICS event
100 if(!((fRawReader->GetType() & EVENT_TYPE_MASK)==AliRawEventHeaderBase::kPhysicsEvent)){
101 return kFALSE ;
102 }
103
104 //Scan subevents until subevent with digits
105 while(fRawReader->ReadNextData(fData)){
106 switch (fRawReader->GetEquipmentType()){
107 case kPattUnitMarker:
108 if(fRawReader->GetEquipmentId() == kPattUnitEquipId){ //Read PHOS trigger
109 Int_t * patt = (Int_t *)fData;
110 if(fRawReader->GetEquipmentSize() >= (Int_t)sizeof(Int_t))
111 fTrig = patt[0];
112 else
113 fTrig = 0 ;
114 }
115 break;
116 case kPhosAdcMarker:
117 if(fRawReader->GetEquipmentId() == kPhosAdcEquipId){
118 Int_t ndigits = fRawReader->GetEquipmentSize()/sizeof(Int_t);
119 digits->Expand(ndigits) ;
120 for(Int_t i=0; i<ndigits; i++){
121 Int_t * amps = (Int_t *)fData ;
122 Int_t absID = fctdb->Raw2AbsId(i) ;
123 Int_t time = 0;
124 if(absID>0) //Only real digits are filled, last ADC numbers (if any) are scipped
125 new((*digits)[i]) AliPHOSDigit( -1, absID, amps[i], time) ;
126 }
127 digits->Sort() ;
128 digits->Compress() ;
129 digits->Expand(digits->GetEntriesFast()) ;
130
131 //Set indexes in list of digits and make true digitization of the energy
132 for (Int_t id = 0 ; id < digits->GetEntriesFast() ; id++) {
133 AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit*>( digits->At(id) ) ;
134 digit->SetIndexInList(id) ;
135 }
136
137 isOK = kTRUE ;
138 }
139 break;
140 case kTdcMarker:
141 if(fRawReader->GetEquipmentId() == kTdcEquipId){
142 // Probably sometime we will need to handle these data
143 }
144 break;
145 case kChargeAdcMarker:
146 if(fRawReader->GetEquipmentId() == kChargeAdcEquipId){
147 //Probably sometime we will need to handle these data
148 }
149 break;
150 case kScalerMarker:
151 if(fRawReader->GetEquipmentId() == kScalerEquipId){
152 //Probably sometime we will need to handle these data
153 }
154 break;
155 default:
156 break;
157 }
158 }
159 return isOK ;
160}
161