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>
37 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};
38 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};
40 //______________________________________________________________________________
41 static void Usage(const char *prognam)
44 // of the alirawdump program
45 fprintf(stderr, "Usage: %s <raw_data_root_file>\n",
47 fprintf(stderr, " <raw_data_root_file> = file with ROOT formatted raw data\n");
50 //______________________________________________________________________________
51 static bool DumpCDH(AliRawDataHeader *cdh)
55 cout << " Size: " << cdh->fSize << endl;
56 cout << " Version: " << (Int_t)cdh->GetVersion() << endl;
57 cout << " Orbit: " << cdh->GetEventID2() << " Bunch-crossing: " << cdh->GetEventID1() << endl;
58 cout << " L1 trigger message: " << (UInt_t)cdh->GetL1TriggerMessage() << endl;
59 cout << " Participating sub-detectors: " << cdh->GetSubDetectors() << endl;
60 cout << " Block attributes: " << (Int_t)cdh->GetAttributes() << endl;
61 cout << " Status: " << cdh->GetStatus() << endl;
62 cout << " Mini event ID: " << cdh->GetMiniEventID() << endl;
63 cout << " Trigger classes: " << cdh->GetTriggerClasses() << endl;
64 cout << " ROI: " << cdh->GetROI() << endl;
69 //______________________________________________________________________________
70 static bool CheckCDH(AliRawDataHeader *cdhRef,AliRawDataHeader *cdh)
72 // Check the consistency of the CDHs
75 if ((cdhRef->GetEventID1() != cdh->GetEventID1())) {
76 cout << "ERROR: CDH mismatch detected in EventID1: " << cdhRef->GetEventID1() << " != " << cdh->GetEventID1() << endl;
79 // if ((cdhRef->GetVersion() != cdh->GetVersion())) {
80 // cout << "ERROR: CDH mismatch detected in Version: " << (Int_t)cdhRef->GetVersion() << " != " << (Int_t)cdh->GetVersion() << endl;
83 if ((cdhRef->GetEventID2() != cdh->GetEventID2())) {
84 cout << "ERROR: CDH mismatch detected in EventID2: " << cdhRef->GetEventID2() << " != " << cdh->GetEventID2() << endl;
87 // if ((cdhRef->GetMiniEventID() != cdh->GetMiniEventID())) {
88 // cout << "ERROR: CDH mismatch detected in MiniEventID: " << cdhRef->GetMiniEventID() << " != " << cdh->GetMiniEventID() << endl;
91 // if ((cdhRef->GetTriggerClasses() != cdh->GetTriggerClasses())) {
92 // cout << "ERROR: CDH mismatch detected in TriggerClasses: " << cdhRef->GetTriggerClasses() << " != " << cdh->GetTriggerClasses() << endl;
96 // if ((cdhRef->GetL1TriggerMessage() != cdh->GetL1TriggerMessage())) {
97 // cout << "ERROR: CDH mismatch detected in L1TriggerMessage: " << (Int_t)cdhRef->GetL1TriggerMessage() << " != " << (Int_t)cdh->GetL1TriggerMessage() << endl;
100 if ((cdhRef->GetSubDetectors() != cdh->GetSubDetectors())) {
101 cout << "ERROR: CDH mismatch detected in ParticipatingSubDetectors: " << cdhRef->GetSubDetectors() << " != " << cdh->GetSubDetectors() << endl;
105 if (iserror) return false;
109 //______________________________________________________________________________
110 static bool DumpEvent(const char *progname, AliRawVEvent *rawEvent)
112 // Dumps and checks one
114 AliRawEventHeaderBase *rawEventHeader = rawEvent->GetHeader();
116 if (rawEventHeader->GetMagic() != 0xDA1E5AFE) {
117 Error(progname,"Wrong magic number ( 0x%x != 0xDA1E5AFE )",rawEventHeader->GetMagic());
121 cout << " *********** Event header ***********" << endl;
122 rawEventHeader->Print();
124 AliRawDataHeader *cdhRef = NULL;
126 for(Int_t iSubEvent=0; iSubEvent < rawEvent->GetNSubEvents(); iSubEvent++) {
127 AliRawVEvent *rawSubEvent = rawEvent->GetSubEvent(iSubEvent);
128 AliRawEventHeaderBase *rawSubEventHeader = rawSubEvent->GetHeader();
129 cout << " *********** Sub-event header ***********" << endl;
130 rawSubEventHeader->Print(" ");
132 for(Int_t iEquipment=0; iEquipment < rawSubEvent->GetNEquipments(); iEquipment++) {
133 AliRawVEquipment *rawEquip = rawSubEvent->GetEquipment(iEquipment);
134 AliRawEquipmentHeader *rawEquipHeader = rawEquip->GetEquipmentHeader();
135 cout << " *********** Equipment event header ***********" << endl;
136 rawEquipHeader->Print(" ");
137 cout << " *********** Common Data Header ***********" << endl;
138 AliRawData *rawData = rawEquip->GetRawData();
139 AliRawDataHeader *cdh = (AliRawDataHeader*)rawData->GetBuffer();
142 Int_t detID = AliDAQ::DetectorIDFromDdlID(rawEquipHeader->GetId(),ddlID);
146 Int_t idOffset = cdh->GetMiniEventID() - cdh->GetEventID1();
147 if (idOffset < 0) idOffset += 3564;
148 if (miniEventIDOffset[detID] == 3565) {
149 miniEventIDOffset[detID] = idOffset;
150 cout << "MiniEvenID offset for detector " << AliDAQ::DetectorName(detID) << " is set to " << idOffset << endl;
153 if (miniEventIDOffset[detID] != idOffset) {
154 cout << "ERROR: MiniEventID offset for detector " << AliDAQ::DetectorName(detID) << " has changed ( " << idOffset << " != " << miniEventIDOffset[detID] << " )" << endl;
158 // TPC is using version 1
159 if ((cdh->GetVersion() != 2) && (detID != 3))
160 cout << "ERROR: Bad CDH version: " << (Int_t)cdh->GetVersion() << endl;
162 if (cdh->GetTriggerClasses() == 0) {
163 if (detTriggerClasses[detID])
164 cout << "Empty trigger class mask for detector " << AliDAQ::DetectorName(detID) << endl;
165 detTriggerClasses[detID] = false;
168 if (!DumpCDH(cdh)) return false;
169 // check the CDH consistency
170 if (cdhRef == NULL) {
174 // TPC L1 trigger message is shifted by 2 bits??
175 UShort_t l1Message = cdh->GetL1TriggerMessage();
176 UShort_t l1MessageRef = cdhRef->GetL1TriggerMessage();
178 if (l1Message != l1MessageRef)
179 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;
181 if ((cdhRef->GetTriggerClasses() == 0) && (cdh->GetTriggerClasses() != 0)) {
182 // update the reference trigger class mask
183 cdhRef->fTriggerClassLow = cdh->fTriggerClassLow;
184 cdhRef->fROILowTriggerClassHigh = (((cdhRef->fROILowTriggerClassHigh >> 28) & 0xF) << 28) | (cdh->fROILowTriggerClassHigh & 0x1FFFF);
186 if (cdh->GetTriggerClasses() != 0) {
187 if (cdhRef->GetTriggerClasses() != cdh->GetTriggerClasses()) {
188 cout << "ERROR: CDH mismatch detected in TriggerClasses: " << cdhRef->GetTriggerClasses() << " != " << cdh->GetTriggerClasses() << endl;
192 CheckCDH(cdhRef,cdh);
193 // if (!CheckCDH(cdhRef,cdh)) return false;
201 //______________________________________________________________________________
202 int main(int argc, char **argv)
204 // Dumps a ROOT formatted
209 if ((argc == 2 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-help"))) || argc != 2) {
214 TString str = argv[1];
215 if (str.BeginsWith("alien://"))
216 TGrid::Connect("alien://");
218 TFile *rawFile = TFile::Open(argv[1],"READ");
220 Error(argv[0],"Raw data file %s can not be opened!",argv[1]);
224 TTree *rawTree=(TTree *)rawFile->Get("RAW");
226 Error(argv[0],"Error getting RAW tree from file %s",argv[1]);
230 AliRawVEvent *rawEvent=NULL;
232 rawTree->SetBranchAddress("rawevent", &rawEvent);
234 Int_t nEvents = rawTree->GetEntries();
236 cout << "*******************************************" << endl;
237 cout << "File: " << argv[1] << endl;
238 cout << "GUID: " << rawFile->GetUUID().AsString() << endl;
239 cout << "Total number of events: " << nEvents << endl;
240 cout << "*******************************************" << endl;
242 for(Int_t iEvent=0; iEvent < nEvents; iEvent++) {
244 rawTree->GetEntry(iEvent);
245 cout << " *********** Event " << iEvent << " *******" << endl;
246 DumpEvent(argv[0],rawEvent);
253 cout << "*******************************************" << endl;
254 cout << "EOF" << endl;
255 cout << "*******************************************" << endl;