1 //SSD dEdx gain calibration task
3 //autor Marek Chojnacki
4 //Marek.Chojnacki@cern.ch
13 #include "AliAnalysisTaskdEdxSSDQA.h"
14 #include "AliAnalysisManager.h"
16 #include "AliESDEvent.h"
17 #include "AliESDInputHandler.h"
20 #include "AliESDtrack.h"
21 #include "AliExternalTrackParam.h"
22 #include "Riostream.h"
24 #include "AliESDfriend.h"
25 #include "AliESDfriendTrack.h"
26 #include "AliTrackPointArray.h"
27 #include "AliCDBManager.h"
28 #include "AliGeomManager.h"
30 #include "TGeoMatrix.h"
33 ClassImp(AliAnalysisTaskdEdxSSDQA)
35 //________________________________________________________________________
36 AliAnalysisTaskdEdxSSDQA::AliAnalysisTaskdEdxSSDQA(const char *name)
37 : AliAnalysisTaskSE(name), fHist1(0),fHist2(0),fHist3(0),fHist4(0),fHist5(0),fHist6(0),fListOfHistos(0),fPcut(0.0),fdothecorrection(0)
40 // Define input and output slots here
41 // Input slot #1 works with a TChain
42 // fcorrections=new Float_t[1698*12];
43 for(int i=0;i<1698*12;i++)
45 DefineOutput(1, TList::Class());
48 //________________________________________________________________________
49 void AliAnalysisTaskdEdxSSDQA::UserCreateOutputObjects()
54 fListOfHistos = new TList();
55 fHist1 =new TH2F("QAChargeRatio","QAChargeRatio;Module;CR",1698,-0.5,1697.5,80,-1.0,1.0);
56 fListOfHistos->Add(fHist1);
57 fHist2=new TH2F("QACharge","QACharge;Module;Q",1698,-0.5,1697.5,150,0,300);
58 fListOfHistos->Add(fHist2);
59 fHist3=new TH3F("ChargeRatiovCharge","CRvQ;module;Q;CR",1698,-0.5,1697.5,80,0,1600,50,-1.0,1.0);
60 fListOfHistos->Add(fHist3);
61 fHist4=new TH2F("QAChargedinchips","chargedinchips;chip;Q",1698*12,-0.5,1698*12-0.5,150,0,300);
62 fListOfHistos->Add(fHist4);
65 fHist5=new TH2F("QAChargeCorrected","chargedCorrected;Module;QCorrected",1698,-0.5,1697.5,150,0,300);
66 fListOfHistos->Add(fHist5);
68 fHist6=new TH2F("QNvQP",";QN;QP",160,0,1600,1600,0,1600);
69 fListOfHistos->Add(fHist6);
71 PostData(1, fListOfHistos);
73 //________________________________________________________________________
74 void AliAnalysisTaskdEdxSSDQA::LocalInit()
77 Printf("end of LocalInit");
79 //______________________________________________________________________
80 AliAnalysisTaskdEdxSSDQA::~AliAnalysisTaskdEdxSSDQA()
84 //________________________________________________________________________
86 void AliAnalysisTaskdEdxSSDQA::UserExec(Option_t *)
89 // Called for each event
90 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
93 Printf("ERROR: Input ESD Event not available");
94 PostData(1, fListOfHistos);
98 Int_t nTracks=esd->GetNumberOfTracks();
104 Printf("problem with friend");
105 PostData(1, fListOfHistos);
108 //Printf("Event nTracks %d", nTracks);
109 AliTrackPointArray* trackar=0x0;
116 Float_t chargeratio=0.0;
118 for(int itr=0;itr<nTracks;itr++)
120 AliESDtrack* track= esd->GetTrack(itr);
122 if(TMath::Abs(track->Eta())>0.9)
124 if(track->GetP()>10.0)
126 if (track->IsOn(AliESDtrack::kITSrefit)&&track->IsOn(AliESDtrack::kTPCrefit))
128 l5=track->HasPointOnITSLayer(4);
129 l6=track->HasPointOnITSLayer(5);
130 if (!(l5||l6))//only tracks with SSD point
132 Double_t tmpQESD[4]={-1.0,-1.0,-1.0,-1.0};
133 track->GetITSdEdxSamples(tmpQESD);
134 trackar=(AliTrackPointArray*)track->GetTrackPointArray();
137 npoints=trackar->GetNPoints();
138 for(int itnp=0;itnp<npoints;itnp++)
140 if(trackar->GetPoint(point,itnp))
142 nlayer=AliGeomManager::VolUIDToLayer(point.GetVolumeID(), id);//layer number
146 if(nlayer==5||nlayer==6)
148 TGeoHMatrix* geomatrix=AliGeomManager::GetMatrix(point.GetVolumeID());
149 //geomatrix->Print();
150 if(point.GetCharge()>0.0&&point.IsExtra()==kFALSE)//do not use additional clusters
152 Double_t local[3]={0.0,0.0,0.0};
153 Double_t global[3]={0.0,0.0,0.0};
154 global[0]=point.GetX();
155 global[1]=point.GetY();
156 global[2]=point.GetZ();
157 geomatrix->MasterToLocal(global,local);
158 chargeratio=point.GetChargeRatio();
159 charge=point.GetCharge();
160 Float_t fQNnotcorr=charge*(1.0+chargeratio);
161 Float_t fQPnotcorr=charge*(1.0-chargeratio);
162 fHist6->Fill(fQNnotcorr,fQPnotcorr);
163 // cout<<point.GetCharge()<<" "<<point.GetChargeRatio()<<" "<<nlayer<<" "<<id<<endl;
164 if(nlayer==5&&tmpQESD[2]>0.0)
166 fHist1->Fill(id,chargeratio);
167 if(track->GetP()>fPcut)
169 Float_t fQP=tmpQESD[2]*(1.0-chargeratio);
170 Float_t fQN=tmpQESD[2]*(1.0+chargeratio);
171 Int_t fPchip=Pstrip5(10000.0*local[0],10000.0*local[2])/128;
172 Int_t fNchip=Nstrip5(10000.0*local[0],10000.0*local[2])/128;
174 fHist2->Fill(id,tmpQESD[2]);
175 fHist4->Fill(id*12+fPchip,fQP);
176 fHist4->Fill(id*12+6+fNchip,fQN);
178 fHist5->Fill(id,0.5*(fQP*fcorrections[12*id+fPchip]+fQN*fcorrections[12*id+6+fNchip]));
180 fHist3->Fill(id,charge,chargeratio);
182 if(nlayer==6&&tmpQESD[3]>0.0)
184 fHist1->Fill(id+748,chargeratio);
185 if(track->GetP()>fPcut)
188 Float_t fQP=tmpQESD[3]*(1.0-chargeratio);
189 Float_t fQN=tmpQESD[3]*(1.0+chargeratio);
190 Int_t fPchip=Pstrip6(10000.0*local[0],10000.0*local[2])/128;
191 Int_t fNchip=Nstrip6(10000.0*local[0],10000.0*local[2])/128;
193 fHist2->Fill(id+748,tmpQESD[3]);
194 fHist4->Fill((id+748)*12+fPchip,fQP);
195 fHist4->Fill((id+748)*12+6+fNchip,fQN);
197 fHist5->Fill((id+748),0.5*(fQP*fcorrections[12*(id+748)+fPchip]+fQN*fcorrections[12*(id+748)+6+fNchip]));
200 fHist3->Fill(id+748,charge,chargeratio);
208 //Printf("Event nTracks end %d", nTracks);
210 PostData(1, fListOfHistos);
213 //________________________________________________________________________
214 void AliAnalysisTaskdEdxSSDQA::Terminate(Option_t *)
217 Printf("end of Terminate");
219 //_____________________________________________________________________________
220 Int_t AliAnalysisTaskdEdxSSDQA::Pstrip5(Float_t x,Float_t z) const
222 // P strip for layer 5 from local cooridnates
226 value=-(3.0/38000.0)*z+x/95.0;
227 return TMath::Nint(value);
229 //___________________________________________________________________________
230 Int_t AliAnalysisTaskdEdxSSDQA::Nstrip5(Float_t x,Float_t z) const
232 // N strip for layer 5 from local cooridnates
236 value=x/95.0+(11.0/38000.0)*z;
237 return TMath::Nint(value);
239 //___________________________________________________________________________
240 Int_t AliAnalysisTaskdEdxSSDQA::Pstrip6(Float_t x,Float_t z) const
242 // P strip for layer 6 from local cooridnates
246 value=-(3.0/38000.0)*z-x/95.0;
247 return TMath::Nint(value);
249 //__________________________________________________________________________________
250 Int_t AliAnalysisTaskdEdxSSDQA::Nstrip6(Float_t x,Float_t z) const
252 // N strip for layer 6 from local cooridnates
256 value=x*(-1.0/95.0)+(11.0/38000.0)*z;
257 return TMath::Nint(value);
259 //___________________________________________________________________________________
260 void AliAnalysisTaskdEdxSSDQA::SetDoChipCorretions(const char* filename)
262 //Upload corrections for each chip only for test
263 cout<<filename<<endl;
264 ifstream infile(filename);
269 for (int i=0;i<1698;i++)
271 for (int j=0;j<6;j++)
276 fcorrections[i*12+j]=84.0/value;
278 fcorrections[i*12+j]=1.0;
283 fcorrections[i*12+j+6]=84.0/value;
285 fcorrections[i*12+j+6]=1.0;