X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ZDC%2FZDCPEDESTALda.cxx;h=b5f81de51b4a2e03d337b769e23b592a98e896c0;hb=983f01b92f4526abf0309bf8d65f7d647dfc6c70;hp=61e0ae5405caaa3229344a5fef623e4e41c2c945;hpb=1a43342e95adc9fa752dc68a0658acecd80665eb;p=u%2Fmrichter%2FAliRoot.git diff --git a/ZDC/ZDCPEDESTALda.cxx b/ZDC/ZDCPEDESTALda.cxx index 61e0ae5405c..b5f81de51b4 100644 --- a/ZDC/ZDCPEDESTALda.cxx +++ b/ZDC/ZDCPEDESTALda.cxx @@ -1,305 +1,629 @@ /* -DAcase2.c +This program reads the DAQ data files passed as argument using the monitoring library. -This program connects to the DAQ data source passed as argument -and populates local "./result.txt" file with the ids of events received -during the run. - -The program exits when being asked to shut down (daqDA_checkshutdown) -or End of Run event. +The program reports about its processing progress. Messages on stdout are exported to DAQ log system. -DA for ZDC standalon pedestal runs -contact: Chiara.Oppedisano@cern.ch +DA for ZDC standalone pedestal runs + +Contact: Chiara.Oppedisano@to.infn.it +Link: +Run Type: STANDALONE_PEDESTAL_RUN +DA Type: LDC +Number of events needed: no constraint (tipically ~10^3) +Input Files: none +Output Files: ZDCPedestal.dat, ZDCChMapping.dat +Trigger Types Used: Standalone Trigger */ +#define PEDDATA_FILE "ZDCPedestal.dat" +#define PEDHISTO_FILE "ZDCPedHisto.root" +#define MAPDATA_FILE "ZDCChMapping.dat" #include +#include #include // DATE -#include #include #include +#include //ROOT -#include +#include +#include #include #include #include #include #include +#include +#include "TMinuitMinimizer.h" //AliRoot #include +#include #include /* Main routine - Arguments: - 1- monitoring data source + Arguments: list of DATE raw data files */ int main(int argc, char **argv) { + + + gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", + "*", + "TStreamerInfo", + "RIO", + "TStreamerInfo()"); + + TMinuitMinimizer m; + gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", "Minuit","TMinuitMinimizer", + "Minuit", "TMinuitMinimizer(const char *)"); + TVirtualFitter::SetDefaultFitter("Minuit"); + + int status = 0; + int const kNModules = 9; + int const kNChannels = 24; + int const kNScChannels = 32; + Int_t kFirstADCGeo=0, kLastADCGeo=3; + + Int_t iMod=-1; + Int_t modGeo[kNModules], modType[kNModules],modNCh[kNModules]; + for(Int_t kl=0; kl=10 && j<20){ - sprintf(namhist1,"PedZP1_%d",j-10); - sprintf(namhist2,"PedZP1OutOfTime_%d",j-10); - sprintf(namhist3,"PedCorrZP1_%d",j-10); + else if(j>=5 && j<=9){ // ZPC + sprintf(namhist1hg,"PedZPChg_%d",j-5); + sprintf(namhist2hg,"PedZPChgOutOfTime_%d",j-5); + sprintf(namhist3hg,"PedCorrZPChg_%d",j-5); + // + sprintf(namhist1lg,"PedZPClg_%d",j-5); + sprintf(namhist2lg,"PedZPClgOutOfTime_%d",j-5); + sprintf(namhist3lg,"PedCorrZPClg_%d",j-5); } - else if(j>=20 && j<24){ - sprintf(namhist1,"PedZEM_%d",j-20); - sprintf(namhist2,"PedZEMOutOfTime_%d",j-20); - sprintf(namhist3,"PedCorrZEM_%d",j-20); + else if(j==10 || j==11){ // ZEM + sprintf(namhist1hg,"PedZEMhg_%d",j-9); + sprintf(namhist2hg,"PedZEMhgOutOfTime_%d",j-9); + sprintf(namhist3hg,"PedCorrZEMhg_%d",j-9); + // + sprintf(namhist1lg,"PedZEMlg_%d",j-9); + sprintf(namhist2lg,"PedZEMlgOutOfTime_%d",j-9); + sprintf(namhist3lg,"PedCorrZEMlg_%d",j-9); } - else if(j>=24 && j<33){ - sprintf(namhist1,"PedZN2_%d",j-24); - sprintf(namhist2,"PedZN2OutOfTime_%d",j-24); - sprintf(namhist3,"PedCorrZN2_%d",j-24); + else if(j>=12 && j<=16){ // ZNA + sprintf(namhist1hg,"PedZNAhg_%d",j-12); + sprintf(namhist2hg,"PedZNAhgOutOfTime_%d",j-12); + sprintf(namhist3hg,"PedCorrZNAhg_%d",j-12); + // + sprintf(namhist1lg,"PedZNAlg_%d",j-12); + sprintf(namhist2lg,"PedZNAlgOutOfTime_%d",j-12); + sprintf(namhist3lg,"PedCorrZNAlg_%d",j-12); } - else if(j>=33 && j<43){ - sprintf(namhist1,"PedZP2_%d",j-33); - sprintf(namhist2,"PedZP2OutOfTime_%d",j-33); - sprintf(namhist3,"PedCorrZP2_%d",j-33); + else if(j>=17 && j<=21){ // ZPA + sprintf(namhist1hg,"PedZPAhg_%d",j-17); + sprintf(namhist2hg,"PedZPAhgOutOfTime_%d",j-17); + sprintf(namhist3hg,"PedCorrZPAhg_%d",j-17); + // + sprintf(namhist1lg,"PedZPAlg_%d",j-17); + sprintf(namhist2lg,"PedZPAlgOutOfTime_%d",j-17); + sprintf(namhist3lg,"PedCorrZPAlg_%d",j-17); } - hPed[j] = new TH1F(namhist1, namhist1, 100,0., 200.); - hPedOutOfTime[j] = new TH1F(namhist2, namhist2, 100,0., 200.); - hPedCorr[j] = new TH2F(namhist3,namhist3,100,0.,200.,100,0.,200.); - } - - int status; - - if (argc!=2) { - printf("Wrong number of arguments\n"); - return -1; + else if(j==22 || j==23){ //Reference PMs + sprintf(namhist1hg,"PedRefhg_%d",j-22); + sprintf(namhist2hg,"PedRefhgOutOfTime_%d",j-22); + sprintf(namhist3hg,"PedCorrRefhg_%d",j-22); + // + sprintf(namhist1lg,"PedReflg_%d",j-22); + sprintf(namhist2lg,"PedReflgOutOfTime_%d",j-22); + sprintf(namhist3lg,"PedCorrReflg_%d",j-22); + } + // --- High gain chain histos + hPedhg[j] = new TH1F(namhist1hg, namhist1hg, 200, 0., 200.); + hPedOutOfTimehg[j] = new TH1F(namhist2hg, namhist2hg, 200, 0., 200.); + hPedCorrhg[j] = new TH2F(namhist3hg,namhist3hg,100,0.,200.,100,0.,200.); + // --- Low gain chain histos + hPedlg[j] = new TH1F(namhist1lg, namhist1lg, 100, 0., 1500.); + hPedOutOfTimelg[j] = new TH1F(namhist2lg, namhist2lg, 100, 0., 1500.); + hPedCorrlg[j] = new TH2F(namhist3lg,namhist3lg,100,0.,1500.,100,0.,1500.); } /* open result file */ FILE *fp=NULL; - fp=fopen("./result.txt","a"); + fp=fopen("./result.txt","w"); if (fp==NULL) { printf("Failed to open file\n"); return -1; } + FILE *mapFile4Shuttle; - /* define data source : this is argument 1 */ - status = monitorSetDataSource( argv[1] ); - if(status!=0) { - printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); - return -1; - } - - - /* declare monitoring program */ - status = monitorDeclareMp( __FILE__ ); - if (status!=0) { - printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); - return -1; - } - + /* report progress */ + daqDA_progressReport(10); - /* define wait event timeout - 1s max */ - monitorSetNowait(); - monitorSetNoWaitNetworkTimeout(1000); - - /* log start of process */ - printf("ZDC PEDESTAL monitoring program started\n"); - /* init some counters */ int nevents_physics=0; int nevents_total=0; - struct equipmentStruct *equipment; - int *eventEnd; - int *eventData; - int *equipmentEnd; - int *equipmentData; - int *equipmentID; - struct eventHeaderStruct *event; eventTypeType eventT; - Int_t iev=0; - - /* main loop (infinite) */ - for(;;) { - - /* check shutdown condition */ - if (daqDA_checkShutdown()) {break;} - - /* get next event (blocking call until timeout) */ - status=monitorGetEventDynamic((void **)&event); - if (status==MON_ERR_EOF) { - printf ("End of File detected\n"); - break; /* end of monitoring file has been reached */ - } - + + /* read the data files */ + int n; + for(n=1;neventType; - - if(eventT==PHYSICS_EVENT){ - //fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n", - // + /* get next event */ + status=monitorGetEventDynamic((void **)&event); + if(status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ + if(status!=0) { + printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); + return -1; + } + + /* retry if got no event */ + if(event==NULL) { + break; + } + // Initalize raw-data reading and decoding AliRawReader *reader = new AliRawReaderDate((void*)event); - const AliRawDataHeader* header = reader->GetDataHeader(); - if(header) { - UChar_t message = header->GetL1TriggerMessage(); - if(message & 0x40000){ // DEDICATED PEDESTAL RUN - printf("\t L1 message -> PEDESTAL raw data\n"); - continue; - } - else{ - printf("\t L1 message -> NO PEDESTAL raw data found\n"); - return -1; - } - } - //Commented until we won't have Raw Data Header... - /*else{ - //printf("\t ERROR! No Raw Data Header found!!!\n"); - //return -1; - }*/ + reader->Select("ZDC"); + // --- Reading event header + //UInt_t evtype = reader->GetType(); + //printf("\n\t ZDCPEDESTALda -> ev. type %d\n",evtype); + //printf("\t ZDCPEDESTALda -> run # %d\n",reader->GetRunNumber()); // - AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader); - // - if (!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); - Int_t counter=0; - Int_t RawADC[44], RawADCoot[44]; - for(Int_t j=0; j<44; j++){ - RawADC[j]=0; - RawADCoot[j]=0; - } - while(rawStreamZDC->Next()){ - Int_t index=-1; - if(rawStreamZDC->IsADCDataWord()){ - if(rawStreamZDC->GetSector(0)==1 || rawStreamZDC->GetSector(0)==2){ // *** ZN1, ZP1 - index = 10*(rawStreamZDC->GetSector(0)-1)+rawStreamZDC->GetSector(1)+5*rawStreamZDC->GetADCGain(); + + + /* use event - here, just write event id to result file */ + eventT=event->eventType; + + if(eventT==START_OF_DATA){ + + iMod=-1; ich=0; iScCh=0; itdcCh=0; + + rawStreamZDC->SetSODReading(kTRUE); + + // -------------------------------------------------------- + // --- Writing ascii data file for the Shuttle preprocessor + mapFile4Shuttle = fopen(MAPDATA_FILE,"w"); + if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); + else{ + while((rawStreamZDC->Next())){ + if(rawStreamZDC->IsHeaderMapping()){ // mapping header + iMod++; + modGeo[iMod] = rawStreamZDC->GetADCModule(); + modType[iMod] = rawStreamZDC->GetModType(); + modNCh[iMod] = rawStreamZDC->GetADCNChannels(); + } + if(rawStreamZDC->IsChMapping()){ + if(modType[iMod]==1){ // ADC mapping ---------------------- + adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich); + adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich); + sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich); + det[ich] = rawStreamZDC->GetDetectorFromMap(ich); + sec[ich] = rawStreamZDC->GetTowerFromMap(ich); + ich++; + } + else if(modType[iMod]==2){ //VME scaler mapping -------------------- + scMod[iScCh] = rawStreamZDC->GetScalerModFromMap(iScCh); + scCh[iScCh] = rawStreamZDC->GetScalerChFromMap(iScCh); + scSigCode[iScCh] = rawStreamZDC->GetScalerSignFromMap(iScCh); + scDet[iScCh] = rawStreamZDC->GetScDetectorFromMap(iScCh); + scSec[iScCh] = rawStreamZDC->GetScTowerFromMap(iScCh); + iScCh++; + } + else if(modType[iMod]==6 && modGeo[iMod]==4){ // ZDC TDC mapping -------------------- + tdcMod[itdcCh] = rawStreamZDC->GetTDCModFromMap(itdcCh); + tdcCh[itdcCh] = rawStreamZDC->GetTDCChFromMap(itdcCh); + tdcSigCode[itdcCh] = rawStreamZDC->GetTDCSignFromMap(itdcCh); + itdcCh++; + } + } + } + // Writing data on output FXS file + for(Int_t is=0; is<2*kNChannels; is++){ + fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n", + is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]); + //printf(" Pedestal DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n", + // is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]); } - else if(rawStreamZDC->GetSector(0)==3){ // *** ZEM - index = 10*(rawStreamZDC->GetSector(0)-1)+(rawStreamZDC->GetSector(1)-1)+2*rawStreamZDC->GetADCGain(); + for(Int_t is=0; is %d Scaler: mod %d ch %d, code %d det %d, sec %d\n", + // is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]); } - else if(rawStreamZDC->GetSector(0)==4 || rawStreamZDC->GetSector(0)==5){ // *** ZN2, ZP2 - index = 10*(rawStreamZDC->GetSector(0)-2)+rawStreamZDC->GetSector(1)+5*rawStreamZDC->GetADCGain()+4; + for(Int_t is=0; is %d TDC: mod %d ch %d, code %d\n", + // is,tdcMod[is],tdcCh[is],tdcSigCode[is]); } - if(counter<44){ - hPed[index]->Fill(rawStreamZDC->GetADCValue()); - RawADC[counter] = rawStreamZDC->GetADCValue(); + for(Int_t is=0; is Module mapping: geo %d type %d #ch %d\n", + // modGeo[is],modType[is],modNCh[is]); } - else{ - hPedOutOfTime[index]->Fill(rawStreamZDC->GetADCValue()); - RawADCoot[counter-44] = rawStreamZDC->GetADCValue(); - } - counter++; - }//IsADCDataWord() + + } + fclose(mapFile4Shuttle); + }// SOD event + + else if(eventT==PHYSICS_EVENT){ + // --- Reading data header + reader->ReadHeader(); + const AliRawDataHeader* header = reader->GetDataHeader(); + if(header){ + UChar_t message = header->GetAttributes(); + if((message & 0x20) == 0x20){ // PEDESTAL RUN + //printf("\t STANDALONE_PEDESTAL RUN raw data found\n"); + } + else{ + printf("ZDCPEDESTALda.cxx -> NO STANDALONE_PEDESTAL RUN raw data found\n"); + printf(" CDH attributes: %x\n", message); + return -1; + } + } + else{ + printf("\t ATTENTION! No Raw Data Header found!!!\n"); + return -1; + } + + rawStreamZDC->SetSODReading(kTRUE); + + if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); + // + // ----- Setting ch. mapping ----- + for(Int_t jk=0; jk<2*kNChannels; jk++){ + //printf("ZDCPEDESTALDA.cxx -> ch.%d mod %d, ch %d, code %d det %d, sec %d\n", + // jk,adcMod[jk],adcCh[jk],sigCode[jk],det[jk],sec[jk]); + rawStreamZDC->SetMapADCMod(jk, adcMod[jk]); + rawStreamZDC->SetMapADCCh(jk, adcCh[jk]); + rawStreamZDC->SetMapADCSig(jk, sigCode[jk]); + rawStreamZDC->SetMapDet(jk, det[jk]); + rawStreamZDC->SetMapTow(jk, sec[jk]); + } + // + Int_t iraw=0; + Int_t RawADChg[kNChannels], RawADCoothg[kNChannels]; + Int_t RawADClg[kNChannels], RawADCootlg[kNChannels]; + for(Int_t j=0; jNext()){ + Int_t index=-1; + Int_t detector = rawStreamZDC->GetSector(0); + Int_t sector = rawStreamZDC->GetSector(1); // - if(counter == 88){ // Last ADC channel - for(Int_t k=0; k<44; k++){ - hPedCorr[k]->Fill(RawADCoot[k], RawADC[k]); - } - } - } - // - nevents_physics++; - - } + //printf(" rawData: det %d sec %d value %d\n", + // detector, sector,rawStreamZDC->GetADCGain(),rawStreamZDC->GetADCValue() ); + + if((rawStreamZDC->IsADCDataWord()) && (detector!=-1) && + (rawStreamZDC->GetADCModule()>=kFirstADCGeo && rawStreamZDC->GetADCModule()<=kLastADCGeo)){ + if(sector!=5){ // Physics signals + if(detector==1) index = sector; // *** ZNC + else if(detector==2) index = sector+5; // *** ZPC + else if(detector==3) index = sector+9; // *** ZEM + else if(detector==4) index = sector+12; // *** ZNA + else if(detector==5) index = sector+17; // *** ZPA + } + else{ // Reference PMs + index = (detector-1)/3+22; + } + // + if(index==-1) printf("ERROR in ZDCPEDESTALda.cxx -> det %d quad %d index %d \n", + detector,sector,index); + + // + if(iraw<2*kNChannels){ // --- In-time pedestals (1st 48 raw data) + if(rawStreamZDC->GetADCGain()==0){ + hPedhg[index]->Fill(rawStreamZDC->GetADCValue()); + RawADChg[index] = rawStreamZDC->GetADCValue(); + // + //printf("\t filling histo hPedhg[%d]\n",index); + } + else{ + hPedlg[index]->Fill(rawStreamZDC->GetADCValue()); + RawADClg[index] = rawStreamZDC->GetADCValue(); + // + //printf("\t filling histo hPedlg[%d]\n",index); + } + } + else{ // --- Out-of-time pedestals + if(rawStreamZDC->GetADCGain()==0){ + hPedOutOfTimehg[index]->Fill(rawStreamZDC->GetADCValue()); + RawADCoothg[index] = rawStreamZDC->GetADCValue(); + // + //printf("\t filling histo hPedOutOfTimehg[%d]\n",index); + } + else{ + hPedOutOfTimelg[index]->Fill(rawStreamZDC->GetADCValue()); + RawADCootlg[index] = rawStreamZDC->GetADCValue(); + // + //printf("\t filling histo hPedOutOfTimelg[%d]\n",index); + } + } + iraw++; + }//IsADCDataWord() + } + // + if(iraw==4*kNChannels ){ // Last ADC channel -> Filling correlation histos + for(Int_t k=0; kFill(RawADCoothg[k], RawADChg[k]); + hPedCorrlg[k]->Fill(RawADCootlg[k], RawADClg[k]); + } + //printf(" ev. %d -> Filling correlation histo %d\n",nevents_physics, kNChannels); + } + nevents_physics++; + // + delete reader; + delete rawStreamZDC; + + }//(if PHYSICS_EVENT) + + /* exit when last event received, no need to wait for TERM signal */ + else if(eventT==END_OF_RUN) { + printf(" -> EOR event detected\n"); + break; + } + + nevents_total++; - nevents_total++; - - + } + /* free resources */ free(event); - - /* exit when last event received, no need to wait for TERM signal */ - if (eventT==END_OF_RUN) { - printf("EOR event detected\n"); - break; - } - } + } /* Analysis of the histograms */ // FILE *fileShuttle; - fileShuttle = fopen("ZDCPedestal.dat","w"); + fileShuttle = fopen(PEDDATA_FILE,"w"); // - Float_t MeanPed[44], MeanPedWidth[44], - MeanPedOOT[44], MeanPedWidthOOT[44], - CorrCoeff0[44], CorrCoeff1[44]; - // --- Out-of-time pedestals - TF1 *ADCfunc[44]; - for(Int_t i=0; i<44; i++){ - hPed[i]->Fit("gaus","Q"); - ADCfunc[i] = hPed[i]->GetFunction("gaus"); - MeanPed[i] = ADCfunc[i]->GetParameter(1); - MeanPedWidth[i] = ADCfunc[i]->GetParameter(2); + Float_t MeanPed[2*kNChannels], MeanPedWidth[2*kNChannels], + MeanPedOOT[2*kNChannels], MeanPedWidthOOT[2*kNChannels]; + // --- In-time pedestals + TF1 *ADCfunchg[kNChannels]; + for(Int_t i=0; iGetEntries() == 0){ + printf("\n WARNING! Empty histos -> ending DA WITHOUT writing output\n\n"); + return -1; + } + hPedhg[i]->Fit("gaus","Q"); + ADCfunchg[i] = hPedhg[i]->GetFunction("gaus"); + MeanPed[i] = (Double_t) ADCfunchg[i]->GetParameter(1); + MeanPedWidth[i] = (Double_t) ADCfunchg[i]->GetParameter(2); fprintf(fileShuttle,"\t%f\t%f\n",MeanPed[i],MeanPedWidth[i]); - //printf("\t MeanPed[%d] = %f\n",i, MeanPed[i]); + //printf("\t MeanPedhg[%d] = %f\n",i, MeanPed[i]); + } + TF1 *ADCfunclg[kNChannels]; + for(Int_t i=0; iFit("gaus","Q"); + ADCfunclg[i] = hPedlg[i]->GetFunction("gaus"); + MeanPed[i+kNChannels] = (Double_t) ADCfunclg[i]->GetParameter(1); + MeanPedWidth[i+kNChannels] = (Double_t) ADCfunclg[i]->GetParameter(2); + fprintf(fileShuttle,"\t%f\t%f\n",MeanPed[i+kNChannels],MeanPedWidth[i+kNChannels]); + //printf("\t MeanPedlg[%d] = %f\n",i+kNChannels, MeanPed[i+kNChannels]); } // --- Out-of-time pedestals - TF1 *ADCootfunc[44]; - for(Int_t i=0; i<44; i++){ - hPedOutOfTime[i]->Fit("gaus","Q"); - ADCootfunc[i] = hPedOutOfTime[i]->GetFunction("gaus"); - MeanPedOOT[i] = ADCootfunc[i]->GetParameter(1); - MeanPedWidthOOT[i] = ADCootfunc[i]->GetParameter(2); + TF1 *ADCootfunchg[kNChannels]; + for(Int_t i=0; iGetEntries() == 0){ + printf("\n WARNING! Empty histos for out-of-time channels!!!\n\n"); + return -1; + } + hPedOutOfTimehg[i]->Fit("gaus","Q"); + ADCootfunchg[i] = hPedOutOfTimehg[i]->GetFunction("gaus"); + MeanPedOOT[i] = (Double_t) ADCootfunchg[i]->GetParameter(1); + MeanPedWidthOOT[i] = (Double_t) ADCootfunchg[i]->GetParameter(2); fprintf(fileShuttle,"\t%f\t%f\n",MeanPedOOT[i],MeanPedWidthOOT[i]); - //printf("\t MeanPedOOT[%d] = %f\n",i, MeanPedOOT[i]); + //printf("\t MeanPedOOThg[%d] = %f\n",i, MeanPedOOT[i]); } - // - // --- Fit of correlations - TProfile* hPedCorrProf[44]; - TF1 *ffunc[44]; + TF1 *ADCootfunclg[kNChannels]; + for(Int_t i=0; iFit("gaus","Q"); + ADCootfunclg[i] = hPedOutOfTimelg[i]->GetFunction("gaus"); + MeanPedOOT[i+kNChannels] = (Double_t) ADCootfunclg[i]->GetParameter(1); + MeanPedWidthOOT[i+kNChannels] = (Double_t) ADCootfunclg[i]->GetParameter(2); + fprintf(fileShuttle,"\t%f\t%f\n",MeanPedOOT[i+kNChannels],MeanPedWidthOOT[i+kNChannels]); + //printf("\t MeanPedOOTlg[%d] = %f\n",i+kNChannels, MeanPedOOT[i+kNChannels]); + } + + // --- Correlations + Float_t CorrCoeff0[2*kNChannels], CorrCoeff1[2*kNChannels]; + TProfile *hPedCorrProfhg[kNChannels], *hPedCorrProflg[kNChannels]; + TF1 *ffunchg[kNChannels], *ffunclg[kNChannels]; char namhist4[50]; - for(int i=0;i<44;i++) { - sprintf(namhist4,"ADCvsOOT%d_Prof",i); - hPedCorrProf[i] = hPedCorr[i]->ProfileX(namhist4,-1,-1,"S"); - hPedCorrProf[i]->SetName(namhist4); - hPedCorrProf[i]->Fit("pol1","Q"); - ffunc[i] = hPedCorrProf[i]->GetFunction("pol1"); - CorrCoeff0[i] = ffunc[i]->GetParameter(0); - CorrCoeff1[i] = ffunc[i]->GetParameter(1); - fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i],CorrCoeff1[i]); - //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",i, CorrCoeff0[i], i, CorrCoeff1[i]); + for(int i=0;iProfileX(namhist4,-1,-1,"S"); + hPedCorrProfhg[i]->SetName(namhist4); + if(hPedCorrProfhg[i]->GetEntries()!=0){ + hPedCorrProfhg[i]->Fit("pol1","Q"); + ffunchg[i] = hPedCorrProfhg[i]->GetFunction("pol1"); + CorrCoeff0[i] = (Double_t) ffunchg[i]->GetParameter(0); + CorrCoeff1[i] = (Double_t) ffunchg[i]->GetParameter(1); + //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",i, CorrCoeff0[i], i, CorrCoeff1[i]); + } + else{ + printf(" Warning -> Correlation for high range ch. %d has no entry and can't be fitted!\n",i); + } + } + else{ + CorrCoeff0[i] = 0.; + CorrCoeff1[i] = 0.; + } + fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i],CorrCoeff1[i]); + } + for(int i=0;iProfileX(namhist4,-1,-1,"S"); + hPedCorrProflg[i]->SetName(namhist4); + if(hPedCorrProflg[i]->GetEntries()!=0){ + hPedCorrProflg[i]->Fit("pol1","Q"); + ffunclg[i] = hPedCorrProflg[i]->GetFunction("pol1"); + CorrCoeff0[i+kNChannels] = (Double_t) ffunclg[i]->GetParameter(0); + CorrCoeff1[i+kNChannels] = (Double_t) ffunclg[i]->GetParameter(1); + //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n", + // i+kNChannels, CorrCoeff0[i+kNChannels], i+kNChannels, CorrCoeff1[i+kNChannels]); + } + else{ + printf(" Warning -> Correlation for low range ch. %d has no entry and can't be fitted!\n",i); + } + } + else{ + CorrCoeff0[i+kNChannels] = 0.; + CorrCoeff1[i+kNChannels] = 0.; + } + fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i+kNChannels],CorrCoeff1[i+kNChannels]); + } + // fclose(fileShuttle); - + // + /* report progress */ + daqDA_progressReport(80); + // + TFile *histofile = new TFile(PEDHISTO_FILE,"RECREATE"); + histofile->cd(); + for(int k=0; kWrite(); + hPedOutOfTimehg[k]->Write(); + hPedCorrhg[k]->Write(); + hPedlg[k]->Write(); + hPedOutOfTimelg[k]->Write(); + hPedCorrlg[k]->Write(); + } + // + histofile->Close(); + // + for(Int_t j=0; j