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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////
18 //Class for reconstruction of clusters V2 //
21 ///////////////////////////////////////////////////////////////////
26 #include <TClonesArray.h>
27 #include <TParticle.h>
30 #include "AliHeader.h"
32 #include "AliITSRecPoint.h"
33 #include "AliITSFindClustersV2.h"
34 #include "AliITSclusterV2.h"
35 #include "AliITSgeom.h"
38 ClassImp(AliITSFindClustersV2)
40 //______________________________________________________________________
41 AliITSFindClustersV2::AliITSFindClustersV2():
51 // Default constructor.
57 // A zero-ed constructed AliITSFindClustersV2 class.
60 //______________________________________________________________________
61 AliITSFindClustersV2::AliITSFindClustersV2(const TString infile,
62 const TString outfile):
72 // Standard constructor.
74 // const TString infile Input file name where the RecPoints are
76 // const TString outfile Output file where V2 tracking clulsters
77 // are to be written. if =="" writen to the
78 // same file as input.
82 // A standardly constructed AliITSFindClustersV2 class.
84 fInFileName = new TString(infile);
85 if(outfile.CompareTo("")!=0){
86 fOutFileName = new TString(outfile);
87 } // end if outfile.CompareeTo("")!=0
90 fIn = new TFile(fInFileName->Data(),"READ");
91 fOut = new TFile(fOutFileName->Data(),"UPDATE");
92 }else{ // open fIn file for update
93 fIn = new TFile(fInFileName->Data(),"UPDATE");
96 fAr = (AliRun*) fIn->Get("gAlice");
98 Warning("AliITSFindClusterV2",
99 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
102 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
104 AliITS *its = (AliITS*) fAr->GetModule("ITS");
106 Warning("AliITSFindClusterV2",
107 "Can't fine the ITS in gAlice. Aborting.");
110 fGeom = its->GetITSgeom();
112 Warning("AliITSFindClusterV2",
113 "Can't fine the ITS geometry in gAlice. Aborting.");
117 AliRunLoader* rl = AliRunLoader::Open("galice.root");
119 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
121 Warning("AliITSFindClusterV2",
122 "Can't fine the ITS geometry in gAlice. Aborting.");
130 //______________________________________________________________________
131 AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
142 // Standard constructor.
144 // const TFile *in Input file where the RecPoints are
146 // const Tfile *out Output file where V2 tracking clulsters
147 // are to be written. if ==0 writen to the
148 // same file as input.
152 // A standardly constructed AliITSFindClustersV2 class.
156 fAr = (AliRun*) fIn->Get("gAlice");
158 Warning("AliITSFindClusterV2",
159 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
162 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
164 AliITS *its = (AliITS*) fAr->GetModule("ITS");
166 Warning("AliITSFindClusterV2",
167 "Can't fine the ITS in gAlice. Aborting.");
170 fGeom = its->GetITSgeom();
172 AliRunLoader* rl = AliRunLoader::Open("galice.root");
174 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
176 Warning("AliITSFindClusterV2",
177 "Can't fine the ITS geometry in gAlice. Aborting.");
185 //______________________________________________________________________
186 AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
187 const TString outfile):
197 // Standard constructor.
199 // const TString infile Input file name where the RecPoints are
201 // const TString outfile Output file where V2 tracking clulsters
202 // are to be written. if =="" writen to the
203 // same file as input.
207 // A standardly constructed AliITSFindClustersV2 class.
209 if(outfile.CompareTo("")!=0){
210 fOutFileName = new TString(outfile);
211 } // end if outfile.CompareeTo("")!=0
214 fOut = new TFile(fOutFileName->Data(),"UPDATE");
219 Warning("AliITSFindClusterV2",
224 /* AliITS *its = (AliITS*) fAr->GetModule("ITS");
226 Warning("AliITSFindClusterV2",
227 "Can't fine the ITS in gAlice. Aborting.");
230 fGeom = its->GetITSgeom();
232 AliRunLoader* rl = AliRunLoader::Open("galice.root");
234 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
236 Warning("AliITSFindClusterV2",
237 "Can't fine the ITS geometry in gAlice. Aborting.");
245 //______________________________________________________________________
246 AliITSFindClustersV2::AliITSFindClustersV2(const AliITSFindClustersV2 &rec):TTask(rec),
248 fDeletfAr(rec.fDeletfAr),
250 fInFileName(rec.fInFileName),
251 fOutFileName(rec.fOutFileName),
255 fSlowFast(rec.fSlowFast){
260 //______________________________________________________________________
261 AliITSFindClustersV2& AliITSFindClustersV2::operator=(const AliITSFindClustersV2& source){
262 // Assignment operator.
263 this->~AliITSFindClustersV2();
264 new(this) AliITSFindClustersV2(source);
268 //______________________________________________________________________
269 AliITSFindClustersV2::~AliITSFindClustersV2(){
270 // Default constructor.
276 // A destroyed AliITSFindclustersV2 class.
278 fGeom = 0; // Deleted when AliRun/ITS is deleted.
279 if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
281 if(fIn->IsOpen()) fIn->Close();
289 if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
291 if(fOut->IsOpen()) fOut->Close();
298 if(fDeletfAr && !fAr){
299 cout << "deleting fAr."<< endl;
302 cout << "fAr deleted OK."<< endl;
303 } // end if fDeletfAr
305 //______________________________________________________________________
306 void AliITSFindClustersV2::Exec(const Option_t *opt){
307 // Main FindclustersV2 function.
309 // Option_t * opt list of subdetector to digitize. =0 all.
317 Warning("Exec","(opt=%s) Initilization not succesfull. Aborting.\n",opt);
324 TTree *pTree = fAr->TreeR();
326 Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
330 if(fSlowFast) sprintf(name,"ITSRecPointsF");
331 else sprintf(name,"ITSRecPoints");
332 branch = pTree->GetBranch(name);
334 Warning("Exec","Can't find branch %s in TreeR fSlowFast=%d",
338 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
339 branch->SetAddress(&points);
340 Int_t nentr = (Int_t) branch->GetEntries();
343 TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
344 sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
345 TTree *cTree = new TTree(name,"ITS clusters");
346 cTree->Branch("Clusters",&cluster);
347 TClonesArray &cl = *cluster;
351 Int_t i,j,lay,lad,det,nclusters=0,ncl;
352 Float_t kmip,x,y,zshift,yshift;
357 for(i=0;i<nentr;i++){
360 ncl = points->GetEntriesFast();
366 fGeom->GetModuleId(i,lay,lad,det);
367 fGeom->GetTrans(i,x,y,zshift);
368 fGeom->GetRotMatrix(i,rot);
369 yshift = x*rot[0] + y*rot[1];
370 kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
371 if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
372 if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
374 p = (AliITSRecPoint*)(points->UncheckedAt(j));
375 lp[0] = - (p->GetDetLocalX() + yshift);
376 if(lay==1) lp[0] = -lp[0];
377 lp[1] = p->GetZ() + zshift;
378 lp[2] = p->GetSigmaDetLocX2();
379 lp[3] = p->GetSigmaZ2();
380 lp[4] = p->GetQ()/kmip;
381 lab[0] = p->GetLabel(0);
382 lab[1] = p->GetLabel(1);
383 lab[2] = p->GetLabel(2);
387 part = (TParticle*) fAr->GetMCApp()->Particle(lad);
389 while(part->P() < 0.005){
390 if(part->GetFirstMother()<0){
391 Warning("Exec","Primary momentum: %e",part->P());
393 } // end if part->GetFirstMother()<0
394 lad = part->GetFirstMother();
395 part = (TParticle*) fAr->GetMCApp()->Particle(lad);
396 } // end while part->P() < 0.005
397 if(lab[1]<0) lab[1] = lad;
398 else if(lab[2]<0) lab[2] = lad;
399 else Warning("Exec","No empty lables!");
401 Int_t info[3]={0,0,0};
402 new(cl[j]) AliITSclusterV2(lab,lp,info);