From 1fd93b67b9abf6d9c0c4339333a65f6d38a85d41 Mon Sep 17 00:00:00 2001 From: masera Date: Fri, 29 Jun 2007 10:13:01 +0000 Subject: [PATCH] SPD DA: updates from H. Tydesjo --- ITS/AliITSOnlineSPDscanAnalyzer.cxx | 83 +++++++++++++--- ITS/AliITSRawStreamSPD.cxx | 6 +- ITS/AliITSRawStreamSPD.h | 1 + ITS/ITSSPDda.cxx | 142 ++++++++++++++++------------ 4 files changed, 160 insertions(+), 72 deletions(-) diff --git a/ITS/AliITSOnlineSPDscanAnalyzer.cxx b/ITS/AliITSOnlineSPDscanAnalyzer.cxx index e8a6b4a469e..4fb17809b79 100644 --- a/ITS/AliITSOnlineSPDscanAnalyzer.cxx +++ b/ITS/AliITSOnlineSPDscanAnalyzer.cxx @@ -1,3 +1,20 @@ +/************************************************************************** + * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$*/ + //////////////////////////////////////////////////////////// // Author: Henrik Tydesjo // // This class is used in the detector algorithm framework // @@ -291,6 +308,9 @@ Bool_t AliITSOnlineSPDscanAnalyzer::SaveDeadNoisyPixels(UInt_t module, Char_t *c return kFALSE; } + + + Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) { // get delay if (hs>=6 || chipNr>10) return -1; @@ -309,23 +329,64 @@ Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) { } } - Char_t funcName[30]; - sprintf(funcName,"Fit delay func HS%d CHIP%d",hs,chipNr); - Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0); - Int_t maxDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(fScanObj->GetNSteps()-1); - TF1* delayFunc = new TF1(funcName,"gaus",minDac,maxDac); - fMeanMultiplicity[hs][chipNr]->Fit(funcName,"Q0"); - Double_t mean = delayFunc->GetParameter(1); - // Double_t sigma = fDelayFunc[hs][chipNr]->GetParameter(2); - delete delayFunc; - if (mean>minDac && meanGetNSteps(); step++) { + Double_t thisDac; + Double_t thisMult; + fMeanMultiplicity[hs][chipNr]->GetPoint(step,thisDac,thisMult); + if (thisMult > maxVal) { + maxVal = thisMult; + maxStep = step; + } + } + + if (maxVal>0) { + return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(maxStep); } else { return -1; } + } + +// ********** old version of "GetDelay", which fits a gaussian to the meanmult graph +//Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) { +// // get delay +// if (hs>=6 || chipNr>10) return -1; +// if (fScanObj==NULL) { +// printf("No data!\n"); +// return -1; +// } +// // should be type kDELAY or kDAC with id 42 (delay_ctrl) +// if (fType!=kDELAY && (fType!=kDAC || fDacId!=42)) { +// printf("Delay only for scan type %d or %d and dac_id 42\n",kDELAY,kDAC); +// return -1; +// } +// if (fMeanMultiplicity[hs][chipNr]==NULL) { +// if (!ProcessMeanMultiplicity()) { +// return -1; +// } +// } +// +// Char_t funcName[30]; +// sprintf(funcName,"Fit delay func HS%d CHIP%d",hs,chipNr); +// Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0); +// Int_t maxDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(fScanObj->GetNSteps()-1); +// TF1* delayFunc = new TF1(funcName,"gaus",minDac,maxDac); +// fMeanMultiplicity[hs][chipNr]->Fit(funcName,"Q0"); +// Double_t mean = delayFunc->GetParameter(1); +// // Double_t sigma = fDelayFunc[hs][chipNr]->GetParameter(2); +// delete delayFunc; +// if (mean>minDac && mean 200 hits) if (hs>=6 || chipNr>10) return -1; diff --git a/ITS/AliITSRawStreamSPD.cxx b/ITS/AliITSRawStreamSPD.cxx index a2884a0d2fd..bcf52869d09 100644 --- a/ITS/AliITSRawStreamSPD.cxx +++ b/ITS/AliITSRawStreamSPD.cxx @@ -1,5 +1,5 @@ /************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * @@ -290,3 +290,7 @@ UInt_t AliITSRawStreamSPD::GetHTPAmp(UInt_t hs) const { if (hs<6) return fCalHeadWord[hs+10]; else return 0; } +Bool_t AliITSRawStreamSPD::GetHminTHchipPresent(UInt_t chip) const { + if (chip<10) return ((( fCalHeadWord[7]>>(16+chip)) & 0x00000001) == 1); + else return kFALSE; +} diff --git a/ITS/AliITSRawStreamSPD.h b/ITS/AliITSRawStreamSPD.h index 8ccffce1336..24a6e62750c 100644 --- a/ITS/AliITSRawStreamSPD.h +++ b/ITS/AliITSRawStreamSPD.h @@ -56,6 +56,7 @@ class AliITSRawStreamSPD: public AliITSRawStream { UInt_t GetHdacHigh(UInt_t hs) const; UInt_t GetHdacLow(UInt_t hs) const; UInt_t GetHTPAmp(UInt_t hs) const; + Bool_t GetHminTHchipPresent(UInt_t chip) const; enum {kDDLsNumber = 20}; // number of DDLs in SPD enum {kModulesPerDDL = 12}; // number of modules in each DDL diff --git a/ITS/ITSSPDda.cxx b/ITS/ITSSPDda.cxx index 31b36d94973..c7b5cb24c76 100644 --- a/ITS/ITSSPDda.cxx +++ b/ITS/ITSSPDda.cxx @@ -1,15 +1,15 @@ -////////////////////////////////////////////////////////////////////////////// -// This program can be run in two modes. // -// // -// 1. With the DAQ DA framework on. In Makefile: -DDA_OFF flag outcommented.// -// Call this program with the name of the executable followed by the // -// data files to process. // -// // -// 2. Without the DAQ DA framework on. In Makefile: with -DDA_OFF flag. // -// Call this program with the name of the executable followed by the // -// runNr and the data files to process. // -// // -////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// This program can be run in two modes. // +// // +// 1. With the DAQ DA framework on. This is the default operating mode. // +// Call this program with the name of the executable followed by the // +// data files to process. // +// // +// 2. Without the DAQ DA framework on. Define the SPD_DA_OFF environment var. // +// Call this program with the name of the executable followed by the // +// runNr and the data files to process. // +// // +//////////////////////////////////////////////////////////////////////////////// extern "C" { #include "daqDA.h" @@ -36,12 +36,18 @@ int main(int argc, char **argv) { return -1; } - char *saveDirNoisy = "./calibResults/Noisy"; // hard wired for now!!! -#ifndef DA_OFF - char *saveDirNoisyToFXS = "./calibResults/NoisyToFXS"; // hard wired for now!!! + // make directory structure (if not here already): + system("mkdir ./calibResults >& /dev/null"); + system("mkdir ./calibResults/Noisy >& /dev/null"); + system("mkdir ./calibResults/NoisyToFXS >& /dev/null"); + system("mkdir ./calibResults/Parameters >& /dev/null"); + system("mkdir ./calibResults/Reference >& /dev/null"); + char *saveDirNoisy = "./calibResults/Noisy"; +#ifndef SPD_DA_OFF + char *saveDirNoisyToFXS = "./calibResults/NoisyToFXS"; #endif - char *saveDirParameters = "./calibResults/Parameters"; // hard wired for now!!! - char *saveDirRef = "./calibResults/Reference"; // hard wired for now!!! + char *saveDirParameters = "./calibResults/Parameters"; + char *saveDirRef = "./calibResults/Reference"; // This line is needed in case of a stand-alone application w/o // $ROOTSYS/etc/system.rootrc file @@ -53,7 +59,7 @@ int main(int argc, char **argv) { // turn off annoying warning messages new AliLog; - AliLog::Instance()->SetModuleDebugLevel("ROOT", -2); + AliLog::Instance()->SetGlobalDebugLevel(-20); // calib scan types enum calib_types{MINTH,MEANTH,DAC,UNIMA,NOISE,DELAY}; @@ -62,13 +68,17 @@ int main(int argc, char **argv) { // ********* STEP 1: Produce scan container files. *********************************** int startSeg = 1; -#ifndef DA_OFF +#ifndef SPD_DA_OFF int runNr = atoi(getenv("DATE_RUN_NUMBER")); #else int runNr = atoi(argv[1]); startSeg = 2; #endif +#ifndef SPD_DA_OFF + UInt_t nrNoisyFilesProduced=0; +#endif + // container objects AliITSOnlineSPDscan *scanObj[20]; Bool_t bScanInit[20]; @@ -94,6 +104,7 @@ int main(int argc, char **argv) { UInt_t dacHigh[20][6]; UInt_t dacLow[20][6]; UInt_t TPAmp[20][6]; + Bool_t minTHchipPresent[20][10]; // current scan step flag Int_t currentStep[20]; for (UInt_t eqId=0; eqId<20; eqId++) currentStep[eqId] = 9999; @@ -130,7 +141,9 @@ int main(int argc, char **argv) { for(;;) { /* check shutdown condition */ +#ifndef SPD_DA_OFF if (daqDA_checkShutdown()) {break;} +#endif /* get next event (blocking call until timeout) */ status=monitorGetEventDynamic((void **)&event); if (status==MON_ERR_EOF) { @@ -148,11 +161,11 @@ int main(int argc, char **argv) { } eventT=event->eventType; - if (event->eventType == PHYSICS_EVENT){ + if (eventT == PHYSICS_EVENT){ eventNr++; - // printf("eventNr %d\n",eventNr); + // printf("eventNr %d\n",eventNr); AliRawReader *reader = new AliRawReaderDate((void*)event); AliITSRawStreamSPD *str = new AliITSRawStreamSPD(reader); @@ -180,27 +193,30 @@ int main(int argc, char **argv) { } // read calib values - routerNr[eqId] = str->GetHrouterNr(); - type[eqId] = str->GetHtype(); - dataFormat[eqId] = str->GetHdataFormat(); - triggers[eqId] = str->GetHtriggers(); - dacStart[eqId] = str->GetHdacStart(); - dacEnd[eqId] = str->GetHdacEnd(); - dacStep[eqId] = str->GetHdacStep(); - dacId[eqId] = str->GetHdacId(); - rowStart[eqId] = str->GetHrowStart(); - rowEnd[eqId] = str->GetHrowEnd(); - rowValue[eqId] = str->GetHrowValue(); - dacValue[eqId] = str->GetHdacValue(); + routerNr[eqId] = str->GetHrouterNr(); + type[eqId] = str->GetHtype(); + dataFormat[eqId] = str->GetHdataFormat(); + triggers[eqId] = str->GetHtriggers(); + dacStart[eqId] = str->GetHdacStart(); + dacEnd[eqId] = str->GetHdacEnd(); + dacStep[eqId] = str->GetHdacStep(); + dacId[eqId] = str->GetHdacId(); + rowStart[eqId] = str->GetHrowStart(); + rowEnd[eqId] = str->GetHrowEnd(); + rowValue[eqId] = str->GetHrowValue(); + dacValue[eqId] = str->GetHdacValue(); for (UInt_t hs=0; hs<6; hs++) { - halfStaveScanned[eqId][hs]=str->GetHhalfStaveScanned(hs); - dacHigh[eqId][hs] = str->GetHdacHigh(hs); - dacLow[eqId][hs] = str->GetHdacLow(hs); - TPAmp[eqId][hs] = str->GetHTPAmp(hs); + halfStaveScanned[eqId][hs] = str->GetHhalfStaveScanned(hs); + dacHigh[eqId][hs] = str->GetHdacHigh(hs); + dacLow[eqId][hs] = str->GetHdacLow(hs); + TPAmp[eqId][hs] = str->GetHTPAmp(hs); for (UInt_t chip=0; chip<10; chip++) { - chipPresent[eqId][hs][chip] = str->GetHchipPresent(hs,chip); + chipPresent[eqId][hs][chip] = str->GetHchipPresent(hs,chip); } } + for (UInt_t chip=0; chip<10; chip++) { + minTHchipPresent[eqId][chip] = str->GetHminTHchipPresent(chip); + } currentStep[eqId] = (dacValue[eqId]-dacStart[eqId])/dacStep[eqId]; if (type[eqId]==DELAY) { @@ -308,9 +324,11 @@ int main(int argc, char **argv) { while (str->Next()) { UInt_t hs = str->GetHalfStaveNr(); UInt_t chip = str->GetChipAddr(); - - if (type[eqId]!=MINTH || dacHigh[eqId][0]==chip) { // dachigh[0] holds chip scanned for minth - +#ifndef SPD_DA_OFF + if (type[eqId]!=MINTH || minTHchipPresent[eqId][chip]) { +#else + if (type[eqId]!=MINTH || minTHchipPresent[eqId][chip] || runNr<=416900) { +#endif scanObj[eqId]->IncrementHits(currentStep[eqId],hs,chip,str->GetChipCol(),str->GetChipRow()); if (!hitEventHSIncremented[hs]) { @@ -350,7 +368,7 @@ int main(int argc, char **argv) { return -1; } -#ifndef DA_OFF +#ifndef SPD_DA_OFF daqDA_progressReport((unsigned int)( ((Float_t)(segNr-startSeg+1))/(argc-startSeg)*50 )); #else printf("progress: %d\n",(unsigned int)( ((Float_t)(segNr-startSeg+1))/(argc-startSeg)*50 )); @@ -368,7 +386,7 @@ int main(int argc, char **argv) { // ********* STEP 2: Analyze scan container files. *********************************** -#ifndef DA_OFF +#ifndef SPD_DA_OFF // clear noisyToFXS dir: Char_t command[200]; sprintf(command,"cd %s; rm -f *",saveDirNoisyToFXS); @@ -402,7 +420,8 @@ int main(int argc, char **argv) { if (analyzer->ProcessNoisyPixels(saveDirNoisy)) { for (UInt_t module=0; module<240; module++) { if (analyzer->SaveDeadNoisyPixels(module,saveDirNoisy)) { -#ifndef DA_OFF +#ifndef SPD_DA_OFF + nrNoisyFilesProduced++; Char_t command[100]; sprintf(command,"cp %s/SPD_DeadNoisy_%d.root %s/.",saveDirNoisy,module,saveDirNoisyToFXS); system(command); @@ -424,7 +443,7 @@ int main(int argc, char **argv) { // ofile << "\n"; // } // ofile.close(); -//#ifndef DA_OFF +//#ifndef SPD_DA_OFF // Char_t id[20]; // sprintf(id,"SPD_delay_%d",eqId); // Int_t status = daqDA_FES_storeFile(ofileName,id); @@ -446,7 +465,7 @@ int main(int argc, char **argv) { ofile << "\n"; } ofile.close(); -#ifndef DA_OFF +#ifndef SPD_DA_OFF Char_t id[20]; sprintf(id,"SPD_minth_%d",eqId); Int_t status = daqDA_FES_storeFile(ofileName,id); @@ -472,7 +491,7 @@ int main(int argc, char **argv) { ofile << "\n"; } ofile.close(); -#ifndef DA_OFF +#ifndef SPD_DA_OFF Char_t id[20]; sprintf(id,"SPD_delay_%d",eqId); Int_t status = daqDA_FES_storeFile(ofileName,id); @@ -485,7 +504,7 @@ int main(int argc, char **argv) { delete analyzer; -#ifndef DA_OFF +#ifndef SPD_DA_OFF daqDA_progressReport((unsigned int)(50+(eqId+1)*2.5)); #else printf("progress: %d\n",(unsigned int)(50+(eqId+1)*2.5)); @@ -495,18 +514,21 @@ int main(int argc, char **argv) { // *** *** *** end loop over equipments (eq_id) -#ifndef DA_OFF - // send a tared file of all new noisy maps - sprintf(command,"cd %s; tar -cf noisy.tar *",saveDirNoisyToFXS); - printf("\n\n%s\n\n",command); - system(command); - Char_t fileName[200]; - sprintf(fileName,"%s/noisy.tar",saveDirNoisyToFXS); - Char_t id[20]; - sprintf(id,"SPD_noisy"); - Int_t status = daqDA_FES_storeFile(fileName,id); - if (status) { - printf("Failed to export file %s , status %d\n",fileName,status); +#ifndef SPD_DA_OFF + if (nrNoisyFilesProduced>0) { + // send a tared file of all new noisy maps + sprintf(command,"cd %s; tar -cf noisy.tar *",saveDirNoisyToFXS); + printf("\n\n%s\n\n",command); + system(command); + Char_t fileName[200]; + sprintf(fileName,"%s/noisy.tar",saveDirNoisyToFXS); + Char_t id[20]; + sprintf(id,"SPD_noisy"); + Int_t status = daqDA_FES_storeFile(fileName,id); + if (status!=0) { + printf("Failed to export file %s , status %d\n",fileName,status); + return -1; + } } #endif -- 2.43.0