-
- iev++;
-
- /* use event - here, just write event id to result file */
- nevents_total++;
- eventT=event->eventType;
- switch (event->eventType) {
-
- /* START OF RUN */
- case START_OF_RUN:
- break;
- /* END START OF RUN */
-
- /* END OF RUN */
- case END_OF_RUN:
- break;
- /* END END OF RUN */
-
- case PHYSICS_EVENT:
- nevents_physics++;
- AliRawReader *rawReader = new AliRawReaderDate((void*)event);
- //rawReader->RequireHeader(kFALSE);
-
- //T0 event
- Int_t meantime = 0;
- AliT0RawReader *rawReaderT0 = new AliT0RawReader(rawReader,kTRUE);
- if (!rawReaderT0->Next()) {
- printf("T0: no raw data found!\n");
- }
- else {
- /*
- Int_t allData[105][5];
- for (Int_t i=0; i<105; i++) {
- allData[i][0]=rawReaderT0->GetData(i,0);
- }
- meantime = allData[49][0];
- */
- //meantime = rawReaderT0->GetData(49,0); //OLD
- meantime = (Int_t)((rawReaderT0->GetData(51,0)+rawReaderT0->GetData(52,0))/2.); //Alla
- if (debugFlag > 0) {
- printf("\nT0 for the current event:\n"); // debugging purpose
- printf("time zero = %i (TDC bin)\n", meantime); // debugging purpose
- printf("time zero = %f (ns)\n\n", (Float_t)(meantime)*24.4*1E-3); // debugging purpose
- }
- }
-
- delete rawReaderT0;
- rawReaderT0 = 0x0;
- rawReader->Reset();
-
- //TOF event
- dummy = -1;
- for (Int_t ii=0; ii<5; ii++) Volume[ii]=-1;
- rawStreamTOF->SetRawReader(rawReader);
- //rawReader->ReadHeader();
- rawStreamTOF->ResetBuffers();
- rawStreamTOF->DecodeDDL(0, AliDAQ::NumberOfDdls("TOF") - 1,0);
- nPDBEntriesToT = 0;
- nDBEntriesToT = 0;
- for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++) {
-
- /* read decoded data */
- DataBuffer = rawStreamTOF->GetDataBuffer(iDDL);
- PackedDataBuffer = rawStreamTOF->GetPackedDataBuffer(iDDL);
-
- /* get buffer entries */
- nDBEntries = DataBuffer.GetEntries();
- nPDBEntries = PackedDataBuffer.GetEntries();
- nPDBEntriesToT+=nPDBEntries;
- nDBEntriesToT+=nDBEntries;
-
- //for (Int_t iHit = 0; iHit < nDBEntries; iHit++) {
- // HitData = DataBuffer->GetHit(iHit);
- /* store volume information */
- // rawStreamTOF->EquipmentId2VolumeId(HitData, Volume);
- //}
- /* reset buffer */
- DataBuffer.Reset();
-
- /* read data buffer hits */
- for (Int_t iHit = 0; iHit < nPDBEntries; iHit++) {
- HitData = PackedDataBuffer.GetHit(iHit);
- /* add volume information */
- HitData->SetDDLID(iDDL);
- rawStreamTOF->EquipmentId2VolumeId(HitData, Volume);
- if (Volume[0]==-1 ||
- Volume[1]==-1 ||
- Volume[2]==-1 ||
- Volume[3]==-1 ||
- Volume[4]==-1) continue;
- else {
- dummy = Volume[3];
- Volume[3] = Volume[4];
- Volume[4] = dummy;
- Int_t tofRaw = (Int_t)((Double_t)HitData->GetTime()*1E3/AliTOFGeometry::TdcBinWidth());
- Int_t tof;
- if (!t0Flag) tof = tofRaw;
- else tof = tofRaw - meantime;
- Int_t index = geom->GetIndex(Volume);
- Float_t pos[3];
- geom->GetPosPar(Volume,pos);
- Float_t texp = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2])/c*1E9; //expected time in ns
- Float_t texpBin = texp*1E3/AliTOFGeometry::TdcBinWidth(); //expected time in number of TDC bin
- Int_t deltabin = tof-TMath::Nint(texpBin); //to be used with real data; rounding expected time to Int_t
- htofPartial->Fill(index,deltabin); //channel index start from 0, bin index from 1
- //debugging printings
- if (debugFlag > 1) {
- printf("tofRaw = %i, tof = %i \n",tofRaw,tof);
- }
- if (debugFlag > 2) {
- printf("sector %2d, plate %1d, strip %2d, padz %1d, padx %2d \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]); // too verbose
- printf("pos x = %f, pos y = %f, pos z = %f \n",pos[0],pos[1],pos[2]); // too verbose
- printf("expected time = %f (ns)\n",texp); // too verbose
- printf("expected time bin = %f (TDC bin)\n",texpBin); // too verbose
- printf("measured time bin = %i (TDC bin) with %f (ns) and ACQ bit = %i \n",tof, HitData->GetTime(), HitData->GetACQ()); // too verbose
- printf("index = %6d, deltabin = %d , filling index = %6d, and bin = %d\n",index, deltabin, index, deltabin); // too verbose
- }
-
- }
- /* reset buffer */
- PackedDataBuffer.Reset();
- }
- }
- //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;