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 Revision 1.2.2.1 2002/10/14 13:14:08 hristov
19 Updating VirtualMC to v3-09-02
21 Revision 1.2 2002/09/23 13:25:52 hristov
24 Revision 1.1 2002/09/09 17:36:05 nilsen
25 new TTask to replace non-working AliITSFindClusterV2.C macro.
32 #include <TClonesArray.h>
33 #include <TParticle.h>
36 #include "AliHeader.h"
39 #include "AliITSRecPoint.h"
40 #include "AliITSFindClustersV2.h"
41 #include "AliITSclusterV2.h"
42 #include "AliITSgeom.h"
44 ClassImp(AliITSFindClustersV2)
46 //______________________________________________________________________
47 AliITSFindClustersV2::AliITSFindClustersV2(){
48 // Default constructor.
54 // A zero-ed constructed AliITSFindClustersV2 class.
57 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
63 fSlowFast = kFALSE; // slow simulation
64 fInit = kFALSE; // Init failed
66 //______________________________________________________________________
67 AliITSFindClustersV2::AliITSFindClustersV2(const TString infile,
68 const TString outfile){
69 // Standard constructor.
71 // const TString infile Input file name where the RecPoints are
73 // const TString outfile Output file where V2 tracking clulsters
74 // are to be written. if =="" writen to the
75 // same file as input.
79 // A standardly constructed AliITSFindClustersV2 class.
82 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
88 fSlowFast = kFALSE; // slow simulation
89 fInit = kFALSE; // Init failed
91 fInFileName = new TString(infile);
92 if(outfile.CompareTo("")!=0){
93 fOutFileName = new TString(outfile);
94 } // end if outfile.CompareeTo("")!=0
97 fIn = new TFile(fInFileName->Data(),"READ");
98 fOut = new TFile(fOutFileName->Data(),"UPDATE");
99 }else{ // open fIn file for update
100 fIn = new TFile(fInFileName->Data(),"UPDATE");
103 fAr = (AliRun*) fIn->Get("gAlice");
105 Warning("AliITSFindClusterV2",
106 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
109 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
111 AliITS *its = (AliITS*) fAr->GetModule("ITS");
113 Warning("AliITSFindClusterV2",
114 "Can't fine the ITS in gAlice. Aborting.");
117 fGeom = its->GetITSgeom();
119 Warning("AliITSFindClusterV2",
120 "Can't fine the ITS geometry in gAlice. Aborting.");
127 //______________________________________________________________________
128 AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
130 // Standard constructor.
132 // const TFile *in Input file where the RecPoints are
134 // const Tfile *out Output file where V2 tracking clulsters
135 // are to be written. if ==0 writen to the
136 // same file as input.
140 // A standardly constructed AliITSFindClustersV2 class.
143 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
149 fSlowFast = kFALSE; // slow simulation
150 fInit = kFALSE; // Init failed
154 fAr = (AliRun*) fIn->Get("gAlice");
156 Warning("AliITSFindClusterV2",
157 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
160 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
161 AliITS *its = (AliITS*) fAr->GetModule("ITS");
163 Warning("AliITSFindClusterV2",
164 "Can't fine the ITS in gAlice. Aborting.");
167 fGeom = its->GetITSgeom();
169 Warning("AliITSFindClusterV2",
170 "Can't fine the ITS geometry in gAlice. Aborting.");
177 //______________________________________________________________________
178 AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
179 const TString outfile){
180 // Standard constructor.
182 // const TString infile Input file name where the RecPoints are
184 // const TString outfile Output file where V2 tracking clulsters
185 // are to be written. if =="" writen to the
186 // same file as input.
190 // A standardly constructed AliITSFindClustersV2 class.
193 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
199 fSlowFast = kFALSE; // slow simulation
200 fInit = kFALSE; // Init failed
202 if(outfile.CompareTo("")!=0){
203 fOutFileName = new TString(outfile);
204 } // end if outfile.CompareeTo("")!=0
207 fOut = new TFile(fOutFileName->Data(),"UPDATE");
212 Warning("AliITSFindClusterV2",
216 AliITS *its = (AliITS*) fAr->GetModule("ITS");
218 Warning("AliITSFindClusterV2",
219 "Can't fine the ITS in gAlice. Aborting.");
222 fGeom = its->GetITSgeom();
224 Warning("AliITSFindClusterV2",
225 "Can't fine the ITS geometry in gAlice. Aborting.");
232 //______________________________________________________________________
233 AliITSFindClustersV2::~AliITSFindClustersV2(){
234 // Default constructor.
240 // A destroyed AliITSFindclustersV2 class.
242 fGeom = 0; // Deleted when AliRun/ITS is deleted.
243 if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
245 if(fIn->IsOpen()) fIn->Close();
253 if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
255 if(fOut->IsOpen()) fOut->Close();
262 if(fDeletfAr && !fAr){
263 cout << "deleting fAr."<< endl;
266 cout << "fAr deleted OK."<< endl;
267 } // end if fDeletfAr
269 //______________________________________________________________________
270 void AliITSFindClustersV2::Exec(const Option_t *opt){
271 // Main FindclustersV2 function.
273 // Option_t * opt list of subdetector to digitize. =0 all.
281 Warning("Exec","Initilization not succesfull. Aborting.");
288 TTree *pTree = fAr->TreeR();
290 Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
294 if(fSlowFast) sprintf(name,"ITSRecPointsF");
295 else sprintf(name,"ITSRecPoints");
296 branch = pTree->GetBranch(name);
298 Warning("Exec","Can't find branch %s in TreeR fSlowFast=%d",
302 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
303 branch->SetAddress(&points);
304 Int_t nentr = (Int_t) branch->GetEntries();
307 TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
308 sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
309 TTree *cTree = new TTree(name,"ITS clusters");
310 cTree->Branch("Clusters",&cluster);
311 TClonesArray &cl = *cluster;
315 Int_t i,j,lay,lad,det,nclusters=0,ncl;
316 Float_t kmip,x,y,zshift,yshift;
321 for(i=0;i<nentr;i++){
324 ncl = points->GetEntriesFast();
330 fGeom->GetModuleId(i,lay,lad,det);
331 fGeom->GetTrans(i,x,y,zshift);
332 fGeom->GetRotMatrix(i,rot);
333 yshift = x*rot[0] + y*rot[1];
334 kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
335 if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
336 if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
338 p = (AliITSRecPoint*)(points->UncheckedAt(j));
339 lp[0] = - (p->GetX() + yshift);
340 if(lay==1) lp[0] = -lp[0];
341 lp[1] = p->GetZ() + zshift;
342 lp[2] = p->GetSigmaX2();
343 lp[3] = p->GetSigmaZ2();
344 lp[4] = p->GetQ()/kmip;
345 lab[0] = p->GetLabel(0);
346 lab[1] = p->GetLabel(1);
347 lab[2] = p->GetLabel(2);
351 part = (TParticle*) fAr->Particle(lad);
353 while(part->P() < 0.005){
354 if(part->GetFirstMother()<0){
355 Warning("Exec","Primary momentum: %e",part->P());
357 } // end if part->GetFirstMother()<0
358 lad = part->GetFirstMother();
359 part = (TParticle*) fAr->Particle(lad);
360 } // end while part->P() < 0.005
361 if(lab[1]<0) lab[1] = lad;
362 else if(lab[2]<0) lab[2] = lad;
363 else Warning("Exec","No empty lables!");
365 new(cl[j]) AliITSclusterV2(lab,lp);