]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITS.cxx
Some vector dimensions increased to cope with full events
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
18Revision 1.37 2001/03/07 12:36:35 barbera
19A change added in the tracking part to manage delta rays
20
21Revision 1.36 2001/03/02 19:44:11 barbera
22 modified to taking into account new version tracking v1
23
24Revision 1.35 2001/02/28 18:16:46 mariana
25Make the code compatible with the new AliRun
26
27Revision 1.34 2001/02/11 15:51:39 mariana
28Set protection in MakeBranch
29
30Revision 1.33 2001/02/10 22:26:39 mariana
31Move the initialization of the containers for raw clusters in MakeTreeC()
32
33Revision 1.32 2001/02/08 23:55:31 nilsen
34Removed fMajor/MinorVersion variables in favor of variables in derived classes.
35Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
36
37Revision 1.31 2001/02/02 23:57:28 nilsen
38Added include file that are no londer included in AliITSgeom.h
39
40Revision 1.30 2001/01/30 09:23:13 hristov
41Streamers removed (R.Brun)
42
43Revision 1.29 2001/01/26 20:01:09 hristov
44Major upgrade of AliRoot code
45
46Revision 1.28 2000/12/18 14:02:00 barbera
47new version of the ITS tracking to take into account the new TPC track parametrization
48
49Revision 1.27 2000/12/08 13:49:27 barbera
50Hidden declaration in a for loop removed to be compliant with HP-UX compiler
51
52Revision 1.26 2000/11/27 13:12:13 barbera
53New version containing the files for tracking
54
55Revision 1.25 2000/11/12 22:38:05 barbera
56Added header file for the SPD Bari model
57
58Revision 1.24 2000/10/09 22:18:12 barbera
59Bug fixes from MAriana to le AliITStest.C run correctly
60
61Revision 1.23 2000/10/05 20:47:42 nilsen
62fixed dependencies of include files. Tryed but failed to get a root automaticly
63generates streamer function to work. Modified SetDefaults.
64
65Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
66Needed to include stdlib.h
67
68=======
69Revision 1.22 2000/10/04 19:45:52 barbera
70Corrected by F. Carminati for v3.04
71
72Revision 1.21 2000/10/02 21:28:08 fca
73Removal of useless dependecies via forward declarations
74
75Revision 1.20 2000/10/02 16:31:39 barbera
76General code clean-up
77
78Revision 1.9.2.14 2000/10/02 15:43:51 barbera
79General code clean-up (e.g., printf -> cout)
80
81Revision 1.19 2000/09/22 12:13:25 nilsen
82Patches and updates for fixes to this and other routines.
83
84Revision 1.18 2000/07/12 05:32:20 fca
85Correcting several syntax problem with static members
86
87Revision 1.17 2000/07/10 16:07:18 fca
88Release version of ITS code
89
90Revision 1.9.2.3 2000/02/02 13:42:09 barbera
91fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
92
93Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
94//fixed FillModule. Removed fi(fabs(xl)<dx....
95
96Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
97This is the version of the files after the merging done in December 1999.
98See the ReadMe110100.txt file for details
99
100Revision 1.9 1999/11/14 14:33:25 fca
101Correct problems with distructors and pointers, thanks to I.Hrivnacova
102
103Revision 1.8 1999/09/29 09:24:19 fca
104Introduction of the Copyright and cvs Log
105
106*/
107
108///////////////////////////////////////////////////////////////////////////////
109//
110// An overview of the basic philosophy of the ITS code development
111// and analysis is show in the figure below.
112//Begin_Html
113/*
114<img src="picts/ITS/ITS_Analysis_schema.gif">
115</pre>
116<br clear=left>
117<font size=+2 color=red>
118<p>Roberto Barbera is in charge of the ITS Offline code (1999).
119<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
120</font>
121<pre>
122*/
123//End_Html
124//
125// AliITS. Inner Traking System base class.
126// This class contains the base procedures for the Inner Tracking System
127//
128//Begin_Html
129/*
130<img src="picts/ITS/AliITS_Class_Diagram.gif">
131</pre>
132<br clear=left>
133<font size=+2 color=red>
134<p>This show the class diagram of the different elements that are part of
135the AliITS class.
136</font>
137<pre>
138*/
139//End_Html
140//
141// Version: 0
142// Written by Rene Brun, Federico Carminati, and Roberto Barbera
143//
144// Version: 1
145// Modified and documented by Bjorn S. Nilsen
146// July 11 1999
147//
148// Version: 2
149// Modified and documented by A. Bologna
150// October 18 1999
151//
152// AliITS is the general base class for the ITS. Also see AliDetector for
153// futher information.
154//
155///////////////////////////////////////////////////////////////////////////////
156#include <iostream.h>
157#include <iomanip.h>
158#include <fstream.h>
159#include <stdlib.h>
160#include <TMath.h>
161#include <TRandom.h>
162#include <TBranch.h>
163#include <TVector.h>
164#include <TClonesArray.h>
165#include <TROOT.h>
166#include <TObjectTable.h>
167#include <TFile.h>
168#include <TTree.h>
169#include <TString.h>
170#include <TParticle.h>
171
172
173#include "AliRun.h"
174#include "AliITS.h"
175#include "AliITSMap.h"
176#include "AliITSDetType.h"
177#include "AliITSClusterFinder.h"
178//#include "AliITSsimulation.h"
179#include "AliITSsimulationSPD.h"
180#include "AliITSsimulationSDD.h"
181#include "AliITSsimulationSSD.h"
182#include "AliITSresponse.h"
183#include "AliITSsegmentationSPD.h"
184#include "AliITSresponseSPD.h"
185#include "AliITSresponseSPDbari.h"
186#include "AliITSsegmentationSDD.h"
187#include "AliITSresponseSDD.h"
188#include "AliITSsegmentationSSD.h"
189#include "AliITSresponseSSD.h"
190#include "AliITShit.h"
191#include "AliITSgeom.h"
192#include "AliITSdigit.h"
193#include "AliITSmodule.h"
194#include "AliITSRecPoint.h"
195#include "AliITSRawCluster.h"
196#include "AliMC.h"
197#include "stdlib.h"
198
199#include "AliITStrack.h"
200#include "AliITSiotrack.h"
201#include "AliITStracking.h"
202#include "AliITSRad.h"
203#include "../TPC/AliTPC.h"
204#include "../TPC/AliTPCParam.h"
205
206
207ClassImp(AliITS)
208
209//_____________________________________________________________________________
210AliITS::AliITS() : AliDetector() {
211 //
212 // Default initialiser for ITS
213 // The default constructor of the AliITS class. In addition to
214 // creating the AliITS class it zeros the variables fIshunt (a member
215 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
216 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
217 // is also called.
218 //
219
220
221 fIshunt = 0;
222 fEuclidOut = 0;
223
224 fNDetTypes = kNTYPES;
225 fIdN = 0;
226 fIdName = 0;
227 fIdSens = 0;
228 fITSmodules = 0;
229 //
230 fDetTypes = 0;
231 //
232 fDtype = 0;
233 fNdtype = 0;
234 fCtype = 0;
235 fNctype = 0;
236 fRecPoints = 0;
237 fNRecPoints = 0;
238 fTreeC = 0;
239 //
240 fITSgeom=0;
241}
242
243//_____________________________________________________________________________
244AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
245 //
246 // Default initialiser for ITS
247 // The constructor of the AliITS class. In addition to creating the
248 // AliITS class, it allocates memory for the TClonesArrays fHits and
249 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
250 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
251 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
252 // macro display.C AliITS also sets the marker color to red. The variables
253 // passes with this constructor, const char *name and *title, are used by
254 // the constructor of AliDetector class. See AliDetector class for a
255 // description of these parameters and its constructor functions.
256 //
257
258
259 fHits = new TClonesArray("AliITShit", 1560);
260 gAlice->AddHitList(fHits);
261
262 fNDetTypes = kNTYPES;
263
264 fNdtype = new Int_t[kNTYPES];
265 fDtype = new TObjArray(kNTYPES);
266
267 fNctype = new Int_t[kNTYPES];
268 fCtype = new TObjArray(kNTYPES);
269
270
271 fRecPoints = 0;
272 fNRecPoints = 0;
273
274 fTreeC = 0;
275
276 fITSmodules = 0;
277
278 fIshunt = 0;
279 fEuclidOut = 0;
280 fIdN = 0;
281 fIdName = 0;
282 fIdSens = 0;
283
284 fDetTypes = new TObjArray(kNTYPES);
285
286 Int_t i;
287 for(i=0;i<kNTYPES;i++) {
288 (*fDetTypes)[i]=new AliITSDetType();
289 fNdtype[i]=0;
290 fNctype[i]=0;
291 }
292 //
293
294 SetMarkerColor(kRed);
295
296 fITSgeom=0;
297}
298//___________________________________________________________________________
299AliITS::AliITS(AliITS &source){
300 // copy constructor
301 if(this==&source) return;
302 Error("AliITS::Copy constructor",
303 "You are not allowed to make a copy of the AliITS");
304 exit(1);
305}
306//____________________________________________________________________________
307AliITS& AliITS::operator=(AliITS &source){
308 // assignment operator
309 if(this==&source) return *this;
310 Error("AliITS::operator=",
311 "You are not allowed to make a copy of the AliITS");
312 exit(1);
313 return *this; //fake return
314}
315//____________________________________________________________________________
316void AliITS::ClearModules(){
317 //clear the modules TObjArray
318
319 if(fITSmodules) fITSmodules->Delete();
320
321}
322//_____________________________________________________________________________
323AliITS::~AliITS(){
324 //
325 // Default distructor for ITS
326 // The default destructor of the AliITS class. In addition to deleting
327 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
328 // fIdSens, fIdName, and fITSpoints.
329 //
330
331
332 delete fHits;
333 delete fDigits;
334 delete fRecPoints;
335// delete fIdName; // TObjArray of TObjStrings
336 if(fIdName!=0) delete[] fIdName; // Array of TStrings
337 if(fIdSens!=0) delete[] fIdSens;
338 if(fITSmodules!=0) {
339 this->ClearModules();
340 delete fITSmodules;
341 }// end if fITSmodules!=0
342
343 //
344 if(fDtype) {
345 fDtype->Delete();
346 delete fDtype;
347 }
348 delete [] fNdtype;
349 if (fCtype) {
350 fCtype->Delete();
351 delete fCtype;
352 }
353 delete [] fNctype;
354 //
355
356 if (fDetTypes) {
357 fDetTypes->Delete();
358 delete fDetTypes;
359 }
360
361 if (fTreeC) delete fTreeC;
362
363 if (fITSgeom) delete fITSgeom;
364
365}
366
367//___________________________________________
368AliITSDetType* AliITS::DetType(Int_t id)
369{
370 //return pointer to id detector type
371 return ((AliITSDetType*) (*fDetTypes)[id]);
372
373}
374//___________________________________________
375void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
376{
377 //set the digit and cluster classes to be used for the id detector type
378 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
379
380}
381//___________________________________________
382void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
383{
384 //set the response model for the id detector type
385
386 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
387
388}
389
390//___________________________________________
391void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
392{
393 //set the segmentation model for the id detector type
394
395 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
396
397}
398
399//___________________________________________
400void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
401{
402 //set the simulation model for the id detector type
403
404 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
405
406}
407//___________________________________________
408void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
409{
410 //set the cluster finder model for the id detector type
411
412 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
413
414}
415
416//_____________________________________________________________________________
417void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
418 //
419 // Add an ITS hit
420 // The function to add information to the AliITShit class. See the
421 // AliITShit class for a full description. This function allocates the
422 // necessary new space for the hit information and passes the variable
423 // track, and the pointers *vol and *hits to the AliITShit constructor
424 // function.
425 //
426 TClonesArray &lhits = *fHits;
427 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
428}
429//_____________________________________________________________________________
430void AliITS::AddRealDigit(Int_t id, Int_t *digits)
431{
432 // add a real digit - as coming from data
433
434 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
435 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
436
437}
438//_____________________________________________________________________________
439void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
440{
441
442 // add a simulated digit
443
444 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
445
446 switch(id)
447 {
448 case 0:
449 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
450 break;
451 case 1:
452 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
453 break;
454 case 2:
455 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
456 break;
457 }
458
459}
460
461//_____________________________________________________________________________
462void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
463
464 // add a simulated digit to the list
465
466 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
467 switch(id)
468 {
469 case 0:
470 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
471 break;
472 case 1:
473 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
474 break;
475 case 2:
476 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
477 break;
478 }
479
480}
481
482//_____________________________________________________________________________
483void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
484{
485
486 // add a cluster to the list
487
488 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
489
490 switch(id)
491 {
492 case 0:
493 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
494 break;
495 case 1:
496 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
497 break;
498 case 2:
499 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
500 break;
501 }
502
503}
504
505
506//_____________________________________________________________________________
507void AliITS::AddRecPoint(const AliITSRecPoint &r)
508{
509 //
510 // Add a reconstructed space point to the list
511 //
512 TClonesArray &lrecp = *fRecPoints;
513 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
514}
515
516
517//____________________________________________
518void AliITS::ResetDigits()
519{
520 //
521 // Reset number of digits and the digits array for the ITS detector
522 //
523
524 if (!fDtype) return;
525
526 Int_t i;
527 for (i=0;i<kNTYPES;i++ ) {
528 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
529 if (fNdtype) fNdtype[i]=0;
530 }
531}
532
533//____________________________________________
534void AliITS::ResetDigits(Int_t i)
535{
536 //
537 // Reset number of digits and the digits array for this branch
538 //
539 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
540 if (fNdtype) fNdtype[i]=0;
541}
542
543
544//____________________________________________
545void AliITS::ResetClusters()
546{
547 //
548 // Reset number of clusters and the clusters array for ITS
549 //
550
551 Int_t i;
552 for (i=0;i<kNTYPES;i++ ) {
553 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
554 if (fNctype) fNctype[i]=0;
555 }
556
557}
558
559//____________________________________________
560void AliITS::ResetClusters(Int_t i)
561{
562 //
563 // Reset number of clusters and the clusters array for this branch
564 //
565 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
566 if (fNctype) fNctype[i]=0;
567
568}
569
570
571//____________________________________________
572void AliITS::ResetRecPoints()
573{
574 //
575 // Reset number of rec points and the rec points array
576 //
577 if (fRecPoints) fRecPoints->Clear();
578 fNRecPoints = 0;
579
580}
581
582//_____________________________________________________________________________
583Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
584 //
585 // Distance from mouse to ITS on the screen. Dummy routine
586 // A dummy routine used by the ROOT macro display.C to allow for the
587 // use of the mouse (pointing device) in the macro. In general this should
588 // never be called. If it is it returns the number 9999 for any value of
589 // x and y.
590 //
591 return 9999;
592}
593
594//_____________________________________________________________________________
595void AliITS::Init(){
596 //
597 // Initialise ITS after it has been built
598 // This routine initializes the AliITS class. It is intended to be called
599 // from the Init function in AliITSv?. Besides displaying a banner
600 // indicating that it has been called it initializes the array fIdSens
601 // and sets the default segmentation, response, digit and raw cluster classes
602 // Therefore it should be called after a call to CreateGeometry.
603 //
604 Int_t i;
605
606//
607 SetDefaults();
608// Array of TStrings
609 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
610//
611}
612
613//_____________________________________________________________________________
614void AliITS::SetDefaults()
615{
616 // sets the default segmentation, response, digit and raw cluster classes
617
618 printf("SetDefaults\n");
619
620 AliITSDetType *iDetType;
621
622
623 //SPD
624
625 iDetType=DetType(0);
626 if (!iDetType->GetSegmentationModel()) {
627 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
628 SetSegmentationModel(0,seg0);
629 }
630 if (!iDetType->GetResponseModel()) {
631 SetResponseModel(0,new AliITSresponseSPD());
632 }
633 // set digit and raw cluster classes to be used
634
635 const char *kData0=(iDetType->GetResponseModel())->DataType();
636 if (strstr(kData0,"real")) {
637 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
638 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
639
640 // SDD //
641 iDetType=DetType(1);
642 if (!iDetType->GetResponseModel()) {
643 SetResponseModel(1,new AliITSresponseSDD());
644 }
645 AliITSresponse *resp1=iDetType->GetResponseModel();
646 if (!iDetType->GetSegmentationModel()) {
647 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
648 SetSegmentationModel(1,seg1);
649 }
650 const char *kData1=(iDetType->GetResponseModel())->DataType();
651 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
652 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
653 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
654 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
655
656 // SSD
657 iDetType=DetType(2);
658 if (!iDetType->GetSegmentationModel()) {
659 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
660 SetSegmentationModel(2,seg2);
661 }
662 if (!iDetType->GetResponseModel()) {
663 SetResponseModel(2,new AliITSresponseSSD());
664 }
665 const char *kData2=(iDetType->GetResponseModel())->DataType();
666 if (strstr(kData2,"real")) {
667 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
668 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
669
670 if (kNTYPES>3) {
671 Warning("SetDefaults","Only the three basic detector types are initialised!");
672 }
673
674}
675
676
677
678//_____________________________________________________________________________
679void AliITS::SetDefaultSimulation()
680{
681 // to be written
682
683}
684//_____________________________________________________________________________
685void AliITS::SetDefaultClusterFinders()
686{
687 // to be written
688
689}
690//_____________________________________________________________________________
691
692void AliITS::MakeTreeC(Option_t *option)
693{
694 // create a separate tree to store the clusters
695
696 cout << "AliITS::MakeTreeC" << endl;
697
698 char *optC = strstr(option,"C");
699 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
700 else return;
701
702 Int_t buffersize = 4000;
703 char branchname[30];
704
705 const char *det[3] = {"SPD","SDD","SSD"};
706
707 char digclass[40];
708 char clclass[40];
709
710 // one branch for Clusters per type of detector
711 Int_t i;
712 for (i=0; i<kNTYPES ;i++) {
713 AliITSDetType *iDetType=DetType(i);
714 iDetType->GetClassNames(digclass,clclass);
715 // clusters
716 (*fCtype)[i] = new TClonesArray(clclass,10000);
717 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
718 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
719 if (fCtype && fTreeC) {
720 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
721 cout << "Making Branch " << branchname;
722 cout << " for Clusters of detector type " << i+1 << endl;
723 }
724 }
725
726}
727
728//_____________________________________________________________________________
729void AliITS::GetTreeC(Int_t event)
730{
731
732 cout << "AliITS::GetTreeC" << endl;
733
734 // get the clusters tree for this event and set the branch address
735 char treeName[20];
736 char branchname[30];
737
738 const char *det[3] = {"SPD","SDD","SSD"};
739
740 ResetClusters();
741 if (fTreeC) {
742 delete fTreeC;
743 }
744
745 sprintf(treeName,"TreeC%d",event);
746 fTreeC = (TTree*)gDirectory->Get(treeName);
747
748 TBranch *branch;
749 if (fTreeC) {
750 Int_t i;
751 for (i=0; i<kNTYPES; i++) {
752 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
753 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
754 if (fCtype) {
755 branch = fTreeC->GetBranch(branchname);
756 if (branch) branch->SetAddress(&((*fCtype)[i]));
757 }
758 }
759 } else {
760 Error("AliITS::GetTreeC",
761 "cannot find Clusters Tree for event:%d\n",event);
762 }
763
764}
765//_____________________________________________________________________________
766void AliITS::MakeBranch(Option_t* option, char *file)
767{
768 //
769 // Creates Tree branches for the ITS.
770 //
771 //
772 Int_t buffersize = 4000;
773 char branchname[30];
774 sprintf(branchname,"%s",GetName());
775
776 AliDetector::MakeBranch(option,file);
777
778 char *cD = strstr(option,"D");
779 char *cR = strstr(option,"R");
780
781 if (cD) {
782 //
783 // one branch for digits per type of detector
784 //
785 const char *det[3] = {"SPD","SDD","SSD"};
786
787 char digclass[40];
788 char clclass[40];
789
790 Int_t i;
791 for (i=0; i<kNTYPES ;i++) {
792 AliITSDetType *iDetType=DetType(i);
793 iDetType->GetClassNames(digclass,clclass);
794 // digits
795 if(!((*fDtype)[i])) (*fDtype)[i] = new TClonesArray(digclass,10000);
796 else ResetDigits(i);
797 }
798
799 for (i=0; i<kNTYPES ;i++) {
800 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
801 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
802 if (fDtype && gAlice->TreeD()) {
803 gAlice->MakeBranchInTree(gAlice->TreeD(),
804 branchname, &((*fDtype)[i]), buffersize, file);
805 cout << "Making Branch " << branchname;
806 cout << " for digits of type "<< i+1 << endl;
807 }
808 }
809 }
810
811 if (cR) {
812 //
813 // only one branch for rec points for all detector types
814 //
815 sprintf(branchname,"%sRecPoints",GetName());
816
817 if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",10000);
818
819 if (fRecPoints && gAlice->TreeR()) {
820 gAlice->MakeBranchInTree(gAlice->TreeR(),
821 branchname, &fRecPoints, buffersize, file) ;
822 cout << "Making Branch " << branchname;
823 cout << " for reconstructed space points" << endl;
824 }
825 }
826}
827
828//___________________________________________
829void AliITS::SetTreeAddress()
830{
831
832 // Set branch address for the Trees.
833
834 char branchname[30];
835 AliDetector::SetTreeAddress();
836
837 const char *det[3] = {"SPD","SDD","SSD"};
838
839 TBranch *branch;
840 TTree *treeD = gAlice->TreeD();
841 TTree *treeR = gAlice->TreeR();
842
843 Int_t i;
844 if (treeD) {
845 for (i=0; i<kNTYPES; i++) {
846 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
847 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
848 if (fDtype) {
849 branch = treeD->GetBranch(branchname);
850 if (branch) branch->SetAddress(&((*fDtype)[i]));
851 }
852 }
853 }
854
855
856 if (treeR) {
857 sprintf(branchname,"%sRecPoints",GetName());
858 branch = treeR->GetBranch(branchname);
859 if (branch) branch->SetAddress(&fRecPoints);
860 }
861
862
863}
864
865//____________________________________________________________________________
866void AliITS::InitModules(Int_t size,Int_t &nmodules){
867
868 //initialize the modules array
869
870 if(fITSmodules){
871 fITSmodules->Delete();
872 delete fITSmodules;
873 }
874
875 Int_t nl,indexMAX,index;
876
877 if(size<=0){ // default to using data stored in AliITSgeom
878 if(fITSgeom==0) {
879 Error("AliITS::InitModules",
880 "in AliITS::InitModule fITSgeom not defined\n");
881 return;
882 } // end if fITSgeom==0
883 nl = fITSgeom->GetNlayers();
884 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
885 fITSgeom->GetNdetectors(nl))+1;
886 nmodules = indexMAX;
887 fITSmodules = new TObjArray(indexMAX);
888 for(index=0;index<indexMAX;index++){
889 fITSmodules->AddAt( new AliITSmodule(index),index);
890 } // end for index
891 }else{
892 fITSmodules = new TObjArray(size);
893 for(index=0;index<size;index++) {
894 fITSmodules->AddAt( new AliITSmodule(index),index);
895 }
896
897 nmodules = size;
898 } // end i size<=0
899}
900
901//____________________________________________________________________________
902void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
903
904 // fill the modules with the sorted by module hits; add hits from background
905 // if option=Add
906
907
908 static TTree *trH1; //Tree with background hits
909 static TClonesArray *fHits2; //List of hits for one track only
910
911 static Bool_t first=kTRUE;
912 static TFile *file;
913 char *addBgr = strstr(option,"Add");
914
915
916 if (addBgr ) {
917 if(first) {
918 cout<<"filename "<<filename<<endl;
919 file=new TFile(filename);
920 cout<<"I have opened "<<filename<<" file "<<endl;
921 fHits2 = new TClonesArray("AliITShit",1000 );
922 }
923 first=kFALSE;
924 file->cd();
925 file->ls();
926 // Get Hits Tree header from file
927 if(fHits2) fHits2->Clear();
928 if(trH1) delete trH1;
929 trH1=0;
930
931 char treeName[20];
932 sprintf(treeName,"TreeH%d",bgrev);
933 trH1 = (TTree*)gDirectory->Get(treeName);
934 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
935
936 if (!trH1) {
937 Error("AliITS::FillModules",
938 "cannot find Hits Tree for event:%d\n",bgrev);
939 }
940 // Set branch addresses
941 TBranch *branch;
942 char branchname[20];
943 sprintf(branchname,"%s",GetName());
944 if (trH1 && fHits2) {
945 branch = trH1->GetBranch(branchname);
946 if (branch) branch->SetAddress(&fHits2);
947 }
948
949 // test
950 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
951 //printf("background - ntracks1 - %d\n",ntracks1);
952 }
953
954 //Int_t npart = gAlice->GetEvent(evnt);
955 //if(npart<=0) return;
956 TClonesArray *itsHits = this->Hits();
957 Int_t lay,lad,det,index;
958 AliITShit *itsHit=0;
959 AliITSmodule *mod=0;
960
961 TTree *iTH = gAlice->TreeH();
962 Int_t ntracks =(Int_t) iTH->GetEntries();
963
964 Int_t t,h;
965 for(t=0; t<ntracks; t++){
966 gAlice->ResetHits();
967 iTH->GetEvent(t);
968 Int_t nhits = itsHits->GetEntriesFast();
969 //printf("nhits %d\n",nhits);
970 if (!nhits) continue;
971 for(h=0; h<nhits; h++){
972 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
973 itsHit->GetDetectorID(lay,lad,det);
974 // temporarily index=det-1 !!!
975 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
976 else index=det-1;
977 //
978 mod = this->GetModule(index);
979 mod->AddHit(itsHit,t,h);
980 } // end loop over hits
981 } // end loop over tracks
982
983 // open the file with background
984
985 if (addBgr ) {
986 Int_t track,i;
987 ntracks =(Int_t)trH1->GetEntries();
988 //printf("background - ntracks1 %d\n",ntracks);
989 //printf("background - Start loop over tracks \n");
990 // Loop over tracks
991
992 for (track=0; track<ntracks; track++) {
993
994 if (fHits2) fHits2->Clear();
995 trH1->GetEvent(track);
996 // Loop over hits
997 for(i=0;i<fHits2->GetEntriesFast();++i) {
998
999 itsHit=(AliITShit*) (*fHits2)[i];
1000 itsHit->GetDetectorID(lay,lad,det);
1001 // temporarily index=det-1 !!!
1002 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1003 else index=det-1;
1004 //
1005 mod = this->GetModule(index);
1006 mod->AddHit(itsHit,track,i);
1007 } // end loop over hits
1008 } // end loop over tracks
1009
1010 TTree *fAli=gAlice->TreeK();
1011 TFile *fileAli=0;
1012
1013 if (fAli) fileAli =fAli->GetCurrentFile();
1014 fileAli->cd();
1015
1016 } // end if add
1017
1018 //gObjectTable->Print();
1019
1020}
1021
1022//____________________________________________________________________________
1023
1024void AliITS::SDigits2Digits()
1025{
1026
1027 AliITSgeom *geom = GetITSgeom();
1028
1029 // SPD
1030 AliITSDetType *iDetType;
1031 iDetType=DetType(0);
1032 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
1033 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
1034 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
1035 SetSimulationModel(0,sim0);
1036 // test
1037 // printf("SPD dimensions %f %f \n",seg0->Dx(),seg0->Dz());
1038 // printf("SPD npixels %d %d \n",seg0->Npz(),seg0->Npx());
1039 // printf("SPD pitches %d %d \n",seg0->Dpz(0),seg0->Dpx(0));
1040 // end test
1041 //
1042 // SDD
1043 //Set response functions
1044 Float_t baseline = 10.;
1045 Float_t noise = 1.75;
1046
1047 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
1048
1049 iDetType=DetType(1);
1050 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
1051 if (!res1) {
1052 res1=new AliITSresponseSDD();
1053 SetResponseModel(1,res1);
1054 }
1055 res1->SetMagicValue(900.);
1056 Float_t maxadc = res1->MaxAdc();
1057 Float_t topValue = res1->MagicValue();
1058 Float_t norm = maxadc/topValue;
1059
1060 Float_t fCutAmp = baseline + 2.*noise;
1061 fCutAmp *= norm;
1062 Int_t cp[8]={0,0,(int)fCutAmp,(int)fCutAmp,0,0,0,0}; //1D
1063
1064 //res1->SetZeroSupp("2D");
1065 res1->SetZeroSupp("1D");
1066 res1->SetNoiseParam(noise,baseline);
1067 res1->SetDo10to8(kTRUE);
1068 res1->SetCompressParam(cp);
1069 res1->SetMinVal(4);
1070 res1->SetDiffCoeff(3.6,40.);
1071 //res1->SetMagicValue(96.95);
1072 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
1073 if (!seg1) {
1074 seg1 = new AliITSsegmentationSDD(geom,res1);
1075 SetSegmentationModel(1,seg1);
1076 }
1077 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
1078 sim1->SetDoFFT(1);
1079 sim1->SetCheckNoise(kFALSE);
1080 SetSimulationModel(1,sim1);
1081
1082 // SSD
1083 iDetType=DetType(2);
1084 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
1085 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
1086 res2->SetSigmaSpread(3.,2.);
1087 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
1088 SetSimulationModel(2,sim2);
1089
1090 cerr<<"Digitizing ITS...\n";
1091
1092 TStopwatch timer;
1093 timer.Start();
1094 HitsToDigits(0,0,-1," ","All"," ");
1095 timer.Stop(); timer.Print();
1096
1097 delete sim0;
1098 delete sim1;
1099 delete sim2;
1100}
1101
1102
1103//____________________________________________________________________________
1104void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
1105{
1106 // keep galice.root for signal and name differently the file for
1107 // background when add! otherwise the track info for signal will be lost !
1108
1109 // the condition below will disappear when the geom class will be
1110 // initialised for all versions - for the moment it is only for v5 !
1111 // 7 is the SDD beam test version
1112 Int_t ver = this->IsVersion();
1113 if(ver!=5 && ver!=7) return;
1114
1115 char *all = strstr(opt,"All");
1116 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1117
1118 Int_t nmodules;
1119 InitModules(size,nmodules);
1120 FillModules(evNumber,bgrev,nmodules,option,filename);
1121
1122 //TBranch *branch;
1123 AliITSsimulation* sim;
1124 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
1125 AliITSgeom *geom = GetITSgeom();
1126
1127 Int_t id,module;
1128 Int_t first,last;
1129 for (id=0;id<kNTYPES;id++) {
1130 if (!all && !det[id]) continue;
1131 //branch = (TBranch*)branches->UncheckedAt(id);
1132 AliITSDetType *iDetType=DetType(id);
1133 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1134 if (!sim) {
1135 Error("HitsToDigits","The simulation class was not instantiated!");
1136 exit(1);
1137 // or SetDefaultSimulation();
1138 }
1139 if(geom) {
1140 first = geom->GetStartDet(id);
1141 last = geom->GetLastDet(id);
1142 } else first=last=0;
1143 cout << "det type " << id << " first, last "<< first << last << endl;
1144 for(module=first;module<=last;module++) {
1145 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1146 sim->DigitiseModule(mod,module,evNumber);
1147 // fills all branches - wasted disk space
1148 gAlice->TreeD()->Fill();
1149 ResetDigits();
1150 // try and fill only the branch
1151 //branch->Fill();
1152 //ResetDigits(id);
1153 } // loop over modules
1154 } // loop over detector types
1155
1156 ClearModules();
1157
1158 Int_t nentries=(Int_t)gAlice->TreeD()->GetEntries();
1159 cout << "nentries in TreeD" << nentries << endl;
1160
1161 char hname[30];
1162 sprintf(hname,"TreeD%d",evNumber);
1163 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1164 // reset tree
1165 gAlice->TreeD()->Reset();
1166
1167}
1168
1169
1170//____________________________________________________________________________
1171void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1172{
1173 // cluster finding and reconstruction of space points
1174
1175 // the condition below will disappear when the geom class will be
1176 // initialised for all versions - for the moment it is only for v5 !
1177 // 7 is the SDD beam test version
1178 Int_t ver = this->IsVersion();
1179 if(ver!=5) return;
1180
1181 char *all = strstr(opt,"All");
1182 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1183
1184 static Bool_t first=kTRUE;
1185 if (!TreeC() && first) {
1186 MakeTreeC("C");
1187 first=kFALSE;
1188 }
1189
1190 TTree *treeC=TreeC();
1191
1192
1193 //TBranch *branch;
1194 AliITSClusterFinder* rec;
1195
1196 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1197 AliITSgeom *geom = GetITSgeom();
1198
1199 Int_t id,module;
1200 for (id=0;id<kNTYPES;id++) {
1201 if (!all && !det[id]) continue;
1202 //branch = (TBranch*)branches->UncheckedAt(id);
1203 AliITSDetType *iDetType=DetType(id);
1204 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1205 if (!rec) {
1206 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1207 exit(1);
1208 // or SetDefaultClusterFinders();
1209 }
1210 TClonesArray *itsDigits = this->DigitsAddress(id);
1211
1212 Int_t first,last;
1213 if(geom) {
1214 first = geom->GetStartDet(id);
1215 last = geom->GetLastDet(id);
1216 } else first=last=0;
1217 //printf("first last %d %d\n",first,last);
1218 for(module=first;module<=last;module++) {
1219 this->ResetDigits();
1220 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1221 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1222 Int_t ndigits = itsDigits->GetEntriesFast();
1223 if (ndigits) rec->FindRawClusters();
1224 gAlice->TreeR()->Fill();
1225 ResetRecPoints();
1226 treeC->Fill();
1227 ResetClusters();
1228 // try and fill only the branch
1229 //branch->Fill();
1230 //ResetRecPoints(id);
1231 } // loop over modules
1232 } // loop over detector types
1233
1234
1235 Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1236 Int_t ncentries=(Int_t)treeC->GetEntries();
1237 cout << " nentries ncentries " << nentries << ncentries << endl;
1238
1239 char hname[30];
1240 sprintf(hname,"TreeR%d",evNumber);
1241 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1242 // reset tree
1243 gAlice->TreeR()->Reset();
1244
1245 sprintf(hname,"TreeC%d",evNumber);
1246 treeC->Write(hname,TObject::kOverwrite);
1247 treeC->Reset();
1248}
1249
1250
1251//____________________________________________________________________________
1252void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1253Option_t *option,Option_t *opt,Text_t *filename)
1254{
1255 // keep galice.root for signal and name differently the file for
1256 // background when add! otherwise the track info for signal will be lost !
1257
1258
1259 // the condition below will disappear when the geom class will be
1260 // initialised for all versions - for the moment it is only for v5 !
1261 Int_t ver = this->IsVersion();
1262 if(ver!=5) return;
1263
1264 char *all = strstr(opt,"All");
1265 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1266
1267 Int_t nmodules;
1268 InitModules(size,nmodules);
1269 FillModules(evNumber,bgrev,nmodules,option,filename);
1270
1271
1272 AliITSsimulation* sim;
1273 AliITSgeom *geom = GetITSgeom();
1274
1275 TRandom *random=new TRandom[9];
1276 random[0].SetSeed(111);
1277 random[1].SetSeed(222);
1278 random[2].SetSeed(333);
1279 random[3].SetSeed(444);
1280 random[4].SetSeed(555);
1281 random[5].SetSeed(666);
1282 random[6].SetSeed(777);
1283 random[7].SetSeed(888);
1284 random[8].SetSeed(999);
1285
1286
1287 Int_t id,module;
1288 for (id=0;id<kNTYPES;id++) {
1289 if (!all && !det[id]) continue;
1290 AliITSDetType *iDetType=DetType(id);
1291 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1292 if (!sim) {
1293 Error("HitsToFastPoints","The simulation class was not instantiated!");
1294 exit(1);
1295 // or SetDefaultSimulation();
1296 }
1297 Int_t first = geom->GetStartDet(id);
1298 Int_t last = geom->GetLastDet(id);
1299 for(module=first;module<=last;module++) {
1300 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1301 sim->CreateFastRecPoints(mod,module,random);
1302 gAlice->TreeR()->Fill();
1303 ResetRecPoints();
1304 } // loop over modules
1305 } // loop over detector types
1306
1307
1308 ClearModules();
1309
1310 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1311
1312 char hname[30];
1313 sprintf(hname,"TreeR%d",evNumber);
1314 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1315 // reset tree
1316 gAlice->TreeR()->Reset();
1317
1318 delete [] random;
1319
1320}
1321
1322//________________________________________________________________
1323
1324AliITStrack AliITS::Tracking(AliITStrack &track, AliITStrack *reference,TObjArray *fastpoints, Int_t
1325**vettid, Bool_t flagvert, AliITSRad *rl ) {
1326
1327//Origin A. Badala' and G.S. Pappalardo: e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1328
1329
1330 TList *list= new TList();
1331
1332 AliITStrack tr(track);
1333
1334 list->AddLast(&tr);
1335
1336 Double_t Pt=(tr).GetPt();
1337 //cout << "\n Pt = " << Pt <<"\n";
1338
1339 AliITStracking obj(list, reference, this, fastpoints,TMath::Abs(Pt),vettid, flagvert, rl);
1340 list->Delete();
1341 delete list;
1342
1343 Int_t itot=-1;
1344 TVector VecTotLabref(18);
1345 Int_t lay, k;
1346 for(lay=5; lay>=0; lay--) {
1347 TVector VecLabref(3);
1348 VecLabref=(*reference).GetLabTrack(lay);
1349 Float_t ClustZ=(*reference).GetZclusterTrack( lay); //modified il 5-3-2001
1350 for(k=0; k<3; k++) { // {itot++; VecTotLabref(itot)=VecLabref(k);} // modified 5-3-2002
1351
1352 Int_t lpp=(Int_t)VecLabref(k);
1353 if(lpp>=0) {
1354 TParticle *p=(TParticle*) gAlice->Particle(lpp);
1355 Int_t pcode=p->GetPdgCode();
1356 if(pcode==11) VecLabref(k)=p->GetFirstMother();
1357 }
1358
1359 itot++; VecTotLabref(itot)=VecLabref(k);
1360 if(VecLabref(k)==0. && ClustZ == 0.) VecTotLabref(itot) =-3.;
1361 }
1362 }
1363 Long_t labref;
1364 Int_t freq;
1365 (*reference).Search(VecTotLabref, labref, freq);
1366
1367 if(freq < 5) labref=-labref;
1368 (*reference).SetLabel(labref);
1369
1370 return *reference;
1371
1372}
1373
1374
1375
1376//________________________________________________________________
1377
1378
1379
1380void AliITS::DoTracking(Int_t evNumber, Int_t min_t, Int_t max_t, TFile *file, Bool_t flagvert) {
1381
1382// ex macro for tracking ITS
1383
1384 printf("begin DoTracking - file %p\n",file);
1385
1386 const char *pname="75x40_100x60";
1387
1388 Int_t imax=200,jmax=450;
1389 AliITSRad *rl = new AliITSRad(imax,jmax);
1390 //cout<<" dopo costruttore AliITSRad\n"; getchar();
1391
1392 struct GoodTrack {
1393 Int_t lab,code;
1394 Float_t px,py,pz,x,y,z,pxg,pyg,pzg,ptg;
1395 Bool_t flag;
1396 };
1397
1398
1399 gAlice->GetEvent(0);
1400
1401 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
1402 AliTPCParam *digp = (AliTPCParam*)file->Get(pname);
1403 if (digp!=0) TPC->SetParam(digp);
1404
1405 GoodTrack gt[15000];
1406 Int_t ngood=0;
1407 ifstream in("itsgood_tracks");
1408
1409 cerr<<"Reading itsgood tracks...\n";
1410 while (in>>gt[ngood].lab>>gt[ngood].code
1411 >>gt[ngood].px >>gt[ngood].py>>gt[ngood].pz
1412 >>gt[ngood].x >>gt[ngood].y >>gt[ngood].z
1413 >>gt[ngood].pxg >>gt[ngood].pyg >>gt[ngood].pzg
1414 >>gt[ngood].ptg >>gt[ngood].flag) {
1415 ngood++;
1416 cerr<<ngood<<'\r';
1417 if (ngood==15000) {
1418 cerr<<"Too many good tracks !\n";
1419 break;
1420 }
1421 }
1422 if (!in.eof()) cerr<<"Read error (itsgood_tracks) !\n";
1423
1424
1425// Load tracks
1426 TFile *tf=TFile::Open("tpctracks.root");
1427 if (!tf->IsOpen()) {cerr<<"Can't open tpctracks.root !\n"; return ;}
1428 TObjArray tracks(200000);
1429 TTree *tracktree=(TTree*)tf->Get("TreeT");
1430 TBranch *tbranch=tracktree->GetBranch("tracks");
1431 Int_t nentr=(Int_t)tracktree->GetEntries();
1432 Int_t kk;
1433 for (kk=0; kk<nentr; kk++) {
1434 AliTPCtrack *iotrack=new AliTPCtrack;
1435 tbranch->SetAddress(&iotrack);
1436 tracktree->GetEvent(kk);
1437 tracks.AddLast(iotrack);
1438 }
1439 tf->Close();
1440
1441
1442 Int_t nt = tracks.GetEntriesFast();
1443 cerr<<"Number of found tracks "<<nt<<endl;
1444
1445 TVector DataOut(9);
1446 Int_t kkk=0;
1447
1448 Double_t ptg=0.,pxg=0.,pyg=0.,pzg=0.;
1449
1450 ////////////////////////////// good tracks definition in TPC ////////////////////////////////
1451
1452 ofstream out1 ("AliITSTrag.out");
1453 Int_t i;
1454 for (i=0; i<ngood; i++) out1 << gt[i].ptg << "\n";
1455 out1.close();
1456
1457
1458 TVector vec(5);
1459 TTree *TR=gAlice->TreeR();
1460 Int_t nent=(Int_t)TR->GetEntries();
1461 TClonesArray *recPoints = RecPoints();
1462 Int_t numbpoints;
1463 Int_t totalpoints=0;
1464 Int_t *np = new Int_t[nent];
1465 Int_t **vettid = new Int_t* [nent];
1466 Int_t mod;
1467 for (mod=0; mod<nent; mod++) {
1468 vettid[mod]=0;
1469 this->ResetRecPoints();
1470 //gAlice->TreeR()->GetEvent(mod+1); //first entry in TreeR is empty
1471 gAlice->TreeR()->GetEvent(mod); //first entry in TreeR is empty
1472 numbpoints = recPoints->GetEntries();
1473 totalpoints+=numbpoints;
1474 np[mod] = numbpoints;
1475 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n"; getchar();
1476 vettid[mod] = new Int_t[numbpoints];
1477 Int_t ii;
1478 for (ii=0;ii<numbpoints; ii++) *(vettid[mod]+ii)=0;
1479 }
1480
1481 AliTPCtrack *track;
1482
1483
1484 if(min_t < 0) {min_t = 0; max_t = nt-1;}
1485
1486/*
1487 ///////////////////////////////// Definition of vertex end its error ////////////////////////////
1488 ////////////////////////// In the future it will be given by a method ///////////////////////////
1489 Double_t Vx=0.;
1490 Double_t Vy=0.;
1491 Double_t Vz=0.;
1492
1493 Float_t sigmavx=0.0050; // 50 microns
1494 Float_t sigmavy=0.0050; // 50 microns
1495 Float_t sigmavz=0.010; // 100 microns
1496
1497 //Vx+=gRandom->Gaus(0,sigmavx); Vy+=gRandom->Gaus(0,sigmavy); Vz+=gRandom->Gaus(0,sigmavz);
1498 TVector vertex(3), ervertex(3)
1499 vertex(0)=Vx; vertex(1)=Vy; vertex(2)=Vz;
1500 ervertex(0)=sigmavx; ervertex(1)=sigmavy; ervertex(2)=sigmavz;
1501 /////////////////////////////////////////////////////////////////////////////////////////////////
1502*/
1503
1504 //TDirectory *savedir=gDirectory;
1505
1506 TTree tracktree1("TreeT","Tree with ITS tracks");
1507 AliITSiotrack *iotrack=0;
1508 tracktree1.Branch("ITStracks","AliITSiotrack",&iotrack,32000,0);
1509
1510 ofstream out ("AliITSTra.out");
1511
1512 Int_t j;
1513 for (j=min_t; j<=max_t; j++) {
1514 track=(AliTPCtrack*)tracks.UncheckedAt(j);
1515 Int_t flaglab=0;
1516 if (!track) continue;
1517 ////// elimination of not good tracks ////////////
1518 Int_t ilab=TMath::Abs(track->GetLabel());
1519 Int_t iii;
1520 for (iii=0;iii<ngood;iii++) {
1521 //cout<<" ilab, gt[iii].lab = "<<ilab<<" "<<gt[iii].lab<<"\n"; getchar();
1522 if (ilab==gt[iii].lab) {
1523 flaglab=1;
1524 ptg=gt[iii].ptg;
1525 pxg=gt[iii].pxg;
1526 pyg=gt[iii].pyg;
1527 pzg=gt[iii].pzg;
1528 break;
1529 }
1530 }
1531 //cout<<" j flaglab = " <<j<<" "<<flaglab<<"\n"; getchar();
1532 if (!flaglab) continue;
1533 //cout<<" j = " <<j<<"\n"; getchar();
1534 /*
1535 ////// old propagation to the end of TPC //////////////
1536 Double_t xk=76.;
1537 track->PropagateTo(xk);
1538 xk-=0.11;
1539 track->PropagateTo(xk,42.7,2.27); //C
1540 xk-=2.6;
1541 track->PropagateTo(xk,36.2,1.98e-3); //C02
1542 xk-=0.051;
1543 track->PropagateTo(xk,42.7,2.27); //C
1544 ///////////////////////////////////////////////////
1545 */
1546
1547 ////// new propagation to the end of TPC //////////////
1548 Double_t xk=77.415;
1549 track->PropagateTo(xk, 28.94, 1.204e-3); //Ne
1550 xk -=0.01;
1551 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1552 xk -=0.04;
1553 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1554 xk -=2.0;
1555 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1556 xk-=16;
1557 track->PropagateTo(xk,36.2,1.98e-3); //C02
1558 xk -=0.01;
1559 track->PropagateTo(xk, 24.01, 2.7); //Al
1560 xk -=0.01;
1561 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1562 xk -=0.04;
1563 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1564 xk -=0.5;
1565 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1566
1567 ///////////////////////////////////////////////////////////////
1568
1569 ///////////////////////////////////////////////////////////////
1570 AliITStrack trackITS(*track);
1571 AliITStrack result(*track);
1572 AliITStrack primarytrack(*track);
1573
1574///////////////////////////////////////////////////////////////////////////////////////////////
1575 TVector Vgeant(3);
1576 Vgeant=result.GetVertex();
1577
1578 // Definition of Dv and Zv for vertex constraint
1579 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
1580 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
1581 Double_t uniform= gRandom->Uniform();
1582 Double_t signdv;
1583 if(uniform<=0.5) signdv=-1.;
1584 else
1585 signdv=1.;
1586
1587 Double_t Vr=TMath::Sqrt(Vgeant(0)*Vgeant(0)+ Vgeant(1)*Vgeant(1));
1588 Double_t Dv=gRandom->Gaus(signdv*Vr,(Float_t)sigmaDv);
1589 Double_t Zv=gRandom->Gaus(Vgeant(2),(Float_t)sigmaZv);
1590
1591 //cout<<" Dv e Zv = "<<Dv<<" "<<Zv<<"\n";
1592 trackITS.SetDv(Dv); trackITS.SetZv(Zv);
1593 trackITS.SetsigmaDv(sigmaDv); trackITS.SetsigmaZv(sigmaZv);
1594 result.SetDv(Dv); result.SetZv(Zv);
1595 result.SetsigmaDv(sigmaDv); result.SetsigmaZv(sigmaZv);
1596 primarytrack.SetDv(Dv); primarytrack.SetZv(Zv);
1597 primarytrack.SetsigmaDv(sigmaDv); primarytrack.SetsigmaZv(sigmaZv);
1598
1599/////////////////////////////////////////////////////////////////////////////////////////////////
1600
1601 primarytrack.PrimaryTrack(rl);
1602 TVector d2=primarytrack.Getd2();
1603 TVector tgl2=primarytrack.Gettgl2();
1604 TVector dtgl=primarytrack.Getdtgl();
1605 trackITS.Setd2(d2); trackITS.Settgl2(tgl2); trackITS.Setdtgl(dtgl);
1606 result.Setd2(d2); result.Settgl2(tgl2); result.Setdtgl(dtgl);
1607 /*
1608 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
1609 result.SetVertex(vertex); result.SetErrorVertex(ervertex);
1610 */
1611 Tracking(trackITS,&result,recPoints,vettid, flagvert,rl);
1612
1613 // cout<<" progressive track number = "<<j<<"\r";
1614 // cout<<j<<"\r";
1615 // cout<<" progressive track number = "<<j<<"\n";
1616 Long_t labITS=result.GetLabel();
1617 // cout << " ITS track label = " << labITS << "\n";
1618 int lab=track->GetLabel();
1619 // cout << " TPC track label = " << lab <<"\n";
1620 //result.GetClusters(); getchar(); //to print the cluster matrix
1621
1622//propagation to vertex
1623
1624 Double_t rbeam=3.;
1625
1626 result.Propagation(rbeam);
1627
1628 TMatrix *cov;
1629 cov=&result.GetCMatrix();
1630 Double_t pt=TMath::Abs(result.GetPt());
1631 Double_t Dr=result.GetD();
1632 Double_t Z=result.GetZ();
1633 Double_t tgl=result.GetTgl();
1634 Double_t C=result.GetC();
1635 Double_t Cy=C/2.;
1636 Double_t Dz=Z-(tgl/Cy)*TMath::ASin(result.arga(rbeam));
1637 Dz-=Vgeant(2);
1638
1639 // cout<<" Dr e dz alla fine = "<<Dr<<" "<<Dz<<"\n"; getchar();
1640 Double_t phi=result.Getphi();
1641 Double_t phivertex = phi - TMath::ASin(result.argA(rbeam));
1642 Double_t duepi=2.*TMath::Pi();
1643 if(phivertex>duepi) phivertex-=duepi;
1644 if(phivertex<0.) phivertex+=duepi;
1645 Double_t Dtot=TMath::Sqrt(Dr*Dr+Dz*Dz);
1646
1647//////////////////////////////////////////////////////////////////////////////////////////
1648 Int_t NumofCluster, idmodule,idpoint;
1649 NumofCluster=result.GetNumClust();
1650 if(NumofCluster >=5) {
1651
1652
1653 AliITSiotrack outtrack;
1654
1655 iotrack=&outtrack;
1656
1657 iotrack->SetStatePhi(phi);
1658 iotrack->SetStateZ(Z);
1659 iotrack->SetStateD(Dr);
1660 iotrack->SetStateTgl(tgl);
1661 iotrack->SetStateC(C);
1662 Double_t radius=result.Getrtrack();
1663 iotrack->SetRadius(radius);
1664 Int_t charge;
1665 if(C>0.) charge=-1; else charge=1;
1666 iotrack->SetCharge(charge);
1667
1668
1669
1670 iotrack->SetCovMatrix(cov);
1671
1672 Double_t px=pt*TMath::Cos(phi);
1673 Double_t py=pt*TMath::Sin(phi);
1674 Double_t pz=pt*tgl;
1675
1676 Double_t xtrack=Dr*TMath::Sin(phi);
1677 Double_t ytrack=Dr*TMath::Cos(phi);
1678 Double_t ztrack=Dz+Vgeant(2);
1679
1680
1681 iotrack->SetPx(px);
1682 iotrack->SetPy(py);
1683 iotrack->SetPz(pz);
1684 iotrack->SetX(xtrack);
1685 iotrack->SetY(ytrack);
1686 iotrack->SetZ(ztrack);
1687 iotrack->SetLabel(labITS);
1688
1689 Int_t il;
1690 for(il=0;il<6; il++){
1691 iotrack->SetIdPoint(il,result.GetIdPoint(il));
1692 iotrack->SetIdModule(il,result.GetIdModule(il));
1693 }
1694 tracktree1.Fill();
1695
1696 //cout<<" labITS = "<<labITS<<"\n";
1697 //cout<<" phi z Dr tgl C = "<<phi<<" "<<Z<<" "<<Dr<<" "<<tgl<<" "<<C<<"\n"; getchar();
1698
1699 DataOut(kkk) = ptg; kkk++; DataOut(kkk)=labITS; kkk++; DataOut(kkk)=lab; kkk++;
1700
1701 for (il=0;il<6;il++) {
1702 idpoint=result.GetIdPoint(il);
1703 idmodule=result.GetIdModule(il);
1704 *(vettid[idmodule]+idpoint)=1;
1705 iotrack->SetIdPoint(il,idpoint);
1706 iotrack->SetIdModule(il,idmodule);
1707 }
1708
1709 // cout<<" +++++++++++++ pt e ptg = "<<pt<<" "<<ptg<<" ++++++++++\n";
1710 Double_t difpt= (pt-ptg)/ptg*100.;
1711 DataOut(kkk)=difpt; kkk++;
1712 Double_t lambdag=TMath::ATan(pzg/ptg);
1713 Double_t lam=TMath::ATan(tgl);
1714 Double_t diflam = (lam - lambdag)*1000.;
1715 DataOut(kkk) = diflam; kkk++;
1716 Double_t phig=TMath::ATan(pyg/pxg);
1717 Double_t phi=phivertex;
1718 Double_t difphi = (phi - phig)*1000.;
1719 DataOut(kkk)=difphi; kkk++;
1720 DataOut(kkk)=Dtot*1.e4; kkk++;
1721 DataOut(kkk)=Dr*1.e4; kkk++;
1722 DataOut(kkk)=Dz*1.e4; kkk++;
1723 Int_t r;
1724 for (r=0; r<9; r++) { out<<DataOut(r)<<" ";}
1725 out<<"\n";
1726 kkk=0;
1727
1728
1729 } // end if on NumofCluster
1730 //gObjectTable->Print(); // stampa memoria
1731 } // end for (int j=min_t; j<=max_t; j++)
1732
1733 out.close();
1734
1735
1736 static Bool_t first=kTRUE;
1737 static TFile *tfile;
1738
1739 if(first) {
1740 tfile=new TFile("itstracks.root","RECREATE");
1741 //cout<<"I have opened itstracks.root file "<<endl;
1742 }
1743 first=kFALSE;
1744 tfile->cd();
1745 tfile->ls();
1746
1747 char hname[30];
1748 sprintf(hname,"TreeT%d",evNumber);
1749
1750 tracktree1.Write(hname);
1751
1752
1753
1754 TTree *fAli=gAlice->TreeK();
1755 TFile *fileAli=0;
1756
1757 if (fAli) fileAli =fAli->GetCurrentFile();
1758 fileAli->cd();
1759
1760 ////////////////////////////////////////////////////////////////////////////////////////////////
1761
1762 printf("delete vectors\n");
1763 if(np) delete [] np;
1764 if(vettid) delete [] vettid;
1765
1766}