ROOT logo
#ifndef ALITRDTENDERSUPPLY_H
#define ALITRDTENDERSUPPLY_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

////////////////////////////////////////////////////////////////////////
//                                                                    //
//  TRD tender, reapply pid on the fly                                //
//                                                                    //
////////////////////////////////////////////////////////////////////////



#include <AliTenderSupply.h>

class AliTRDCalDet;
class AliESDEvent;
class AliOADBContainer;
class AliTRDonlineTrackMatching;

class AliTRDTenderSupply: public AliTenderSupply {
  
public:
  enum{
    kNNpid = 0,
    k1DLQpid = 1,
    k2DLQpid = 2
  };
  AliTRDTenderSupply();
  AliTRDTenderSupply(const char *name, const AliTender *tender=NULL);
  virtual ~AliTRDTenderSupply();

  void SetRunByRunCorrection(const char *filename) { fNameRunByRunCorrection = filename; }
//  void SetLoadReferencesFromCDB() { fLoadReferences = kTRUE; fLoadReferencesFromCDB = kTRUE; }
//  void SetLoadReferencesFromFile() { fLoadReferences = kTRUE; fLoadReferencesFromCDB = kFALSE; }
  void SetLoadDeadChambersFromCDB(){ fLoadDeadChambers = kTRUE;} ;
  void SetPIDmethod(Int_t pidMethod) { fPIDmethod = pidMethod; }
  void SetNormalizationFactor(Double_t norm, Int_t runMin, Int_t runMax);
  void SetNormalizationFactor(Double_t norm) { fNormalizationFactor = norm; }
  void SetCalibLowpThreshold(Double_t pmin) { fPthreshold = pmin; };
  void SetGeoFile(const char *filename) { fGeoFile = filename; }
  void SetDebugMode() { fDebugMode = kTRUE; }
  void SetRedoTRDMatching(Bool_t redo = kTRUE) {fRedoTrdMatching = redo;}

  virtual void              Init();
  virtual void              ProcessEvent();
  
  void SwitchOnGainCorrection() { fGainCorrection = kTRUE; }
  void SwitchOffGainCorrection() { fGainCorrection = kFALSE; }
  void SetSlicesForPID(UInt_t min, UInt_t max) { fSlicesForPID[0] = min; fSlicesForPID[1] = max;}
  void AddBadChamber(Int_t chamberID){fBadChamberID[fNBadChambers++] = chamberID;};
  
private:
  enum{
    kNPlanes = 6,
    kNStacks = 5,
    kNChambers = 540
  };

  Bool_t GetTRDchamberID(AliESDtrack * const track, Int_t *detectors);
  void SetChamberGain();
  void ApplyGainCorrection(AliESDtrack *track, const Int_t * const detectors);
  void ApplyRunByRunCorrection(AliESDtrack *const track);
  void MaskChambers(AliESDtrack * const track, const Int_t * const detectors); 
  void LoadReferences();
  void LoadDeadChambersFromCDB();
  void LoadRunByRunCorrection(const char *filename);
  Bool_t IsBadChamber(Int_t chamberID);
  Double_t GetNormalizationFactor(Int_t runnumber);
  
  AliESDEvent           *fESD;       //! the ESD Event
  AliESDpid             *fESDpid;    //! ESD PID object
  AliTRDonlineTrackMatching  *fTrdOnlineTrackMatcher;   //! TRD online track matcher

  AliTRDCalDet *fChamberGainOld;     // TRD Chamber Gain Factor used for producing the ESD
  AliTRDCalDet *fChamberGainNew;     // New TRD Chamber Gain Factor
  AliTRDCalDet *fChamberVdriftOld;   // Old drift velocity calibration
  AliTRDCalDet *fChamberVdriftNew;   // New drift velocity calibration
  AliOADBContainer *fRunByRunCorrection;    // Run by run gain correction

  Int_t fPIDmethod;                  // PID method
  Double_t fNormalizationFactor;     // dE/dx Normalization Factor 
  Double_t fPthreshold;              // Low Momentum threshold for calibration
  Int_t fBadChamberID[kNChambers];   // List of Bad Chambers
  UInt_t fSlicesForPID[2];           // Select range of slices used in the PID response
  UInt_t fNBadChambers;              // Number of bad chambers
  const char *fGeoFile;              // File with geometry.root
  Bool_t fGainCorrection;            // Apply gain correction 
//  Bool_t fLoadReferences;            // Tender Load references
//  Bool_t fLoadReferencesFromCDB;     // Load References from CDB
  Bool_t fLoadDeadChambers;          // Load dead chambers
  Bool_t fHasReferences;             // has references loaded
  Bool_t fHasNewCalibration;         // has new calibration
  Bool_t fDebugMode;                 // Run in debug mode
  Bool_t fRedoTrdMatching;           // Redo Track Matching
  TString fNameRunByRunCorrection;   // filename with the run-by-run gain correction
  TObjArray *fNormalizationFactorArray; // Array with normalisation Factors
  
  AliTRDTenderSupply(const AliTRDTenderSupply&c);
  AliTRDTenderSupply& operator= (const AliTRDTenderSupply&c);
  
  ClassDef(AliTRDTenderSupply, 1);  // TRD tender task
};
#endif

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