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 ///////////////////////////////////////////////////////////////////////////////
29 #include "AliRunLoader.h"
30 #include "AliLoader.h"
32 #include "AliTRDclusterizer.h"
33 #include "AliTRDcluster.h"
34 #include "AliTRDrecPoint.h"
35 #include "AliTRDgeometry.h"
36 #include "AliTRDparameter.h"
37 #include "AliTRDcalibDB.h"
39 ClassImp(AliTRDclusterizer)
41 //_____________________________________________________________________________
42 AliTRDclusterizer::AliTRDclusterizer():TNamed()
45 // AliTRDclusterizer default constructor
55 //_____________________________________________________________________________
56 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
60 // AliTRDclusterizer default constructor
70 //_____________________________________________________________________________
71 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c):TNamed(c)
74 // AliTRDclusterizer copy constructor
77 ((AliTRDclusterizer &) c).Copy(*this);
81 //_____________________________________________________________________________
82 AliTRDclusterizer::~AliTRDclusterizer()
85 // 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;
115 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
116 ((AliTRDclusterizer &) c).fPar = 0;
120 //_____________________________________________________________________________
121 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
124 // Opens the AliROOT file. Output and input are in the same file
126 TString evfoldname = AliConfig::GetDefaultEventFolderName();
127 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
129 fRunLoader = AliRunLoader::Open(name);
132 Error("Open","Can not open session for file %s.",name);
142 //_____________________________________________________________________________
143 Bool_t AliTRDclusterizer::OpenOutput()
146 // Open the output file
149 TObjArray *ioArray = 0;
151 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
152 loader->MakeTree("R");
153 fClusterTree = loader->TreeR();
154 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
161 //_____________________________________________________________________________
162 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
165 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
168 // Connect the AliRoot file containing Geometry, Kine, and Hits
169 if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice();
170 gAlice = fRunLoader->GetAliRun();
173 fRunLoader->LoadgAlice();
174 gAlice = fRunLoader->GetAliRun();
176 printf("AliTRDclusterizer::OpenInput -- ");
177 printf("Could not find AliRun object.\n");
182 // Import the Trees for the event nEvent in the file
183 fRunLoader->GetEvent(nEvent);
189 //_____________________________________________________________________________
190 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
193 // Fills TRDcluster branch in the tree with the clusters
194 // found in detector = det. For det=-1 writes the tree.
197 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
198 printf("AliTRDclusterizer::WriteClusters -- ");
199 printf("Unexpected detector index %d.\n",det);
204 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
206 TObjArray *ioArray = 0;
207 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
210 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
212 Int_t nRecPoints = RecPoints()->GetEntriesFast();
213 TObjArray *detRecPoints = new TObjArray(400);
215 for (Int_t i = 0; i < nRecPoints; i++) {
216 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
217 if (det == c->GetDetector()) {
218 detRecPoints->AddLast(c);
221 printf("AliTRDclusterizer::WriteClusters --");
222 printf("Attempt to write a cluster with unexpected detector index\n");
226 branch->SetAddress(&detRecPoints);
227 fClusterTree->Fill();
237 Info("WriteClusters","Writing the cluster tree %s for event %d."
238 ,fClusterTree->GetName(),fRunLoader->GetEventNumber());
240 fClusterTree->Write();
241 AliTRDgeometry *geo = fTRD->GetGeometry();
242 geo->SetName("TRDgeometry");
246 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
247 loader->WriteRecPoints("OVERWRITE");
253 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
254 loader->WriteDigits("OVERWRITE");
256 printf("AliTRDclusterizer::WriteClusters -- ");
257 printf("Unexpected detector index %d.\n",det);
264 //_____________________________________________________________________________
265 AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin, Int_t det, Double_t amp
266 , Int_t *tracks, Double_t *sig, Int_t iType, Float_t center)
269 // Add a cluster for the TRD
272 AliTRDcluster *c = new AliTRDcluster();
275 c->AddTrackIndex(tracks);
280 c->SetSigmaY2(sig[0]);
281 c->SetSigmaZ2(sig[1]);
282 c->SetLocalTimeBin(timebin);
283 c->SetCenter(center);
306 //_____________________________________________________________________________
307 Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Float_t vdrift)
310 // Calculates the local x position in the detector from the timebin, depends on the drift velocity
311 // The timebin has to be t0 corrected already
314 AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
318 Int_t totalTimebins = calibration->GetNumberOfTimeBins();
319 Float_t samplingFrequency = calibration->GetSamplingFrequency();
320 return (totalTimebins - timebin) / samplingFrequency * vdrift;