]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFRawDataRead.C
94ed79fe75ea1438f65b9131a196438fa22f92e6
[u/mrichter/AliRoot.git] / TOF / AliTOFRawDataRead.C
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
23 void AliTOFRawDataRead(Int_t iEvent=0);
24
25 void AliTOFRawDataRead(Int_t iEvent)
26 {
27   //
28   // To read TOF raw data
29   //
30
31   TClonesArray *fTOFrawData = new TClonesArray("AliTOFrawData",1000);
32   Int_t fPackedDigits=0;
33
34   Int_t indexDDL = 0;
35   Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
36   Int_t dummy = -1;
37
38   AliRawReaderFile reader(iEvent);
39   reader.RewindEvents();
40
41   ofstream ftxt;
42   ftxt.open("TOFrawDataReading.txt",ios::app);
43
44   while (reader.NextEvent()) {
45
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);
60
61      reader.Select("TOF", indexDDL, indexDDL);
62      Bool_t signal = kFALSE;
63
64      while(stream.Next()) {
65
66        signal = (stream.GetSector()!=-1 &&
67                  stream.GetPlate()!=-1 &&
68                  stream.GetStrip()!=-1 &&
69                  stream.GetPadZ()!=-1 &&
70                  stream.GetPadX()!=-1);
71
72        if (signal) {
73          printf("  %2i  %1i  %2i  %1i  %2i  \n", stream.GetSector(), stream.GetPlate(), stream.GetStrip(), stream.GetPadZ(), stream.GetPadX());
74
75          slot[0] = stream.GetTRM();
76          slot[1] = stream.GetTRMchain();
77          slot[2] = stream.GetTDC();
78          slot[3] = stream.GetTDCchannel();
79
80          if (rawMap->TestHit(slot) != kEmpty) {
81
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());
84
85          }
86          else {
87
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());
92
93            rawMap->SetHit(slot);
94
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++;
149
150   } // end while loop on event
151
152   ftxt.close();
153
154 }