/*
- Contact: - prino@to.infn.it
-- Link: - http://www.to.infn.it/~prino/alice/RawData/run11161.date
+- Link: - alien:///alice/data/2009/LHC09c_SDD/000079094/raw/09000079094024.10.root
- Run Type: - PEDESTAL_RUN
- DA Type: - LDC
-- Number of events needed: 100
+- Number of events needed: > 10
- Input Files: -
- Output Files: - SDDbase_step1_ddl*c*_sid*.data SDDbase_step2_ddl*c*_sid*.data
- Trigger types used:
#include <TH2F.h>
#include <TROOT.h>
#include <TPluginManager.h>
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TDatime.h>
// AliRoot includes
#include "AliRawReaderDate.h"
#include "AliITSOnlineSDDCMN.h"
#include "AliITSRawStreamSDD.h"
#include "AliITSRawStreamSDDCompressed.h"
+
+#ifdef ALI_AMORE
+#include <AmoreDA.h>
+#endif
+
/* Main routine
Arguments: list of DATE raw data files
*/
const Int_t kTotDDL=24;
const Int_t kModPerDDL=12;
const Int_t kSides=2;
- Int_t adcSamplFreq=40;
- Bool_t readfeeconf=kFALSE;
- Int_t dataformat=1;
+ UInt_t amSamplFreq=40;
+
gSystem->Exec("rm -f SDDbase_*.data");
gSystem->Exec("rm -f SDDbase_step2_LDC.tar");
- if(gSystem->Getenv("DAQ_DETDB_LOCAL")!=NULL){
- const char* dir=gSystem->Getenv("DAQ_DETDB_LOCAL");
- TString filnam=Form("%s/fee.conf",dir);
- FILE* feefil=fopen(filnam.Data(),"r");
- if(feefil){
- fscanf(feefil,"%d \n",&adcSamplFreq);
- fscanf(feefil,"%d \n",&dataformat);
- fclose(feefil);
- readfeeconf=kTRUE;
- printf("ADC sampling frequency = %d MHz dataformat code =%d \n",adcSamplFreq,dataformat);
- }
- }
- if(!readfeeconf) printf("File fee.conf not found, sampling frequency set to 40 MHz and data format to 1\n");
AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
+ Bool_t writtenoutput=kFALSE;
Char_t hisnam[20];
for(Int_t iddl=0; iddl<kTotDDL;iddl++){
for(Int_t isid=0;isid<kSides;isid++){
Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
- if(adcSamplFreq==20) base[index]->SetLastGoodTB(126);
- else base[index]->SetLastGoodTB(254);
sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
isFilled[index]=0;
for(Int_t isid=0;isid<kSides;isid++){
Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
- if(adcSamplFreq==20) corr[index]->SetLastGoodTB(126);
- else corr[index]->SetLastGoodTB(254);
isFilled[index]=0;
}
}
printf(" event number = %i \n",iev);
ievPed++;
AliRawReader *rawReader = new AliRawReaderDate((void*)event);
-
-
- Int_t evtyp=0;
- while(rawReader->ReadHeader()){
- const UInt_t *subev = rawReader->GetSubEventAttributes();
- if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
+ rawReader->Reset();
+ UChar_t cdhAttr=AliITSRawStreamSDD::ReadBlockAttributes(rawReader);
+ amSamplFreq=AliITSRawStreamSDD::ReadAMSamplFreqFromCDH(cdhAttr);
+ AliITSRawStream* s=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader,cdhAttr);
+ if(!writtenoutput){
+ printf("Use %s raw stream, sampling frequency %d MHz\n",s->ClassName(),amSamplFreq);
+ writtenoutput=kTRUE;
}
- rawReader->Reset();
+
for(Int_t iddl=0; iddl<kTotDDL;iddl++){
for(Int_t imod=0; imod<kModPerDDL;imod++){
for(Int_t isid=0;isid<kSides;isid++){
}
}
}
- AliITSRawStream* s;
- if(dataformat==0){
- s=new AliITSRawStreamSDD(rawReader);
- }else{
- s=new AliITSRawStreamSDDCompressed(rawReader);
- if(dataformat==1) s->SetADCEncoded(kTRUE);
- }
while(s->Next()){
Int_t iDDL=rawReader->GetDDLID();
for(Int_t imod=0; imod<kModPerDDL;imod++){
for(Int_t isid=0;isid<kSides;isid++){
Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
- if(iStep==0) base[index]->AddEvent(histo[index]);
- if(iStep==1) corr[index]->AddEvent(histo[index]);
+ if(iStep==0){
+ if(amSamplFreq==20) base[index]->SetLastGoodTB(126);
+ else base[index]->SetLastGoodTB(254);
+ base[index]->AddEvent(histo[index]);
+ }
+ if(iStep==1){
+ if(amSamplFreq==20) corr[index]->SetLastGoodTB(126);
+ else corr[index]->SetLastGoodTB(254);
+ corr[index]->AddEvent(histo[index]);
+ }
}
}
}
}
/* write report */
- printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),ievPed);
+ TDatime time;
+ TObjString timeinfo(Form("%02d%02d%02d%02d%02d%02d",time.GetYear()-2000,time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()));
+ printf("Run #%s, received %d calibration events, time %s\n",getenv("DATE_RUN_NUMBER"),ievPed,timeinfo.GetString().Data());
/* report progress */
daqDA_progressReport(90);
+ TObjArray* basHistos=new TObjArray();
+ TObjArray* noiseHistos=new TObjArray();
+ TObjArray* cmnHistos=new TObjArray();
+ TObjArray* corrnHistos=new TObjArray();
+ TObjArray* statusHistos=new TObjArray();
Char_t filnam[100],command[150];
- TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
for(Int_t iddl=0; iddl<kTotDDL;iddl++){
for(Int_t imod=0; imod<kModPerDDL;imod++){
for(Int_t isid=0;isid<kSides;isid++){
corr[index]->ValidateAnodes();
corr[index]->WriteToASCII();
if(isFilled[index]){
- corr[index]->WriteToROOT(fh);
+ basHistos->AddLast(corr[index]->GetBaselineAnodeHisto());
+ noiseHistos->AddLast(corr[index]->GetRawNoiseAnodeHisto());
+ cmnHistos->AddLast(corr[index]->GetCMNCoefAnodeHisto());
+ corrnHistos->AddLast(corr[index]->GetCorrNoiseAnodeHisto());
+ statusHistos->AddLast(corr[index]->GetStatusAnodeHisto());
sprintf(filnam,"SDDbase_step2_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
sprintf(command,"tar -rf SDDbase_step2_LDC.tar %s",filnam);
gSystem->Exec(command);
}
}
}
- fh->Close();
+#ifdef ALI_AMORE
+ amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
+ Int_t statusamore =0;
+ statusamore += amoreDA.Send("TimeInfoPedestal",&timeinfo);
+ statusamore += amoreDA.Send("Baselines",basHistos);
+ statusamore += amoreDA.Send("RawNoise",noiseHistos);
+ statusamore += amoreDA.Send("CommonMode",cmnHistos);
+ statusamore += amoreDA.Send("CorrectedNoise",corrnHistos);
+ statusamore += amoreDA.Send("NoisyChannels",statusHistos);
+ if ( statusamore )
+ printf("Warning: Failed to write Arrays in the AMORE database\n");
+ else
+ printf("amoreDA.Send() OK\n");
+#else
+ printf("Warning: SDDBAS DA not compiled with AMORE support\n");
+#endif
+
+
+ TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
+ basHistos->Write();
+ noiseHistos->Write();
+ cmnHistos->Write();
+ corrnHistos->Write();
+ statusHistos->Write();
+ fh->Close();
/* report progress */
daqDA_progressReport(100);