corrected TRD/TOF MV position
[u/mrichter/AliRoot.git] / TOF / AliTOFRawDataRead.C
CommitLineData
15ec34b9 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
3// Root include files
4#include "TClonesArray.h"
5
6// AliRoot include files
7#include "AliDAQ.h"
8#include "AliHitMap.h"
9
10#include "AliRawReader.h"
11#include "AliRawReaderFile.h"
12
13#include "AliTOFrawData.h"
14#include "AliTOFRawMap.h"
15#include "AliTOFRawStream.h"
16
17#endif
18
19void AliTOFRawDataRead(Int_t iEvent=0);
20
21void AliTOFRawDataRead(Int_t iEvent)
571dda3d 22{
23 //
24 // To read TOF raw data
25 //
26
2b79b4a5 27 AliTOFrawData *tofRawDatum=new AliTOFrawData();
28 TTree *PackedDataTree= new TTree("PackedDataTree", "Decoded Packed Data");
29 PackedDataTree->Branch("HitData", "AliTOFrawData", &tofRawDatum);
30
515faf5d 31 TClonesArray *clonesRawData = new TClonesArray("AliTOFrawData",1000);
15ec34b9 32 Int_t fPackedDigits=0;
33
d0eb8f39 34 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
15ec34b9 35 Int_t dummy = -1;
571dda3d 36
515faf5d 37 AliRawReader *reader = new AliRawReaderFile(iEvent);
38 reader->RewindEvents();
571dda3d 39
15ec34b9 40 ofstream ftxt;
41 ftxt.open("TOFrawDataReading.txt",ios::app);
42
515faf5d 43 while (reader->NextEvent()) {
571dda3d 44
515faf5d 45 AliTOFRawMap *rawMap = new AliTOFRawMap(clonesRawData);
15ec34b9 46
47 Int_t slot[4] = {-1, -1, -1, -1};
48
515faf5d 49 for (Int_t indexDDL = 0; indexDDL < AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
15ec34b9 50
515faf5d 51 reader->Reset();
52 AliTOFRawStream stream(reader);
53 stream.LoadRawData(indexDDL);
15ec34b9 54
515faf5d 55 clonesRawData = (TClonesArray*)stream.GetRawData();
15ec34b9 56
515faf5d 57 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
571dda3d 58
2b79b4a5 59 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
15ec34b9 60
61 if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
62
63 if (indexDDL<10) ftxt << " " << indexDDL;
64 else ftxt << " " << indexDDL;
65 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
66 else ftxt << " " << tofRawDatum->GetTRM();
67 ftxt << " " << tofRawDatum->GetTRMchain();
68 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
69 else ftxt << " " << tofRawDatum->GetTDC();
70 ftxt << " " << tofRawDatum->GetTDCchannel();
71
72 stream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
73 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
74 dummy = detectorIndex[3];
75 detectorIndex[3] = detectorIndex[4];
76 detectorIndex[4] = dummy;
77
78 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
79 else ftxt << " -> " << detectorIndex[0];
80 ftxt << " " << detectorIndex[1];
81 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
82 else ftxt << " " << detectorIndex[2];
83 ftxt << " " << detectorIndex[3];
84 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
85 else ftxt << " " << detectorIndex[4];
86
515faf5d 87 if (tofRawDatum->GetTOT()<10) ftxt << " " << tofRawDatum->GetTOT();
88 else if (tofRawDatum->GetTOT()>=10 && tofRawDatum->GetTOT()<100) ftxt << " " << tofRawDatum->GetTOT();
89 else if (tofRawDatum->GetTOT()>=100 && tofRawDatum->GetTOT()<1000) ftxt << " " << tofRawDatum->GetTOT();
90 else if (tofRawDatum->GetTOT()>=1000 && tofRawDatum->GetTOT()<10000) ftxt << " " << tofRawDatum->GetTOT();
91 else if (tofRawDatum->GetTOT()>=10000 && tofRawDatum->GetTOT()<100000) ftxt << " " << tofRawDatum->GetTOT();
92 else if (tofRawDatum->GetTOT()>=100000 && tofRawDatum->GetTOT()<1000000) ftxt << " " << tofRawDatum->GetTOT();
93 else ftxt << " " << tofRawDatum->GetTOT();
94 if (tofRawDatum->GetTOF()<10) ftxt << " " << tofRawDatum->GetTOF() << endl;
95 else if (tofRawDatum->GetTOF()>=10 && tofRawDatum->GetTOF()<100) ftxt << " " << tofRawDatum->GetTOF() << endl;
96 else if (tofRawDatum->GetTOF()>=100 && tofRawDatum->GetTOF()<1000) ftxt << " " << tofRawDatum->GetTOF() << endl;
97 else if (tofRawDatum->GetTOF()>=1000 && tofRawDatum->GetTOF()<10000) ftxt << " " << tofRawDatum->GetTOF() << endl;
98 else if (tofRawDatum->GetTOF()>=10000 && tofRawDatum->GetTOF()<100000) ftxt << " " << tofRawDatum->GetTOF() << endl;
99 else if (tofRawDatum->GetTOF()>=100000 && tofRawDatum->GetTOF()<1000000) ftxt << " " << tofRawDatum->GetTOF() << endl;
100 else ftxt << " " << tofRawDatum->GetTOF() << endl;
15ec34b9 101
2b79b4a5 102 PackedDataTree->Fill();
15ec34b9 103 } // end loop
104
105 } // endl loop on DDL files
106
107 iEvent++;
d0eb8f39 108
109 } // end while loop on event
571dda3d 110
15ec34b9 111 ftxt.close();
2b79b4a5 112 TFile fileOut("TOF_rawQA_OldDecoder.root", "RECREATE");
113 PackedDataTree->Write();
114 fileOut.Close();
15ec34b9 115
571dda3d 116}
515faf5d 117