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"
38 ClassImp(AliTRDclusterizer)
40 //_____________________________________________________________________________
41 AliTRDclusterizer::AliTRDclusterizer():TNamed()
44 // AliTRDclusterizer default constructor
54 //_____________________________________________________________________________
55 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
59 // AliTRDclusterizer default constructor
69 //_____________________________________________________________________________
70 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c):TNamed(c)
73 // AliTRDclusterizer copy constructor
76 ((AliTRDclusterizer &) c).Copy(*this);
80 //_____________________________________________________________________________
81 AliTRDclusterizer::~AliTRDclusterizer()
84 // AliTRDclusterizer destructor
93 //_____________________________________________________________________________
94 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
97 // Assignment operator
100 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
105 //_____________________________________________________________________________
106 void AliTRDclusterizer::Copy(TObject &c)
112 ((AliTRDclusterizer &) c).fClusterTree = NULL;
113 ((AliTRDclusterizer &) c).fRecPoints = NULL;
114 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
115 ((AliTRDclusterizer &) c).fPar = 0;
119 //_____________________________________________________________________________
120 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
123 // Opens the AliROOT file. Output and input are in the same file
125 TString evfoldname = AliConfig::GetDefaultEventFolderName();
126 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
128 fRunLoader = AliRunLoader::Open(name);
131 Error("Open","Can not open session for file %s.",name);
141 //_____________________________________________________________________________
142 Bool_t AliTRDclusterizer::OpenOutput()
145 // Open the output file
148 TObjArray *ioArray = 0;
150 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
151 loader->MakeTree("R");
152 fClusterTree = loader->TreeR();
153 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
160 //_____________________________________________________________________________
161 Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
164 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
167 // Connect the AliRoot file containing Geometry, Kine, and Hits
168 if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice();
169 gAlice = fRunLoader->GetAliRun();
172 fRunLoader->LoadgAlice();
173 gAlice = fRunLoader->GetAliRun();
175 printf("AliTRDclusterizer::OpenInput -- ");
176 printf("Could not find AliRun object.\n");
181 // Import the Trees for the event nEvent in the file
182 fRunLoader->GetEvent(nEvent);
188 //_____________________________________________________________________________
189 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
192 // Fills TRDcluster branch in the tree with the clusters
193 // found in detector = det. For det=-1 writes the tree.
196 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
197 printf("AliTRDclusterizer::WriteClusters -- ");
198 printf("Unexpected detector index %d.\n",det);
203 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
205 TObjArray *ioArray = 0;
206 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
209 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
211 Int_t nRecPoints = RecPoints()->GetEntriesFast();
212 TObjArray *detRecPoints = new TObjArray(400);
214 for (Int_t i = 0; i < nRecPoints; i++) {
215 AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
216 if (det == c->GetDetector()) {
217 detRecPoints->AddLast(c);
220 printf("AliTRDclusterizer::WriteClusters --");
221 printf("Attempt to write a cluster with unexpected detector index\n");
225 branch->SetAddress(&detRecPoints);
226 fClusterTree->Fill();
236 Info("WriteClusters","Writing the cluster tree %s for event %d."
237 ,fClusterTree->GetName(),fRunLoader->GetEventNumber());
239 fClusterTree->Write();
240 AliTRDgeometry *geo = fTRD->GetGeometry();
241 geo->SetName("TRDgeometry");
245 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
246 loader->WriteRecPoints("OVERWRITE");
252 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
253 loader->WriteDigits("OVERWRITE");
255 printf("AliTRDclusterizer::WriteClusters -- ");
256 printf("Unexpected detector index %d.\n",det);
263 //_____________________________________________________________________________
264 void AliTRDclusterizer::AddCluster(Float_t *pos, Int_t det, Float_t amp
265 , Int_t *tracks, Float_t *sig, Int_t iType)
268 // Add a cluster for the TRD
271 AliTRDcluster *c = new AliTRDcluster();
274 c->AddTrackIndex(tracks);
278 c->SetSigmaY2(sig[0]);
279 c->SetSigmaZ2(sig[1]);
280 c->SetLocalTimeBin(((Int_t) pos[2]));