X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FTOFpulserda.cxx;h=d75ee2db2711cc952c561599d966eb08eb56029b;hb=99f4c25490bc764e5ec6ff9a63b42b6adddfb6ad;hp=e19d8dca8136b2ee9cc719ce58dc1c503d574280;hpb=9512a9646969da603bed8a0c07f05ddef3f97c2b;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/TOFpulserda.cxx b/TOF/TOFpulserda.cxx index e19d8dca813..d75ee2db271 100644 --- a/TOF/TOFpulserda.cxx +++ b/TOF/TOFpulserda.cxx @@ -1,6 +1,6 @@ /* -TOF DA for online calibration from pulser data +TOF DA for pulser data Contact: Chiara.Zampolli@bo.infn.it Link: www.bo.infn.it/~zampolli @@ -9,7 +9,7 @@ DA Type: LDC Number of events needed: 10000 Input Files: TOF.raw, where is the run number Output Files: TOFoutPulserLDC_.root, where is the id of the LDC which is read (2 characters field, e.g. TOFoutPulserLDC_03.root),to be exported to the DAQ FXS -Trigger types used: PHYSICS_EVENT, for the time being +Trigger types used: PHYSICS_EVENT (for the time being) */ @@ -30,6 +30,7 @@ Trigger types used: PHYSICS_EVENT, for the time being #include #include #include +#include //ROOT #include @@ -40,6 +41,7 @@ Trigger types used: PHYSICS_EVENT, for the time being #include #include "TROOT.h" #include "TPluginManager.h" +#include "TSAXParser.h" /* Main routine Arguments: list of DATE raw data files @@ -58,11 +60,11 @@ int main(int argc, char **argv) { static const Int_t size = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); TH1F::AddDirectory(0); TH1I * htofPulser = new TH1I("hTOFpulser","histo with signals on TOF during pulser", size,-0.5,size-0.5); - for (Int_t ibin =1;ibin<=size;ibin++){ + for (Int_t ibin =1;ibin<=size;ibin++) htofPulser->SetBinContent(ibin,-1); - } - UInt_t ldcId=0; + UInt_t ldcId=99; + UInt_t ldcIdOLD=99; int status; @@ -75,18 +77,52 @@ int main(int argc, char **argv) { return -1; } - /* open result file */ - FILE *fp=NULL; - fp=fopen("./result.txt","a"); - if (fp==NULL) { - printf("Failed to open file\n"); + /* retrieve config file */ + int getConfigFile = daqDA_DB_getFile("TOFNoiseConfig.xml","TOFNoiseConfig.xml"); + if (getConfigFile != 0){ + printf("Failed to retrieve config file from DB! returning...\n"); return -1; } - + + AliTOFNoiseConfigHandler* tofHandler = new AliTOFNoiseConfigHandler(); + TSAXParser *parser = new TSAXParser(); + parser->ConnectToHandler("AliTOFNoiseConfigHandler", tofHandler); + if (parser->ParseFile("./TOFNoiseConfig.xml") != 0) { + printf("Failed parsing config file! retunring... \n"); + return -1; + } + + Int_t debugFlag = tofHandler->GetDebugFlag(); + printf("the debug flag is %i\n",debugFlag); + /* init some counters */ int nevents_physics=0; int nevents_total=0; + Int_t nPDBEntriesToT = 0; + Int_t nDBEntriesToT = 0; + AliTOFHitData *HitData = 0; + Int_t dummy = -1; + Int_t Volume[5]; + for (Int_t i=0;i<5;i++) Volume[i]=-1; + AliTOFRawStream *rawStreamTOF = new AliTOFRawStream(); + AliTOFDecoder * decoderTOF = new AliTOFDecoder(); + AliTOFHitDataBuffer *DataBuffer[AliDAQ::NumberOfDdls("TOF")]; + AliTOFHitDataBuffer *PackedDataBuffer[AliDAQ::NumberOfDdls("TOF")]; + for (Int_t i=0;iClear(); + currentEquipment = 0; + currentDDL = 0; + data = 0x0; + nPDBEntriesToT = 0; + nDBEntriesToT = 0; + dummy = -1; + nchDDL = 0; + nDBEntries = 0; + nPDBEntries = 0; + HitData = 0; /* get next event */ status=monitorGetEventDynamic((void **)&event); @@ -111,66 +157,55 @@ int main(int argc, char **argv) { } /* retry if got no event */ - if (event==NULL) { + if (event==NULL) break; - } /* use event - here, just write event id to result file */ eventT=event->eventType; if (eventT==PHYSICS_EVENT) { //printf ("event %i \n", nevents_physics); - Int_t nPDBEntriesToT = 0; - Int_t nDBEntriesToT = 0; - AliTOFHitData *HitData; - Int_t dummy = -1; - Int_t Volume[5]; + AliRawReader *rawReader = new AliRawReaderDate((void*)event); - AliTOFRawStream *rawStreamTOF = new AliTOFRawStream(rawReader); - const AliRawDataHeader *currentCDH; - AliTOFDecoder * decoderTOF = new AliTOFDecoder(); - AliTOFHitDataBuffer *DataBuffer[72]; - AliTOFHitDataBuffer *PackedDataBuffer[72]; - for (Int_t i=0;iReadHeader()){ - ldcId = rawReader->GetLDCId(); - //printf ("ldcId = %i \n",ldcId); + rawStreamTOF->SetRawReader(rawReader); + + while (rawReader->ReadHeader()) { + ldcId = rawReader->GetLDCId(); + //debugging printings + if (debugFlag && ldcId!=ldcIdOLD) { + ldcIdOLD = ldcId; + printf ("ldcId = %i \n",ldcId); + } //memory leak prevention (actually data should be always 0x0 here) - if (data != 0x0)delete [] data; + if (data != 0x0) delete [] data; //get equipment infos currentEquipment = rawReader->GetEquipmentId(); currentDDL = rawReader->GetDDLID(); - currentCDH = rawReader->GetDataHeader(); - Int_t nchDDL = 0; - if (currentDDL%2==0) { + const AliRawDataHeader *currentCDH = (AliRawDataHeader*)rawReader->GetDataHeader(); + if (currentDDL%2==0) nchDDL = 2160; - } - else { + else nchDDL = 2208; - } - Int_t * array = new Int_t[nchDDL]; + + //Int_t * array = new Int_t[nchDDL]; + Int_t array[nchDDL]; + for (Int_t ii=0; iiGetArrayDDL(array, currentDDL); - - for (Int_t i=0;iGetBinContent(array[i]+1)<0) htofPulser->SetBinContent(array[i]+1,0); - } - - //printf(" Equipment = %i, and DDL = %i \n", currentEquipment,currentDDL); + + //debugging printings + //if (debugFlag) printf(" Equipment = %i, and DDL = %i \n", currentEquipment,currentDDL); const Int_t kDataSize = rawReader->GetDataSize(); const Int_t kDataWords = kDataSize / 4; data = new UChar_t[kDataSize]; decoderTOF->SetDataBuffer(DataBuffer[currentDDL]); decoderTOF->SetPackedDataBuffer(PackedDataBuffer[currentDDL]); //start decoding - if (!rawReader->ReadNext(data, kDataSize)){ + if (!rawReader->ReadNext(data, kDataSize)) { rawReader->AddMajorErrorLog(AliTOFRawStream::kDDLdataReading); printf("Error while reading DDL data. Go to next equipment \n"); delete [] data; @@ -181,19 +216,20 @@ int main(int argc, char **argv) { rawReader->AddMajorErrorLog(AliTOFRawStream::kDDLDecoder,Form("DDL # = %d",currentDDL)); printf("Error while decoding DDL # %d: decoder returned with errors \n", currentDDL); } - - Int_t nDBEntries = DataBuffer[currentDDL]->GetEntries(); - Int_t nPDBEntries = PackedDataBuffer[currentDDL]->GetEntries(); + + nDBEntries = DataBuffer[currentDDL]->GetEntries(); + nPDBEntries = PackedDataBuffer[currentDDL]->GetEntries(); nPDBEntriesToT+=nPDBEntries; nDBEntriesToT+=nDBEntries; /* reset buffer */ DataBuffer[currentDDL]->Reset(); - + /* read data buffer hits */ for (Int_t iHit = 0; iHit < nPDBEntries; iHit++){ HitData = PackedDataBuffer[currentDDL]->GetHit(iHit); /* add volume information */ HitData->SetDDLID(currentDDL); + for (Int_t i=0;i<5;i++) Volume[i]=-1; rawStreamTOF->EquipmentId2VolumeId(HitData, Volume); if (Volume[0]==-1 || Volume[1]==-1 || @@ -205,32 +241,35 @@ int main(int argc, char **argv) { Volume[3] = Volume[4]; Volume[4] = dummy; Int_t index = geom->GetIndex(Volume); - //printf ("index = %i \n",index); + // to check array indexes + /* + Bool_t found =kFALSE; + for (Int_t j=0;jFill(index); //channel index start from 0, bin index from 1 //debugging printings - //printf("sector %i, plate %i, strip %i, padz %i, padx %i \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]); + //if (debugFlag) printf("sector %2d, plate %1d, strip %2d, padz %1d, padx %2d \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]); // too verbose } } /* reset buffer */ PackedDataBuffer[currentDDL]->Reset(); delete [] data; data = 0x0; - delete [] array; - } - - //printf(" Packed Hit Buffer Entries = %i \n",nPDBEntriesToT); - //printf(" Hit Buffer Entries = %i \n",nDBEntriesToT); - - delete decoderTOF; - decoderTOF=0x0; - - for (Int_t i=0;i<72;i++){ - delete DataBuffer[i]; - delete PackedDataBuffer[i]; + //delete [] array; } - - delete rawStreamTOF; - rawStreamTOF = 0x0; + + //debugging printings + //if (debugFlag) { + // printf(" Packed Hit Buffer Entries = %i \n",nPDBEntriesToT); // too verbose + // printf(" Hit Buffer Entries = %i \n",nDBEntriesToT); // too verbose + //} delete rawReader; rawReader = 0x0; @@ -241,9 +280,20 @@ int main(int argc, char **argv) { /* free resources */ free(event); } - + + } + + delete decoderTOF; + decoderTOF=0x0; + + for (Int_t i=0;iWrite(); fileRun->Close(); - + /* write report */ - fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total); + printf("Run #%s, received %d physics events out of %d\n", + getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total); + + status = 0; - /* close result file */ - fclose(fp); - /* store the result file on FES */ status=daqDA_FES_storeFile(filename,"PULSER"); - if (status) { + if (status) status = -2; - } return status; }