ROOT logo
#ifndef ALIITSONLINESPDSCAN_H
#define ALIITSONLINESPDSCAN_H

////////////////////////////////////////////////////////////
// Author: Henrik Tydesjo                                 //
// Interface class to the containers of an online scan.   //
// Directly connected to a TFile with all containers.     //
// Handles reading and writing of this TFile.             //
// Hitmaps and information on nr of events with hits      //
// is stored in this file (AliITSOnlineSPDHitArray and    //
// AliITSOnlineSPDHitEvent). Also some general            //
// information is stored (AliITSOnlineSPDscanInfo).       //
////////////////////////////////////////////////////////////

#include <TString.h>

class TFile;
class AliITSOnlineSPDscanInfo;
class AliITSOnlineSPDHitArray;
class AliITSOnlineSPDHitEvent;

class AliITSOnlineSPDscan {

 public:
  AliITSOnlineSPDscan():fFile(NULL),fWrite(kFALSE),fCurrentStep(-1),fModified(kFALSE),fInfoModified(kFALSE),fScanInfo(NULL),fFileName("./test.root"){for(Int_t ihs=0; ihs<6; ihs++){fCurrentHitArray[ihs]=0x0; fCurrentHitEvent[ihs]=0x0;}}
  AliITSOnlineSPDscan(const Char_t *fileName, Bool_t readFromGridFile=kFALSE);
  AliITSOnlineSPDscan(const AliITSOnlineSPDscan& scan);
  virtual ~AliITSOnlineSPDscan();
  AliITSOnlineSPDscan& operator=(const AliITSOnlineSPDscan& scan);

  virtual UInt_t     AddScanStep(); // returns the index (nsi) of the added step
  virtual void       ClearThis();       // clear all steps
  // SET METHODS ***********************************
  void     SetType(UInt_t val);
  void     SetRunNr(UInt_t val);
  void     SetRouterNr(UInt_t val);
  void     SetHalfStaveScanned(UInt_t val, Bool_t b);
  void     SetDataFormat(UInt_t val);
  void     SetTriggers(UInt_t nsi, UInt_t val);
  void     SetChipPresent(UInt_t hs, UInt_t chipi, Bool_t val);
  void     SetRowStart(UInt_t val);
  void     SetRowEnd(UInt_t val);
  void     SetDacStart(UInt_t val);
  void     SetDacEnd(UInt_t val);
  void     SetDacStep(UInt_t val);
  void     SetDCSVersion(UInt_t val);

  void     SetHits(UInt_t nsi, UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi, UInt_t val);
  void     IncrementTriggers(UInt_t nsi);
  void     IncrementHits(UInt_t nsi, UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi);
  void     SetHitEvents(UInt_t nsi, UInt_t hs, UInt_t chipi, Int_t val);
  void     SetHitEventsTot(UInt_t nsi, UInt_t hs, Int_t val);
  void     IncrementHitEvents(UInt_t nsi, UInt_t hs, UInt_t chipi);
  void     IncrementHitEventsTot(UInt_t nsi, UInt_t hs);
  // GET METHODS ***********************************
  UInt_t   GetNSteps() const;
  UInt_t   GetType() const;
  UInt_t   GetRunNr() const;
  UInt_t   GetRouterNr() const;
  Bool_t   GetHalfStaveScanned(UInt_t val) const;
  UInt_t   GetDataFormat() const;
  UInt_t   GetTriggers(UInt_t nsi) const;
  Bool_t   GetChipPresent(UInt_t hs, UInt_t chipi) const;
  UInt_t   GetRowStart() const;
  UInt_t   GetRowEnd() const;
  UInt_t   GetDacStart() const;
  UInt_t   GetDacEnd() const;
  UInt_t   GetDacStep() const;
  UInt_t   GetDCSVersion() const;

  UInt_t   GetHits(UInt_t nsi, UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi) ;
  Float_t  GetHitsEfficiency(UInt_t nsi, UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi) ;
  Float_t  GetHitsEfficiencyError(UInt_t nsi, UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi);
  UInt_t   GetHitEvents(UInt_t nsi, UInt_t hs, UInt_t chipi) ;
  UInt_t   GetHitEventsTot(UInt_t nsi, UInt_t hs) ;
  Float_t  GetHitEventsEfficiency(UInt_t nsi, UInt_t hs, UInt_t chipi) ;
  Float_t  GetHitEventsTotEfficiency(UInt_t nsi, UInt_t hs) ;
  Float_t  GetHitEventsEfficiencyError(UInt_t nsi, UInt_t hs, UInt_t chipi) ;
  Float_t  GetHitEventsTotEfficiencyError(UInt_t nsi, UInt_t hs) ;
  Float_t  GetAverageMultiplicity(UInt_t nsi, UInt_t hs, UInt_t chipi) ;
  Float_t  GetAverageMultiplicityTot(UInt_t nsi, UInt_t hs) ;

 protected:
  TFile    *fFile;                  // file to read and write from
  Bool_t   fWrite;                  // is file opened for writing?
  Int_t    fCurrentStep;            // index of current step (kept in memory)
  Bool_t   fModified;               // is the current step modified (needs saving)?
  Bool_t   fInfoModified;           // is the overall scan information modified (needs saving)?
  AliITSOnlineSPDscanInfo *fScanInfo;           // overall scan information
  AliITSOnlineSPDHitArray *fCurrentHitArray[6]; // hit array, one for each halfstave
  AliITSOnlineSPDHitEvent *fCurrentHitEvent[6]; // hit events, one for each halfstave
  TString  fFileName;                           // filename of file to read write

