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>
30 #include "AliRunLoader.h"
31 #include "AliLoader.h"
34 #include "AliTRDclusterizer.h"
35 #include "AliTRDcluster.h"
36 #include "AliTRDrecPoint.h"
37 #include "AliTRDgeometry.h"
38 #include "AliTRDcalibDB.h"
40 ClassImp(AliTRDclusterizer)
42 //_____________________________________________________________________________
43 AliTRDclusterizer::AliTRDclusterizer()
50 // AliTRDclusterizer default constructor
55 //_____________________________________________________________________________
56 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
63 // AliTRDclusterizer constructor
68 //_____________________________________________________________________________
69 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
76 // AliTRDclusterizer copy constructor
81 //_____________________________________________________________________________
82 AliTRDclusterizer::~AliTRDclusterizer()
85 // AliTRDclusterizer destructor
95 //_____________________________________________________________________________
96 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
99 // Assignment operator
102 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
107 //_____________________________________________________________________________
108 void AliTRDclusterizer::Copy(TObject &c) const
114 ((AliTRDclusterizer &) c).fClusterTree = NULL;
115 ((AliTRDclusterizer &) c).fRecPoints = NULL;
119 //_____________________________________________________________________________
120 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
123 // Opens the AliROOT file. Output and input are in the same file
126 TString evfoldname = AliConfig::GetDefaultEventFolderName();
127 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
130 fRunLoader = AliRunLoader::Open(name);
134 AliError(Form("Can not open session for file %s.",name));
145 //_____________________________________________________________________________
146 Bool_t AliTRDclusterizer::OpenOutput()
149 // Open the output file
152 TObjArray *ioArray = 0;
154 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
155 loader->MakeTree("R");
157 fClusterTree = loader->TreeR();
158 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
164 //_____________________________________________________________________________
165 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
168 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
171 // Connect the AliRoot file containing Geometry, Kine, and Hits
172 if (fRunLoader->GetAliRun() == 0x0) {
173 fRunLoader->LoadgAlice();
175 gAlice = fRunLoader->GetAliRun();
178 fRunLoader->LoadgAlice();
179 gAlice = fRunLoader->GetAliRun();
181 AliError("Could not find AliRun object.\n");
186 // Import the Trees for the event nEvent in the file
187 fRunLoader->GetEvent(nEvent);
193 //_____________________________________________________________________________
194 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
197 // Fills TRDcluster branch in the tree with the clusters
198 // found in detector = det. For det=-1 writes the tree.
202 (det >= AliTRDgeometry::Ndet())) {
203 AliError(Form("Unexpected detector index %d.\n",det));
207 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
209 TObjArray *ioArray = 0;
210 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
214 (det < AliTRDgeometry::Ndet())) {
216 Int_t nRecPoints = RecPoints()->GetEntriesFast();
217 TObjArray *detRecPoints = new TObjArray(400);
219 for (Int_t i = 0; i < nRecPoints; i++) {
220 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
221 if (det == c->GetDetector()) {
222 detRecPoints->AddLast(c);
225 AliError("Attempt to write a cluster with unexpected detector index\n");
229 branch->SetAddress(&detRecPoints);
230 fClusterTree->Fill();
240 AliInfo(Form("Writing the cluster tree %s for event %d."
241 ,fClusterTree->GetName(),fRunLoader->GetEventNumber()));
245 branch->SetAddress(&fRecPoints);
247 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
248 loader->WriteRecPoints("OVERWRITE");
253 AliError("Cluster tree does not exist. Cannot write clusters.\n");
262 AliError(Form("Unexpected detector index %d.\n",det));
269 //_____________________________________________________________________________
270 AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin
271 , Int_t det, Double_t amp
272 , Int_t *tracks, Double_t *sig
273 , Int_t iType, Float_t center)
276 // Add a cluster for the TRD
279 AliTRDcluster *c = new AliTRDcluster();
286 c->SetSigmaY2(sig[0]);
287 c->SetSigmaZ2(sig[1]);
288 c->SetLocalTimeBin(timebin);
289 c->SetCenter(center);
292 c->AddTrackIndex(tracks);
318 //_____________________________________________________________________________
319 Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet
320 , Int_t col, Int_t row)
323 // Calculates the local x position in the detector from the timebin,
324 // depends on the drift velocity and t0
327 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
329 AliError("Cannot find calibration object");
333 Float_t vdrift = calibration->GetVdrift(idet,col,row);
334 Float_t t0 = calibration->GetT0(idet,col,row);
335 Float_t samplingFrequency = calibration->GetSamplingFrequency();
339 return timebin / samplingFrequency * vdrift;
343 //_____________________________________________________________________________
344 void AliTRDclusterizer::ResetRecPoints()
347 // Resets the list of rec points
351 fRecPoints->Delete();
356 //_____________________________________________________________________________
357 TObjArray* AliTRDclusterizer::RecPoints()
360 // Returns the list of rec points
364 fRecPoints = new TObjArray(400);