LCOV - code coverage report
Current view: top level - ITS/ITSrec - AliITSOnlineSPDscanAnalyzer.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 636 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 36 0.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ////////////////////////////////////////////////////////////
      19             : // Author: Henrik Tydesjo                                 //
      20             : // This class is used in the detector algorithm framework //
      21             : // to process the data stored in special container files  //
      22             : // (see AliITSOnlineSPDscan). For instance, minimum       //
      23             : // threshold values can be extracted.                     //
      24             : ////////////////////////////////////////////////////////////
      25             : 
      26             : #include "AliITSOnlineSPDscanAnalyzer.h"
      27             : #include "AliITSOnlineSPDscan.h"
      28             : #include "AliITSOnlineSPDscanSingle.h"
      29             : #include "AliITSOnlineSPDscanMultiple.h"
      30             : #include "AliITSOnlineSPDscanMeanTh.h"
      31             : #include "AliITSOnlineCalibrationSPDhandler.h"
      32             : #include "AliITSRawStreamSPD.h"
      33             : #include <TStyle.h>
      34             : #include <TMath.h>
      35             : #include <TLine.h>
      36             : #include <TF1.h>
      37             : #include <TGraph.h>
      38             : #include <TH2F.h>
      39             : #include <TError.h>
      40             : #include <iostream>
      41             : #include <fstream>
      42             : 
      43             : using std::ifstream;
      44             : 
      45             : Double_t itsSpdErrorf(Double_t *x, Double_t *par){
      46           0 :   if (par[2]<0) par[2]=0;
      47           0 :   Double_t val = par[2]+(0.12*256*32-par[2])*(0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.)));
      48           0 :   return val;
      49             : }
      50             : //Double_t itsSpdErrorfOrig(Double_t *x, Double_t *par){
      51             : //  return 0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.));
      52             : //}
      53             : //_________________________________________________________________________
      54             : Double_t itsSpdScurveForMeanTh(Double_t *x, Double_t *par){
      55           0 :   if (par[2]<0) par[2]=0;
      56           0 :   Double_t val = 1.- par[2]*(1.-TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.)));
      57             : //  Double_t val = par[2]+(0.12*256*32-par[2])*(0.5+0.5*TMath::Erf((x[0]-par[0])/par[1]/sqrt(2.)));
      58           0 :   return val;
      59             : }
      60             : 
      61             : //_________________________________________________________________________
      62             : AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const Char_t *fileName, AliITSOnlineCalibrationSPDhandler *handler, Bool_t readFromGridFile) :
      63           0 :   fType(99),fDacId(99),fFileName(fileName),fScanObj(NULL),fHandler(handler),fTriggers(NULL),fTPeff(0),fTPeffHS(NULL),fDeadPixel(0),fDeadPixelHS(NULL),fNoisyPixel(0),fNoisyPixelHS(NULL),
      64           0 :   fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
      65           0 :   fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(5),fMaxBaseLineLevel(10)
      66           0 : {
      67             :   // constructor
      68           0 :   for (UInt_t chipNr=0; chipNr<11; chipNr++) {
      69           0 :     for (UInt_t hs=0; hs<6; hs++) {
      70           0 :       fMeanMultiplicity[hs][chipNr]=NULL;
      71           0 :       fHitEventEfficiency[hs][chipNr]=NULL;
      72             :     }
      73             :   }
      74           0 :   for (UInt_t hs=0; hs<6; hs++) {
      75           0 :     fTPeffChip[hs]=NULL;
      76           0 :     fDeadPixelChip[hs]=NULL;
      77           0 :     fNoisyPixelChip[hs]=NULL;
      78             :   }
      79             : 
      80           0 :   for (UInt_t mod=0; mod<240; mod++) {
      81           0 :     fbModuleScanned[mod]=kFALSE;
      82             :   }
      83             : 
      84           0 :   Init(readFromGridFile);
      85           0 : }
      86             : //_________________________________________________________________________
      87             : AliITSOnlineSPDscanAnalyzer::AliITSOnlineSPDscanAnalyzer(const AliITSOnlineSPDscanAnalyzer& handle) :
      88           0 :   fType(99),fDacId(99),fFileName("."),fScanObj(NULL),fHandler(NULL),fTriggers(NULL),fTPeff(0),fTPeffHS(NULL),fDeadPixel(0),fDeadPixelHS(NULL),fNoisyPixel(0),fNoisyPixelHS(NULL),
      89           0 :   fOverWrite(kFALSE),fNoiseThreshold(0.01),fNoiseMinimumEvents(100),
      90           0 :   fMinNrStepsBeforeIncrease(5),fMinIncreaseFromBaseLine(2),fStepDownDacSafe(5),fMaxBaseLineLevel(10)
      91           0 : {
      92             :   // copy constructor, only copies the filename and params (not the processed data)
      93           0 :   fFileName=handle.fFileName;
      94           0 :   fOverWrite=handle.fOverWrite;
      95           0 :   fNoiseThreshold=handle.fNoiseThreshold;
      96           0 :   fNoiseMinimumEvents=handle.fNoiseMinimumEvents;
      97           0 :   fMinNrStepsBeforeIncrease=handle.fMinNrStepsBeforeIncrease;
      98           0 :   fMinIncreaseFromBaseLine=handle.fMinIncreaseFromBaseLine;
      99           0 :   fStepDownDacSafe=handle.fStepDownDacSafe;
     100           0 :   fMaxBaseLineLevel=handle.fMaxBaseLineLevel;
     101             : 
     102           0 :   for (UInt_t chipNr=0; chipNr<11; chipNr++) {
     103           0 :     for (UInt_t hs=0; hs<6; hs++) {
     104           0 :       fMeanMultiplicity[hs][chipNr]=NULL;
     105           0 :       fHitEventEfficiency[hs][chipNr]=NULL;
     106             :     }
     107             :   }
     108           0 :   for (UInt_t hs=0; hs<6; hs++) {
     109           0 :     fTPeffChip[hs]=NULL;
     110           0 :     fDeadPixelChip[hs]=NULL;
     111           0 :     fNoisyPixelChip[hs]=NULL;
     112             :   }
     113             : 
     114           0 :   for (UInt_t mod=0; mod<240; mod++) {
     115           0 :     fbModuleScanned[mod]=kFALSE;
     116             :   }
     117             : 
     118           0 :   Init();
     119           0 : }
     120             : //_________________________________________________________________________
     121           0 : AliITSOnlineSPDscanAnalyzer::~AliITSOnlineSPDscanAnalyzer() {
     122             :   // destructor
     123           0 :   for (UInt_t hs=0; hs<6; hs++) {
     124           0 :     for (UInt_t chipNr=0; chipNr<11; chipNr++) {
     125           0 :       if (fMeanMultiplicity[hs][chipNr]!=NULL) {
     126           0 :         delete fMeanMultiplicity[hs][chipNr];
     127           0 :         fMeanMultiplicity[hs][chipNr]=NULL;
     128           0 :       }
     129           0 :       if (fHitEventEfficiency[hs][chipNr]!=NULL) {
     130           0 :         delete fHitEventEfficiency[hs][chipNr];
     131           0 :         fHitEventEfficiency[hs][chipNr]=NULL;
     132           0 :       }
     133             :     }
     134             :   }
     135             : 
     136           0 :   if (fTriggers!=NULL) {
     137           0 :     delete fTriggers;
     138           0 :     fTriggers=NULL;
     139           0 :   }
     140             : 
     141           0 :   DeleteUniformityHistograms();
     142             : 
     143           0 :   if (fScanObj!=NULL) {
     144           0 :     delete fScanObj;
     145           0 :     fScanObj=NULL;
     146           0 :   }
     147           0 : }
     148             : //_________________________________________________________________________
     149             : AliITSOnlineSPDscanAnalyzer& AliITSOnlineSPDscanAnalyzer::operator=(const AliITSOnlineSPDscanAnalyzer& handle) {
     150             :   // assignment operator, only copies the filename and params (not the processed data)
     151           0 :   if (this!=&handle) {
     152           0 :     for (UInt_t hs=0; hs<6; hs++) {
     153           0 :       for (UInt_t chipNr=0; chipNr<11; chipNr++) {
     154           0 :         if (fMeanMultiplicity[hs][chipNr]!=NULL) {
     155           0 :           delete fMeanMultiplicity[hs][chipNr];
     156             :         }
     157           0 :         if (fHitEventEfficiency[hs][chipNr]!=NULL) {
     158           0 :           delete fHitEventEfficiency[hs][chipNr];
     159             :         }
     160             :       }
     161             :     }
     162           0 :     if (fTriggers!=NULL) {
     163           0 :       delete fTriggers;
     164           0 :       fTriggers=NULL;
     165           0 :     }
     166             : 
     167           0 :     DeleteUniformityHistograms();
     168             : 
     169           0 :     if (fScanObj!=NULL) {
     170           0 :       delete fScanObj;
     171           0 :       fScanObj=NULL;
     172           0 :     }
     173             :    
     174           0 :     fFileName=handle.fFileName;
     175           0 :     fOverWrite=handle.fOverWrite;
     176           0 :     fNoiseThreshold=handle.fNoiseThreshold;
     177           0 :     fNoiseMinimumEvents=handle.fNoiseMinimumEvents;
     178           0 :     fMinNrStepsBeforeIncrease=handle.fMinNrStepsBeforeIncrease;
     179           0 :     fMinIncreaseFromBaseLine=handle.fMinIncreaseFromBaseLine;
     180           0 :     fStepDownDacSafe=handle.fStepDownDacSafe;
     181           0 :     fMaxBaseLineLevel=handle.fMaxBaseLineLevel;
     182             : 
     183           0 :     for (UInt_t chipNr=0; chipNr<11; chipNr++) {
     184           0 :       for (UInt_t hs=0; hs<6; hs++) {
     185           0 :         fMeanMultiplicity[hs][chipNr]=NULL;
     186           0 :         fHitEventEfficiency[hs][chipNr]=NULL;
     187             :       }
     188             :     }
     189           0 :     for (UInt_t mod=0; mod<240; mod++) {
     190           0 :       fbModuleScanned[mod]=kFALSE;
     191             :     }
     192             : 
     193           0 :     fHandler=NULL;
     194             :     
     195           0 :     fType=99;
     196           0 :     fDacId=99;
     197             : 
     198           0 :     Init();    
     199           0 :   }
     200           0 :   return *this;
     201             : }
     202             : //_________________________________________________________________________
     203             : void AliITSOnlineSPDscanAnalyzer::Init(Bool_t readFromGridFile) {
     204             :   // first checks type of container and then initializes container obj
     205           0 :   if (!readFromGridFile) {
     206           0 :     FILE* fp0 = fopen(fFileName.Data(), "r");
     207           0 :     if (fp0 == NULL) {
     208           0 :       return;
     209             :     }
     210             :     else {
     211           0 :       fclose(fp0);
     212             :     }
     213           0 :   }
     214             : 
     215           0 :   fScanObj = new AliITSOnlineSPDscan(fFileName.Data(),readFromGridFile);
     216           0 :   fType = fScanObj->GetType();
     217           0 :   delete fScanObj;
     218             : 
     219             :   // init container
     220           0 :   switch(fType) {
     221             :   case kUNIMA:
     222             :   case kNOISE:
     223           0 :     fScanObj = new AliITSOnlineSPDscanSingle(fFileName.Data(),readFromGridFile);
     224           0 :     break;
     225             :   case kMINTH:
     226             :   case kDAC:
     227             :   case kDELAY:
     228           0 :     fScanObj = new AliITSOnlineSPDscanMultiple(fFileName.Data(),readFromGridFile);
     229           0 :     fDacId = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacId();
     230           0 :     break;
     231             :   case kMEANTH:
     232           0 :     fScanObj = new AliITSOnlineSPDscanMeanTh(fFileName.Data(),readFromGridFile);
     233           0 :     fDacId = ((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetDacId();
     234           0 :     break;
     235             :   default:
     236           0 :     Error("AliITSOnlineSPDscanAnalyzer::Init","Type %d not defined!",fType);
     237           0 :     fScanObj=NULL;
     238           0 :     return;
     239             :     break;
     240             :   }
     241             : 
     242           0 : }
     243             : //_________________________________________________________________________
     244             : void AliITSOnlineSPDscanAnalyzer::SetParam(const Char_t *pname, const Char_t *pval) {
     245             :   // set a parameter
     246           0 :   TString name = pname;
     247           0 :   TString val = pval;
     248           0 :   if (name.CompareTo("fOverWrite")==0) {
     249           0 :     if (val.CompareTo("YES")==0 || val.CompareTo("1")==0) {
     250           0 :       fOverWrite = kTRUE;
     251           0 :     }
     252           0 :     else fOverWrite = kFALSE;
     253             :   }
     254           0 :   else if (name.CompareTo("fNoiseThreshold")==0) {
     255           0 :     fNoiseThreshold = val.Atof();
     256           0 :   }
     257           0 :   else if (name.CompareTo("fNoiseMinimumEvents")==0) {
     258           0 :     fNoiseMinimumEvents = val.Atoi();
     259           0 :   }
     260           0 :   else if (name.CompareTo("fMinNrStepsBeforeIncrease")==0) {
     261           0 :     fMinNrStepsBeforeIncrease = val.Atoi();
     262           0 :   }
     263           0 :   else if (name.CompareTo("fMinIncreaseFromBaseLine")==0) {
     264           0 :     fMinIncreaseFromBaseLine = val.Atof();
     265           0 :   }
     266           0 :   else if (name.CompareTo("fStepDownDacSafe")==0) {
     267           0 :     fStepDownDacSafe = val.Atoi();
     268           0 :   }
     269           0 :   else if (name.CompareTo("fMaxBaseLineLevel")==0) {
     270           0 :     fMaxBaseLineLevel = val.Atof();
     271           0 :   }
     272             :   else {
     273           0 :     Error("AliITSOnlineSPDscanAnalyzer::SetParam","Parameter %s in configuration file unknown.",name.Data());
     274             :   }
     275           0 : }
     276             : //_________________________________________________________________________
     277             : void AliITSOnlineSPDscanAnalyzer::ReadParamsFromLocation(const Char_t *dirName) {
     278             :   // opens file (default name) in dir dirName and reads parameters from it
     279           0 :   TString paramsFileName = Form("%s/standal_params.txt",dirName);
     280           0 :   ifstream paramsFile;
     281           0 :   paramsFile.open(paramsFileName, ifstream::in);
     282           0 :   if (paramsFile.fail()) {
     283           0 :     printf("No config file (%s) present. Using default tuning parameters.\n",paramsFileName.Data());
     284             :   }
     285             :   else {
     286             :     while(1) {
     287           0 :       Char_t paramN[50];
     288           0 :       Char_t paramV[50];
     289           0 :       paramsFile >> paramN;
     290           0 :       if (paramsFile.eof()) break;
     291           0 :       paramsFile >> paramV;
     292           0 :       SetParam(paramN,paramV);
     293           0 :       if (paramsFile.eof()) break;
     294           0 :     }
     295           0 :     paramsFile.close();
     296             :   }
     297           0 : }
     298             : //_________________________________________________________________________
     299             : Bool_t AliITSOnlineSPDscanAnalyzer::IsChipPresent(UInt_t hs, UInt_t chipNr) {
     300             :   // is the chip present?
     301           0 :   if (fScanObj==NULL) {
     302           0 :     Warning("AliITSOnlineSPDscanAnalyzer::IsChipPresent","No data!");
     303           0 :     return kFALSE;
     304             :   }
     305           0 :   return fScanObj->GetChipPresent(hs,chipNr);
     306           0 : }
     307             : //_________________________________________________________________________
     308             : Bool_t AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels(/*Char_t *oldcalibDir*/) {
     309             :   // process dead pixel data, for uniformity scan, 
     310             :   // NB: This will not be the general way of finding dead pixels.
     311           0 :   if (fScanObj==NULL) {
     312           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","No data!");
     313           0 :     return kFALSE;
     314             :   }
     315             :   // should be type kUNIMA
     316           0 :   if (fType!=kUNIMA) {
     317           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","Dead pixels only for scan type %d.",kUNIMA);
     318           0 :     return kFALSE;
     319             :   }
     320             :   // handler should be initialized
     321           0 :   if (fHandler==NULL) {
     322           0 :     Error("AliITSOnlineSPDscanAnalyzer::ProcessDeadPixels","Calibration handler is not initialized!");
     323           0 :     return kFALSE;
     324             :   }
     325             : 
     326           0 :   UInt_t routerNr = fScanObj->GetRouterNr();
     327           0 :   UInt_t rowStart = fScanObj->GetRowStart();
     328           0 :   UInt_t rowEnd   = fScanObj->GetRowEnd();
     329           0 :   for (UInt_t hs=0; hs<6; hs++) {
     330           0 :     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
     331           0 :       if (fScanObj->GetChipPresent(hs,chipNr) && fScanObj->GetAverageMultiplicity(0,hs,chipNr)>0) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     332           0 :         if (fOverWrite) {fHandler->ResetDeadForChip(routerNr,hs,chipNr);}
     333           0 :         for (UInt_t col=0; col<32; col++) {
     334           0 :           for (UInt_t row=rowStart; row<=rowEnd; row++) {
     335           0 :             if (col!=1 && col!=9 && col!=17 && col!=25) { //exclude test columns!!!
     336           0 :               if (fScanObj->GetHits(0,hs,chipNr,col,row)==0) {
     337           0 :                 fHandler->SetDeadPixel(routerNr,hs,chipNr,col,row);
     338           0 :               }
     339             :             }
     340             :           }
     341             :         }
     342           0 :       }
     343             :     }
     344             :   }
     345             :   return kTRUE;
     346           0 : }
     347             : //_________________________________________________________________________
     348             : Bool_t AliITSOnlineSPDscanAnalyzer::ProcessUniformity() {
     349             :   // process uniformity scan data (thanks to Roberta Ferretti for providing this method)
     350           0 :   if (fScanObj==NULL) {
     351           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessUniformity","No data!");
     352           0 :     return kFALSE;
     353             :   }
     354             :   // should be type kUNIMA
     355           0 :   if (fType!=kUNIMA) {
     356           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessUniformity","Only for scan type %d.",kUNIMA);
     357           0 :     return kFALSE;
     358             :   }
     359             : 
     360           0 :   CreateUniformityHistograms(); // create all histograms that will be filled here
     361             : 
     362             :   //  UInt_t routerNr = fScanObj->GetRouterNr();
     363           0 :   UInt_t rowStart = fScanObj->GetRowStart();
     364           0 :   UInt_t rowEnd   = fScanObj->GetRowEnd();
     365           0 :   UInt_t nrTriggers = fScanObj->GetTriggers(0)/(rowEnd-rowStart+1);
     366             : 
     367             :   Float_t pixel100=0;
     368             :   Float_t zeri=0;
     369             :   Float_t pixelN=0;
     370             :   UInt_t numChipsActive=0;
     371             : 
     372           0 :   for (UInt_t hs=0; hs<6; hs++) {
     373             :     Float_t pixel100hs=0;
     374             :     Float_t zerihs=0;
     375             :     Float_t pixelNhs=0;
     376             :     UInt_t numChipsActiveHS=0;
     377             : 
     378           0 :     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
     379             :       Float_t pixel100chip=0;
     380             :       Float_t zerichip=0;
     381             :       Float_t pixelNchip=0;
     382             : 
     383           0 :       if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     384           0 :         numChipsActive++;
     385           0 :         numChipsActiveHS++;
     386             : 
     387           0 :         for (UInt_t col=0; col<32; col++) {
     388           0 :           for (UInt_t row=rowStart; row<=rowEnd; row++) {
     389           0 :             if (col!=1 && col!=9 && col!=17 && col!=25) { //exclude test columns!!!
     390             :             
     391           0 :               if (fScanObj->GetHits(0,hs,chipNr,col,row)==nrTriggers) {   
     392           0 :                         pixel100++;
     393           0 :                         pixel100hs++;
     394           0 :                         pixel100chip++;
     395           0 :               }
     396           0 :               if (fScanObj->GetHits(0,hs,chipNr,col,row)==0) {
     397           0 :                         zeri++;
     398           0 :                         zerihs++;
     399           0 :                         zerichip++;
     400           0 :               }
     401           0 :               if (fScanObj->GetHits(0,hs,chipNr,col,row)>nrTriggers) {    
     402           0 :                         pixelN++;
     403           0 :                         pixelNhs++;
     404           0 :                         pixelNchip++;
     405           0 :               }
     406             :             }
     407             :           }
     408             :         }
     409             :       
     410           0 :         Float_t tPeffChip=(pixel100chip/(28*(rowEnd-rowStart+1)))*100;
     411           0 :         fTPeffChip[hs]->Fill(chipNr,tPeffChip);
     412             :         
     413           0 :         Float_t deadPixelChip=(zerichip/(28*(rowEnd-rowStart+1)))*100;
     414           0 :         fDeadPixelChip[hs]->Fill(chipNr,deadPixelChip);
     415             :         
     416           0 :         Float_t noisyPixelChip=(pixelNchip/(28*(rowEnd-rowStart+1)))*100;
     417           0 :         fNoisyPixelChip[hs]->Fill(chipNr,noisyPixelChip);
     418           0 :       }
     419             :     }
     420             :     
     421           0 :     Float_t tPeffHS=(pixel100hs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
     422           0 :     fTPeffHS->Fill(hs,tPeffHS);
     423             :     
     424           0 :     Float_t deadPixelHS=(zerihs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
     425           0 :     fDeadPixelHS->Fill(hs,deadPixelHS);
     426             :     
     427           0 :     Float_t noisyPixelHS=(pixelNhs/(28*numChipsActiveHS*(rowEnd-rowStart+1)))*100;
     428           0 :     fNoisyPixelHS->Fill(hs,noisyPixelHS);
     429             :   }
     430             :   
     431           0 :   fTPeff=(pixel100/(28*numChipsActive*(rowEnd-rowStart+1)))*100;
     432           0 :   fDeadPixel=(zeri/(28*numChipsActive*(rowEnd-rowStart+1)))*100;
     433           0 :   fNoisyPixel=(pixelN/(28*numChipsActive*(rowEnd-rowStart+1)))*100;
     434             : 
     435             :   return kTRUE;
     436           0 : }
     437             : //_________________________________________________________________________
     438             : void AliITSOnlineSPDscanAnalyzer::CreateUniformityHistograms() {
     439             :   // create uniformity histograms to be filled by "ProcessUniformity" method
     440           0 :   DeleteUniformityHistograms(); // make sure no old histograms are lying around...
     441           0 :   UInt_t eq = GetRouterNr();
     442           0 :   TString label;
     443             : 
     444           0 :   label = Form("Ratio of 'Good' Pixels Per HS (eq %d)",eq);
     445           0 :   fTPeffHS = new TH1F(label.Data(),label.Data(),6,-0.5,5.5);
     446           0 :   fTPeffHS->SetXTitle("hs");
     447           0 :   fTPeffHS->SetYTitle("ratio [%]");
     448           0 :   fTPeffHS->SetFillColor(kBlue);
     449           0 :   fTPeffHS->SetStats(0);
     450             : 
     451           0 :   label = Form("Ratio of 'Dead' Pixels Per HS (eq %d)",eq);
     452           0 :   fDeadPixelHS = new TH1F(label.Data(),label.Data(),6,-0.5,5.5);
     453           0 :   fDeadPixelHS->SetXTitle("hs");
     454           0 :   fDeadPixelHS->SetYTitle("ratio [%]");
     455           0 :   fDeadPixelHS->SetFillColor(kBlue);
     456           0 :   fDeadPixelHS->SetStats(0);
     457             : 
     458           0 :   label = Form("Ratio of 'Noisy' Pixels Per HS (eq %d)",eq);
     459           0 :   fNoisyPixelHS = new TH1F(label.Data(),label.Data(),6,-0.5,5.5);
     460           0 :   fNoisyPixelHS->SetXTitle("hs");
     461           0 :   fNoisyPixelHS->SetYTitle("ratio [%]");
     462           0 :   fNoisyPixelHS->SetFillColor(kBlue);
     463           0 :   fNoisyPixelHS->SetStats(0);
     464             : 
     465           0 :   for (UInt_t hs=0; hs<6; hs++) {
     466           0 :     label = Form("Ratio of 'Good' Pixels Per Chip (eq %d, hs %d)",eq,hs);
     467           0 :     fTPeffChip[hs] = new TH1F(label.Data(),label.Data(),10,-0.5,9.5);
     468           0 :     fTPeffChip[hs]->SetXTitle("chip");
     469           0 :     fTPeffChip[hs]->SetYTitle("ratio [%]");
     470           0 :     fTPeffChip[hs]->SetFillColor(kBlue);
     471           0 :     fTPeffChip[hs]->SetStats(0);
     472             : 
     473           0 :     label = Form("Ratio of 'Dead' Pixels Per Chip (eq %d, hs %d)",eq,hs);
     474           0 :     fDeadPixelChip[hs] = new TH1F(label.Data(),label.Data(),10,-0.5,9.5);
     475           0 :     fDeadPixelChip[hs]->SetXTitle("chip");
     476           0 :     fDeadPixelChip[hs]->SetYTitle("ratio [%]");
     477           0 :     fDeadPixelChip[hs]->SetFillColor(kBlue);
     478           0 :     fDeadPixelChip[hs]->SetStats(0);
     479             : 
     480           0 :     label = Form("Ratio of 'Noisy' Pixels Per Chip (eq %d, hs %d)",eq,hs);
     481           0 :     fNoisyPixelChip[hs] = new TH1F(label.Data(),label.Data(),10,-0.5,9.5);
     482           0 :     fNoisyPixelChip[hs]->SetXTitle("chip");
     483           0 :     fNoisyPixelChip[hs]->SetYTitle("ratio [%]");
     484           0 :     fNoisyPixelChip[hs]->SetFillColor(kBlue);
     485           0 :     fNoisyPixelChip[hs]->SetStats(0);
     486             :   }
     487             : 
     488           0 : }
     489             : //_________________________________________________________________________
     490             : void AliITSOnlineSPDscanAnalyzer::DeleteUniformityHistograms() {
     491             :   // remove uniformity histograms if they are created
     492           0 :   if (fTPeffHS!=NULL) {
     493           0 :     delete fTPeffHS;
     494           0 :     fTPeffHS=NULL;
     495           0 :   }
     496           0 :   if (fDeadPixelHS!=NULL) {
     497           0 :     delete fDeadPixelHS;
     498           0 :     fDeadPixelHS=NULL;
     499           0 :   }
     500           0 :   if (fNoisyPixelHS!=NULL) {
     501           0 :     delete fNoisyPixelHS;
     502           0 :     fNoisyPixelHS=NULL;
     503           0 :   }
     504           0 :   for (UInt_t hs=0; hs<6; hs++) {
     505           0 :     if (fTPeffChip[hs]!=NULL) {
     506           0 :       delete fTPeffChip[hs];
     507           0 :       fTPeffChip[hs]=NULL;
     508           0 :     }
     509           0 :     if (fDeadPixelChip[hs]!=NULL) {
     510           0 :       delete fDeadPixelChip[hs];
     511           0 :       fDeadPixelChip[hs]=NULL;
     512           0 :     }
     513           0 :     if (fNoisyPixelChip[hs]!=NULL) {
     514           0 :       delete fNoisyPixelChip[hs];
     515           0 :       fNoisyPixelChip[hs]=NULL;
     516           0 :     }
     517             :   }
     518           0 : }
     519             : //_________________________________________________________________________
     520             : Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels(/*Char_t *oldcalibDir*/) {
     521             :   // process noisy pixel data
     522           0 :   if (fScanObj==NULL) {
     523           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","No data!");
     524           0 :     return kFALSE;
     525             :   }
     526             :   // should be type kNOISE
     527           0 :   if (fType != kNOISE) {
     528           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Noisy pixels only for scan type %d.",kNOISE);
     529           0 :     return kFALSE;
     530             :   }
     531             :   // handler should be initialized
     532           0 :   if (fHandler==NULL) {
     533           0 :     Error("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Calibration handler is not initialized!");
     534           0 :     return kFALSE;
     535             :   }
     536             :   // check if enough statistics
     537           0 :   if (fScanObj->GetTriggers(0)<fNoiseMinimumEvents) {
     538           0 :     Warning("AliITSOnlineSPDscanAnalyzer::ProcessNoisyPixels","Process noisy: Too few events.");
     539           0 :     return kFALSE;
     540             :   }
     541             : 
     542           0 :   UInt_t routerNr = fScanObj->GetRouterNr();
     543           0 :   for (UInt_t hs=0; hs<6; hs++) {
     544           0 :     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
     545           0 :       if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     546           0 :         if (fOverWrite) {fHandler->ResetNoisyForChip(routerNr,hs,chipNr);}
     547           0 :         for (UInt_t col=0; col<32; col++) {
     548           0 :           for (UInt_t row=0; row<256; row++) {
     549           0 :             if (fScanObj->GetHitsEfficiency(0,hs,chipNr,col,row)>fNoiseThreshold) {
     550           0 :               fHandler->SetNoisyPixel(routerNr,hs,chipNr,col,row);
     551           0 :             }
     552             :           }
     553             :         }
     554           0 :       }
     555             :     }
     556             :   }
     557             :   return kTRUE;
     558           0 : }
     559             : //_________________________________________________________________________
     560             : Int_t AliITSOnlineSPDscanAnalyzer::GetDelay(UInt_t hs, UInt_t chipNr) {
     561             :   // get delay
     562           0 :   if (hs>=6 || chipNr>10) return -1;
     563           0 :   if (fScanObj==NULL) {
     564           0 :     Warning("AliITSOnlineSPDscanAnalyzer::GetDelay","No data!");
     565           0 :     return -1;
     566             :   }
     567             :   // should be type kDELAY or kDAC with id 42 (delay_ctrl)
     568           0 :   if (fType!=kDELAY && (fType!=kDAC || fDacId!=42)) {
     569           0 :     Warning("AliITSOnlineSPDscanAnalyzer::GetDelay","Delay only for scan type %d or %d and dac_id 42.",kDELAY,kDAC);
     570           0 :     return -1;
     571             :   }
     572           0 :   if (fMeanMultiplicity[hs][chipNr]==NULL) {
     573           0 :     if (!ProcessMeanMultiplicity()) {
     574           0 :       return -1;
     575             :     }
     576             :   }
     577             : 
     578             :   UInt_t maxStep=0;
     579             :   Float_t maxVal=0;
     580           0 :   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
     581           0 :     Double_t thisDac;
     582           0 :     Double_t thisMult;
     583           0 :     fMeanMultiplicity[hs][chipNr]->GetPoint(step,thisDac,thisMult);
     584           0 :     if (thisMult > maxVal) {
     585           0 :       maxVal = thisMult;
     586             :       maxStep = step;
     587           0 :     }
     588           0 :   }
     589             : 
     590           0 :   if (maxVal>0) {
     591           0 :     return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(maxStep);
     592             :   }
     593             :   else {
     594           0 :     return -1;
     595             :   }
     596             : 
     597           0 : }
     598             : //_________________________________________________________________________
     599             : Int_t AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima(UInt_t hs, UInt_t chipNr) {
     600             :   // in case of a uniformity scan, returns the nr of noisy pixels, (here > 200 hits)
     601           0 :   if (hs>=6 || chipNr>10) return -1;
     602           0 :   if (fScanObj==NULL) {
     603           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","No data!");
     604           0 :     return kFALSE;
     605             :   }
     606             :   // should be type kUNIMA
     607           0 :   if (fType != kUNIMA) {
     608           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","Noisy pixels Unima only for scan type %d.",kUNIMA);
     609           0 :     return kFALSE;
     610             :   }
     611           0 :   if (fScanObj->GetTriggers(0)!=25600) {
     612           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetNrNoisyUnima","Process noisy unima: Incorrect number of events (!=25600.");
     613           0 :     return kFALSE;
     614             :   }
     615             : 
     616             :   Int_t nrNoisy=0;
     617           0 :   if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     618           0 :     for (UInt_t col=0; col<32; col++) {
     619           0 :       for (UInt_t row=0; row<256; row++) {
     620           0 :         if (fScanObj->GetHits(0,hs,chipNr,col,row)>200) {
     621           0 :           nrNoisy++;
     622           0 :         }
     623             :       }
     624             :     }
     625             :   }
     626             :   else {
     627           0 :     return -1;
     628             :   }
     629           0 :   return nrNoisy;
     630           0 : }
     631             : //_________________________________________________________________________
     632             : Int_t AliITSOnlineSPDscanAnalyzer::FindLastMinThDac(UInt_t hs, UInt_t chipNr) {
     633             :   // returns dac value where fMinIncreaseFromBaseLine reached
     634           0 :   if (hs>=6 || chipNr>10) return -1;
     635           0 :   if (fMeanMultiplicity[hs][chipNr]==NULL) {
     636           0 :     if (!ProcessMeanMultiplicity()) {
     637           0 :       return -1;
     638             :     }
     639             :   }
     640           0 :   Double_t firstVal, dummy1;
     641           0 :   fMeanMultiplicity[hs][chipNr]->GetPoint(0,dummy1,firstVal);
     642             :   UInt_t step=0;
     643           0 :   while (step<fScanObj->GetNSteps()-1) {
     644           0 :     Double_t graphVal, dummy2;
     645           0 :     fMeanMultiplicity[hs][chipNr]->GetPoint(step+1,dummy2,graphVal);
     646           0 :     if (graphVal>firstVal+fMinIncreaseFromBaseLine) break;
     647             :     step++;
     648           0 :   }
     649           0 :   if (step==fScanObj->GetNSteps()-1) return -1;
     650           0 :   return ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step);
     651           0 : }
     652             : 
     653             : Int_t AliITSOnlineSPDscanAnalyzer::FindClosestLowerStep(Float_t dacValueInput) {
     654             :   // returns step closest (lower) to a dacvalue 
     655             :   UInt_t step=0;
     656           0 :   while (step<fScanObj->GetNSteps()-1) {
     657           0 :     Int_t dacVal = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step+1);
     658           0 :     if (dacVal>=dacValueInput) break;
     659             :     step++;
     660           0 :   }
     661           0 :   return step;
     662             : }
     663             : //_________________________________________________________________________
     664             : Float_t AliITSOnlineSPDscanAnalyzer::GetCompareLine(UInt_t step, UInt_t hs, UInt_t chipNr, Float_t basePar2) {
     665             :   // returns value to compare mean mult with (when finding min th)
     666           0 :   if (hs>=6 || chipNr>10) return -1;
     667           0 :   if (step<fMinNrStepsBeforeIncrease) return -1;
     668             :   Float_t baseLine = basePar2;
     669           0 :   if (baseLine<0) baseLine=0;
     670             :   Float_t baseAdd;
     671             :   Double_t baseM=0;
     672             :   Double_t baseS=0;
     673           0 :   Double_t d,m;
     674           0 :   for (UInt_t st=1;st<2*step/3;st++) { // skip first point...
     675           0 :     fMeanMultiplicity[hs][chipNr]->GetPoint(st,d,m);
     676           0 :     baseM+=m-baseLine;
     677           0 :     baseS+=(m-baseLine)*(m-baseLine);
     678             :   }
     679           0 :   baseAdd=2*sqrt( baseS/(2*step/3-1) - (baseM/(2*step/3-1))*(baseM/(2*step/3-1)) );
     680           0 :   baseAdd+=0.03; // magic number
     681           0 :   if (baseAdd>fMinIncreaseFromBaseLine) baseAdd=fMinIncreaseFromBaseLine;
     682           0 :   return baseLine + baseAdd;
     683           0 : }
     684             : 
     685             : Int_t AliITSOnlineSPDscanAnalyzer::GetMinTh(UInt_t hs, UInt_t chipNr) {
     686             :   // calculates and returns the minimum threshold
     687           0 :   if (hs>=6 || chipNr>10) return -1;
     688           0 :   if (fScanObj==NULL) {
     689           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetMinTh","No data!");
     690           0 :     return -1;
     691             :   }
     692             :   // should be type  kMINTH  or  kDAC with id 39 (pre_vth)
     693           0 :   if (fType!=kMINTH && (fType!=kDAC || fDacId!=39)) {
     694           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetMinTh","MinTh only for scan type %d OR %d with dac_id 39.",kMINTH,kDAC);
     695           0 :     return -1;
     696             :   }
     697           0 :   if (fMeanMultiplicity[hs][chipNr]==NULL) {
     698           0 :     if (!ProcessMeanMultiplicity()) {
     699           0 :       return -1;
     700             :     }
     701             :   }
     702             : 
     703           0 :   Int_t lastDac = FindLastMinThDac(hs,chipNr);
     704           0 :   if (lastDac==-1) {
     705           0 :     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Increase of Mean Multiplicity by %1.2f never reached.",hs,chipNr,fMinIncreaseFromBaseLine);
     706           0 :     return -1;
     707             :   }
     708             : 
     709           0 :   Int_t minDac = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(0);
     710           0 :   TString funcName = Form("Fit minth func HS%d CHIP%d",hs,chipNr);
     711           0 :   TF1 *minThFunc = new TF1(funcName.Data(),itsSpdErrorf,100,500,3);
     712           0 :   minThFunc->SetParameter(0,lastDac+10);
     713           0 :   minThFunc->SetParameter(1,2);
     714           0 :   minThFunc->SetParameter(2,0);
     715           0 :   minThFunc->SetParName(0,"Mean");
     716           0 :   minThFunc->SetParName(1,"Sigma");
     717           0 :   minThFunc->SetParName(2,"BaseLine");
     718           0 :   minThFunc->SetLineWidth(1);
     719           0 :   if (fMeanMultiplicity[hs][chipNr]==NULL) {
     720           0 :     if (!ProcessMeanMultiplicity()) {
     721           0 :       return -1;
     722             :     }
     723             :   }
     724           0 :   fMeanMultiplicity[hs][chipNr]->Fit(funcName,"Q0","",minDac,lastDac);
     725             : 
     726             :   //  Double_t mean = fMinThFunc[hs][chipNr]->GetParameter(0);
     727             :   //  Double_t sigma = fMinThFunc[hs][chipNr]->GetParameter(1);
     728           0 :   Double_t baseLine = minThFunc->GetParameter(2);
     729           0 :   delete minThFunc;
     730             : 
     731           0 :   if (baseLine>fMaxBaseLineLevel) {
     732           0 :     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: BaseLine too large (%1.2f>%1.2f).",hs,chipNr,baseLine,fMaxBaseLineLevel);
     733           0 :     return -1;
     734             :   }
     735           0 :   UInt_t step=FindClosestLowerStep(lastDac);
     736           0 :   Float_t compareLine = GetCompareLine(step,hs,chipNr,baseLine);
     737           0 :   if (compareLine==-1) {
     738           0 :     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Not enough steps (%d<%d) before increase to get a compare line.",hs,chipNr,step,fMinNrStepsBeforeIncrease);
     739           0 :     return -1;
     740             :   }
     741             : 
     742           0 :   Double_t mult, dummy;
     743           0 :   mult=1000;
     744           0 :   while (mult > compareLine && step>0) {
     745           0 :     fMeanMultiplicity[hs][chipNr]->GetPoint(step,dummy,mult);
     746           0 :     step--;
     747             :   }
     748           0 :   Int_t minth = ((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step+1)-fStepDownDacSafe;
     749             : 
     750           0 :   if (step>0) {
     751           0 :     return minth;
     752             :   }
     753             :   else {
     754           0 :     Warning("AliITSOnlineSPDscanAnalyzer::GetMinTh","HS%d, Chip%d: Did not find a point below the compare line (%f).",hs,chipNr,compareLine);
     755           0 :     return -1;
     756             :   }
     757           0 : }
     758             : //_________________________________________________________________________
     759             : TArrayI AliITSOnlineSPDscanAnalyzer::GetMeanTh(UInt_t hs, UInt_t chipNr) {
     760             :   // calculates and returns the mean threshold
     761           0 :   TArrayI fitresults(4);
     762           0 :   if (hs>=6 || chipNr>10) return fitresults;
     763           0 :   if (fScanObj==NULL) {
     764           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetMeanTh","No data!");
     765           0 :     return fitresults;
     766             :   }
     767             :   // should be type  kMEANTH  or  kDAC with id 39
     768           0 :   if (fType!=kMEANTH && (fType!=kDAC || fDacId!=105)) {
     769           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetMeanTh","MeanTh only for scan type %d OR %d with dac_id 105.",kMEANTH,kDAC);
     770           0 :     return fitresults;
     771             :   }
     772           0 :   if (fHitEventEfficiency[hs][chipNr]==NULL) {
     773           0 :    printf("processing hit efficiency \n");
     774           0 :     if (!ProcessHitEventEfficiency()) {
     775           0 :       printf("...not processed!!\n");
     776           0 :       return fitresults;
     777             :     }
     778             :   }
     779           0 :   Double_t x,y;
     780           0 :   fHitEventEfficiency[hs][chipNr]->GetPoint(fHitEventEfficiency[hs][chipNr]->GetN()-1,x,y);
     781           0 :   Double_t min = x;
     782           0 :   fHitEventEfficiency[hs][chipNr]->GetPoint(0,x,y);
     783           0 :   Double_t max = x;
     784             : 
     785           0 :   Double_t mean = 0.5*(min+max);
     786           0 :   TString funcName = Form("Fit meanth func HS%d CHIP%d",hs,chipNr);
     787           0 :   TF1 *minThFunc = new TF1(funcName.Data(),itsSpdScurveForMeanTh,min,max,3);
     788           0 :   minThFunc->SetParameter(0,mean);
     789           0 :   minThFunc->SetParameter(1,264); //  4 (mV) * 66 (el)
     790           0 :   minThFunc->SetParLimits(1,100,1000); // minimum value is 1 mV (-> 100 in TPAmplitude)
     791           0 :   minThFunc->SetParameter(2,0.4);
     792           0 :   minThFunc->SetParName(0,"Mean");
     793           0 :   minThFunc->SetParName(1,"Sigma");
     794           0 :   minThFunc->SetParName(2,"Half");
     795           0 :   minThFunc->SetLineWidth(1);
     796             : 
     797           0 :   fHitEventEfficiency[hs][chipNr]->Fit(funcName,"Q","",min,max);
     798             : 
     799           0 :   fitresults.AddAt((Int_t)minThFunc->GetParameter(0),0);
     800           0 :   fitresults.AddAt((Int_t)minThFunc->GetParError(0),1);
     801           0 :   fitresults.AddAt((Int_t)minThFunc->GetParameter(1),2);
     802           0 :   fitresults.AddAt((Int_t)minThFunc->GetParError(1),3);
     803           0 :   TLine *ly = new TLine((Double_t)min,0.5,(Double_t)fitresults.At(0),0.5); ly->SetLineStyle(6);
     804           0 :   ly->Draw("same");
     805           0 :   TLine *lx = new TLine((Double_t)fitresults.At(0),0.,(Double_t)fitresults.At(0),0.5);
     806           0 :   lx->SetLineStyle(6);
     807           0 :   lx->Draw("same");
     808           0 :   delete minThFunc;
     809             :   
     810             :   return fitresults;
     811           0 : }
     812             : 
     813             : //_________________________________________________________________________
     814             : Bool_t AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity() {
     815             :   // process mean multiplicity data
     816           0 :   if (fScanObj==NULL) {
     817           0 :     Error("AliITSOnlineSPDscanAnalyzer::ProcessMeanMultiplicity","No data!");
     818           0 :     return kFALSE;
     819             :   }
     820           0 :   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
     821           0 :     for (UInt_t hs=0; hs<6; hs++) {
     822           0 :       for (UInt_t chipNr=0; chipNr<11; chipNr++) {
     823             :         //      if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     824           0 :         if (step==0) {
     825           0 :           if (fMeanMultiplicity[hs][chipNr]!=NULL) {
     826           0 :             delete fMeanMultiplicity[hs][chipNr];
     827             :           }
     828           0 :           fMeanMultiplicity[hs][chipNr] = new TGraph();
     829           0 :         }
     830           0 :         Float_t multiplMean=fScanObj->GetAverageMultiplicity(step,hs,chipNr);
     831           0 :         if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
     832           0 :           fMeanMultiplicity[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),multiplMean);
     833           0 :         }
     834             :         else {
     835           0 :           fMeanMultiplicity[hs][chipNr]->SetPoint(step,0,multiplMean);
     836             :         }
     837             :       }
     838             :       //      }
     839             :     }
     840             :   }
     841           0 :   return kTRUE;
     842           0 : }
     843             : //_________________________________________________________________________
     844             : TGraph* AliITSOnlineSPDscanAnalyzer::GetMeanMultiplicityG(UInt_t hs, UInt_t chipNr) {
     845             :   // returns mean multiplicity graph
     846           0 :   if (hs>=6 || chipNr>10) return NULL;
     847           0 :   if (fMeanMultiplicity[hs][chipNr]==NULL) {
     848           0 :     if (!ProcessMeanMultiplicity()) {
     849           0 :       return NULL;
     850             :     }
     851             :   }
     852           0 :   return fMeanMultiplicity[hs][chipNr];
     853           0 : }
     854             : //_________________________________________________________________________
     855             : Bool_t AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency() {
     856             :   // process hit event efficiency
     857           0 :   if (fScanObj==NULL) {
     858           0 :     Error("AliITSOnlineSPDscanAnalyzer::ProcessHitEventEfficiency","No data!");
     859           0 :     return kFALSE;
     860             :   }
     861           0 :   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
     862           0 :     for (UInt_t hs=0; hs<6; hs++) {
     863           0 :       for (UInt_t chipNr=0; chipNr<11; chipNr++) {
     864             :         //      if (fScanObj->GetChipPresent(hs,chipNr)) { // check the status of the chippresent parameter in the mood header!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     865           0 :         if (step==0) {
     866           0 :           if (fHitEventEfficiency[hs][chipNr]!=NULL) {
     867           0 :             delete fHitEventEfficiency[hs][chipNr];
     868             :           }
     869           0 :           fHitEventEfficiency[hs][chipNr] = new TGraph();
     870           0 :         }
     871           0 :         Float_t efficiency=fScanObj->GetHitEventsEfficiency(step,hs,chipNr);
     872           0 :         if (fType==kMINTH || fType==kDAC || fType==kDELAY) {
     873           0 :           fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),efficiency);
     874           0 :         } else if(fType==kMEANTH){
     875           0 :           fHitEventEfficiency[hs][chipNr]->SetPoint(step,((AliITSOnlineSPDscanMeanTh*)fScanObj)->GetTPAmp(step,hs),efficiency);
     876           0 :         } else {
     877           0 :           fHitEventEfficiency[hs][chipNr]->SetPoint(step,0,efficiency);
     878             :         }
     879             :       }
     880             :       //      }
     881             :     }
     882             :   }
     883           0 :   return kTRUE;
     884           0 : }
     885             : //_________________________________________________________________________
     886             : TGraph* AliITSOnlineSPDscanAnalyzer::GetHitEventEfficiencyG(UInt_t hs, UInt_t chipNr) {
     887             :   // returns hit event efficiency graph
     888           0 :   if (hs>=6 || chipNr>10) return NULL;
     889           0 :   if (fHitEventEfficiency[hs][chipNr]==NULL) {
     890           0 :     if (!ProcessHitEventEfficiency()) {
     891           0 :       return NULL;
     892             :     }
     893             :   }
     894           0 :   return fHitEventEfficiency[hs][chipNr];
     895           0 : }
     896             : //_________________________________________________________________________
     897             : Bool_t AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers() {
     898             :   // process nr of triggers data
     899           0 :   if (fScanObj==NULL) {
     900           0 :     Error("AliITSOnlineSPDscanAnalyzer::ProcessNrTriggers","No data!");
     901           0 :     return kFALSE;
     902             :   }
     903           0 :   for (UInt_t step=0; step<fScanObj->GetNSteps(); step++) {
     904           0 :     if (step==0) {
     905           0 :       if (fTriggers!=NULL) {
     906           0 :         delete fTriggers;
     907             :       }
     908           0 :       fTriggers = new TGraph();
     909           0 :     }
     910           0 :     if (fType==kMINTH || fType==kMEANTH || fType==kDAC || fType==kDELAY) {
     911           0 :       fTriggers->SetPoint(step,((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step),fScanObj->GetTriggers(step));
     912           0 :     }
     913             :     else {
     914           0 :       fTriggers->SetPoint(step,0,fScanObj->GetTriggers(step));
     915             :     }
     916             :   }
     917           0 :   return kTRUE;
     918           0 : }
     919             : //_________________________________________________________________________
     920             : TGraph* AliITSOnlineSPDscanAnalyzer::GetNrTriggersG() {
     921             :   // returns nr of triggers graph
     922           0 :   if (fTriggers==NULL) {
     923           0 :     if (!ProcessNrTriggers()) {
     924           0 :       return NULL;
     925             :     }
     926             :   }
     927           0 :   return fTriggers;
     928           0 : }
     929             : //_________________________________________________________________________
     930             : Bool_t AliITSOnlineSPDscanAnalyzer::GetHalfStavePresent(UInt_t hs) {
     931             :   // returns half stave present info
     932           0 :   if (hs<6 && fScanObj!=NULL) {
     933             :     Int_t chipstatus=0;
     934           0 :     for (Int_t chip=0; chip<10; chip++) {
     935           0 :       chipstatus+=fScanObj->GetChipPresent(hs,chip);
     936             :     }
     937           0 :     if (chipstatus>0) return kTRUE;
     938           0 :   }
     939           0 :   return kFALSE;
     940           0 : }
     941             : //_________________________________________________________________________
     942             : UInt_t AliITSOnlineSPDscanAnalyzer::GetRouterNr() {
     943             :   // returns the router nr of scan obj
     944           0 :   if (fScanObj!=NULL) return fScanObj->GetRouterNr(); 
     945           0 :   else return 99;
     946           0 : }
     947             : //_________________________________________________________________________
     948             : TH2F* AliITSOnlineSPDscanAnalyzer::GetHitMapTot(UInt_t step) {
     949             :   // creates and returns a pointer to a hitmap histo (half sector style a la spdmood)
     950           0 :   if (fScanObj==NULL) {
     951           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetHitMapTot","No data!");
     952           0 :     return NULL;
     953             :   }
     954           0 :   TString histoname;
     955           0 :   if (fType==kMINTH || fType==kMEANTH || fType==kDAC) {
     956           0 :     histoname = Form("Router %d , DAC %d",GetRouterNr(),((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step));
     957             :   }
     958             :   else {
     959           0 :     histoname = Form("Router %d ",GetRouterNr());
     960             :   }
     961           0 :   TH2F* fHitMapTot = new TH2F(histoname.Data(),histoname.Data(),32*10,-0.5,32*10-0.5,256*6,-0.5,256*6-0.5);
     962           0 :   fHitMapTot->SetNdivisions(-10,"X");
     963           0 :   fHitMapTot->SetNdivisions(-006,"Y");
     964           0 :   fHitMapTot->SetTickLength(0,"X");
     965           0 :   fHitMapTot->SetTickLength(0,"Y");
     966           0 :   fHitMapTot->GetXaxis()->SetLabelColor(gStyle->GetCanvasColor());
     967           0 :   fHitMapTot->GetYaxis()->SetLabelColor(gStyle->GetCanvasColor());
     968           0 :   for (UInt_t hs=0; hs<6; hs++) {
     969           0 :     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
     970           0 :       for (UInt_t col=0; col<32; col++) {
     971           0 :         for (UInt_t row=0; row<256; row++) {
     972           0 :           fHitMapTot->Fill(chipNr*32+col,(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
     973             :         }
     974             :       }
     975             :     }
     976             :   }
     977             :   return fHitMapTot;
     978           0 : }
     979             : //_________________________________________________________________________
     980             : TH2F* AliITSOnlineSPDscanAnalyzer::GetPhysicalHitMapTot(UInt_t step) {
     981             :   // creates and returns a pointer to a hitmap histo (-> 1 equpment opened up)
     982             : 
     983           0 :   if (fScanObj==NULL) {
     984           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetHitMapTot","No data!");
     985           0 :     return NULL;
     986             :   }
     987           0 :   TString histoname;
     988           0 :   if (fType==kMINTH || fType==kMEANTH || fType==kDAC) {
     989           0 :     histoname = Form("Router %d , DAC %d",GetRouterNr(),((AliITSOnlineSPDscanMultiple*)fScanObj)->GetDacValue(step));
     990             :   }
     991             :   else {
     992           0 :     histoname = Form("Router %d ",GetRouterNr());
     993             :   }
     994           0 :   TH2F* hPhysicalHitMapTot = new TH2F(histoname.Data(),histoname.Data(),32*10,-0.5,32*10-0.5,256*6,-0.5,256*6-0.5);
     995           0 :   hPhysicalHitMapTot->SetNdivisions(-10,"X");
     996           0 :   hPhysicalHitMapTot->SetNdivisions(-006,"Y");
     997           0 :   hPhysicalHitMapTot->SetTickLength(0,"X");
     998           0 :   hPhysicalHitMapTot->SetTickLength(0,"Y");
     999           0 :   hPhysicalHitMapTot->GetXaxis()->SetLabelColor(gStyle->GetCanvasColor());
    1000           0 :   hPhysicalHitMapTot->GetYaxis()->SetLabelColor(gStyle->GetCanvasColor());
    1001             :   Int_t correctChip = -1;
    1002           0 :   for (UInt_t hs=0; hs<6; hs++) {
    1003           0 :     for (UInt_t chipNr=0; chipNr<10; chipNr++) {
    1004           0 :     if(GetRouterNr()<10) correctChip = 9-chipNr;
    1005             :     else correctChip=chipNr;
    1006           0 :       for (UInt_t col=0; col<32; col++) {
    1007           0 :         for (UInt_t row=0; row<256; row++) {
    1008           0 :           if(hs<2) hPhysicalHitMapTot->Fill(correctChip*32+col,(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
    1009           0 :           else hPhysicalHitMapTot->Fill(correctChip*32+(31-col),(5-hs)*256+row,fScanObj->GetHits(step,hs,chipNr,col,row));
    1010             :         }
    1011             :       }
    1012             :     }
    1013             :   }
    1014             :   return hPhysicalHitMapTot;
    1015           0 : }
    1016             : 
    1017             : //_________________________________________________________________________
    1018             : TH2F* AliITSOnlineSPDscanAnalyzer::GetHitMapChip(UInt_t step, UInt_t hs, UInt_t chip) {
    1019             :   // creates and returns a pointer to a hitmap histo (chip style a la spdmood)
    1020           0 :   if (fScanObj==NULL) {
    1021           0 :     Error("AliITSOnlineSPDscanAnalyzer::GetHitMapChip","No data!");
    1022           0 :     return NULL;
    1023             :   }
    1024             : 
    1025           0 :   TString histoName;
    1026           0 :   TString histoTitle;
    1027           0 :   histoName = Form("fChipHisto_%d_%d_%d", GetRouterNr(), hs, chip);
    1028           0 :   histoTitle = Form("Eq ID %d, Half Stave %d, Chip %d ", GetRouterNr(), hs, chip);
    1029             : 
    1030           0 :   TH2F *returnHisto = new TH2F(histoName.Data(), histoTitle.Data(), 32, -0.5, 31.5, 256, -0.5, 255.5);
    1031           0 :   returnHisto->SetMinimum(0);
    1032           0 :   for (UInt_t col=0; col<32; col++) {
    1033           0 :     for (UInt_t row=0; row<256; row++) {
    1034           0 :       if(hs<2) returnHisto->Fill(31-col,row,fScanObj->GetHits(step,hs,chip,col,row));
    1035           0 :       else returnHisto->Fill(col,row,fScanObj->GetHits(step,hs,chip,col,row));
    1036             :     }
    1037             :   }
    1038             : 
    1039             :   return returnHisto;
    1040           0 : }
    1041             : 

Generated by: LCOV version 1.11