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 ///////////////////////////////////////////////////////////////////////////////
20 // TRD cluster finder base class //
22 ///////////////////////////////////////////////////////////////////////////////
27 #include <TObjArray.h>
29 #include "AliRunLoader.h"
30 #include "AliLoader.h"
33 #include "AliTRDclusterizer.h"
34 #include "AliTRDcluster.h"
35 #include "AliTRDrecPoint.h"
36 #include "AliTRDgeometry.h"
37 #include "AliTRDcalibDB.h"
39 ClassImp(AliTRDclusterizer)
41 //_____________________________________________________________________________
42 AliTRDclusterizer::AliTRDclusterizer()
49 // AliTRDclusterizer default constructor
54 //_____________________________________________________________________________
55 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
62 // AliTRDclusterizer constructor
67 //_____________________________________________________________________________
68 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
75 // AliTRDclusterizer copy constructor
80 //_____________________________________________________________________________
81 AliTRDclusterizer::~AliTRDclusterizer()
84 // AliTRDclusterizer destructor
94 //_____________________________________________________________________________
95 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
98 // Assignment operator
101 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
106 //_____________________________________________________________________________
107 void AliTRDclusterizer::Copy(TObject &c) const
113 ((AliTRDclusterizer &) c).fClusterTree = NULL;
114 ((AliTRDclusterizer &) c).fRecPoints = NULL;
118 //_____________________________________________________________________________
119 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
122 // Opens the AliROOT file. Output and input are in the same file
125 TString evfoldname = AliConfig::GetDefaultEventFolderName();
126 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
129 fRunLoader = AliRunLoader::Open(name);
133 AliError(Form("Can not open session for file %s.",name));
144 //_____________________________________________________________________________
145 Bool_t AliTRDclusterizer::OpenOutput()
148 // Open the output file
151 TObjArray *ioArray = 0;
153 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
154 loader->MakeTree("R");
156 fClusterTree = loader->TreeR();
157 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
163 //_____________________________________________________________________________
164 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
167 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
170 // Import the Trees for the event nEvent in the file
171 fRunLoader->GetEvent(nEvent);
177 //_____________________________________________________________________________
178 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
181 // Fills TRDcluster branch in the tree with the clusters
182 // found in detector = det. For det=-1 writes the tree.
186 (det >= AliTRDgeometry::Ndet())) {
187 AliError(Form("Unexpected detector index %d.\n",det));
191 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
193 TObjArray *ioArray = 0;
194 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
198 (det < AliTRDgeometry::Ndet())) {
200 Int_t nRecPoints = RecPoints()->GetEntriesFast();
201 TObjArray *detRecPoints = new TObjArray(400);
203 for (Int_t i = 0; i < nRecPoints; i++) {
204 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
205 if (det == c->GetDetector()) {
206 detRecPoints->AddLast(c);
209 AliError("Attempt to write a cluster with unexpected detector index\n");
213 branch->SetAddress(&detRecPoints);
214 fClusterTree->Fill();
224 AliInfo(Form("Writing the cluster tree %s for event %d."
225 ,fClusterTree->GetName(),fRunLoader->GetEventNumber()));
229 branch->SetAddress(&fRecPoints);
231 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
232 loader->WriteRecPoints("OVERWRITE");
237 AliError("Cluster tree does not exist. Cannot write clusters.\n");
246 AliError(Form("Unexpected detector index %d.\n",det));
253 //_____________________________________________________________________________
254 AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin
255 , Int_t det, Double_t amp
256 , Int_t *tracks, Double_t *sig
257 , Int_t iType, Float_t center)
260 // Add a cluster for the TRD
263 AliTRDcluster *c = new AliTRDcluster();
270 c->SetSigmaY2(sig[0]);
271 c->SetSigmaZ2(sig[1]);
272 c->SetLocalTimeBin(timebin);
273 c->SetCenter(center);
276 c->AddTrackIndex(tracks);
302 //_____________________________________________________________________________
303 Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet
304 , Int_t col, Int_t row)
307 // Calculates the local x position in the detector from the timebin,
308 // depends on the drift velocity and t0
311 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
313 AliError("Cannot find calibration object");
317 Float_t vdrift = calibration->GetVdrift(idet,col,row);
318 Float_t t0 = calibration->GetT0(idet,col,row);
319 Float_t samplingFrequency = calibration->GetSamplingFrequency();
323 return timebin / samplingFrequency * vdrift;
327 //_____________________________________________________________________________
328 void AliTRDclusterizer::ResetRecPoints()
331 // Resets the list of rec points
335 fRecPoints->Delete();
340 //_____________________________________________________________________________
341 TObjArray* AliTRDclusterizer::RecPoints()
344 // Returns the list of rec points
348 fRecPoints = new TObjArray(400);