Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibTask.h
1 #ifndef ALITRDCALIBTASK_H
2 #define ALITRDCALIBTASK_H
3
4 ///////////////////////////////////////////////////////////////////////////////
5 //                                                                           //
6 //  TRD calibration task for offline calibration                             //
7 //                                                                           //
8 ///////////////////////////////////////////////////////////////////////////////
9
10
11 class TList;
12 class TObject;
13 class TObjArray;
14 class TH2F;
15 class TH1F;
16 class TH1I;
17 class TH2S;
18 class TProfile2D;
19 class TH2I;
20 class TTree;
21 class AliESDEvent;
22 class AliESDfriend;
23 class AliESDtrack;
24 class AliESDfriendTrack;
25 class AliTRDtrackV1;
26 class AliTRDseedV1;
27 class AliTRDCalibraFillHisto;
28 class AliTRDcluster;
29 class AliESDtrackCuts;
30 class AliTRDCalDet;
31 class AliTRDCalibChamberStatus;
32
33 #include "TObjString.h"
34 #include "AliAnalysisTaskSE.h" 
35 #include "TMath.h"
36
37 class AliTRDCalibTask : public AliAnalysisTaskSE {
38  public:
39   AliTRDCalibTask(const char *name = "AliTRDCalibTask");
40   virtual ~AliTRDCalibTask();
41   
42   //  virtual void   ConnectInputData(Option_t *);
43   virtual void   UserCreateOutputObjects();
44   virtual void   UserExec(Option_t *);
45   virtual void   Terminate(Option_t *);
46   virtual Bool_t Load(const Char_t *filename);
47   virtual Bool_t Load(TList *lister);
48   virtual Long64_t  Merge(TCollection *li);
49   void           AddTask(const AliTRDCalibTask * calibTask);
50   Bool_t         FindP1TrackPHtrackletV1Test(const AliTRDseedV1 *tracklet, Int_t nbclusters);
51   TList          *GetList() const {return fListHist;};
52
53   void SetOnInstance(Bool_t onInstance)                             {fOnInstance=onInstance;};
54   void SetHisto2d(Bool_t histo2d)                                   {fHisto2d=histo2d;};
55   void SetVector2d(Bool_t vector2d)                                 {fVector2d=vector2d;};
56   void SetVdriftLinear(Bool_t vdriftLinear)                         {fVdriftLinear = vdriftLinear;};
57   void SetExbAlt(Bool_t exbalt)                                     {fExbAlt = exbalt;};
58   void SetNbTimeBins(Int_t nbTimeBins)                              {fNbTimeBins=nbTimeBins;};  
59   void SetNumberBinCharge(Short_t nbBinCharge)                      {fNumberBinCharge=nbBinCharge;};  
60   void SetRangeCharge(Float_t rangeCharge)                          {fRangeCharge=rangeCharge;};
61   void SetVdBindx(Short_t vdBindx)                                  {fVdBindx=vdBindx;};  
62   void SetVdBindy(Short_t vdBindy)                                  {fVdBindy=vdBindy;};    
63   void SetVdRangedx(Double_t vdRangex)                               {fVdRangex=vdRangex;};  
64   void SetVdRangedy(Double_t vdRangey)                               {fVdRangey=vdRangey;};    
65   void SetDebugLevelTRDCalibraFillHisto(Short_t debugLevelTRDCalibraFillHisto) {fDebugLevelTRDCalibraFillHisto = debugLevelTRDCalibraFillHisto;};
66
67   
68   void SetNz(Short_t nz, Int_t i)                                      {fNz[i]=nz;};
69   void SetNrphi(Short_t nrphi, Int_t i)                                {fNrphi[i]=nrphi;};
70   
71   void SetSelectTrigger(Bool_t selectTrigger)                          {fSelectTrigger = selectTrigger;};
72   void AddSelectedTriggerClass(const char*name)                        {fSelectedTrigger->Add(new TObjString(name));};
73   void SetReject(Bool_t rejected)                                      {fRejected = rejected;};
74   
75   void SetESDtrackCuts(AliESDtrackCuts * const esdtrackCuts)           {fEsdTrackCuts = esdtrackCuts;};
76   void SetRequirePrimaryVertex(Bool_t requirePrimaryVertex)            {fRequirePrimaryVertex = requirePrimaryVertex;};
77   void SetUseTPCVertex()                                               {fVtxTPC=kTRUE ; fVtxSPD=kFALSE;} 
78   void SetUseSPDVertex()                                               {fVtxTPC=kFALSE; fVtxSPD=kTRUE ;} 
79   void SetMinNbOfContributors(Int_t minNbOfContributors)               {fMinNbContributors = minNbOfContributors;};  
80   void SetRangePrimaryVertexZ(Double_t rangePrimaryVertexZ)            {fRangePrimaryVertexZ = TMath::Abs(rangePrimaryVertexZ);}; 
81   void SetRejectPileUpWithSPD(Bool_t rejectPileUpWithSPD)              {fRejectPileUpWithSPD = rejectPileUpWithSPD;};
82   void SetRejectPileUpWithTOF(Bool_t rejectPileUpWithTOF)              {fRejectPileUpWithTOF = rejectPileUpWithTOF;};
83   void SetRejectPileUpWithTOFOrITS(Bool_t rejectPileUpWithTOFOrITS)    {fRejectPileUpWithTOFOrITS = rejectPileUpWithTOFOrITS;};
84   void SetMinNbTracks(Int_t minNbTracks)                               {fMinNbTracks = minNbTracks;};
85   void SetMaxNbTracks(Int_t maxNbTracks)                               {fMaxNbTracks = maxNbTracks;};
86   void SetCutWithVdriftCalib(Bool_t cutWithVdriftCalib)                {fCutWithVdriftCalib = cutWithVdriftCalib;};
87   void SetMinNbTRDtracklets(Int_t minNbTRDtracklets)                   {fMinNbTRDtracklets = minNbTRDtracklets;};
88   void SetMinTRDMometum(Double_t minTRDMomentum)                       {fMinTRDMomentum = minTRDMomentum;};
89   void SetScaleGainWithTPCSignal(Bool_t scaleGainWithTPCSignal)        {fScaleGainWithTPCSignal = scaleGainWithTPCSignal;}; 
90
91   void SetVersionGainUsed(Int_t versionGainUsed)                       { fVersionGainUsed = versionGainUsed;   }
92   void SetSubVersionGainUsed(Int_t subVersionGainUsed)                 { fSubVersionGainUsed = subVersionGainUsed;   }
93   void SetVersionGainLocalUsed(Int_t versionGainLocalUsed)             { fVersionGainLocalUsed = versionGainLocalUsed;   }
94   void SetSubVersionGainLocalUsed(Int_t subVersionGainLocalUsed)       { fSubVersionGainLocalUsed = subVersionGainLocalUsed;   }
95   void SetVersionVdriftUsed(Int_t versionVdriftUsed)                   { fVersionVdriftUsed = versionVdriftUsed;   }
96   void SetSubVersionVdriftUsed(Int_t subVersionVdriftUsed)             { fSubVersionVdriftUsed = subVersionVdriftUsed;   }
97   
98   void SetLow(Int_t low)                                               {fLow=low;};
99   void SetHigh(Int_t high)                                             {fHigh=high;};
100   void SetFillZero(Bool_t fillZero)                                    {fFillZero =  fillZero;};
101   void SetNormalizeNbOfCluster(Bool_t normalizeNbOfCluster =  kTRUE)   {fNormalizeNbOfCluster = normalizeNbOfCluster;};
102   void SetMaxCluster(Float_t maxCluster)                               {fMaxCluster =  maxCluster; }; 
103   void SetNbMaxCluster(Short_t nbMaxCluster)                           {fNbMaxCluster =  nbMaxCluster; }; 
104   void SetOfflineTracks()                                              {fOfflineTracks=kTRUE; fStandaloneTracks=kFALSE; };
105   void SetStandaloneTracks()                                           {fStandaloneTracks=kTRUE; fOfflineTracks=kFALSE; };
106   
107   void SetCalDetGain(AliTRDCalDet * const calDetGain)                  {fCalDetGain = calDetGain;};  
108
109   void SetMaxEvent(Int_t nbevents)                                     { fMaxEvent = nbevents; };
110   void SetDebug(Int_t debug)                                           { fDebug = debug; };
111
112   Bool_t IsPHQon() const {return fPHQon;}
113   void SetPHQon(const Bool_t kphq){ fPHQon = kphq; }
114
115  private:
116   Bool_t SetVersionSubversion();
117   Bool_t ParticleGood(int i) const;
118
119   AliESDEvent  *fESD;                            //! ESD object
120   const AliESDtrack *fkEsdTrack;                  //! ESD track
121   AliESDfriendTrack *fFriendTrack;               //! ESD friend track
122   TObject *fCalibObject;                         //! calibration objects attached to the ESD friend
123   AliTRDtrackV1 *fTrdTrack;                      //! trdtrack
124   AliTRDcluster *fCl;                            //! cluster
125   
126   TList       *fListHist;                        //! list of histograms
127
128   AliTRDCalibraFillHisto *fTRDCalibraFillHisto;  //! calibration analyse object
129   AliTRDCalibChamberStatus *fTRDChamberStatus;   //! calibration chamber status
130
131   TH1I        *fNEvents;                         //! counter  
132   TH1I        *fNEventsInput;                    //! counter
133   TH1I        *fNEventsTrigger;                  //! counter trigger   
134   
135   TH1F        *fNbTRDTrack;                      //! nb ESD tracks with TRD clusters
136   TH1F        *fNbTRDTrackOffline;               //! nb ESD tracks with TRD clusters
137   TH1F        *fNbTRDTrackStandalone;            //! nb ESD tracks with TRD clusters
138   TH2F        *fNbTPCTRDtrack;                   //! nb TPC and TRD tracks when problems
139   TH2F        *fNbGoodTracks;                    //! nb of good tracks
140    
141   TH1F        *fNbTimeBin;                       //! nb Time Bin
142   TH1F        *fNbTimeBinOffline;                //! nb Time Bin offline
143   TH1F        *fNbTimeBinStandalone;             //! nb Time Bin standalone
144   TH1F        *fNbClusters;                      //! nb Clusters
145   TH1F        *fNbClustersOffline;               //! nb Clusters offline
146   TH1F        *fNbClustersStandalone;            //! nb Clusters standalone
147   TH1F        *fNbTracklets;                     //! nb Tracklets
148   TH1F        *fNbTrackletsOffline;              //! nb Tracklets offline
149   TH1F        *fNbTrackletsStandalone;           //! nb Tracklets standalone
150   
151   TH2F        *fAbsoluteGain;                    //! Absolute Gain without AliESDfriend
152   TH2F        *fTOFbc;                           //! Check TOF branch crossing
153   TH2I        *fCH2dSum;                         //! CH2d charge all
154   TProfile2D  *fPH2dSum;                         //! PH2d PH all
155   TH2I        *fCH2dSM;                          //! CH2d per SM
156   TProfile2D  *fPH2dSM;                          //! PH2d per SM
157   TH2I        *fCH2dTest;                        //! CH2d for test
158   TProfile2D  *fPH2dTest;                        //! PH2d for test
159   TH2S *fLinearVdriftTest;                       //! VdriftLinear for test
160
161   Bool_t      fOnInstance;                       // On Instance
162   Bool_t      fHisto2d;                          // histo
163   Bool_t      fVector2d;                         // vector
164   Bool_t      fVdriftLinear;                     // vdrift Linear
165   Bool_t      fExbAlt;                           // alternative exb calculation
166
167   Short_t     fDebugLevelTRDCalibraFillHisto;    // Debug Level Fill Histo
168   Int_t       fNbTimeBins;                       // number of timebins 
169   Short_t     fNumberBinCharge;                  // Number of bins for the gain factor
170   Float_t     fRangeCharge;                      // Range Charge
171   Short_t     fVdBindx;                          // Nb of bin in vd histos x
172   Short_t     fVdBindy;                          // Nb of bin in vd histos y
173   Double_t    fVdRangex;                         // Range vd histos x
174   Double_t    fVdRangey;                         // Range vd histos y
175
176   Short_t     fNz[3];                            // Nz mode 
177   Short_t     fNrphi[3];                         // Nrphi mode
178    
179   Bool_t      fSelectTrigger;                    // Select trigger
180   TObjArray   *fSelectedTrigger;                 // Trigger class names accepted/rejected
181   Bool_t      fRejected;                         // Reject the selected trigger class
182   
183   AliESDtrackCuts *fEsdTrackCuts;                // Quality cut on the AliESDtrack
184   Bool_t      fRequirePrimaryVertex;             // Primary Vertex
185   Bool_t      fVtxTPC;                           // Flag for use of TPC vertex
186   Bool_t      fVtxSPD;                           // Flag for use of SPD vertex
187   Int_t       fMinNbContributors;                // Min number of contributors
188   Double_t    fRangePrimaryVertexZ;              // Were the primary vertex is
189   Bool_t      fRejectPileUpWithSPD;              // Reject pile-up events with SPD
190   Bool_t      fRejectPileUpWithTOF;              // Reject pile-up tracks with TOF
191   Bool_t      fRejectPileUpWithTOFOrITS;         // Reject pile-up tracks with TOF or ITS
192   Int_t       fMinNbTracks;                      // Min Nb Tracks
193   Int_t       fMaxNbTracks;                      // Max Nb Tracks
194   Bool_t      fCutWithVdriftCalib;               // CutWithVdriftCalib for the gain and PH
195   Int_t       fMinNbTRDtracklets;                // Min number of TRD tracklets
196   Float_t     fMinTRDMomentum;                   // Min TRD momentum  
197   Bool_t      fScaleGainWithTPCSignal;           // Scale the TPC gain with the TPC signal
198
199   Int_t       fLow;                              // lower limit of nb of TRD clusters per tracklet
200   Int_t       fHigh;                             // higher limit of nb of TRD clusters per tracklet
201   Bool_t      fFillZero;                         // fill zero
202   Bool_t      fNormalizeNbOfCluster;             // normalize with number of clusters (per default not) 
203   Float_t     fRelativeScale;                    // relative scale for gas gain
204   Float_t     fMaxCluster;                       // Maxcluster 
205   Short_t     fNbMaxCluster;                     // Number of tb at the end
206   Bool_t      fOfflineTracks;                    // Only Offline refitted tracks
207   Bool_t      fStandaloneTracks;                 // Take only standalone tracks
208
209   Int_t       fFirstRunGain;                     // FirstRunGainUsed 
210   Int_t       fVersionGainUsed;                  // VersionGainUsed 
211   Int_t       fSubVersionGainUsed;               // SubVersionGainUsed
212   Int_t       fFirstRunGainLocal;                // FirstRunGainLocalUsed 
213   Int_t       fVersionGainLocalUsed;             // VersionGainLocalUsed 
214   Int_t       fSubVersionGainLocalUsed;          // SubVersionGainLocalUsed
215   Int_t       fFirstRunVdrift;                   // FirstRunVdriftUsed 
216   Int_t       fVersionVdriftUsed;                // VersionVdriftUsed 
217   Int_t       fSubVersionVdriftUsed;             // SubVersionVdriftUsed
218   Int_t       fFirstRunExB;                      // FirstRunExBUsed 
219   Int_t       fVersionExBUsed;                   // VersionExBUsed 
220   Int_t       fSubVersionExBUsed;                // SubVersionExBUsed
221
222   AliTRDCalDet *fCalDetGain;                     // Calib object gain
223
224   Int_t       fMaxEvent;                         // max events
225   Int_t       fCounter;                          // max events
226
227   Bool_t fPHQon;                                  //switch of phq
228
229   AliTRDCalibTask(const AliTRDCalibTask&); 
230   AliTRDCalibTask& operator=(const AliTRDCalibTask&); 
231
232   ClassDef(AliTRDCalibTask, 7); 
233 };
234
235 #endif
236
237