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(){
42 // Default constructor.
48 // A zero-ed constructed AliITSFindClustersV2 class.
51 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
57 fSlowFast = kFALSE; // slow simulation
58 fInit = kFALSE; // Init failed
60 //______________________________________________________________________
61 AliITSFindClustersV2::AliITSFindClustersV2(const TString infile,
62 const TString outfile){
63 // Standard constructor.
65 // const TString infile Input file name where the RecPoints are
67 // const TString outfile Output file where V2 tracking clulsters
68 // are to be written. if =="" writen to the
69 // same file as input.
73 // A standardly constructed AliITSFindClustersV2 class.
76 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
82 fSlowFast = kFALSE; // slow simulation
83 fInit = kFALSE; // Init failed
85 fInFileName = new TString(infile);
86 if(outfile.CompareTo("")!=0){
87 fOutFileName = new TString(outfile);
88 } // end if outfile.CompareeTo("")!=0
91 fIn = new TFile(fInFileName->Data(),"READ");
92 fOut = new TFile(fOutFileName->Data(),"UPDATE");
93 }else{ // open fIn file for update
94 fIn = new TFile(fInFileName->Data(),"UPDATE");
97 fAr = (AliRun*) fIn->Get("gAlice");
99 Warning("AliITSFindClusterV2",
100 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
103 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
105 AliITS *its = (AliITS*) fAr->GetModule("ITS");
107 Warning("AliITSFindClusterV2",
108 "Can't fine the ITS in gAlice. Aborting.");
111 fGeom = its->GetITSgeom();
113 Warning("AliITSFindClusterV2",
114 "Can't fine the ITS geometry in gAlice. Aborting.");
118 AliRunLoader* rl = AliRunLoader::Open("galice.root");
120 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
122 Warning("AliITSFindClusterV2",
123 "Can't fine the ITS geometry in gAlice. Aborting.");
131 //______________________________________________________________________
132 AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
134 // Standard constructor.
136 // const TFile *in Input file where the RecPoints are
138 // const Tfile *out Output file where V2 tracking clulsters
139 // are to be written. if ==0 writen to the
140 // same file as input.
144 // A standardly constructed AliITSFindClustersV2 class.
147 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
153 fSlowFast = kFALSE; // slow simulation
154 fInit = kFALSE; // Init failed
158 fAr = (AliRun*) fIn->Get("gAlice");
160 Warning("AliITSFindClusterV2",
161 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
164 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
166 AliITS *its = (AliITS*) fAr->GetModule("ITS");
168 Warning("AliITSFindClusterV2",
169 "Can't fine the ITS in gAlice. Aborting.");
172 fGeom = its->GetITSgeom();
174 AliRunLoader* rl = AliRunLoader::Open("galice.root");
176 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
178 Warning("AliITSFindClusterV2",
179 "Can't fine the ITS geometry in gAlice. Aborting.");
187 //______________________________________________________________________
188 AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
189 const TString outfile){
190 // Standard constructor.
192 // const TString infile Input file name where the RecPoints are
194 // const TString outfile Output file where V2 tracking clulsters
195 // are to be written. if =="" writen to the
196 // same file as input.
200 // A standardly constructed AliITSFindClustersV2 class.
203 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
209 fSlowFast = kFALSE; // slow simulation
210 fInit = kFALSE; // Init failed
212 if(outfile.CompareTo("")!=0){
213 fOutFileName = new TString(outfile);
214 } // end if outfile.CompareeTo("")!=0
217 fOut = new TFile(fOutFileName->Data(),"UPDATE");
222 Warning("AliITSFindClusterV2",
227 /* AliITS *its = (AliITS*) fAr->GetModule("ITS");
229 Warning("AliITSFindClusterV2",
230 "Can't fine the ITS in gAlice. Aborting.");
233 fGeom = its->GetITSgeom();
235 AliRunLoader* rl = AliRunLoader::Open("galice.root");
237 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
239 Warning("AliITSFindClusterV2",
240 "Can't fine the ITS geometry in gAlice. Aborting.");
248 //______________________________________________________________________
249 AliITSFindClustersV2::AliITSFindClustersV2(const AliITSFindClustersV2 &/*rec*/):TTask(/*rec*/){
252 Error("Copy constructor","Copy constructor not allowed");
255 //______________________________________________________________________
256 AliITSFindClustersV2& AliITSFindClustersV2::operator=(const AliITSFindClustersV2& /*source*/){
257 // Assignment operator. This is a function which is not allowed to be
259 Error("operator=","Assignment operator not allowed\n");
263 //______________________________________________________________________
264 AliITSFindClustersV2::~AliITSFindClustersV2(){
265 // Default constructor.
271 // A destroyed AliITSFindclustersV2 class.
273 fGeom = 0; // Deleted when AliRun/ITS is deleted.
274 if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
276 if(fIn->IsOpen()) fIn->Close();
284 if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
286 if(fOut->IsOpen()) fOut->Close();
293 if(fDeletfAr && !fAr){
294 cout << "deleting fAr."<< endl;
297 cout << "fAr deleted OK."<< endl;
298 } // end if fDeletfAr
300 //______________________________________________________________________
301 void AliITSFindClustersV2::Exec(const Option_t *opt){
302 // Main FindclustersV2 function.
304 // Option_t * opt list of subdetector to digitize. =0 all.
312 Warning("Exec","(opt=%s) Initilization not succesfull. Aborting.\n",opt);
319 TTree *pTree = fAr->TreeR();
321 Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
325 if(fSlowFast) sprintf(name,"ITSRecPointsF");
326 else sprintf(name,"ITSRecPoints");
327 branch = pTree->GetBranch(name);
329 Warning("Exec","Can't find branch %s in TreeR fSlowFast=%d",
333 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
334 branch->SetAddress(&points);
335 Int_t nentr = (Int_t) branch->GetEntries();
338 TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
339 sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
340 TTree *cTree = new TTree(name,"ITS clusters");
341 cTree->Branch("Clusters",&cluster);
342 TClonesArray &cl = *cluster;
346 Int_t i,j,lay,lad,det,nclusters=0,ncl;
347 Float_t kmip,x,y,zshift,yshift;
352 for(i=0;i<nentr;i++){
355 ncl = points->GetEntriesFast();
361 fGeom->GetModuleId(i,lay,lad,det);
362 fGeom->GetTrans(i,x,y,zshift);
363 fGeom->GetRotMatrix(i,rot);
364 yshift = x*rot[0] + y*rot[1];
365 kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
366 if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
367 if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
369 p = (AliITSRecPoint*)(points->UncheckedAt(j));
370 lp[0] = - (p->GetDetLocalX() + yshift);
371 if(lay==1) lp[0] = -lp[0];
372 lp[1] = p->GetZ() + zshift;
373 lp[2] = p->GetSigmaDetLocX2();
374 lp[3] = p->GetSigmaZ2();
375 lp[4] = p->GetQ()/kmip;
376 lab[0] = p->GetLabel(0);
377 lab[1] = p->GetLabel(1);
378 lab[2] = p->GetLabel(2);
382 part = (TParticle*) fAr->GetMCApp()->Particle(lad);
384 while(part->P() < 0.005){
385 if(part->GetFirstMother()<0){
386 Warning("Exec","Primary momentum: %e",part->P());
388 } // end if part->GetFirstMother()<0
389 lad = part->GetFirstMother();
390 part = (TParticle*) fAr->GetMCApp()->Particle(lad);
391 } // end while part->P() < 0.005
392 if(lab[1]<0) lab[1] = lad;
393 else if(lab[2]<0) lab[2] = lad;
394 else Warning("Exec","No empty lables!");
396 Int_t info[3]={0,0,0};
397 new(cl[j]) AliITSclusterV2(lab,lp,info);