]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/ZDCMAPPINGda.cxx
No more relevant
[u/mrichter/AliRoot.git] / ZDC / ZDCMAPPINGda.cxx
CommitLineData
967dda6e 1/*
2
3This program reads the DAQ data files passed as argument using the monitoring library.
4
5It computes the average event size and populates local "./result.txt" file with the
6result.
7
8The program reports about its processing progress.
9
10Messages on stdout are exported to DAQ log system.
11
1af38adf 12DA to write mapping for the ZDC ADCs
967dda6e 13
14Contact: Chiara.Oppedisano@to.infn.it
15Link:
16Run Type: PHYSICS, STANDALONE_BC, STANDALONE_COSMIC, STANDALONE_CENTRAL,
17 STANDALONE_MB, STANDALONE_SEMICENTRAL
1af38adf 18DA Type: MON
19Number of events needed: 1 (SOD is read)
20Input Files: none
967dda6e 21Output Files: ZDCChMapping.dat
1af38adf 22Trigger Types Used: different trigger types are used
967dda6e 23
24*/
1af38adf 25
218f916a 26#define MAPDATA_FILE "ZDCChMapping.dat"
967dda6e 27
28#include <stdio.h>
29#include <stdlib.h>
30#include <Riostream.h>
31
32// DATE
33#include <event.h>
34#include <monitor.h>
35#include <daqDA.h>
36
37//ROOT
38#include <TFile.h>
39
40//AliRoot
41#include <AliRawReaderDate.h>
42#include <AliRawEventHeaderBase.h>
43#include <AliZDCRawStream.h>
44
967dda6e 45int main(int argc, char **argv) {
1af38adf 46
47 const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL};
48 monitorDeclareTable(const_cast<char**>(tableSOD));
967dda6e 49
50 int status = 0;
51
52 /* log start of process */
3b1e0ac9 53 printf("\nZDC MAPPING program started\n");
967dda6e 54
55 /* check that we got some arguments = list of files */
56 if (argc<2) {
57 printf("Wrong number of arguments\n");
58 return -1;
59 }
967dda6e 60
61 FILE *mapFile4Shuttle;
967dda6e 62
63 /* read the data files */
64 int n;
65 for(n=1;n<argc;n++){
66
67 status=monitorSetDataSource( argv[n] );
68 if (status!=0) {
69 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
70 return -1;
71 }
1af38adf 72
73 /* declare monitoring program */
74 status=monitorDeclareMp( __FILE__ );
75 if (status!=0) {
76 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
77 return -1;
78 }
79 monitorSetNowait();
80 monitorSetNoWaitNetworkTimeout(1000);
967dda6e 81
1af38adf 82 struct eventHeaderStruct *event;
83 eventTypeType eventT;
967dda6e 84
1af38adf 85 Int_t iev = 0;
86 Bool_t sodRead = kFALSE;
87 while(!sodRead && iev<1000){
88
89 /* check shutdown condition */
90 if (daqDA_checkShutdown()) {break;}
967dda6e 91
92 /* get next event */
93 status=monitorGetEventDynamic((void **)&event);
1af38adf 94 if(status==MON_ERR_EOF){
95 printf ("End of File detected\n");
96 break; /* end of monitoring file has been reached */
97 }
967dda6e 98 if(status!=0) {
99 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
100 return -1;
101 }
102
103 /* retry if got no event */
104 if(event==NULL) {
1af38adf 105 continue;
106 }
967dda6e 107
108 // Initalize raw-data reading and decoding
109 AliRawReader *reader = new AliRawReaderDate((void*)event);
967dda6e 110 // --- Reading event header
7f4bde92 111 //UInt_t evtype = reader->GetType();
967dda6e 112 //printf("\n\t ZDCPEDESTALda -> ev. type %d\n",evtype);
113 //printf("\t ZDCPEDESTALda -> run # %d\n",reader->GetRunNumber());
114 //
115 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
116
1af38adf 117
967dda6e 118 /* use event - here, just write event id to result file */
119 eventT=event->eventType;
120
121 Int_t ich=0, adcMod[48], adcCh[48], sigCode[48], det[48], sec[48];
1af38adf 122
967dda6e 123 if(eventT==START_OF_DATA){
1af38adf 124 sodRead = kTRUE;
125
7f4bde92 126 rawStreamZDC->SetSODReading(kTRUE);
127
967dda6e 128 if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
129 else{
130 while(rawStreamZDC->Next()){
131 if(rawStreamZDC->IsChMapping()){
132 adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich);
133 adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich);
134 sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
135 det[ich] = rawStreamZDC->GetDetectorFromMap(ich);
136 sec[ich] = rawStreamZDC->GetTowerFromMap(ich);
137 ich++;
138 }
139 }
140 }
141 // --------------------------------------------------------
142 // --- Writing ascii data file for the Shuttle preprocessor
218f916a 143 mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
967dda6e 144 for(Int_t i=0; i<ich; i++){
145 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",i,
146 adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
147 //
1af38adf 148 //printf("ZDCMAPPING.cxx -> mod %d ch %d, ch %d, code %d det %d, sec %d\n",
967dda6e 149 // i,adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
150 }
151 fclose(mapFile4Shuttle);
1af38adf 152 } // SOD event
153 else{
154 if(sodRead){
155 printf("\t SOR read -> exiting from DA\n");
156 break;
157 }
158 else continue;
967dda6e 159 }
1af38adf 160
161 iev++;
162 }
163
7f4bde92 164 /* free resources */
165 //free(event);
1af38adf 166 }
967dda6e 167
967dda6e 168 /* store the result files on FES */
218f916a 169 status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE);
967dda6e 170 if(status){
171 printf("Failed to export file : %d\n",status);
172 return -1;
173 }
174
967dda6e 175 return status;
176}