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.1 2002/09/09 17:36:05 nilsen
19 new TTask to replace non-working AliITSFindClusterV2.C macro.
26 #include <TClonesArray.h>
27 #include <TParticle.h>
30 #include "AliHeader.h"
33 #include "AliITSRecPoint.h"
34 #include "AliITSFindClustersV2.h"
35 #include "AliITSclusterV2.h"
36 #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.");
121 //______________________________________________________________________
122 AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
124 // Standard constructor.
126 // const TFile *in Input file where the RecPoints are
128 // const Tfile *out Output file where V2 tracking clulsters
129 // are to be written. if ==0 writen to the
130 // same file as input.
134 // A standardly constructed AliITSFindClustersV2 class.
137 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
143 fSlowFast = kFALSE; // slow simulation
144 fInit = kFALSE; // Init failed
148 fAr = (AliRun*) fIn->Get("gAlice");
150 Warning("AliITSFindClusterV2",
151 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
154 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
155 AliITS *its = (AliITS*) fAr->GetModule("ITS");
157 Warning("AliITSFindClusterV2",
158 "Can't fine the ITS in gAlice. Aborting.");
161 fGeom = its->GetITSgeom();
163 Warning("AliITSFindClusterV2",
164 "Can't fine the ITS geometry in gAlice. Aborting.");
171 //______________________________________________________________________
172 AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
173 const TString outfile){
174 // Standard constructor.
176 // const TString infile Input file name where the RecPoints are
178 // const TString outfile Output file where V2 tracking clulsters
179 // are to be written. if =="" writen to the
180 // same file as input.
184 // A standardly constructed AliITSFindClustersV2 class.
187 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
193 fSlowFast = kFALSE; // slow simulation
194 fInit = kFALSE; // Init failed
196 if(outfile.CompareTo("")!=0){
197 fOutFileName = new TString(outfile);
198 } // end if outfile.CompareeTo("")!=0
201 fOut = new TFile(fOutFileName->Data(),"UPDATE");
206 Warning("AliITSFindClusterV2",
210 AliITS *its = (AliITS*) fAr->GetModule("ITS");
212 Warning("AliITSFindClusterV2",
213 "Can't fine the ITS in gAlice. Aborting.");
216 fGeom = its->GetITSgeom();
218 Warning("AliITSFindClusterV2",
219 "Can't fine the ITS geometry in gAlice. Aborting.");
226 //______________________________________________________________________
227 AliITSFindClustersV2::~AliITSFindClustersV2(){
228 // Default constructor.
234 // A destroyed AliITSFindclustersV2 class.
236 fGeom = 0; // Deleted when AliRun/ITS is deleted.
237 if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
239 if(fIn->IsOpen()) fIn->Close();
247 if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
249 if(fOut->IsOpen()) fOut->Close();
256 if(fDeletfAr && !fAr){
257 cout << "deleting fAr."<< endl;
260 cout << "fAr deleted OK."<< endl;
261 } // end if fDeletfAr
263 //______________________________________________________________________
264 void AliITSFindClustersV2::Exec(const Option_t *opt){
265 // Main FindclustersV2 function.
267 // Option_t * opt list of subdetector to digitize. =0 all.
275 Warning("Exec","Initilization not succesfull. Aborting.");
282 TTree *pTree = fAr->TreeR();
284 Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
288 if(fSlowFast) sprintf(name,"ITSRecPointsF");
289 else sprintf(name,"ITSRecPoints");
290 branch = pTree->GetBranch(name);
292 Warning("Exec","Can't find branch %s in TreeR fSlowFast=%d",
296 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
297 branch->SetAddress(&points);
298 Int_t nentr = (Int_t) branch->GetEntries();
301 TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
302 sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
303 TTree *cTree = new TTree(name,"ITS clusters");
304 cTree->Branch("Clusters",&cluster);
305 TClonesArray &cl = *cluster;
309 Int_t i,j,lay,lad,det,nclusters=0,ncl;
310 Float_t kmip,x,y,zshift,yshift;
315 for(i=0;i<nentr;i++){
318 ncl = points->GetEntriesFast();
324 fGeom->GetModuleId(i,lay,lad,det);
325 fGeom->GetTrans(i,x,y,zshift);
326 fGeom->GetRotMatrix(i,rot);
327 yshift = x*rot[0] + y*rot[1];
328 kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
329 if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
330 if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
332 p = (AliITSRecPoint*)(points->UncheckedAt(j));
333 lp[0] = - (p->GetX() + yshift);
334 if(lay==1) lp[0] = -lp[0];
335 lp[1] = p->GetZ() + zshift;
336 lp[2] = p->GetSigmaX2();
337 lp[3] = p->GetSigmaZ2();
338 lp[4] = p->GetQ()/kmip;
339 lab[0] = p->GetLabel(0);
340 lab[1] = p->GetLabel(1);
341 lab[2] = p->GetLabel(2);
345 part = (TParticle*) fAr->Particle(lad);
347 while(part->P() < 0.005){
348 if(part->GetFirstMother()<0){
349 Warning("Exec","Primary momentum: %e",part->P());
351 } // end if part->GetFirstMother()<0
352 lad = part->GetFirstMother();
353 part = (TParticle*) fAr->Particle(lad);
354 } // end while part->P() < 0.005
355 if(lab[1]<0) lab[1] = lad;
356 else if(lab[2]<0) lab[2] = lad;
357 else Warning("Exec","No empty lables!");
359 new(cl[j]) AliITSclusterV2(lab,lp);