#include "AliRawReader.h"
#include "AliRawReaderDate.h"
#include "AliPHOSRcuDA1.h"
-#include "AliPHOSRawDecoder.h"
+#include "AliPHOSRawFitterv0.h"
#include "AliCaloAltroMapping.h"
+#include "AliCaloRawStreamV3.h"
/* Main routine
printf("Wrong number of arguments\n");
return -1;
}
-
+
+ /* Retrieve ZS parameters from DAQ DB */
+ const char* zsfile = "zs.txt";
+ int failZS = daqDA_DB_getFile(zsfile, zsfile);
+
+ Int_t offset,threshold;
+
+ if(!failZS) {
+ FILE *f = fopen(zsfile,"r");
+ int scan = fscanf(f,"%d %d",&offset,&threshold);
+ }
+
/* Retrieve mapping files from DAQ DB */
const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
-
+
for(Int_t iFile=0; iFile<4; iFile++) {
int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
if(failed) {
mapping[i] = new AliCaloAltroMapping(path2.Data());
}
-
/* define data source : this is argument 1 */
status=monitorSetDataSource( argv[1] );
if (status!=0) {
int nevents_total=0;
AliRawReader *rawReader = NULL;
+ AliPHOSRcuDA1* dAs[5];
- AliPHOSRcuDA1 da1(2,-1); // DA1 (Calibration DA) for module2
+ for(Int_t iMod=0; iMod<5; iMod++) {
+ dAs[iMod] = 0;
+ }
Float_t e[64][56][2];
Float_t t[64][56][2];
- Int_t gain = -1;
- Int_t X = -1;
- Int_t Z = -1;
+ for(Int_t iX=0; iX<64; iX++) {
+ for(Int_t iZ=0; iZ<56; iZ++) {
+ for(Int_t iGain=0; iGain<2; iGain++) {
+ e[iX][iZ][iGain] = 0.;
+ t[iX][iZ][iGain] = 0.;
+ }
+ }
+ }
+
+ Int_t cellX = -1;
+ Int_t cellZ = -1;
+ Int_t nBunches = 0;
+ Int_t sigStart, sigLength;
+ Int_t caloFlag;
/* main loop (infinite) */
for(;;) {
if (eventT==PHYSICS_EVENT) {
- for(Int_t iX=0; iX<64; iX++) {
- for(Int_t iZ=0; iZ<56; iZ++) {
- for(Int_t iGain=0; iGain<2; iGain++) {
- e[iX][iZ][iGain] = 0.;
- t[iX][iZ][iGain] = 0.;
- }
- }
- }
-
rawReader = new AliRawReaderDate((void*)event);
-// AliPHOSRawDecoderv1 dc(rawReader,mapping);
- AliPHOSRawDecoder dc(rawReader,mapping);
- dc.SubtractPedestals(kTRUE);
+ AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
+ AliPHOSRawFitterv0 fitter;
+ fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
- while(dc.NextDigit()) {
-
- X = dc.GetRow() - 1;
- Z = dc.GetColumn() - 1;
+ if(!failZS) {
+ fitter.SubtractPedestals(kFALSE);
+ fitter.SetAmpOffset(offset);
+ fitter.SetAmpThreshold(threshold);
+ }
+
+ while (stream.NextDDL()) {
+ while (stream.NextChannel()) {
- if(dc.IsLowGain()) gain = 0;
- else
- gain = 1;
+ cellX = stream.GetCellX();
+ cellZ = stream.GetCellZ();
+ caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
+
+ if(caloFlag!=0 && caloFlag!=1) continue; //TRU data!
+
+ // In case of oscillating signals with ZS,
+ //a channel can have several bunches.
+
+ nBunches = 0;
+ while (stream.NextBunch()) {
+ nBunches++;
+ if (nBunches > 1) continue;
+ sigStart = stream.GetStartTimeBin();
+ sigLength = stream.GetBunchLength();
+ fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
+ fitter.Eval(stream.GetSignals(),sigStart,sigLength);
+ } // End of NextBunch()
+
+ if (nBunches>1) continue;
+
+ e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
+ t[cellX][cellZ][caloFlag] = fitter.GetTime();
+ }
- e[X][Z][gain] = dc.GetEnergy();
- t[X][Z][gain] = dc.GetTime();
+ if(stream.GetModule()<0 || stream.GetModule()>4) continue;
+ if(dAs[stream.GetModule()])
+ dAs[stream.GetModule()]->FillHistograms(e,t);
+ else {
+ dAs[stream.GetModule()] = new AliPHOSRcuDA1(stream.GetModule(),-1);
+ dAs[stream.GetModule()]->FillHistograms(e,t);
+ }
+
+ for(Int_t iX=0; iX<64; iX++) {
+ for(Int_t iZ=0; iZ<56; iZ++) {
+ for(Int_t iGain=0; iGain<2; iGain++) {
+ e[iX][iZ][iGain] = 0.;
+ t[iX][iZ][iGain] = 0.;
+ }
+ }
+ }
+
}
- da1.FillHistograms(e,t);
- //da1.UpdateHistoFile();
+// da1.FillHistograms(e,t);
+// //da1.UpdateHistoFile();
- delete rawReader;
- nevents_physics++;
+ delete rawReader;
+ nevents_physics++;
}
nevents_total++;
for(Int_t i = 0; i < 4; i++) delete mapping[i];
/* Be sure that all histograms are saved */
-
- da1.UpdateHistoFile();
- da1.SetWriteToFile(kFALSE);
- /* Store output files to the File Exchange Server */
char localfile[128];
for(Int_t iMod=0; iMod<5; iMod++) {
+ if(!dAs[iMod]) continue;
+
+ dAs[iMod]->UpdateHistoFile();
+ dAs[iMod]->SetWriteToFile(kFALSE);
+
+ /* Store output files to the File Exchange Server */
sprintf(localfile,"PHOS_Module%d_Calib.root",iMod);
daqDA_FES_storeFile(localfile,"AMPLITUDES");
}