adding cut study of primaries vs. secondaries
[u/mrichter/AliRoot.git] / ZDC / AliZDCRawStream.cxx
CommitLineData
8309c1ab 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///////////////////////////////////////////////////////////////////////////////
83347831 19// //
20// This class provides access to ZDC digits in raw data. //
21// //
22// It loops over all ZDC 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// Getters provide information about the current digit. //
26// //
8309c1ab 27///////////////////////////////////////////////////////////////////////////////
28
29#include "AliZDCRawStream.h"
30#include "AliRawReader.h"
cc2abffd 31#include "AliLog.h"
8309c1ab 32
33ClassImp(AliZDCRawStream)
34
35
36//_____________________________________________________________________________
37AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
38 fRawReader(rawReader),
cc2abffd 39 fRawADC(0),
83347831 40 fADCModule(0),
cc2abffd 41 fADCValue(-1),
c0aec6f6 42 fADCGain(0),
43 fIsADCDataWord(kFALSE)
8309c1ab 44{
abf60186 45 // Create an object to read ZDC raw digits
8309c1ab 46
362c9d61 47 fRawReader->Select("ZDC");
8309c1ab 48}
49
50//_____________________________________________________________________________
51AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
c0aec6f6 52 TObject(stream)
8309c1ab 53{
abf60186 54 // Copy constructor
c0aec6f6 55 fRawADC = stream.GetADCRaw();
56 for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j);
57 fADCModule = stream.GetADCModule();
58 fADCValue = stream.GetADCValue();
59 fADCGain = stream.GetADCGain();
ea628de7 60 fIsADCDataWord = stream.IsADCDataWord();
c0aec6f6 61
8309c1ab 62}
63
64//_____________________________________________________________________________
65AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream&
66 /* stream */)
67{
abf60186 68 // Assignment operator
8309c1ab 69 Fatal("operator =", "assignment operator not implemented");
70 return *this;
71}
72
73//_____________________________________________________________________________
74AliZDCRawStream::~AliZDCRawStream()
75{
abf60186 76// Destructor
8309c1ab 77
78}
79
80
81//_____________________________________________________________________________
82Bool_t AliZDCRawStream::Next()
83{
abf60186 84 // Read the next raw digit
85 // Returns kFALSE if there is no digit left
8309c1ab 86
abf60186 87 if(!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE;
8309c1ab 88 fIsADCDataWord = kFALSE;
89
6006df88 90 printf("fRawADC %x",fRawADC);
91 //
92 if((fRawADC == 0xe52b6300) || (fRawADC == 0xdeadface) || (fRawADC == 0xffffffff) || (fRawADC == 0xdeadbeef)){
93 printf(" This is a DARC header!!!\n");
abf60186 94 }
6006df88 95 else if(fRawADC == 0xcafefade) printf(" End of data!\n");
96 else{
97 if((fRawADC & 0x6000000) == 0x6000000){//Not valid datum
98 printf(" AliZDCRawStream -> Not valid datum in ADC module!!! %d\n",fADCModule);
99 }
100 else if((fRawADC & 0x4000000) == 0x4000000){//ADC EOB
101 printf(" AliZDCRawStream -> ADC %d End Of Block - Event no. %d\n\n",fADCModule, (fRawADC & 0xffffff));
102 fSector[0] = fSector[1] = 99;
103 }
104 else if((fRawADC & 0x2000000) == 0x2000000){//ADC Header
105 fADCModule++;
106 printf(" AliZDCRawStream -> Header ADC %d - ADC datum contains %d data words \n",fADCModule,((fRawADC & 0x3f00) >> 8));
107 }
108 else{//ADC data word
109 fIsADCDataWord = kTRUE;
110 printf(" \t \t ADC Data Word");
111 if(!(fRawADC & 0x1000) && !(fRawADC & 0x2000)){ // Valid ADC data
112 fADCGain = (fRawADC & 0x10000) >> 16;
113 fADCValue = (fRawADC & 0xfff);
114 //
115 Int_t vADCChannel = (fRawADC & 0x1e0000) >> 17;
116 if(fADCModule==1 || fADCModule==3){ //1st & 3rd ADC modules
117 if(vADCChannel >= 0 && vADCChannel <= 4){
118 fSector[0] = 1; // ZN1
119 fSector[1] = vADCChannel;
120 }
121 else if(vADCChannel >= 8 && vADCChannel <= 12){
122 fSector[0] = 2; // ZP1
123 fSector[1] = vADCChannel-8;
124 }
125 else if(vADCChannel == 5 || vADCChannel == 13){
126 fSector[0] = 3; // ZEM 1,2
127 fSector[1] = ((vADCChannel-5)/8)+1;
128 }
83347831 129 }
6006df88 130 else if(fADCModule==2 || fADCModule==4){ //2nd & 4rth ADC modules
131 if(vADCChannel >= 0 && vADCChannel <= 4){
132 fSector[0] = 4; // ZN2
83347831 133 fSector[1] = vADCChannel;
6006df88 134 }
135 else if(vADCChannel >= 8 && vADCChannel <= 12){
136 fSector[0] = 5; // ZP2
137 fSector[1] = vADCChannel-8;
138 }
139 else if(vADCChannel == 5 || vADCChannel == 13){
140 fSector[0] = (vADCChannel-5)*3/8+1; // PM Ref 1,2
141 fSector[1] = 5;
142 }
83347831 143 }
6006df88 144 else{
145 AliWarning(" AliZDCRawStream -> No valid ADC module!!!");
146 printf(" ADCmod = %d\n", fADCModule);
147 fRawReader->AddMajorErrorLog(kInvalidADCModule);
148 }
149 printf(" ADC %d ch %d range %d -> det %d quad %d value %x\n",
83347831 150 fADCModule, vADCChannel, fADCGain, fSector[0], fSector[1], fADCValue);//Chiara debugging
6006df88 151
152 }
153 else if(fRawADC & 0x1000)
154 printf(" ADC %d ch %d range %d overflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Overflow
155 else if(fRawADC & 0x2000)
156 printf(" ADC %d ch %d range %d underflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Underflow
abf60186 157 }
6006df88 158 }//Not DARC Header
83347831 159
8309c1ab 160 return kTRUE;
161}