  void     Init();
  void     CreateNewStep();
  void     SwitchToStep(UInt_t nsi) ;
  void     FillGap(UInt_t nsi);
  void     ReadCurrentStep();
  void     SaveCurrentStep();
  
};

#endif
 AliITSOnlineSPDscan.h:1
 AliITSOnlineSPDscan.h:2
 AliITSOnlineSPDscan.h:3
 AliITSOnlineSPDscan.h:4
 AliITSOnlineSPDscan.h:5
 AliITSOnlineSPDscan.h:6
 AliITSOnlineSPDscan.h:7
 AliITSOnlineSPDscan.h:8
 AliITSOnlineSPDscan.h:9
 AliITSOnlineSPDscan.h:10
 AliITSOnlineSPDscan.h:11
 AliITSOnlineSPDscan.h:12
 AliITSOnlineSPDscan.h:13
 AliITSOnlineSPDscan.h:14
 AliITSOnlineSPDscan.h:15
 AliITSOnlineSPDscan.h:16
 AliITSOnlineSPDscan.h:17
 AliITSOnlineSPDscan.h:18
 AliITSOnlineSPDscan.h:19
 AliITSOnlineSPDscan.h:20
 AliITSOnlineSPDscan.h:21
 AliITSOnlineSPDscan.h:22
 AliITSOnlineSPDscan.h:23
 AliITSOnlineSPDscan.h:24
 AliITSOnlineSPDscan.h:25
 AliITSOnlineSPDscan.h:26
 AliITSOnlineSPDscan.h:27
 AliITSOnlineSPDscan.h:28
 AliITSOnlineSPDscan.h:29
 AliITSOnlineSPDscan.h:30
 AliITSOnlineSPDscan.h:31
 AliITSOnlineSPDscan.h:32
 AliITSOnlineSPDscan.h:33
 AliITSOnlineSPDscan.h:34
 AliITSOnlineSPDscan.h:35
 AliITSOnlineSPDscan.h:36
 AliITSOnlineSPDscan.h:37
 AliITSOnlineSPDscan.h:38
 AliITSOnlineSPDscan.h:39
 AliITSOnlineSPDscan.h:40
 AliITSOnlineSPDscan.h:41
 AliITSOnlineSPDscan.h:42
 AliITSOnlineSPDscan.h:43
 AliITSOnlineSPDscan.h:44
 AliITSOnlineSPDscan.h:45
 AliITSOnlineSPDscan.h:46
 AliITSOnlineSPDscan.h:47
 AliITSOnlineSPDscan.h:48
 AliITSOnlineSPDscan.h:49
 AliITSOnlineSPDscan.h:50
 AliITSOnlineSPDscan.h:51
 AliITSOnlineSPDscan.h:52
 AliITSOnlineSPDscan.h:53
 AliITSOnlineSPDscan.h:54
 AliITSOnlineSPDscan.h:55
 AliITSOnlineSPDscan.h:56
 AliITSOnlineSPDscan.h:57
 AliITSOnlineSPDscan.h:58
 AliITSOnlineSPDscan.h:59
 AliITSOnlineSPDscan.h:60
 AliITSOnlineSPDscan.h:61
 AliITSOnlineSPDscan.h:62
 AliITSOnlineSPDscan.h:63
 AliITSOnlineSPDscan.h:64
 AliITSOnlineSPDscan.h:65
 AliITSOnlineSPDscan.h:66
 AliITSOnlineSPDscan.h:67
 AliITSOnlineSPDscan.h:68
 AliITSOnlineSPDscan.h:69
 AliITSOnlineSPDscan.h:70
 AliITSOnlineSPDscan.h:71
 AliITSOnlineSPDscan.h:72
 AliITSOnlineSPDscan.h:73
 AliITSOnlineSPDscan.h:74
 AliITSOnlineSPDscan.h:75
 AliITSOnlineSPDscan.h:76
 AliITSOnlineSPDscan.h:77
 AliITSOnlineSPDscan.h:78
 AliITSOnlineSPDscan.h:79
 AliITSOnlineSPDscan.h:80
 AliITSOnlineSPDscan.h:81
 AliITSOnlineSPDscan.h:82
 AliITSOnlineSPDscan.h:83
 AliITSOnlineSPDscan.h:84
 AliITSOnlineSPDscan.h:85
 AliITSOnlineSPDscan.h:86
 AliITSOnlineSPDscan.h:87
 AliITSOnlineSPDscan.h:88
 AliITSOnlineSPDscan.h:89
 AliITSOnlineSPDscan.h:90
 AliITSOnlineSPDscan.h:91
 AliITSOnlineSPDscan.h:92
 AliITSOnlineSPDscan.h:93
 AliITSOnlineSPDscan.h:94
 AliITSOnlineSPDscan.h:95
 AliITSOnlineSPDscan.h:96
 AliITSOnlineSPDscan.h:97
 AliITSOnlineSPDscan.h:98
 AliITSOnlineSPDscan.h:99
 AliITSOnlineSPDscan.h:100
 AliITSOnlineSPDscan.h:101
 AliITSOnlineSPDscan.h:102
 AliITSOnlineSPDscan.h:103