Use of global coordinates of the clusters (L. Gaudichet)
[u/mrichter/AliRoot.git] / TOF / AliTOFRawDataRead.C
CommitLineData
15ec34b9 1// gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/RAW -I$ALICE_ROOT/TOF")
2// .L AliTOFRawDataRead.C++
3// AliTOFRawDataRead()
4
5#if !defined(__CINT__) || defined(__MAKECINT__)
6
7// Root include files
8#include "TClonesArray.h"
9
10// AliRoot include files
11#include "AliDAQ.h"
12#include "AliHitMap.h"
13
14#include "AliRawReader.h"
15#include "AliRawReaderFile.h"
16
17#include "AliTOFrawData.h"
18#include "AliTOFRawMap.h"
19#include "AliTOFRawStream.h"
20
21#endif
22
23void AliTOFRawDataRead(Int_t iEvent=0);
24
25void AliTOFRawDataRead(Int_t iEvent)
571dda3d 26{
27 //
28 // To read TOF raw data
29 //
30
15ec34b9 31 TClonesArray *fTOFrawData = new TClonesArray("AliTOFrawData",1000);
32 Int_t fPackedDigits=0;
33
571dda3d 34 Int_t indexDDL = 0;
d0eb8f39 35 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
15ec34b9 36 Int_t dummy = -1;
571dda3d 37
d0eb8f39 38 AliRawReaderFile reader(iEvent);
39 reader.RewindEvents();
571dda3d 40
15ec34b9 41 ofstream ftxt;
42 ftxt.open("TOFrawDataReading.txt",ios::app);
43
d0eb8f39 44 while (reader.NextEvent()) {
571dda3d 45
15ec34b9 46 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
47
48 Int_t slot[4] = {-1, -1, -1, -1};
49
50 for (indexDDL = 0; indexDDL < AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
51
52 rawMap->Clear();
53 fTOFrawData->Clear();
54 fPackedDigits = 0;
55
56 printf(" \n \n \n DRM number %2i \n \n \n ", indexDDL);
57
58 reader.Reset();
59 AliTOFRawStream stream(&reader);
571dda3d 60
15ec34b9 61 reader.Select("TOF", indexDDL, indexDDL);
62 Bool_t signal = kFALSE;
571dda3d 63
15ec34b9 64 while(stream.Next()) {
571dda3d 65
15ec34b9 66 signal = (stream.GetSector()!=-1 &&
67 stream.GetPlate()!=-1 &&
68 stream.GetStrip()!=-1 &&
69 stream.GetPadZ()!=-1 &&
70 stream.GetPadX()!=-1);
571dda3d 71
15ec34b9 72 if (signal) {
73 printf(" %2i %1i %2i %1i %2i \n", stream.GetSector(), stream.GetPlate(), stream.GetStrip(), stream.GetPadZ(), stream.GetPadX());
571dda3d 74
15ec34b9 75 slot[0] = stream.GetTRM();
76 slot[1] = stream.GetTRMchain();
77 slot[2] = stream.GetTDC();
78 slot[3] = stream.GetTDCchannel();
571dda3d 79
15ec34b9 80 if (rawMap->TestHit(slot) != kEmpty) {
571dda3d 81
15ec34b9 82 AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
83 rawDigit->Update(stream.GetTofBin(), stream.GetToTbin(), stream.GetLeadingEdge(), stream.GetTrailingEdge(), stream.GetPSbit(), stream.GetACQ(), stream.GetErrorFlag());
d0eb8f39 84
15ec34b9 85 }
86 else {
d0eb8f39 87
15ec34b9 88 TClonesArray &arrayTofRawData = *fTOFrawData;
89 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(stream.GetTRM(), stream.GetTRMchain(), stream.GetTDC(), stream.GetTDCchannel(),
90 stream.GetTofBin(), stream.GetToTbin(), stream.GetLeadingEdge(), stream.GetTrailingEdge(),
91 stream.GetPSbit(), stream.GetACQ(), stream.GetErrorFlag());
d0eb8f39 92
15ec34b9 93 rawMap->SetHit(slot);
d0eb8f39 94
15ec34b9 95 printf(" %6i \n", rawMap->GetHitIndex(slot));
96
97 }
98
99 } // end if (signal)
100
101 } // closed loop on TOF raw data per current DDL file
102
103 printf("\n \n \n end of reading DRM number %2i\n", indexDDL);
104 printf(" packed data %5i\n \n \n ", fTOFrawData->GetEntriesFast());
105
106 for (Int_t iRawData = 0; iRawData<fTOFrawData->GetEntriesFast(); iRawData++) {
107
108 AliTOFrawData *tofRawDatum = (AliTOFrawData*)fTOFrawData->UncheckedAt(iRawData);
109
110 if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
111
112 if (indexDDL<10) ftxt << " " << indexDDL;
113 else ftxt << " " << indexDDL;
114 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
115 else ftxt << " " << tofRawDatum->GetTRM();
116 ftxt << " " << tofRawDatum->GetTRMchain();
117 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
118 else ftxt << " " << tofRawDatum->GetTDC();
119 ftxt << " " << tofRawDatum->GetTDCchannel();
120
121 stream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
122 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
123 dummy = detectorIndex[3];
124 detectorIndex[3] = detectorIndex[4];
125 detectorIndex[4] = dummy;
126
127 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
128 else ftxt << " -> " << detectorIndex[0];
129 ftxt << " " << detectorIndex[1];
130 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
131 else ftxt << " " << detectorIndex[2];
132 ftxt << " " << detectorIndex[3];
133 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
134 else ftxt << " " << detectorIndex[4];
135
136 if (tofRawDatum->GetTOT()<10) ftxt << " " << tofRawDatum->GetTOT();
137 else if (tofRawDatum->GetTOT()>=10 && tofRawDatum->GetTOT()<100) ftxt << " " << tofRawDatum->GetTOT();
138 else ftxt << " " << tofRawDatum->GetTOT();
139 if (tofRawDatum->GetTOF()<10) ftxt << " " << tofRawDatum->GetTOF() << endl;
140 else if (tofRawDatum->GetTOF()>=10 && tofRawDatum->GetTOF()<100) ftxt << " " << tofRawDatum->GetTOF() << endl;
141 else if (tofRawDatum->GetTOF()>=100 && tofRawDatum->GetTOF()<1000) ftxt << " " << tofRawDatum->GetTOF() << endl;
142 else ftxt << " " << tofRawDatum->GetTOF() << endl;
143
144 } // end loop
145
146 } // endl loop on DDL files
147
148 iEvent++;
d0eb8f39 149
150 } // end while loop on event
571dda3d 151
15ec34b9 152 ftxt.close();
153
571dda3d 154}