// class for TOF calibration:: simulation of uncalibrated data //
//////////////////////////////////////////////////////////////////
+#define CHENTRIESSMALL 300 // number of entries per TOF channel per run
+ // (to be divided by 3 to get the
+ // real number of entries), smallarray
+#define MAXCHENTRIESSMALL 10000 // max number of entries per TOF channel
+ // (to be divided by 3 to get the
+ // real number of entries), smallarray
+
+#define NIDXSMALL 3 // number of values stored
+ // after Comb PID per ESD track
+#define DELTAIDXTOT 0 // index for ToT in bigarray
+#define DELTAIDXTIME 1 // index for TOF time in big/smallarray
+#define DELTAIDXPID 2 // index for Exp Time after Comb PID
+ // in smallarray
+#define MEANENTRIES 15 // Mean number of entries per channel
+ // to perform calibration
+
#include "TTask.h"
-#include "TH1F.h"
-#include "AliTOFChannel.h"
-#include "TClonesArray.h"
-#include "TList.h"
-#include "AliTOFCal.h"
-#include "AliTOFGeometry.h"
-#include "AliESD.h"
-#include "AliRunLoader.h"
+
+class TArrayF;
+class TF1;
+class TH1F;
+class TH1C;
+class TObjArray;
+class TTree;
+class TChain;
+class TMap;
+
+//class AliESD;
+
+class AliTOFCal;
+class AliTOFRecoParam;
+class AliTOFChannelOnlineStatusArray;
+class AliTOFChannelOnlineArray;
+class AliTOFDeltaBCOffset;
+class AliTOFCTPLatency;
+class AliTOFT0Fill;
+class AliTOFRunParams;
+class AliTOFResponseParams;
+class AliESDEvent;
class AliTOFcalib:public TTask{
public:
AliTOFcalib(); // ctor
- AliTOFcalib(char* headerFile, Int_t nEvents=0) ;
- AliTOFcalib(const AliTOFcalib & calib);
- void Init();
+ AliTOFcalib(const AliTOFcalib & calib); // copy constructor
+ AliTOFcalib& operator=(const AliTOFcalib & calib); // assignment operator
virtual ~AliTOFcalib() ; // dtor
- Int_t NSector()const {return fNSector;}
- Int_t NPlate()const {return fNPlate;}
- Int_t NStripA()const {return fNStripA;}
- Int_t NStripB()const {return fNStripB;}
- Int_t NStripC()const {return fNStripC;}
- Int_t NpadZ()const {return fNpadZ;}
- Int_t NpadX()const {return fNpadX;}
- TClonesArray * DecalibrateDigits(TClonesArray *digits);
- void SelectESD(AliESD *event, AliRunLoader * rl);
- void CombESDId();
- void CalibrateESD();
- TH1F* Profile(Int_t i);
- Int_t Size()const{return fsize;}
- void SetFitFunctions();
- TF1* SetFitFunctions(TH1F* histo);
- TList* GetFitFunctions() {return flistFunc;}
- TH1F** GetHistosToT() {return fhToT;}
- void SetHistos();
- void CorrectESDTime();
- void CorrectESDTime(AliESD *event, AliRunLoader *rl);
- void WriteOnCDB();
- void ReadFromCDB(Char_t *sel, Int_t nrun);
- Int_t GetIndex(Int_t *detId);
-
- public:
- class AliTOFArray : public TObject {
- public:
- AliTOFArray(): TObject(),fSize(0),fArray(0x0){}
- AliTOFArray(Int_t size) :
- TObject(),
- fSize(size),
- fArray(new TArrayF*[size]) {
- }
- Int_t GetSize() const {return fSize;}
- void AddArray(Int_t pos, TArrayF * parr) {
- if (pos>-1 && pos < fSize)
- fArray[pos] = parr;
- //else
- //AliError("Index out of range");
- }
- TArrayF * GetArray(Int_t pos) {
- TArrayF * parr = 0x0;
- if (pos>-1 && pos < fSize)
- parr = fArray[pos];
- //else
- //AliError("Index out of range");
- return parr;
- }
- virtual ~AliTOFArray() {
- delete [] fArray;
- }
-
- private:
-
- Int_t fSize; // Size of the array of TArrayFs
- TArrayF ** fArray; //[fSize]};
-
- };
+ void CreateCalArrays();
+ void CreateCalObjects();
+ TObjArray * GetTOFCalArrayOnline() const {return fTOFCalOnline;}
+ AliTOFChannelOnlineArray * GetTOFOnlineDelay() const {return fCal;}
+ AliTOFChannelOnlineStatusArray * GetTOFOnlineStatus() const {return fStatus;}
+ TObjArray * GetTOFCalArrayOnlinePulser() const {return fTOFCalOnlinePulser;}
+ TObjArray * GetTOFCalArrayOnlineNoise() const {return fTOFCalOnlineNoise;}
+ TObjArray * GetTOFCalArrayOnlineHW() const {return fTOFCalOnlineHW;}
+ TObjArray * GetTOFCalArrayOffline() const {return fTOFCalOffline;}
+ TMap * GetConfigMap() const {return fConfigMap;}
+ TH1F * GetTOFSimToT() const {return fTOFSimToT;}
+ TTree * GetTOFCalibTree() const {return fTree;}
+ TChain * GetTOFCalibChain() const {return fChain;}
+ const char * GetOfflineValidity() const {return fkValidity;}
+ void SetOfflineValidity(const char* validity) {fkValidity = validity;}
+ Int_t NChannels()const{return fNChannels;}
+
+ void CreateDeltaBCOffset();
+ void CreateCTPLatency();
+ void CreateT0Fill();
+ void CreateRunParams();
+ AliTOFDeltaBCOffset *GetDeltaBCOffset() const {return fDeltaBCOffset;};
+ AliTOFCTPLatency *GetCTPLatency() const {return fCTPLatency;};
+ AliTOFT0Fill *GetT0Fill() const {return fT0Fill;};
+ AliTOFRunParams *GetRunParams() const {return fRunParams;};
+ AliTOFResponseParams *GetResponseParams() const {return fResponseParams;};
+
+ // Methods to retrieve/write parameters from/on CDB
+ // writing
+
+ void WriteSimHistoOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo);
+ void WriteConfigMapOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteConfigMapOnCDB(const Char_t *sel);
+ // new calib objs
+ void WriteParOnlineDelayOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteParOnlineStatusOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteParOnlineDelayOnCDB(const Char_t *sel);
+ void WriteParOnlineStatusOnCDB(const Char_t *sel);
+ // old calib objs
+ void WriteParOnlineOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteParOnlinePulserOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteParOnlineNoiseOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteParOnlineHWOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun);
+ void WriteParOnlineOnCDB(const Char_t *sel);
+ void WriteParOnlinePulserOnCDB(const Char_t *sel); // old, before unification of status info
+ void WriteParOnlineNoiseOnCDB(const Char_t *sel); // old, before unification of status info
+ void WriteParOnlineHWOnCDB(const Char_t *sel); // old, before unification of status info
+ void WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity);
+
+ void WriteDeltaBCOffsetOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteCTPLatencyOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteT0FillOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteRunParamsOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteReadoutEfficiencyOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ void WriteProblematicOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun);
+ // reading
+ Bool_t ReadSimHistoFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadConfigMapFromCDB(const Char_t *sel, Int_t nrun);
+ // new objs
+ Bool_t ReadParOnlineDelayFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadParOnlineStatusFromCDB(const Char_t *sel, Int_t nrun);
+ // old objs
+ Bool_t ReadParOnlineFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadParOnlinePulserFromCDB(const Char_t *sel, Int_t nrun); // old, before unification of status info
+ Bool_t ReadParOnlineNoiseFromCDB(const Char_t *sel, Int_t nrun); // old, before unification of status info
+ Bool_t ReadParOnlineHWFromCDB(const Char_t *sel, Int_t nrun); // old, before unification of status info
+ Bool_t ReadParOfflineFromCDB(const Char_t *sel, Int_t nrun);
+ void WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param);
+ void WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TObjArray *arr);
+ AliTOFRecoParam * ReadRecParFromCDB(const Char_t *sel, Int_t nrun, Int_t eventType=0);
+ void CreateTreeFromCDB(Int_t minrun, Int_t maxrun);
+ void CreateTreeFromFile(Int_t minrun, Int_t maxrun);
+ void CreateTreeFromGrid(Int_t minrun, Int_t maxrun);
+ void CreateChainFromGrid(Int_t minrun, Int_t maxrun);
+ Int_t Calibrate(Option_t *optionSave="", Option_t *optionFit="RQ");
+ Int_t Calibrate(Int_t nch,Int_t *ich, Option_t *optionSave="", Option_t *optionFit="RQ");
+ Int_t Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave="", Option_t *optionFit="RQ");
+ Int_t Calibrate(Int_t ich, Option_t *optionSave="", Option_t *optionFit="RQ");
+ Int_t CalibrateFromProfile(Int_t ich, Option_t *optionSave="", Option_t *optionFit="RQ");
+ TH1F* Profile(Int_t i);
+ Int_t FindBins (TH1F* h, Double_t *bins) const;
+ void SetNruns(Int_t nruns) {fNruns=nruns;}
+ Int_t GetNruns() const {return fNruns;}
+ void SetFirstRun(Int_t firstRun) {fFirstRun=firstRun;}
+ Int_t GetFirstRun() const {return fFirstRun;}
+ void SetLastRun(Int_t lastRun) {fLastRun=lastRun;}
+ Int_t GetLastRun() const {return fLastRun;}
+
+ Bool_t ReadDeltaBCOffsetFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadCTPLatencyFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadT0FillFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadRunParamsFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadReadoutEfficiencyFromCDB(const Char_t *sel, Int_t nrun);
+ Bool_t ReadProblematicFromCDB(const Char_t *sel, Int_t nrun);
+
+ Bool_t Init(Int_t run = -1); // init
+ Double_t GetTimeCorrection(Int_t index, Double_t tot, Int_t deltaBC, Int_t l0l1, UInt_t timestamp); // get time correction
+ void CalibrateESD(AliESDEvent *event); // calibrate ESD
+ void CalibrateTExp(AliESDEvent *event) const; // calibrate TExp
+ void SetRemoveMeanT0(Bool_t value) {fRemoveMeanT0 = value;}; // setter
+ void SetCalibrateTOFsignal(Bool_t value) {fCalibrateTOFsignal = value;}; // setter
+ void SetCorrectTExp(Bool_t value) {fCorrectTExp = value;}; // setter
+ Bool_t IsChannelEnabled(Int_t index, Bool_t checkEfficiency = kTRUE, Bool_t checkProblematic = kTRUE); // is channel enabled
+ Bool_t IsChannelEfficient(Int_t index); // is channel efficient
+ Bool_t IsChannelProblematic(Int_t index); // is channel problematic
+ Double_t TuneForMC(AliESDEvent *event, Double_t resolution); // tune for MC
private:
- static const Int_t fgkchannel; // max number of entries per channel
- static const Char_t * ffile[6]; // spectra
- Int_t fsize; // number of channels
- Int_t fNSector; // number of TOF sectors
- Int_t fNPlate; // number of TOF plates
- Int_t fNStripA; // number of TOF strips A
- Int_t fNStripB; // number of TOF strips B
- Int_t fNStripC; // number of TOF strips C
- Int_t fNpadZ; // number of TOF pads Z
- Int_t fNpadX; // number of TOF pads X
- TObjArray * fESDsel; // selected ESD tracks for calibration
- TList *flistFunc; // functions for simulated Time Slewing spectra
- TH1F* fhToT[6]; // simulated ToT distributions
- Float_t fMaxToT[6]; // max simulated ToT
- Float_t fMinToT[6]; // min simulated ToT
- Float_t fMaxToTDistr[6]; // max value in the ToT distributions
- AliTOFArray *fArrayToT; // array for ToT values
- AliTOFArray *fArrayTime; // array for Time values
- Int_t fNevents; // number of events
- AliTOFCal *fTOFCal; // array of AliTOFChannels storing calib parameters
- TString fT0File ; // output file;
- TString fHeadersFile; // input file
- AliTOFGeometry *fGeom; // AliTOFgeometry pointer
- ClassDef(AliTOFcalib,1);
+ Int_t fNChannels; // number of TOF channels
+
+ // old calibration objects
+ TObjArray *fTOFCalOnline; // array of AliTOFChannels storing calib parameters
+ TObjArray *fTOFCalOnlinePulser; // array of AliTOFChannels storing calib status from pulser // old, before unification of status info
+ TObjArray *fTOFCalOnlineNoise; // array of AliTOFChannels storing calib status from noise // old, before unification of status info
+ TObjArray *fTOFCalOnlineHW; // array of AliTOFChannels storing calib status from hardware // old, before unification of status info
+ TObjArray *fTOFCalOffline; // array of AliTOFChannels storing calib parameters
+
+ // new calibration objects
+ AliTOFChannelOnlineArray *fCal; // object with delay array for TOF channels
+ AliTOFChannelOnlineStatusArray *fStatus; // object with status array for TOF channels
+
+ TH1F *fTOFSimToT; // histo with realistic ToT signal from TB Data
+ const char *fkValidity; // validity for offline calibration object
+ TTree *fTree; // tree for TOF calibration
+ TChain *fChain; // chain for TOF calibration
+ Int_t fNruns; // number of runs to be processed
+ Int_t fFirstRun; // first run for calibration obj validity
+ Int_t fLastRun; // last run for calib obj validity
+ TMap* fConfigMap; // map holding configuration obj
+
+ AliTOFDeltaBCOffset *fDeltaBCOffset; // deltaBC offset
+ AliTOFCTPLatency *fCTPLatency; // CTP latency
+ AliTOFT0Fill *fT0Fill; // T0 fill
+ AliTOFRunParams *fRunParams; // run params
+ AliTOFResponseParams *fResponseParams; // run params
+ TH1F *fReadoutEfficiency; // readout efficiency
+ TH1C *fProblematic; // problematic
+
+ Bool_t fInitFlag; // init flag
+ Bool_t fRemoveMeanT0; // remove mean T0
+ Bool_t fCalibrateTOFsignal; // calibrate TOF signal
+ Bool_t fCorrectTExp; // correct expected time
+
+ ClassDef(AliTOFcalib,11);
};
#endif // AliTOFcalib_H