Fixes in order to treat correctly event and sub-event header extensions.
[u/mrichter/AliRoot.git] / MONITOR / root2date.cxx
CommitLineData
36470d8d 1// Author: Filimon Roukoutakis 02/08/2006
2// Cvetan Cheshkov
3
4/******************************************************************************
5 MOOD - Monitor Of On-line Data and Detector Debugger for ALICE Experiment
6******************************************************************************/
7
8#include "root2date.h"
9
8e8e0e3e 10int Root2Date(AliRawEvent *gdcRootEvent, unsigned char *gdcDateEvent, char *ddlDir) {
36470d8d 11
12 unsigned char *p=gdcDateEvent;
13 int ldcCounter, equipmentCounter, chunkSize;
14 AliRawEquipment *aliEquipment=NULL;
15 AliRawEquipmentHeader *aliEquipmentHeader=NULL;
16 AliRawEventHeaderBase *aliHeader=NULL;
17 AliRawEvent *ldcRootEvent=NULL;
18
19 aliHeader=gdcRootEvent->GetHeader();
20 memcpy(p, aliHeader->HeaderBaseBegin(), chunkSize=aliHeader->HeaderBaseSize());
21 p+=chunkSize;
22 memcpy(p, aliHeader->HeaderBegin(), chunkSize=aliHeader->HeaderSize()); // Write DATE GDC header
23 p+=chunkSize;
33778962 24 memcpy(p, aliHeader->GetExtendedData(), chunkSize=aliHeader->GetExtendedDataSize());
25 p+=chunkSize;
36470d8d 26 for(ldcCounter=0; ldcCounter<gdcRootEvent->GetNSubEvents(); ldcCounter++) {
27 ldcRootEvent=gdcRootEvent->GetSubEvent(ldcCounter);
28 aliHeader=ldcRootEvent->GetHeader();
29 memcpy(p, aliHeader->HeaderBaseBegin(), chunkSize=aliHeader->HeaderBaseSize());
30 p+=chunkSize;
31 memcpy(p, aliHeader->HeaderBegin(), chunkSize=aliHeader->HeaderSize()); // Write DATE LDC header
32 p+=chunkSize;
33778962 33 memcpy(p, aliHeader->GetExtendedData(), chunkSize=aliHeader->GetExtendedDataSize());
34 p+=chunkSize;
36470d8d 35 for(equipmentCounter=0; equipmentCounter<ldcRootEvent->GetNEquipments(); equipmentCounter++) {
36 aliEquipment=ldcRootEvent->GetEquipment(equipmentCounter);
37 aliEquipmentHeader=aliEquipment->GetEquipmentHeader();
38 if(aliEquipmentHeader->GetEquipmentSize()) {
39 memcpy(p, aliEquipmentHeader->HeaderBegin(), chunkSize=aliEquipmentHeader->HeaderSize()); // Write DATE Equipment header
40 p+=chunkSize;
41 }
42 memcpy(p, aliEquipment->GetRawData()->GetBuffer(), chunkSize=aliEquipment->GetRawData()->GetSize()); // Write Equipment payload (including CDH)
8e8e0e3e 43 // Write ddl files if requested by the user
44 if (ddlDir) {
45 Int_t ddlIndex;
46 Int_t detId = AliDAQ::DetectorIDFromDdlID(aliEquipmentHeader->GetId(),ddlIndex);
47 char ddlFileName[256];
48 sprintf(ddlFileName,"%s/%s",ddlDir,AliDAQ::DdlFileName(detId,ddlIndex));
49 FILE *ddlFile;
50 if(ddlFile=fopen(ddlFileName, "wb")) {
51 fwrite(p, chunkSize, 1, ddlFile);
52 }
53 fclose(ddlFile);
54 }
36470d8d 55 p+=chunkSize;
56 }
57 }
58
59 return(p-gdcDateEvent);
60
61}