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"
34 ClassImp(AliITSFindClustersV2)
36 //______________________________________________________________________
37 AliITSFindClustersV2::AliITSFindClustersV2(){
38 // Default constructor.
44 // A zero-ed constructed AliITSFindClustersV2 class.
47 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
53 fSlowFast = kFALSE; // slow simulation
54 fInit = kFALSE; // Init failed
56 //______________________________________________________________________
57 AliITSFindClustersV2::AliITSFindClustersV2(const TString infile,
58 const TString outfile){
59 // Standard constructor.
61 // const TString infile Input file name where the RecPoints are
63 // const TString outfile Output file where V2 tracking clulsters
64 // are to be written. if =="" writen to the
65 // same file as input.
69 // A standardly constructed AliITSFindClustersV2 class.
72 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
78 fSlowFast = kFALSE; // slow simulation
79 fInit = kFALSE; // Init failed
81 fInFileName = new TString(infile);
82 if(outfile.CompareTo("")!=0){
83 fOutFileName = new TString(outfile);
84 } // end if outfile.CompareeTo("")!=0
87 fIn = new TFile(fInFileName->Data(),"READ");
88 fOut = new TFile(fOutFileName->Data(),"UPDATE");
89 }else{ // open fIn file for update
90 fIn = new TFile(fInFileName->Data(),"UPDATE");
93 fAr = (AliRun*) fIn->Get("gAlice");
95 Warning("AliITSFindClusterV2",
96 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
99 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
101 AliITS *its = (AliITS*) fAr->GetModule("ITS");
103 Warning("AliITSFindClusterV2",
104 "Can't fine the ITS in gAlice. Aborting.");
107 fGeom = its->GetITSgeom();
109 Warning("AliITSFindClusterV2",
110 "Can't fine the ITS geometry in gAlice. Aborting.");
117 //______________________________________________________________________
118 AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
120 // Standard constructor.
122 // const TFile *in Input file where the RecPoints are
124 // const Tfile *out Output file where V2 tracking clulsters
125 // are to be written. if ==0 writen to the
126 // same file as input.
130 // A standardly constructed AliITSFindClustersV2 class.
133 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
139 fSlowFast = kFALSE; // slow simulation
140 fInit = kFALSE; // Init failed
144 fAr = (AliRun*) fIn->Get("gAlice");
146 Warning("AliITSFindClusterV2",
147 "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
150 fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
151 AliITS *its = (AliITS*) fAr->GetModule("ITS");
153 Warning("AliITSFindClusterV2",
154 "Can't fine the ITS in gAlice. Aborting.");
157 fGeom = its->GetITSgeom();
159 Warning("AliITSFindClusterV2",
160 "Can't fine the ITS geometry in gAlice. Aborting.");
167 //______________________________________________________________________
168 AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
169 const TString outfile){
170 // Standard constructor.
172 // const TString infile Input file name where the RecPoints are
174 // const TString outfile Output file where V2 tracking clulsters
175 // are to be written. if =="" writen to the
176 // same file as input.
180 // A standardly constructed AliITSFindClustersV2 class.
183 fDeletfAr = kFALSE; // fAr=0 dont't delete it.
189 fSlowFast = kFALSE; // slow simulation
190 fInit = kFALSE; // Init failed
192 if(outfile.CompareTo("")!=0){
193 fOutFileName = new TString(outfile);
194 } // end if outfile.CompareeTo("")!=0
197 fOut = new TFile(fOutFileName->Data(),"UPDATE");
202 Warning("AliITSFindClusterV2",
206 AliITS *its = (AliITS*) fAr->GetModule("ITS");
208 Warning("AliITSFindClusterV2",
209 "Can't fine the ITS in gAlice. Aborting.");
212 fGeom = its->GetITSgeom();
214 Warning("AliITSFindClusterV2",
215 "Can't fine the ITS geometry in gAlice. Aborting.");
222 //______________________________________________________________________
223 AliITSFindClustersV2::~AliITSFindClustersV2(){
224 // Default constructor.
230 // A destroyed AliITSFindclustersV2 class.
232 fGeom = 0; // Deleted when AliRun/ITS is deleted.
233 if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
235 if(fIn->IsOpen()) fIn->Close();
243 if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
245 if(fOut->IsOpen()) fOut->Close();
252 if(fDeletfAr && !fAr){
253 cout << "deleting fAr."<< endl;
256 cout << "fAr deleted OK."<< endl;
257 } // end if fDeletfAr
259 //______________________________________________________________________
260 void AliITSFindClustersV2::Exec(const Option_t *opt){
261 // Main FindclustersV2 function.
263 // Option_t * opt list of subdetector to digitize. =0 all.
271 Warning("Exec","(opt=%s) Initilization not succesfull. Aborting.\n",opt);
278 TTree *pTree = fAr->TreeR();
280 Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
284 if(fSlowFast) sprintf(name,"ITSRecPointsF");
285 else sprintf(name,"ITSRecPoints");
286 branch = pTree->GetBranch(name);
288 Warning("Exec","Can't find branch %s in TreeR fSlowFast=%d",
292 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
293 branch->SetAddress(&points);
294 Int_t nentr = (Int_t) branch->GetEntries();
297 TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
298 sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
299 TTree *cTree = new TTree(name,"ITS clusters");
300 cTree->Branch("Clusters",&cluster);
301 TClonesArray &cl = *cluster;
305 Int_t i,j,lay,lad,det,nclusters=0,ncl;
306 Float_t kmip,x,y,zshift,yshift;
311 for(i=0;i<nentr;i++){
314 ncl = points->GetEntriesFast();
320 fGeom->GetModuleId(i,lay,lad,det);
321 fGeom->GetTrans(i,x,y,zshift);
322 fGeom->GetRotMatrix(i,rot);
323 yshift = x*rot[0] + y*rot[1];
324 kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
325 if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
326 if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
328 p = (AliITSRecPoint*)(points->UncheckedAt(j));
329 lp[0] = - (p->GetX() + yshift);
330 if(lay==1) lp[0] = -lp[0];
331 lp[1] = p->GetZ() + zshift;
332 lp[2] = p->GetSigmaX2();
333 lp[3] = p->GetSigmaZ2();
334 lp[4] = p->GetQ()/kmip;
335 lab[0] = p->GetLabel(0);
336 lab[1] = p->GetLabel(1);
337 lab[2] = p->GetLabel(2);
341 part = (TParticle*) fAr->Particle(lad);
343 while(part->P() < 0.005){
344 if(part->GetFirstMother()<0){
345 Warning("Exec","Primary momentum: %e",part->P());
347 } // end if part->GetFirstMother()<0
348 lad = part->GetFirstMother();
349 part = (TParticle*) fAr->Particle(lad);
350 } // end while part->P() < 0.005
351 if(lab[1]<0) lab[1] = lad;
352 else if(lab[2]<0) lab[2] = lad;
353 else Warning("Exec","No empty lables!");
355 new(cl[j]) AliITSclusterV2(lab,lp);