From 039a08c3d8dca7e23531b6a284979fcb80235a2a Mon Sep 17 00:00:00 2001 From: coppedis Date: Fri, 30 Nov 2007 10:35:22 +0000 Subject: [PATCH] Changes suggested by Sylvain --- ZDC/ZDCPEDESTALda.cxx | 278 +++++++++++++++++++++--------------------- 1 file changed, 142 insertions(+), 136 deletions(-) diff --git a/ZDC/ZDCPEDESTALda.cxx b/ZDC/ZDCPEDESTALda.cxx index 56b95020f8e..cae1b4c1b9b 100644 --- a/ZDC/ZDCPEDESTALda.cxx +++ b/ZDC/ZDCPEDESTALda.cxx @@ -2,12 +2,14 @@ DAcase2.c -This program connects to the DAQ data source passed as argument -and populates local "./result.txt" file with the ids of events received -during the run. +DAcase1.c -The program exits when being asked to shut down (daqDA_checkshutdown) -or End of Run event. +This program reads the DAQ data files passed as argument using the monitoring library. + +It computes the average event size and populates local "./result.txt" file with the +result. + +The program reports about its processing progress. Messages on stdout are exported to DAQ log system. @@ -25,12 +27,13 @@ Trigger Types Used: Standalone Trigger */ #include +#include #include // DATE -#include #include #include +#include //ROOT #include @@ -46,15 +49,25 @@ Trigger Types Used: Standalone Trigger /* Main routine - Arguments: - 1- monitoring data source + Arguments: list of DATE raw data files */ int main(int argc, char **argv) { - TH1F::AddDirectory(0); + int status = 0; + + /* log start of process */ + printf("ZDC PEDESTAL monitoring program started\n"); + + /* check that we got some arguments = list of files */ + if (argc<2) { + printf("Wrong number of arguments\n"); + return -1; + } + // --- Histograms for ADC pedestals // [22 signal channels + 2 reference PTMs] x 2 gain chains // + TH1F::AddDirectory(0); int const kNChannels = 24; TH1F *hPedhg[kNChannels], *hPedOutOfTimehg[kNChannels]; TH2F *hPedCorrhg[kNChannels]; @@ -128,13 +141,6 @@ int main(int argc, char **argv) { hPedCorrlg[j] = new TH2F(namhist3lg,namhist3lg,100,0.,600.,100,0.,600.); } - int status; - - if (argc!=2) { - printf("Wrong number of arguments\n"); - return -1; - } - /* open result file */ FILE *fp=NULL; @@ -145,80 +151,62 @@ int main(int argc, char **argv) { } - /* define data source : this is argument 1 */ - status = monitorSetDataSource( argv[1] ); - if(status!=0) { - printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); - return -1; - } - - - /* declare monitoring program */ - status = monitorDeclareMp( __FILE__ ); - if (status!=0) { - printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); - return -1; - } - + /* report progress */ + daqDA_progressReport(10); - /* define wait event timeout - 1s max */ - monitorSetNowait(); - monitorSetNoWaitNetworkTimeout(1000); - - /* log start of process */ - printf("ZDC PEDESTAL monitoring program started\n"); - /* init some counters */ int nevents_physics=0; int nevents_total=0; - struct equipmentStruct *equipment; - int *eventEnd; - int *eventData; - int *equipmentEnd; - int *equipmentData; - int *equipmentID; - - struct eventHeaderStruct *event; - eventTypeType eventT; - Int_t iev=0; - - /* main loop (infinite) */ - for(;;) { - - /* check shutdown condition */ - if (daqDA_checkShutdown()) {break;} - - /* get next event (blocking call until timeout) */ - status=monitorGetEventDynamic((void **)&event); - if (status==MON_ERR_EOF) { - printf ("End of File detected\n"); - break; /* end of monitoring file has been reached */ - } - + /* read the data files */ + int n; + for (n=1;neventType; + /* use event - here, just write event id to result file */ + eventT=event->eventType; - if(eventT==PHYSICS_EVENT){ - //fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n", - // - // Initalize raw-data reading and decoding - AliRawReader *reader = new AliRawReaderDate((void*)event); - const AliRawDataHeader* header = reader->GetDataHeader(); - if(header) { + if(eventT==PHYSICS_EVENT){ + fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n", + (unsigned long)event->eventRunNb, + (unsigned long)event->eventSize, + EVENT_ID_GET_BUNCH_CROSSING(event->eventId), + EVENT_ID_GET_ORBIT(event->eventId), + EVENT_ID_GET_PERIOD(event->eventId)); + // + // Initalize raw-data reading and decoding + AliRawReader *reader = new AliRawReaderDate((void*)event); + const AliRawDataHeader* header = reader->GetDataHeader(); + if(header) { UChar_t message = header->GetAttributes(); if(message & 0x20){ // DEDICATED PEDESTAL RUN printf("\t STANDALONE_PEDESTAL_RUN raw data found\n"); @@ -228,26 +216,26 @@ int main(int argc, char **argv) { printf("\t NO STANDALONE_PEDESTAL_RUN raw data found\n"); return -1; } - } - //Commented until we won't have true Raw Data Header... - //else{ - // printf("\t ATTENTION! No Raw Data Header found!!!\n"); - // return -1; - //} - // - AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader); - // - if (!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); - Int_t counter=0; - Int_t RawADChg[kNChannels], RawADCoothg[kNChannels]; - Int_t RawADClg[kNChannels], RawADCootlg[kNChannels]; - for(Int_t j=0; jNext()){ - Int_t index=-1; - if(rawStreamZDC->IsADCDataWord()){ + } + //Commented until we won't have true Raw Data Header... + //else{ + // printf("\t ATTENTION! No Raw Data Header found!!!\n"); + // return -1; + //} + // + AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader); + // + if (!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); + Int_t counter=0; + Int_t RawADChg[kNChannels], RawADCoothg[kNChannels]; + Int_t RawADClg[kNChannels], RawADCootlg[kNChannels]; + for(Int_t j=0; jNext()){ + Int_t index=-1; + if(rawStreamZDC->IsADCDataWord()){ if(rawStreamZDC->GetSector(1)!=5){ // Physics signals if(rawStreamZDC->GetSector(0)==1) index = rawStreamZDC->GetSector(1); // *** ZN1 else if(rawStreamZDC->GetSector(0)==2) index = rawStreamZDC->GetSector(1)+5; // *** ZP1 @@ -273,49 +261,47 @@ int main(int argc, char **argv) { hPedlg[index]->Fill(rawStreamZDC->GetADCValue()); RawADClg[index] = rawStreamZDC->GetADCValue(); } - } - else{ // --- Out-of-time pedestals - if(rawStreamZDC->GetADCGain()==0){ - hPedOutOfTimehg[index]->Fill(rawStreamZDC->GetADCValue()); - RawADCoothg[index] = rawStreamZDC->GetADCValue(); - } - else{ - hPedOutOfTimelg[index]->Fill(rawStreamZDC->GetADCValue()); - RawADCootlg[index] = rawStreamZDC->GetADCValue(); - } - } - counter++; - }//IsADCDataWord() - // - if(counter == 4*kNChannels){ // Last ADC channel -> Filling correlation histos - for(Int_t k=0; kFill(RawADCoothg[k], RawADChg[k]); - hPedCorrlg[k]->Fill(RawADCootlg[k], RawADClg[k]); - } - } - } - // - nevents_physics++; - - } - - nevents_total++; - - - /* free resources */ - free(event); + } + else{ // --- Out-of-time pedestals + if(rawStreamZDC->GetADCGain()==0){ + hPedOutOfTimehg[index]->Fill(rawStreamZDC->GetADCValue()); + RawADCoothg[index] = rawStreamZDC->GetADCValue(); + } + else{ + hPedOutOfTimelg[index]->Fill(rawStreamZDC->GetADCValue()); + RawADCootlg[index] = rawStreamZDC->GetADCValue(); + } + } + counter++; + }//IsADCDataWord() + // + if(counter == 4*kNChannels){ // Last ADC channel -> Filling correlation histos + for(Int_t k=0; kFill(RawADCoothg[k], RawADChg[k]); + hPedCorrlg[k]->Fill(RawADCootlg[k], RawADClg[k]); + } + } + } + // + nevents_physics++; + // + delete reader; + delete rawStreamZDC; + + }//(if PHYSICS_EVENT) + nevents_total++; + + /* free resources */ + free(event); - /* exit when last event received, no need to wait for TERM signal */ - if (eventT==END_OF_RUN) { - printf("EOR event detected\n"); - break; } - } + } /* Analysis of the histograms */ // FILE *fileShuttle; - fileShuttle = fopen("ZDCPedestal.dat","w"); + const char *fName = "ZDCPedestal.dat"; + fileShuttle = fopen(fName,"w"); // Float_t MeanPed[2*kNChannels], MeanPedWidth[2*kNChannels], MeanPedOOT[2*kNChannels], MeanPedWidthOOT[2*kNChannels], @@ -389,13 +375,33 @@ int main(int argc, char **argv) { // fclose(fileShuttle); // - + for(Int_t j=0; j