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 **************************************************************************/
22 #include <TClonesArray.h>
23 #include <TParticle.h>
26 #include "AliHeader.h"
29 #include "AliITSRecPoint.h"
30 #include "AliITSFindClustersV2.h"
31 #include "AliITSclusterV2.h"
32 #include "AliITSgeom.h"
35 ClassImp(AliITSFindClustersV2)
37 //______________________________________________________________________
38 AliITSFindClustersV2::AliITSFindClustersV2(){
39 // Default constructor.
45 // A zero-ed constructed AliITSFindClustersV2 class.
48 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
54 fSlowFast = kFALSE; // slow simulation
55 fInit = kFALSE; // Init failed
57 //______________________________________________________________________
58 AliITSFindClustersV2::AliITSFindClustersV2(const TString infile,
59 const TString outfile){
60 // Standard constructor.
62 // const TString infile Input file name where the RecPoints are
64 // const TString outfile Output file where V2 tracking clulsters
65 // are to be written. if =="" writen to the
66 // same file as input.
70 // A standardly constructed AliITSFindClustersV2 class.
73 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
79 fSlowFast = kFALSE; // slow simulation
80 fInit = kFALSE; // Init failed
82 fInFileName = new TString(infile);
83 if(outfile.CompareTo("")!=0){
84 fOutFileName = new TString(outfile);
85 } // end if outfile.CompareeTo("")!=0
88 fIn = new TFile(fInFileName->Data(),"READ");
89 fOut = new TFile(fOutFileName->Data(),"UPDATE");
90 }else{ // open fIn file for update
91 fIn = new TFile(fInFileName->Data(),"UPDATE");
94 fAr = (AliRun*) fIn->Get("gAlice");
96 Warning("AliITSFindClusterV2",
97 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
100 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
102 AliITS *its = (AliITS*) fAr->GetModule("ITS");
104 Warning("AliITSFindClusterV2",
105 "Can't fine the ITS in gAlice. Aborting.");
108 fGeom = its->GetITSgeom();
110 Warning("AliITSFindClusterV2",
111 "Can't fine the ITS geometry in gAlice. Aborting.");
118 //______________________________________________________________________
119 AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
121 // Standard constructor.
123 // const TFile *in Input file where the RecPoints are
125 // const Tfile *out Output file where V2 tracking clulsters
126 // are to be written. if ==0 writen to the
127 // same file as input.
131 // A standardly constructed AliITSFindClustersV2 class.
134 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
140 fSlowFast = kFALSE; // slow simulation
141 fInit = kFALSE; // Init failed
145 fAr = (AliRun*) fIn->Get("gAlice");
147 Warning("AliITSFindClusterV2",
148 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
151 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
152 AliITS *its = (AliITS*) fAr->GetModule("ITS");
154 Warning("AliITSFindClusterV2",
155 "Can't fine the ITS in gAlice. Aborting.");
158 fGeom = its->GetITSgeom();
160 Warning("AliITSFindClusterV2",
161 "Can't fine the ITS geometry in gAlice. Aborting.");
168 //______________________________________________________________________
169 AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
170 const TString outfile){
171 // Standard constructor.
173 // const TString infile Input file name where the RecPoints are
175 // const TString outfile Output file where V2 tracking clulsters
176 // are to be written. if =="" writen to the
177 // same file as input.
181 // A standardly constructed AliITSFindClustersV2 class.
184 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
190 fSlowFast = kFALSE; // slow simulation
191 fInit = kFALSE; // Init failed
193 if(outfile.CompareTo("")!=0){
194 fOutFileName = new TString(outfile);
195 } // end if outfile.CompareeTo("")!=0
198 fOut = new TFile(fOutFileName->Data(),"UPDATE");
203 Warning("AliITSFindClusterV2",
207 AliITS *its = (AliITS*) fAr->GetModule("ITS");
209 Warning("AliITSFindClusterV2",
210 "Can't fine the ITS in gAlice. Aborting.");
213 fGeom = its->GetITSgeom();
215 Warning("AliITSFindClusterV2",
216 "Can't fine the ITS geometry in gAlice. Aborting.");
223 //______________________________________________________________________
224 AliITSFindClustersV2::~AliITSFindClustersV2(){
225 // Default constructor.
231 // A destroyed AliITSFindclustersV2 class.
233 fGeom = 0; // Deleted when AliRun/ITS is deleted.
234 if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
236 if(fIn->IsOpen()) fIn->Close();
244 if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
246 if(fOut->IsOpen()) fOut->Close();
253 if(fDeletfAr && !fAr){
254 cout << "deleting fAr."<< endl;
257 cout << "fAr deleted OK."<< endl;
258 } // end if fDeletfAr
260 //______________________________________________________________________
261 void AliITSFindClustersV2::Exec(const Option_t *opt){
262 // Main FindclustersV2 function.
264 // Option_t * opt list of subdetector to digitize. =0 all.
272 Warning("Exec","(opt=%s) Initilization not succesfull. Aborting.\n",opt);
279 TTree *pTree = fAr->TreeR();
281 Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
285 if(fSlowFast) sprintf(name,"ITSRecPointsF");
286 else sprintf(name,"ITSRecPoints");
287 branch = pTree->GetBranch(name);
289 Warning("Exec","Can't find branch %s in TreeR fSlowFast=%d",
293 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
294 branch->SetAddress(&points);
295 Int_t nentr = (Int_t) branch->GetEntries();
298 TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
299 sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
300 TTree *cTree = new TTree(name,"ITS clusters");
301 cTree->Branch("Clusters",&cluster);
302 TClonesArray &cl = *cluster;
306 Int_t i,j,lay,lad,det,nclusters=0,ncl;
307 Float_t kmip,x,y,zshift,yshift;
312 for(i=0;i<nentr;i++){
315 ncl = points->GetEntriesFast();
321 fGeom->GetModuleId(i,lay,lad,det);
322 fGeom->GetTrans(i,x,y,zshift);
323 fGeom->GetRotMatrix(i,rot);
324 yshift = x*rot[0] + y*rot[1];
325 kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
326 if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
327 if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
329 p = (AliITSRecPoint*)(points->UncheckedAt(j));
330 lp[0] = - (p->GetX() + yshift);
331 if(lay==1) lp[0] = -lp[0];
332 lp[1] = p->GetZ() + zshift;
333 lp[2] = p->GetSigmaX2();
334 lp[3] = p->GetSigmaZ2();
335 lp[4] = p->GetQ()/kmip;
336 lab[0] = p->GetLabel(0);
337 lab[1] = p->GetLabel(1);
338 lab[2] = p->GetLabel(2);
342 part = (TParticle*) fAr->GetMCApp()->Particle(lad);
344 while(part->P() < 0.005){
345 if(part->GetFirstMother()<0){
346 Warning("Exec","Primary momentum: %e",part->P());
348 } // end if part->GetFirstMother()<0
349 lad = part->GetFirstMother();
350 part = (TParticle*) fAr->GetMCApp()->Particle(lad);
351 } // end while part->P() < 0.005
352 if(lab[1]<0) lab[1] = lad;
353 else if(lab[2]<0) lab[2] = lad;
354 else Warning("Exec","No empty lables!");
356 new(cl[j]) AliITSclusterV2(lab,lp);