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 //////////////////////////////////////////////////////////////////////////
24 #include "AliRawEvent.h"
25 #include "AliRawEventHeaderBase.h"
26 #include "AliRawEquipment.h"
27 #include "AliRawEquipmentHeader.h"
28 #include "AliRawDataHeader.h"
29 #include "AliRawData.h"
32 #include <Riostream.h>
34 static Int_t miniEventIDOffset[AliDAQ::kNDetectors] = {3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565,3565};
35 static Bool_t detTriggerClasses[AliDAQ::kNDetectors] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
37 //______________________________________________________________________________
38 static void Usage(const char *prognam)
41 // of the alirawdump program
42 fprintf(stderr, "Usage: %s <raw_data_root_file>\n",
44 fprintf(stderr, " <raw_data_root_file> = file with ROOT formatted raw data\n");
47 //______________________________________________________________________________
48 static bool DumpCDH(AliRawDataHeader *cdh)
52 cout << " Size: " << cdh->fSize << endl;
53 cout << " Version: " << (Int_t)cdh->GetVersion() << endl;
54 cout << " Orbit: " << cdh->GetEventID2() << " Bunch-crossing: " << cdh->GetEventID1() << endl;
55 cout << " L1 trigger message: " << (UInt_t)cdh->GetL1TriggerMessage() << endl;
56 cout << " Participating sub-detectors: " << cdh->GetSubDetectors() << endl;
57 cout << " Block attributes: " << (Int_t)cdh->GetAttributes() << endl;
58 cout << " Status: " << cdh->GetStatus() << endl;
59 cout << " Mini event ID: " << cdh->GetMiniEventID() << endl;
60 cout << " Trigger classes: " << cdh->GetTriggerClasses() << endl;
61 cout << " ROI: " << cdh->GetROI() << endl;
66 //______________________________________________________________________________
67 static bool CheckCDH(AliRawDataHeader *cdhRef,AliRawDataHeader *cdh)
69 // Check the consistency of the CDHs
72 if ((cdhRef->GetEventID1() != cdh->GetEventID1())) {
73 cout << "ERROR: CDH mismatch detected in EventID1: " << cdhRef->GetEventID1() << " != " << cdh->GetEventID1() << endl;
76 // if ((cdhRef->GetVersion() != cdh->GetVersion())) {
77 // cout << "ERROR: CDH mismatch detected in Version: " << (Int_t)cdhRef->GetVersion() << " != " << (Int_t)cdh->GetVersion() << endl;
80 if ((cdhRef->GetEventID2() != cdh->GetEventID2())) {
81 cout << "ERROR: CDH mismatch detected in EventID2: " << cdhRef->GetEventID2() << " != " << cdh->GetEventID2() << endl;
84 // if ((cdhRef->GetMiniEventID() != cdh->GetMiniEventID())) {
85 // cout << "ERROR: CDH mismatch detected in MiniEventID: " << cdhRef->GetMiniEventID() << " != " << cdh->GetMiniEventID() << endl;
88 // if ((cdhRef->GetTriggerClasses() != cdh->GetTriggerClasses())) {
89 // cout << "ERROR: CDH mismatch detected in TriggerClasses: " << cdhRef->GetTriggerClasses() << " != " << cdh->GetTriggerClasses() << endl;
93 // if ((cdhRef->GetL1TriggerMessage() != cdh->GetL1TriggerMessage())) {
94 // cout << "ERROR: CDH mismatch detected in L1TriggerMessage: " << (Int_t)cdhRef->GetL1TriggerMessage() << " != " << (Int_t)cdh->GetL1TriggerMessage() << endl;
97 if ((cdhRef->GetSubDetectors() != cdh->GetSubDetectors())) {
98 cout << "ERROR: CDH mismatch detected in ParticipatingSubDetectors: " << cdhRef->GetSubDetectors() << " != " << cdh->GetSubDetectors() << endl;
102 if (iserror) return false;
106 //______________________________________________________________________________
107 static bool DumpEvent(const char *progname, AliRawEvent *rawEvent)
109 // Dumps and checks one
111 AliRawEventHeaderBase *rawEventHeader = rawEvent->GetHeader();
113 if (rawEventHeader->GetMagic() != 0xDA1E5AFE) {
114 Error(progname,"Wrong magic number ( 0x%x != 0xDA1E5AFE )",rawEventHeader->GetMagic());
118 cout << " *********** Event header ***********" << endl;
119 rawEventHeader->Print();
121 AliRawDataHeader *cdhRef = NULL;
123 for(Int_t iSubEvent=0; iSubEvent < rawEvent->GetNSubEvents(); iSubEvent++) {
124 AliRawEvent *rawSubEvent = rawEvent->GetSubEvent(iSubEvent);
125 AliRawEventHeaderBase *rawSubEventHeader = rawSubEvent->GetHeader();
126 cout << " *********** Sub-event header ***********" << endl;
127 rawSubEventHeader->Print(" ");
129 for(Int_t iEquipment=0; iEquipment < rawSubEvent->GetNEquipments(); iEquipment++) {
130 AliRawEquipment *rawEquip = rawSubEvent->GetEquipment(iEquipment);
131 AliRawEquipmentHeader *rawEquipHeader = rawEquip->GetEquipmentHeader();
132 cout << " *********** Equipment event header ***********" << endl;
133 rawEquipHeader->Print(" ");
134 cout << " *********** Common Data Header ***********" << endl;
135 AliRawData *rawData = rawEquip->GetRawData();
136 AliRawDataHeader *cdh = (AliRawDataHeader*)rawData->GetBuffer();
139 Int_t detID = AliDAQ::DetectorIDFromDdlID(rawEquipHeader->GetId(),ddlID);
140 Int_t idOffset = cdh->GetMiniEventID() - cdh->GetEventID1();
141 if (idOffset < 0) idOffset += 3564;
142 if (miniEventIDOffset[detID] == 3565) {
143 miniEventIDOffset[detID] = idOffset;
144 cout << "MiniEvenID offset for detector " << AliDAQ::DetectorName(detID) << " is set to " << idOffset << endl;
147 if (miniEventIDOffset[detID] != idOffset) {
148 cout << "ERROR: MiniEventID offset for detector " << AliDAQ::DetectorName(detID) << " has changed ( " << idOffset << " != " << miniEventIDOffset[detID] << " )" << endl;
152 // TPC is using version 1
153 if ((cdh->GetVersion() != 2) && (detID != 3))
154 cout << "ERROR: Bad CDH version: " << (Int_t)cdh->GetVersion() << endl;
156 if (cdh->GetTriggerClasses() == 0) {
157 if (detTriggerClasses[detID])
158 cout << "Empty trigger class mask for detector " << AliDAQ::DetectorName(detID) << endl;
159 detTriggerClasses[detID] = false;
162 if (!DumpCDH(cdh)) return false;
163 // check the CDH consistency
164 if (cdhRef == NULL) {
168 // TPC L1 trigger message is shifted by 2 bits??
169 UShort_t l1Message = cdh->GetL1TriggerMessage();
170 UShort_t l1MessageRef = cdhRef->GetL1TriggerMessage();
172 if (l1Message != l1MessageRef)
173 cout << "ERROR: CDH mismatch detected in L1TriggerMessage for detector " << AliDAQ::DetectorName(detID) << ": " << (Int_t)l1MessageRef << " ( " << (Int_t)cdhRef->GetL1TriggerMessage() << " ) " << " != " << (Int_t)l1Message << " ( " << (Int_t)cdh->GetL1TriggerMessage() << " )" << endl;
175 if ((cdhRef->GetTriggerClasses() == 0) && (cdh->GetTriggerClasses() != 0)) {
176 // update the reference trigger class mask
177 cdhRef->fTriggerClassLow = cdh->fTriggerClassLow;
178 cdhRef->fROILowTriggerClassHigh = (((cdhRef->fROILowTriggerClassHigh >> 28) & 0xF) << 28) | (cdh->fROILowTriggerClassHigh & 0x1FFFF);
180 if (cdh->GetTriggerClasses() != 0) {
181 if (cdhRef->GetTriggerClasses() != cdh->GetTriggerClasses()) {
182 cout << "ERROR: CDH mismatch detected in TriggerClasses: " << cdhRef->GetTriggerClasses() << " != " << cdh->GetTriggerClasses() << endl;
186 CheckCDH(cdhRef,cdh);
187 // if (!CheckCDH(cdhRef,cdh)) return false;
195 //______________________________________________________________________________
196 int main(int argc, char **argv)
198 // Dumps a ROOT formatted
203 if ((argc == 2 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-help"))) || argc != 2) {
208 TString str = argv[1];
209 if (str.BeginsWith("alien://"))
210 TGrid::Connect("alien://");
212 TFile *rawFile = TFile::Open(argv[1],"READ");
214 Error(argv[0],"Raw data file %s can not be opened!",argv[1]);
218 TTree *rawTree=(TTree *)rawFile->Get("RAW");
220 Error(argv[0],"Error getting RAW tree from file %s",argv[1]);
224 AliRawEvent *rawEvent=NULL;
226 rawTree->SetBranchAddress("rawevent", &rawEvent);
228 Int_t nEvents = rawTree->GetEntries();
230 cout << "*******************************************" << endl;
231 cout << "File: " << argv[1] << endl;
232 cout << "GUID: " << rawFile->GetUUID().AsString() << endl;
233 cout << "Total number of events: " << nEvents << endl;
234 cout << "*******************************************" << endl;
236 for(Int_t iEvent=0; iEvent < nEvents; iEvent++) {
237 rawEvent=new AliRawEvent;
238 rawTree->GetEntry(iEvent);
239 cout << " *********** Event " << iEvent << " *******" << endl;
240 DumpEvent(argv[0],rawEvent);
244 cout << "*******************************************" << endl;
245 cout << "EOF" << endl;
246 cout << "*******************************************" << endl;