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"
38 #include "AliTRDCommonParam.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
103 ((AliTRDclusterizer &) c).Copy(*this);
109 //_____________________________________________________________________________
110 void AliTRDclusterizer::Copy(TObject &c) const
116 ((AliTRDclusterizer &) c).fClusterTree = NULL;
117 ((AliTRDclusterizer &) c).fRecPoints = NULL;
121 //_____________________________________________________________________________
122 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
125 // Opens the AliROOT file. Output and input are in the same file
128 TString evfoldname = AliConfig::GetDefaultEventFolderName();
129 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
132 fRunLoader = AliRunLoader::Open(name);
136 AliError(Form("Can not open session for file %s.",name));
147 //_____________________________________________________________________________
148 Bool_t AliTRDclusterizer::OpenOutput()
151 // Open the output file
154 TObjArray *ioArray = 0;
156 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
157 loader->MakeTree("R");
159 fClusterTree = loader->TreeR();
160 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
166 //_____________________________________________________________________________
167 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
170 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
173 // Import the Trees for the event nEvent in the file
174 fRunLoader->GetEvent(nEvent);
180 //_____________________________________________________________________________
181 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
184 // Fills TRDcluster branch in the tree with the clusters
185 // found in detector = det. For det=-1 writes the tree.
189 (det >= AliTRDgeometry::Ndet())) {
190 AliError(Form("Unexpected detector index %d.\n",det));
194 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
196 TObjArray *ioArray = 0;
197 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
201 (det < AliTRDgeometry::Ndet())) {
203 Int_t nRecPoints = RecPoints()->GetEntriesFast();
204 TObjArray *detRecPoints = new TObjArray(400);
206 for (Int_t i = 0; i < nRecPoints; i++) {
207 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
208 if (det == c->GetDetector()) {
209 detRecPoints->AddLast(c);
212 AliError("Attempt to write a cluster with unexpected detector index\n");
216 branch->SetAddress(&detRecPoints);
217 fClusterTree->Fill();
227 AliInfo(Form("Writing the cluster tree %s for event %d."
228 ,fClusterTree->GetName(),fRunLoader->GetEventNumber()));
232 branch->SetAddress(&fRecPoints);
234 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
235 loader->WriteRecPoints("OVERWRITE");
240 AliError("Cluster tree does not exist. Cannot write clusters.\n");
249 AliError(Form("Unexpected detector index %d.\n",det));
256 //_____________________________________________________________________________
257 AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin
258 , Int_t det, Double_t amp
259 , Int_t *tracks, Double_t *sig
260 , Int_t iType, Float_t center)
263 // Add a cluster for the TRD
266 AliTRDcluster *c = new AliTRDcluster();
273 c->SetSigmaY2(sig[0]);
274 c->SetSigmaZ2(sig[1]);
275 c->SetLocalTimeBin(timebin);
276 c->SetCenter(center);
279 c->AddTrackIndex(tracks);
305 //_____________________________________________________________________________
306 Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet
307 , Int_t col, Int_t row)
310 // Calculates the local x position in the detector from the timebin,
311 // depends on the drift velocity and t0
314 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
316 AliError("Cannot find calibration object");
319 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
321 AliError("Could not get common parameters\n");
325 Float_t vdrift = calibration->GetVdrift(idet,col,row);
326 Float_t t0 = calibration->GetT0(idet,col,row);
327 Float_t samplingFrequency = parCom->GetSamplingFrequency();
331 return timebin / samplingFrequency * vdrift;
335 //_____________________________________________________________________________
336 void AliTRDclusterizer::ResetRecPoints()
339 // Resets the list of rec points
343 fRecPoints->Delete();
348 //_____________________________________________________________________________
349 TObjArray* AliTRDclusterizer::RecPoints()
352 // Returns the list of rec points
356 fRecPoints = new TObjArray(400);