1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // The ESD is available as member fESD
20 // The Process function is nearly empty. Implement your analysis there and look at the other listed below functions you
23 // The following methods can be overrriden. Please do not forgot to call the base class function.
25 // Begin(): called everytime a loop on the tree starts,
26 // a convenient place to create your histograms.
27 // SlaveBegin(): called after Begin(), when on PROOF called only on the
29 // Init(): called for each new tree. Enable/Disable branches here.
30 // Process(): called for each event, in this function you decide what
31 // to read and fill your histograms.
32 // SlaveTerminate: called at the end of the loop on the tree, when on PROOF
33 // called only on the slave servers.
34 // Terminate(): called at the end of the loop on the tree,
35 // a convenient place to draw/fit your histograms.
37 // Author: Jan.Fiete.Grosse-Oetringhaus@cern.ch
39 #include "AliROCESDAnalysisSelector.h"
43 #include <AliESDfriend.h>
44 #include <../TPC/AliTPCclusterMI.h>
45 #include <../TPC/AliTPCseed.h>
51 #include "TPC/AliTPCClusterHistograms.h"
53 ClassImp(AliROCESDAnalysisSelector)
55 AliROCESDAnalysisSelector::AliROCESDAnalysisSelector() :
60 // Constructor. Initialization of pointers
63 for (Int_t i=0; i<kTPCSectors; i++)
64 fClusterHistograms[i] = 0;
67 AliROCESDAnalysisSelector::~AliROCESDAnalysisSelector()
74 void AliROCESDAnalysisSelector::SlaveBegin(TTree* tree)
78 AliSelector::SlaveBegin(tree);
81 void AliROCESDAnalysisSelector::Init(TTree *tree)
83 // The Init() function is called when the selector needs to initialize
84 // a new tree or chain. Typically here the branch addresses of the tree
85 // will be set. It is normaly not necessary to make changes to the
86 // generated code, but the routine can be extended by the user if needed.
87 // Init() will be called many times when running with PROOF.
89 AliSelector::Init(tree);
93 tree->SetBranchAddress("ESDfriend", &fESDfriend);
96 AliDebug(AliLog::kInfo, "INFO: Found ESDfriend branch in chain.");
99 Bool_t AliROCESDAnalysisSelector::Process(Long64_t entry)
102 // Implement your analysis here. Do not forget to call the parent class Process by
103 // if (AliSelector::Process(entry) == kFALSE)
107 if (AliSelector::Process(entry) == kFALSE)
110 // Check prerequisites
113 AliDebug(AliLog::kError, "ESD branch not available");
117 // Check prerequisites
120 AliDebug(AliLog::kError, "ESDfriend branch not available");
124 fESD->SetESDfriend(fESDfriend);
126 Int_t nTracks = fESD->GetNumberOfTracks();
128 Int_t nSkippedSeeds = 0;
130 // loop over esd tracks
131 for (Int_t t=0; t<nTracks; t++)
133 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (fESD->GetTrack(t));
136 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t));
140 AliESDfriendTrack* friendtrack = const_cast<AliESDfriendTrack*> (dynamic_cast<const AliESDfriendTrack*> (esdTrack->GetFriendTrack()));
143 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve friend of track %d.", t));
147 const AliTPCseed* seed = dynamic_cast<const AliTPCseed*> (friendtrack->GetCalibObject(0));
150 AliDebug(AliLog::kDebug, Form("ERROR: Could not retrieve seed of track %d.", t));
155 for (Int_t clusterID = 0; clusterID < 160; clusterID++)
157 AliTPCclusterMI* cluster = seed->GetClusterPointer(clusterID);
160 //AliDebug(AliLog::kError, Form("ERROR: Could not retrieve cluster %d of track %d.", clusterID, t));
164 //AliDebug(AliLog::kDebug, Form("We found a cluster from sector %d", cluster->GetDetector()));
166 Int_t detector = cluster->GetDetector();
168 if (detector < 0 || detector >= kTPCSectors)
170 AliDebug(AliLog::kDebug, Form("We found a cluster from invalid sector %d", detector));
174 if (!fClusterHistograms[detector])
177 title.Form("sector_%d", detector);
178 // TODO claus will put a nice title here
179 fClusterHistograms[detector] = new AliTPCClusterHistograms(Form("sector_%d", detector), title);
182 fClusterHistograms[detector]->FillCluster(cluster);
186 if (nSkippedSeeds > 0)
187 printf("WARNING: The seed was not found for %d out of %d tracks.\n", nSkippedSeeds, nTracks);
192 void AliROCESDAnalysisSelector::SlaveTerminate()
196 for (Int_t i=0; i<kTPCSectors; i++)
197 if (fClusterHistograms[i])
198 fOutput->Add(fClusterHistograms[i]);
201 void AliROCESDAnalysisSelector::Terminate()
203 // TODO read from output list for PROOF
205 TFile* file = TFile::Open("rocESD.root", "RECREATE");
207 for (Int_t i=0; i<kTPCSectors; i++)
208 if (fClusterHistograms[i])
209 fClusterHistograms[i]->SaveHistograms();