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 "AliRawVEvent.h"
25 #include "AliRawEventHeaderBase.h"
26 #include "AliRawVEquipment.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, AliRawVEvent *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 AliRawVEvent *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 AliRawVEquipment *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);
143 Int_t idOffset = cdh->GetMiniEventID() - cdh->GetEventID1();
144 if (idOffset < 0) idOffset += 3564;
145 if (miniEventIDOffset[detID] == 3565) {
146 miniEventIDOffset[detID] = idOffset;
147 cout << "MiniEvenID offset for detector " << AliDAQ::DetectorName(detID) << " is set to " << idOffset << endl;
150 if (miniEventIDOffset[detID] != idOffset) {
151 cout << "ERROR: MiniEventID offset for detector " << AliDAQ::DetectorName(detID) << " has changed ( " << idOffset << " != " << miniEventIDOffset[detID] << " )" << endl;
155 // TPC is using version 1
156 if ((cdh->GetVersion() != 2) && (detID != 3))
157 cout << "ERROR: Bad CDH version: " << (Int_t)cdh->GetVersion() << endl;
159 if (cdh->GetTriggerClasses() == 0) {
160 if (detTriggerClasses[detID])
161 cout << "Empty trigger class mask for detector " << AliDAQ::DetectorName(detID) << endl;
162 detTriggerClasses[detID] = false;
165 if (!DumpCDH(cdh)) return false;
166 // check the CDH consistency
167 if (cdhRef == NULL) {
171 // TPC L1 trigger message is shifted by 2 bits??
172 UShort_t l1Message = cdh->GetL1TriggerMessage();
173 UShort_t l1MessageRef = cdhRef->GetL1TriggerMessage();
175 if (l1Message != l1MessageRef)
176 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;
178 if ((cdhRef->GetTriggerClasses() == 0) && (cdh->GetTriggerClasses() != 0)) {
179 // update the reference trigger class mask
180 cdhRef->fTriggerClassLow = cdh->fTriggerClassLow;
181 cdhRef->fROILowTriggerClassHigh = (((cdhRef->fROILowTriggerClassHigh >> 28) & 0xF) << 28) | (cdh->fROILowTriggerClassHigh & 0x1FFFF);
183 if (cdh->GetTriggerClasses() != 0) {
184 if (cdhRef->GetTriggerClasses() != cdh->GetTriggerClasses()) {
185 cout << "ERROR: CDH mismatch detected in TriggerClasses: " << cdhRef->GetTriggerClasses() << " != " << cdh->GetTriggerClasses() << endl;
189 CheckCDH(cdhRef,cdh);
190 // if (!CheckCDH(cdhRef,cdh)) return false;
198 //______________________________________________________________________________
199 int main(int argc, char **argv)
201 // Dumps a ROOT formatted
206 if ((argc == 2 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-help"))) || argc != 2) {
211 TString str = argv[1];
212 if (str.BeginsWith("alien://"))
213 TGrid::Connect("alien://");
215 TFile *rawFile = TFile::Open(argv[1],"READ");
217 Error(argv[0],"Raw data file %s can not be opened!",argv[1]);
221 TTree *rawTree=(TTree *)rawFile->Get("RAW");
223 Error(argv[0],"Error getting RAW tree from file %s",argv[1]);
227 AliRawVEvent *rawEvent=NULL;
229 rawTree->SetBranchAddress("rawevent", &rawEvent);
231 Int_t nEvents = rawTree->GetEntries();
233 cout << "*******************************************" << endl;
234 cout << "File: " << argv[1] << endl;
235 cout << "GUID: " << rawFile->GetUUID().AsString() << endl;
236 cout << "Total number of events: " << nEvents << endl;
237 cout << "*******************************************" << endl;
239 for(Int_t iEvent=0; iEvent < nEvents; iEvent++) {
241 rawTree->GetEntry(iEvent);
242 cout << " *********** Event " << iEvent << " *******" << endl;
243 DumpEvent(argv[0],rawEvent);
250 cout << "*******************************************" << endl;
251 cout << "EOF" << endl;
252 cout << "*******************************************" << endl;