/*
- 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:
// ROOT includes
#include <TFile.h>
+#include <TSystem.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TROOT.h>
#include <TPluginManager.h>
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TDatime.h>
// AliRoot includes
#include "AliRawReaderDate.h"
#include "AliITSOnlineSDDBase.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
*/
}
- Int_t eqOffset = 256;
- Int_t DDLrange = 24;
- Int_t maxNEvents=18; // maximum number of events to be analyzed
+ Int_t maxNEvents=10; // maximum number of events to be analyzed
const Int_t kTotDDL=24;
const Int_t kModPerDDL=12;
const Int_t kSides=2;
+ UInt_t amSamplFreq=40;
+
+ gSystem->Exec("rm -f SDDbase_*.data");
+ gSystem->Exec("rm -f SDDbase_step2_LDC.tar");
+
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++){
base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
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;
}
}
}
/* report progress */
daqDA_progressReport(8);
Int_t iev;
+ Int_t ievPed;
for(Int_t iStep=0;iStep<2;iStep++){
printf("Start Analysis Step %d\n",iStep);
iev=0;
+ ievPed=0;
if(iStep==1){
for(Int_t iddl=0; iddl<kTotDDL;iddl++){
for(Int_t imod=0; imod<kModPerDDL;imod++){
for(Int_t isid=0;isid<kSides;isid++){
Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
+ isFilled[index]=0;
}
}
}
}
iev++;
- if(iev>maxNEvents) break;
/* use event - here, just write event id to result file */
eventT=event->eventType;
break; // uncomment this line for test raw data
case PHYSICS_EVENT: // uncomment this line for test raw data
printf(" event number = %i \n",iev);
+ ievPed++;
AliRawReader *rawReader = new AliRawReaderDate((void*)event);
- rawReader->SelectEquipment(17,eqOffset+1,eqOffset+DDLrange);
-
-
- 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++){
}
}
}
- AliITSRawStreamSDD s(rawReader);
- while(s.Next()){
+ while(s->Next()){
Int_t iDDL=rawReader->GetDDLID();
- Int_t iCarlos=s.GetCarlosId();
- if(iDDL>=0 && iDDL<kTotDDL && s.IsCompletedModule()==kFALSE){
- Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel();
- histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
+ Int_t iCarlos=s->GetCarlosId();
+ if(s->IsCompletedModule()) continue;
+ if(s->IsCompletedDDL()) continue;
+ if(iDDL>=0 && iDDL<kTotDDL){
+ Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
+ histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
+ isFilled[index]=1;
}
}
+ delete s;
delete rawReader;
for(Int_t iddl=0; iddl<kTotDDL;iddl++){
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]);
+ }
}
}
}
/* free resources */
free(event);
}
+ if(ievPed>=maxNEvents) break;
}
}
base[index]->WriteToASCII();
}
}
- }
+ }
}
}
/* write report */
- printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iev);
+ 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();
- TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
+ Char_t filnam[100],command[150];
for(Int_t iddl=0; iddl<kTotDDL;iddl++){
for(Int_t imod=0; imod<kModPerDDL;imod++){
for(Int_t isid=0;isid<kSides;isid++){
Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
corr[index]->ValidateAnodes();
corr[index]->WriteToASCII();
- corr[index]->WriteToROOT(fh);
+ if(isFilled[index]){
+ 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);