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"
33 #include "AliTRDclusterizer.h"
34 #include "AliTRDcluster.h"
35 #include "AliTRDrecPoint.h"
36 #include "AliTRDgeometry.h"
37 #include "AliTRDparameter.h"
39 ClassImp(AliTRDclusterizer)
41 //_____________________________________________________________________________
42 AliTRDclusterizer::AliTRDclusterizer():TNamed()
45 // AliTRDclusterizer default constructor
56 //_____________________________________________________________________________
57 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
61 // AliTRDclusterizer default constructor
71 //_____________________________________________________________________________
72 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c):TNamed(c)
75 // AliTRDclusterizer copy constructor
78 ((AliTRDclusterizer &) c).Copy(*this);
82 //_____________________________________________________________________________
83 AliTRDclusterizer::~AliTRDclusterizer()
86 // 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)
110 ((AliTRDclusterizer &) c).fClusterTree = NULL;
111 ((AliTRDclusterizer &) c).fEvent = 0;
112 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
113 ((AliTRDclusterizer &) c).fPar = 0;
117 //_____________________________________________________________________________
118 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
121 // Opens the AliROOT file. Output and input are in the same file
123 fRunLoader = AliRunLoader::Open(name);
126 Error("Open","Can not open session for file %s.",name);
136 //_____________________________________________________________________________
137 Bool_t AliTRDclusterizer::OpenOutput()
140 // Open the output file
143 TObjArray *ioArray = 0;
145 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
146 loader->MakeTree("R");
147 fClusterTree = loader->TreeR();
148 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
155 //_____________________________________________________________________________
156 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
159 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
162 // Connect the AliRoot file containing Geometry, Kine, and Hits
163 fRunLoader->LoadgAlice();
164 gAlice = fRunLoader->GetAliRun();
167 fRunLoader->LoadgAlice();
168 gAlice = fRunLoader->GetAliRun();
170 printf("AliTRDclusterizer::OpenInput -- ");
171 printf("Could not find AliRun object.\n");
178 // Import the Trees for the event nEvent in the file
179 fRunLoader->GetEvent(fEvent);
181 // Get the TRD object
182 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
184 printf("AliTRDclusterizer::OpenInput -- ");
185 printf("No TRD detector object found\n");
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.
201 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
202 printf("AliTRDclusterizer::WriteClusters -- ");
203 printf("Unexpected detector index %d.\n",det);
208 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
210 TObjArray *ioArray = 0;
211 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
214 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
216 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
217 TObjArray *detRecPoints = new TObjArray(400);
219 for (Int_t i = 0; i < nRecPoints; i++) {
220 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
221 if (det == c->GetDetector()) {
222 detRecPoints->AddLast(c);
225 printf("AliTRDclusterizer::WriteClusters --");
226 printf("Attempt to write a cluster with unexpected detector index\n");
230 branch->SetAddress(&detRecPoints);
231 fClusterTree->Fill();
239 printf("AliTRDclusterizer::WriteClusters -- ");
240 printf("Writing the cluster tree %-18s for event %d.\n"
241 ,fClusterTree->GetName(),fEvent);
243 fClusterTree->Write();
244 AliTRDgeometry *geo = fTRD->GetGeometry();
245 geo->SetName("TRDgeometry");
249 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
250 loader->WriteRecPoints("OVERWRITE");
256 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
257 loader->WriteDigits("OVERWRITE");
259 printf("AliTRDclusterizer::WriteClusters -- ");
260 printf("Unexpected detector index %d.\n",det);