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 "AliTRDcalibDB.h"
38 ClassImp(AliTRDclusterizer)
40 //_____________________________________________________________________________
41 AliTRDclusterizer::AliTRDclusterizer():TNamed()
44 // AliTRDclusterizer default constructor
53 //_____________________________________________________________________________
54 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
58 // AliTRDclusterizer default constructor
67 //_____________________________________________________________________________
68 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c):TNamed(c)
71 // AliTRDclusterizer copy constructor
74 ((AliTRDclusterizer &) c).Copy(*this);
78 //_____________________________________________________________________________
79 AliTRDclusterizer::~AliTRDclusterizer()
82 // AliTRDclusterizer destructor
91 //_____________________________________________________________________________
92 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
95 // Assignment operator
98 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
103 //_____________________________________________________________________________
104 void AliTRDclusterizer::Copy(TObject &c) const
110 ((AliTRDclusterizer &) c).fClusterTree = NULL;
111 ((AliTRDclusterizer &) c).fRecPoints = NULL;
112 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
116 //_____________________________________________________________________________
117 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
120 // Opens the AliROOT file. Output and input are in the same file
122 TString evfoldname = AliConfig::GetDefaultEventFolderName();
123 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
125 fRunLoader = AliRunLoader::Open(name);
128 Error("Open","Can not open session for file %s.",name);
138 //_____________________________________________________________________________
139 Bool_t AliTRDclusterizer::OpenOutput()
142 // Open the output file
145 TObjArray *ioArray = 0;
147 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
148 loader->MakeTree("R");
149 fClusterTree = loader->TreeR();
150 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
157 //_____________________________________________________________________________
158 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
161 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
164 // Connect the AliRoot file containing Geometry, Kine, and Hits
165 if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice();
166 gAlice = fRunLoader->GetAliRun();
169 fRunLoader->LoadgAlice();
170 gAlice = fRunLoader->GetAliRun();
172 printf("AliTRDclusterizer::OpenInput -- ");
173 printf("Could not find AliRun object.\n");
178 // Import the Trees for the event nEvent in the file
179 fRunLoader->GetEvent(nEvent);
185 //_____________________________________________________________________________
186 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
189 // Fills TRDcluster branch in the tree with the clusters
190 // found in detector = det. For det=-1 writes the tree.
193 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
194 printf("AliTRDclusterizer::WriteClusters -- ");
195 printf("Unexpected detector index %d.\n",det);
200 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
202 TObjArray *ioArray = 0;
203 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
206 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
208 Int_t nRecPoints = RecPoints()->GetEntriesFast();
209 TObjArray *detRecPoints = new TObjArray(400);
211 for (Int_t i = 0; i < nRecPoints; i++) {
212 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
213 if (det == c->GetDetector()) {
214 detRecPoints->AddLast(c);
217 printf("AliTRDclusterizer::WriteClusters --");
218 printf("Attempt to write a cluster with unexpected detector index\n");
222 branch->SetAddress(&detRecPoints);
223 fClusterTree->Fill();
233 Info("WriteClusters","Writing the cluster tree %s for event %d."
234 ,fClusterTree->GetName(),fRunLoader->GetEventNumber());
236 fClusterTree->Write();
237 AliTRDgeometry *geo = fTRD->GetGeometry();
238 geo->SetName("TRDgeometry");
241 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
242 loader->WriteRecPoints("OVERWRITE");
248 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
249 loader->WriteDigits("OVERWRITE");
251 printf("AliTRDclusterizer::WriteClusters -- ");
252 printf("Unexpected detector index %d.\n",det);
259 //_____________________________________________________________________________
260 AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin, Int_t det, Double_t amp
261 , Int_t *tracks, Double_t *sig, Int_t iType, Float_t center)
264 // Add a cluster for the TRD
267 AliTRDcluster *c = new AliTRDcluster();
270 c->AddTrackIndex(tracks);
275 c->SetSigmaY2(sig[0]);
276 c->SetSigmaZ2(sig[1]);
277 c->SetLocalTimeBin(timebin);
278 c->SetCenter(center);
301 //_____________________________________________________________________________
302 Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet, Int_t col, Int_t row)
305 // Calculates the local x position in the detector from the timebin, depends on the drift velocity
309 AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
313 Float_t vdrift = calibration->GetVdrift(idet, col, row);
314 Float_t t0 = calibration->GetT0(idet, col, row);
315 Float_t samplingFrequency = calibration->GetSamplingFrequency();
319 return timebin / samplingFrequency * vdrift;