]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TRD/macros/EVE/chargeDistr.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / TRD / macros / EVE / chargeDistr.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TRD/AliTRDcluster.h>
3 #include <TRD/AliTRDseedV1.h>
4 #include <TRD/AliTRDtrackV1.h>
5 #endif
6
7 void chargeDistr(const AliTRDtrackV1* track, Double_t* results, Int_t& nResults)
8 {
9   if (!track){
10     Error("chargeDistr()", "Missing track.");
11     return;
12   }
13   Int_t Nt = track->GetNumberOfTracklets();
14   AliTRDcluster* cls(NULL);
15   AliTRDseedV1 *tracklet(NULL);
16
17   // Count clusters
18   Int_t nCls = 0;
19   for (Int_t ily = 0; ily < 6; ily++) {
20     if(!(tracklet = track->GetTracklet(ily))){
21       //Warning("chargeDistr()", "Missing tracklet in ly[%d]", ily);
22       continue;
23     }
24     if(!tracklet->IsOK()){
25       //Warning("chargeDistr()", "Bad tracklet in ly[%d]", ily);
26       continue;
27     }
28     for (Int_t icl = 0; icl < AliTRDseedV1::kNclusters; icl++) {
29       if(!(cls = tracklet->GetClusters(icl))){
30         //Warning("chargeDistr()", "Missing cls[%2d] tracklet in ly[%d]", icl, ily);
31         continue;
32       }
33       nCls++;
34     }
35   }
36   
37   // Nothing to do?
38   if(!nCls){
39     Warning("chargeDistr()", "Missing clusters.");
40     return;
41   }
42   //Info("chargeDistr()", "Found %3d clusters.", nCls);
43
44   // Allocate memory for the results (AliEveTRDAnalyseObjectList will clean this memory automatically)
45   //results = new Double_t[nResults];
46   nResults = 2;
47   for (Int_t i = 0; i < nResults; i++)  results[i] = 0.;
48   Int_t currentIndex = 0;
49
50   for (Int_t trackletInd = 0; trackletInd < Nt && currentIndex < nResults; trackletInd++){
51     if(!(tracklet = track->GetTracklet(trackletInd))) continue;
52     if(!tracklet->IsOK()) continue;
53     for (Int_t clusterInd = 0; clusterInd < AliTRDseedV1::kNclusters; clusterInd++){
54       if(!(cls = tracklet->GetClusters(clusterInd))) continue;
55       results[1] += cls->GetQ();
56     }
57   }
58   results[0] =nCls;
59   results[1]/=nCls;
60 }