X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FITSSDDINJda.cxx;h=59eb1b8b640e676fe528aa4a2b2ec9283813fee3;hb=83decb5f97a9170379eec64cef3179390406e806;hp=7e100dc47ab3cc778042ce949d52c4f3bc7b5e57;hpb=a8cd2ab2449ca108cc604ed102d81d99fc887bb8;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/ITSSDDINJda.cxx b/ITS/ITSSDDINJda.cxx index 7e100dc47ab..59eb1b8b640 100644 --- a/ITS/ITSSDDINJda.cxx +++ b/ITS/ITSSDDINJda.cxx @@ -1,9 +1,9 @@ /* - Contact: - prino@to.infn.it -- Link: - -- Run Type: - PHYSICS +- Link: - alien:///alice/data/2009/LHC09c_SDD/000079098/raw/09000079098024.10.root +- Run Type: - INJECTOR - DA Type: - LDC -- Number of events needed: +- Number of events needed: >20 - Input Files: - - Output Files: - SDDinj_ddl*c*_sid*.data - Trigger types used: @@ -42,6 +42,9 @@ extern "C" { #include #include #include +#include +#include +#include // AliRoot includes @@ -49,11 +52,16 @@ extern "C" { #include "AliITSOnlineSDDInjectors.h" #include "AliITSRawStreamSDD.h" #include "AliITSRawStreamSDDCompressed.h" + +#ifdef ALI_AMORE +#include +#endif + /* Main routine Arguments: list of DATE raw data files */ int main(int argc, char **argv) { - + // main - Arguments: list of DATE raw data files int status = 0; @@ -75,27 +83,14 @@ int main(int argc, char **argv) { } - Int_t maxNEvents=10; // maximum number of events to be analyzed + Int_t maxNEvents=20; // maximum number of events to be analyzed 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; + Int_t amSamplFreq=40; + gSystem->Exec("rm -f SDDinj_ddl*.data"); - 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"); + gSystem->Exec("rm -f SDDinj_LDC.tar"); @@ -103,15 +98,14 @@ int main(int argc, char **argv) { TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides]; Int_t nWrittenEv[kTotDDL*kModPerDDL*kSides]; Bool_t isFilled[kTotDDL*kModPerDDL*kSides]; - + Bool_t writtenoutput=kFALSE; + UInt_t timeSt=0; Char_t hisnam[20]; for(Int_t iddl=0; iddlSet20MHzConfig(); - else injan[index]->Set40MHzConfig(); sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid); histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5); nWrittenEv[index]=0; @@ -122,8 +116,12 @@ int main(int argc, char **argv) { /* report progress */ daqDA_progressReport(10); + Int_t iev=0; Int_t ievInj=0; + Int_t ievUsed=0; + Int_t nEvToBeSkipped=5; + /* read the data files */ int n; for (n=1;nGetTimestamp(); - - 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; + if(ievInj<=nEvToBeSkipped){ + printf(" -> SKIP\n"); + break; } - + printf(" -> Analyze\n"); + ievUsed++; + + AliRawReader *rawReader = new AliRawReaderDate((void*)event); + timeSt=rawReader->GetTimestamp(); 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; + } for(Int_t iddl=0; iddlSetADCEncoded(kTRUE); - } - + while(s->Next()){ Int_t iDDL=rawReader->GetDDLID(); Int_t iCarlos=s->GetCarlosId(); @@ -216,15 +213,18 @@ int main(int argc, char **argv) { isFilled[index]=1; } } + delete s; delete rawReader; + for(Int_t iddl=0; iddlReset(); - injan[index]->AnalyzeEvent(histo[index]); - injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]); + if(amSamplFreq==20) injan[index]->Set20MHzConfig(); + else injan[index]->Set40MHzConfig(); + injan[index]->AddEvent(histo[index]); + // injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]); nWrittenEv[index]++; } } @@ -233,19 +233,30 @@ int main(int argc, char **argv) { /* free resources */ free(event); } - if(ievInj>=maxNEvents) break; + if(ievUsed>=maxNEvents) break; } } + /* write report */ - printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),ievInj); + 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"),ievUsed,timeinfo.GetString().Data()); - gSystem->Exec("rm -f SDDinj_LDC.tar"); + /* report progress */ + daqDA_progressReport(90); + TObjArray* dspHistos=new TObjArray(); + + Char_t filnam[100],command[120]; for(Int_t iddl=0; iddl0){ + injan[index]->FitMeanDriftSpeedVsAnode(); + injan[index]->WriteToASCII(0,timeSt,0); + injan[index]->WriteInjectorStatusToASCII(); + dspHistos->AddLast(injan[index]->GetMeanDriftSpeedVsPadHisto()); sprintf(filnam,"SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); sprintf(command,"tar -rf SDDinj_LDC.tar %s",filnam); gSystem->Exec(command); @@ -253,13 +264,26 @@ int main(int argc, char **argv) { } } } + status=daqDA_FES_storeFile("./SDDinj_LDC.tar","SDD_Injec"); - /* report progress */ - daqDA_progressReport(90); +#ifdef ALI_AMORE + amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); + Int_t statusamore =0; + statusamore += amoreDA.Send("TimeInfoInject",&timeinfo); + statusamore += amoreDA.Send("DriftSpeed",dspHistos); + if ( statusamore ) + printf("Warning: Failed to write Arrays in the AMORE database\n"); + else + printf("amoreDA.Send() OK\n"); +#else + printf("Warning: SDDINJ DA not compiled with AMORE support\n"); +#endif + TFile *fh=new TFile("SDDinjectHistos.root","RECREATE"); + dspHistos->Write(); + fh->Close(); - status=daqDA_FES_storeFile("./SDDinj_LDC.tar","SDD_Injec"); /* report progress */ daqDA_progressReport(100);