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