Added new class to store ZDC timing cut window and other trigger analysis configurati...
[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
33314186 10int Root2Date(AliRawVEvent *gdcRootEvent, unsigned char *gdcDateEvent, char *ddlDir) {
36470d8d 11
12 unsigned char *p=gdcDateEvent;
13 int ldcCounter, equipmentCounter, chunkSize;
33314186 14 AliRawVEquipment *aliEquipment=NULL;
36470d8d 15 AliRawEquipmentHeader *aliEquipmentHeader=NULL;
16 AliRawEventHeaderBase *aliHeader=NULL;
33314186 17 AliRawVEvent *ldcRootEvent=NULL;
36470d8d 18
19 aliHeader=gdcRootEvent->GetHeader();
bc54f885 20
21 char runNbFileName[256];
a696b49b 22 snprintf(runNbFileName,sizeof(runNbFileName),"%s/run%u",ddlDir,aliHeader->Get("RunNb"));
bc54f885 23 ofstream runNbFile(runNbFileName);
24 runNbFile.close();
25
36470d8d 26 memcpy(p, aliHeader->HeaderBaseBegin(), chunkSize=aliHeader->HeaderBaseSize());
27 p+=chunkSize;
28 memcpy(p, aliHeader->HeaderBegin(), chunkSize=aliHeader->HeaderSize()); // Write DATE GDC header
29 p+=chunkSize;
33778962 30 memcpy(p, aliHeader->GetExtendedData(), chunkSize=aliHeader->GetExtendedDataSize());
31 p+=chunkSize;
36470d8d 32 for(ldcCounter=0; ldcCounter<gdcRootEvent->GetNSubEvents(); ldcCounter++) {
33 ldcRootEvent=gdcRootEvent->GetSubEvent(ldcCounter);
34 aliHeader=ldcRootEvent->GetHeader();
35 memcpy(p, aliHeader->HeaderBaseBegin(), chunkSize=aliHeader->HeaderBaseSize());
36 p+=chunkSize;
37 memcpy(p, aliHeader->HeaderBegin(), chunkSize=aliHeader->HeaderSize()); // Write DATE LDC header
38 p+=chunkSize;
33778962 39 memcpy(p, aliHeader->GetExtendedData(), chunkSize=aliHeader->GetExtendedDataSize());
40 p+=chunkSize;
36470d8d 41 for(equipmentCounter=0; equipmentCounter<ldcRootEvent->GetNEquipments(); equipmentCounter++) {
42 aliEquipment=ldcRootEvent->GetEquipment(equipmentCounter);
43 aliEquipmentHeader=aliEquipment->GetEquipmentHeader();
44 if(aliEquipmentHeader->GetEquipmentSize()) {
45 memcpy(p, aliEquipmentHeader->HeaderBegin(), chunkSize=aliEquipmentHeader->HeaderSize()); // Write DATE Equipment header
46 p+=chunkSize;
47 }
48 memcpy(p, aliEquipment->GetRawData()->GetBuffer(), chunkSize=aliEquipment->GetRawData()->GetSize()); // Write Equipment payload (including CDH)
8e8e0e3e 49 // Write ddl files if requested by the user
c32025f0 50 if (ddlDir && aliEquipmentHeader->GetEquipmentSize()) {
8e8e0e3e 51 Int_t ddlIndex;
52 Int_t detId = AliDAQ::DetectorIDFromDdlID(aliEquipmentHeader->GetId(),ddlIndex);
53 char ddlFileName[256];
4f27cd98 54 snprintf(ddlFileName,sizeof(ddlFileName),"%s/%s",ddlDir,AliDAQ::DdlFileName(detId,ddlIndex));
8e8e0e3e 55 FILE *ddlFile;
e41f1e44 56 if((ddlFile=fopen(ddlFileName, "wb"))) {
8e8e0e3e 57 fwrite(p, chunkSize, 1, ddlFile);
dbcd589e 58 fclose(ddlFile);
8e8e0e3e 59 }
8e8e0e3e 60 }
36470d8d 61 p+=chunkSize;
62 }
63 }
64
65 return(p-gdcDateEvent);
66
67}