Added data member fGainFactor
[u/mrichter/AliRoot.git] / RAW / alirawdump_main.cxx
CommitLineData
e255ff6a 1// Author: Cvetan Cheshkov 29/01/2008
2
3//////////////////////////////////////////////////////////////////////////
4// //
5// alirawdump //
6// //
7// Program can used to dump the raw-data files in ROOT format. //
8// It dumps the event,sub-event,equipment and common-data header. //
9// Additional application of the program is to check if the CDHs //
10// of different raw-data payloads are compatible. In this sense //
11// it replaces the DAQ online checks in case the DAQ is running //
12// UNCHECKED partition. //
13// //
14// Written by: Cvetan Cheshkov, 29/01/2008. //
15// //
16//////////////////////////////////////////////////////////////////////////
17
18#include <TROOT.h>
19#include <TError.h>
20#include <TFile.h>
21#include <TTree.h>
22
23#include "AliRawEvent.h"
24#include "AliRawEventHeaderBase.h"
25#include "AliRawEquipment.h"
26#include "AliRawEquipmentHeader.h"
27#include "AliRawDataHeader.h"
28#include "AliRawData.h"
29
30#include <Riostream.h>
31
32//______________________________________________________________________________
33static void Usage(const char *prognam)
34{
35 // Prints the usage
36 // of the alirawdump program
37 fprintf(stderr, "Usage: %s <raw_data_root_file>\n",
38 prognam);
39 fprintf(stderr, " <raw_data_root_file> = file with ROOT formatted raw data\n");
40}
41
42//______________________________________________________________________________
43static bool DumpCDH(AliRawDataHeader *cdh)
44{
45 // Dumps the CDH
46 // ...
47 cout << " Size: " << cdh->fSize << endl;
48 cout << " Version: " << (Int_t)cdh->GetVersion() << endl;
49 cout << " Orbit: " << cdh->GetEventID2() << " Bunch-crossing: " << cdh->GetEventID1() << endl;
50 cout << " L1 trigger message: " << (UInt_t)cdh->GetL1TriggerMessage() << endl;
51 cout << " Participating sub-detectors: " << cdh->GetSubDetectors() << endl;
52 cout << " Block attributes: " << (Int_t)cdh->GetAttributes() << endl;
53 cout << " Status: " << cdh->GetStatus() << endl;
54 cout << " Mini event ID: " << cdh->GetMiniEventID() << endl;
55 cout << " Trigger classes: " << cdh->GetTriggerClasses() << endl;
56 cout << " ROI: " << cdh->GetROI() << endl;
57
58 return true;
59}
60
61//______________________________________________________________________________
62static bool DumpEvent(const char *progname, AliRawEvent *rawEvent)
63{
64 // Dumps and checks one
65 // raw-data event
66 AliRawEventHeaderBase *rawEventHeader = rawEvent->GetHeader();
67
68 if (rawEventHeader->GetMagic() != 0xDA1E5AFE) {
69 Error(progname,"Wrong magic number ( 0x%x != 0xDA1E5AFE )",rawEventHeader->GetMagic());
70 return false;
71 }
72
73 cout << " *********** Event header ***********" << endl;
74 rawEventHeader->Print();
75
76 for(Int_t iSubEvent=0; iSubEvent < rawEvent->GetNSubEvents(); iSubEvent++) {
77 AliRawEvent *rawSubEvent = rawEvent->GetSubEvent(iSubEvent);
78 AliRawEventHeaderBase *rawSubEventHeader = rawSubEvent->GetHeader();
79 cout << " *********** Sub-event header ***********" << endl;
80 rawSubEventHeader->Print(" ");
81
82 for(Int_t iEquipment=0; iEquipment < rawSubEvent->GetNEquipments(); iEquipment++) {
83 AliRawEquipment *rawEquip = rawSubEvent->GetEquipment(iEquipment);
84 AliRawEquipmentHeader *rawEquipHeader = rawEquip->GetEquipmentHeader();
85 cout << " *********** Equipment event header ***********" << endl;
86 rawEquipHeader->Print(" ");
87 cout << " *********** Common Data Header ***********" << endl;
88 AliRawData *rawData = rawEquip->GetRawData();
89 AliRawDataHeader *cdh = (AliRawDataHeader*)rawData->GetBuffer();
90 if (!DumpCDH(cdh)) return false;
91 }
92 }
93
94 return true;
95}
96
97//______________________________________________________________________________
98int main(int argc, char **argv)
99{
100 // Dumps a ROOT formatted
101 // raw-data file
102
103 gROOT->SetBatch();
104
105 if ((argc == 2 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-help"))) || argc != 2) {
106 Usage(argv[0]);
107 return 1;
108 }
109
110 TFile *rawFile = TFile::Open(argv[1],"READ");
111 if (!rawFile) {
112 Error(argv[0],"Raw data file %s can not be opened!",argv[1]);
113 return 1;
114 }
115
116 TTree *rawTree=(TTree *)rawFile->Get("RAW");
117 if(!rawTree) {
118 Error(argv[0],"Error getting RAW tree from file %s",argv[1]);
119 return 1;
120 }
121
122 AliRawEvent *rawEvent=NULL;
123
124 rawTree->SetBranchAddress("rawevent", &rawEvent);
125
126 Int_t nEvents = rawTree->GetEntries();
127
128 cout << "*******************************************" << endl;
129 cout << "File: " << argv[1] << endl;
130 cout << "GUID: " << rawFile->GetUUID().AsString() << endl;
131 cout << "Total number of events: " << nEvents << endl;
132 cout << "*******************************************" << endl;
133
134 for(Int_t iEvent=0; iEvent < nEvents; iEvent++) {
135 rawEvent=new AliRawEvent;
136 rawTree->GetEntry(iEvent);
137 cout << " *********** Event " << iEvent << " *******" << endl;
138 DumpEvent(argv[0],rawEvent);
139 delete rawEvent;
140 }
141
142 cout << "*******************************************" << endl;
143 cout << "EOF" << endl;
144 cout << "*******************************************" << endl;
145 delete rawTree;
146 rawFile->Close();
147}