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::OpenOutput(TTree *clusterTree)
170 // Connect the output tree
173 TObjArray *ioArray = 0;
175 fClusterTree = clusterTree;
176 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
182 //_____________________________________________________________________________
183 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
186 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
189 // Import the Trees for the event nEvent in the file
190 fRunLoader->GetEvent(nEvent);
196 //_____________________________________________________________________________
197 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
200 // Fills TRDcluster branch in the tree with the clusters
201 // found in detector = det. For det=-1 writes the tree.
205 (det >= AliTRDgeometry::Ndet())) {
206 AliError(Form("Unexpected detector index %d.\n",det));
210 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
212 TObjArray *ioArray = 0;
213 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
217 (det < AliTRDgeometry::Ndet())) {
219 Int_t nRecPoints = RecPoints()->GetEntriesFast();
220 TObjArray *detRecPoints = new TObjArray(400);
222 for (Int_t i = 0; i < nRecPoints; i++) {
223 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
224 if (det == c->GetDetector()) {
225 detRecPoints->AddLast(c);
228 AliError("Attempt to write a cluster with unexpected detector index\n");
232 branch->SetAddress(&detRecPoints);
233 fClusterTree->Fill();
243 AliInfo(Form("Writing the cluster tree %s for event %d."
244 ,fClusterTree->GetName(),fRunLoader->GetEventNumber()));
248 branch->SetAddress(&fRecPoints);
250 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
251 loader->WriteRecPoints("OVERWRITE");
256 AliError("Cluster tree does not exist. Cannot write clusters.\n");
265 AliError(Form("Unexpected detector index %d.\n",det));
272 //_____________________________________________________________________________
273 AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin
274 , Int_t det, Double_t amp
275 , Int_t *tracks, Double_t *sig
276 , Int_t iType, Int_t col
281 // Add a cluster for the TRD
284 AliTRDcluster *c = new AliTRDcluster();
291 c->SetSigmaY2(sig[0]);
292 c->SetSigmaZ2(sig[1]);
293 c->SetLocalTimeBin(timebin);
294 c->SetCenter(center);
296 c->SetVolumeId(volid);
299 c->AddTrackIndex(tracks);
325 //_____________________________________________________________________________
326 Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet
327 , Int_t col, Int_t row)
330 // Calculates the local x position in the detector from the timebin,
331 // depends on the drift velocity and t0
334 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
336 AliError("Cannot find calibration object");
339 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
341 AliError("Could not get common parameters\n");
345 Float_t vdrift = calibration->GetVdrift(idet,col,row);
346 Float_t t0 = calibration->GetT0(idet,col,row);
347 Float_t samplingFrequency = parCom->GetSamplingFrequency();
351 return timebin / samplingFrequency * vdrift;
355 //_____________________________________________________________________________
356 void AliTRDclusterizer::ResetRecPoints()
359 // Resets the list of rec points
363 fRecPoints->Delete();
368 //_____________________________________________________________________________
369 TObjArray* AliTRDclusterizer::RecPoints()
372 // Returns the list of rec points
376 fRecPoints = new TObjArray(400);