1 // Author: Cvetan Cheshkov 29/01/2008
3 //////////////////////////////////////////////////////////////////////////
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. //
14 // Written by: Cvetan Cheshkov, 29/01/2008. //
16 //////////////////////////////////////////////////////////////////////////
23 #include "AliRawEvent.h"
24 #include "AliRawEventHeaderBase.h"
25 #include "AliRawEquipment.h"
26 #include "AliRawEquipmentHeader.h"
27 #include "AliRawDataHeader.h"
28 #include "AliRawData.h"
30 #include <Riostream.h>
32 //______________________________________________________________________________
33 static void Usage(const char *prognam)
36 // of the alirawdump program
37 fprintf(stderr, "Usage: %s <raw_data_root_file>\n",
39 fprintf(stderr, " <raw_data_root_file> = file with ROOT formatted raw data\n");
42 //______________________________________________________________________________
43 static bool DumpCDH(AliRawDataHeader *cdh)
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;
61 //______________________________________________________________________________
62 static bool CheckCDH(AliRawDataHeader *cdhRef,AliRawDataHeader *cdh)
64 // Check the consistency of the CDHs
66 if ((cdhRef->GetEventID1() != cdh->GetEventID1()) ||
67 (cdhRef->GetVersion() != cdh->GetVersion()) ||
68 (cdhRef->GetEventID2() != cdh->GetEventID2()) ||
69 (cdhRef->GetMiniEventID() != cdh->GetMiniEventID()) ||
70 (cdhRef->GetTriggerClasses() != cdh->GetTriggerClasses())) {
71 cout << "CDH mismatch detected:" << endl;
79 //______________________________________________________________________________
80 static bool DumpEvent(const char *progname, AliRawEvent *rawEvent)
82 // Dumps and checks one
84 AliRawEventHeaderBase *rawEventHeader = rawEvent->GetHeader();
86 if (rawEventHeader->GetMagic() != 0xDA1E5AFE) {
87 Error(progname,"Wrong magic number ( 0x%x != 0xDA1E5AFE )",rawEventHeader->GetMagic());
91 cout << " *********** Event header ***********" << endl;
92 rawEventHeader->Print();
94 AliRawDataHeader *cdhRef = NULL;
96 for(Int_t iSubEvent=0; iSubEvent < rawEvent->GetNSubEvents(); iSubEvent++) {
97 AliRawEvent *rawSubEvent = rawEvent->GetSubEvent(iSubEvent);
98 AliRawEventHeaderBase *rawSubEventHeader = rawSubEvent->GetHeader();
99 cout << " *********** Sub-event header ***********" << endl;
100 rawSubEventHeader->Print(" ");
102 for(Int_t iEquipment=0; iEquipment < rawSubEvent->GetNEquipments(); iEquipment++) {
103 AliRawEquipment *rawEquip = rawSubEvent->GetEquipment(iEquipment);
104 AliRawEquipmentHeader *rawEquipHeader = rawEquip->GetEquipmentHeader();
105 cout << " *********** Equipment event header ***********" << endl;
106 rawEquipHeader->Print(" ");
107 cout << " *********** Common Data Header ***********" << endl;
108 AliRawData *rawData = rawEquip->GetRawData();
109 AliRawDataHeader *cdh = (AliRawDataHeader*)rawData->GetBuffer();
110 if (!DumpCDH(cdh)) return false;
111 // check the CDH consistency
112 if (cdhRef == NULL) {
116 if (!CheckCDH(cdhRef,cdh)) return false;
124 //______________________________________________________________________________
125 int main(int argc, char **argv)
127 // Dumps a ROOT formatted
132 if ((argc == 2 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-help"))) || argc != 2) {
137 TFile *rawFile = TFile::Open(argv[1],"READ");
139 Error(argv[0],"Raw data file %s can not be opened!",argv[1]);
143 TTree *rawTree=(TTree *)rawFile->Get("RAW");
145 Error(argv[0],"Error getting RAW tree from file %s",argv[1]);
149 AliRawEvent *rawEvent=NULL;
151 rawTree->SetBranchAddress("rawevent", &rawEvent);
153 Int_t nEvents = rawTree->GetEntries();
155 cout << "*******************************************" << endl;
156 cout << "File: " << argv[1] << endl;
157 cout << "GUID: " << rawFile->GetUUID().AsString() << endl;
158 cout << "Total number of events: " << nEvents << endl;
159 cout << "*******************************************" << endl;
161 for(Int_t iEvent=0; iEvent < nEvents; iEvent++) {
162 rawEvent=new AliRawEvent;
163 rawTree->GetEntry(iEvent);
164 cout << " *********** Event " << iEvent << " *******" << endl;
165 DumpEvent(argv[0],rawEvent);
169 cout << "*******************************************" << endl;
170 cout << "EOF" << endl;
171 cout << "*******************************************" << endl;