]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITS.cxx
Bugfix in DisplayTracks()
[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.63 2001/10/24 21:16:34 nilsen
19Removed some dead code and improved comments/documntation.
20
21Revision 1.62 2001/10/21 19:23:21 nilsen
22Added function to allow to limit which detectors to digitize and reconstruct.
23The default is All. This change makes no changes to any root file.
24
25Revision 1.61 2001/10/11 15:26:07 mariana
26Correct HitsToFastRecPoints
27
28Revision 1.60 2001/10/04 22:38:10 nilsen
29Changes made to support PreDigits (SDigits) plus other helpful changes.
30
31Revision 1.59 2001/08/30 09:56:18 hristov
32The operator[] is replaced by At() or AddAt() in case of TObjArray.
33
34Revision 1.58 2001/07/26 15:05:29 hristov
35Use global gRandom generator (M.Ivanov)
36
37Revision 1.57 2001/07/24 14:26:11 mariana
38Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
39
40Revision 1.56 2001/07/05 12:49:49 mariana
41Temporary patches required by root.v3.01.05
42
43Revision 1.55 2001/06/14 14:59:00 barbera
44Tracking V1 decoupled from AliITS
45
46Revision 1.54 2001/05/31 20:37:56 barbera
47Bari/Salerno model set as defaault SPD simulation
48
49Revision 1.53 2001/05/31 18:52:24 barbera
50Bari model becomes the default
51
52Revision 1.53 2001/05/30 07:52:24 hristov
53TPC and CONTAINERS included in the search path
54
55Revision 1.52 2001/05/30 06:04:58 hristov
56Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
57
58Revision 1.51 2001/05/16 14:57:15 alibrary
59New files for folders and Stack
60
61Revision 1.50 2001/05/11 09:15:21 barbera
62Corrected to make fast point creation working with PPR geometry
63
64Revision 1.49 2001/05/11 07:37:49 hristov
65Legacy lines commented
66
67Revision 1.48 2001/05/10 18:14:25 barbera
68A typo corrected
69
70Revision 1.47 2001/05/10 17:55:59 barbera
71Modified to create rec points also for PPR geometries
72
73Revision 1.46 2001/05/10 00:05:28 nilsen
74Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
75should probably be cleaned up to only check to make sure that fITSgeom has
76been properly defined.
77
78Revision 1.45 2001/05/01 22:35:48 nilsen
79Remove/commented a number of cout<< statements. and made change needed by
80SSD code.
81
82Revision 1.44 2001/04/26 22:44:01 nilsen
83Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
84done properly in AliITSv???.cxx via SetDefaults.
85
86Revision 1.43 2001/04/26 13:22:52 barbera
87TMatrix and TVector elimininated to speed up the code
88
89Revision 1.42 2001/04/25 21:55:12 barbera
90Updated version to be compatible with actual verion of STEER and TPC
91
92Revision 1.41 2001/04/21 15:16:51 barbera
93Updated with the new SSD reconstruction code
94
95Revision 1.40 2001/03/17 15:07:06 mariana
96Update SDD response parameters
97
98Revision 1.39 2001/03/12 17:45:32 hristov
99Changes needed on Sun with CC 5.0
100
101Revision 1.38 2001/03/07 14:04:51 barbera
102Some vector dimensions increased to cope with full events
103
104Revision 1.37 2001/03/07 12:36:35 barbera
105A change added in the tracking part to manage delta rays
106
107Revision 1.36 2001/03/02 19:44:11 barbera
108 modified to taking into account new version tracking v1
109
110Revision 1.35 2001/02/28 18:16:46 mariana
111Make the code compatible with the new AliRun
112
113Revision 1.34 2001/02/11 15:51:39 mariana
114Set protection in MakeBranch
115
116Revision 1.33 2001/02/10 22:26:39 mariana
117Move the initialization of the containers for raw clusters in MakeTreeC()
118
119Revision 1.32 2001/02/08 23:55:31 nilsen
120Removed fMajor/MinorVersion variables in favor of variables in derived classes.
121Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
122
123Revision 1.31 2001/02/02 23:57:28 nilsen
124Added include file that are no londer included in AliITSgeom.h
125
126Revision 1.30 2001/01/30 09:23:13 hristov
127Streamers removed (R.Brun)
128
129Revision 1.29 2001/01/26 20:01:09 hristov
130Major upgrade of AliRoot code
131
132Revision 1.28 2000/12/18 14:02:00 barbera
133new version of the ITS tracking to take into account the new TPC track parametrization
134
135Revision 1.27 2000/12/08 13:49:27 barbera
136Hidden declaration in a for loop removed to be compliant with HP-UX compiler
137
138Revision 1.26 2000/11/27 13:12:13 barbera
139New version containing the files for tracking
140
141Revision 1.25 2000/11/12 22:38:05 barbera
142Added header file for the SPD Bari model
143
144Revision 1.24 2000/10/09 22:18:12 barbera
145Bug fixes from MAriana to le AliITStest.C run correctly
146
147Revision 1.23 2000/10/05 20:47:42 nilsen
148fixed dependencies of include files. Tryed but failed to get a root automaticly
149generates streamer function to work. Modified SetDefaults.
150
151Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
152Needed to include stdlib.h
153
154=======
155Revision 1.22 2000/10/04 19:45:52 barbera
156Corrected by F. Carminati for v3.04
157
158Revision 1.21 2000/10/02 21:28:08 fca
159Removal of useless dependecies via forward declarations
160
161Revision 1.20 2000/10/02 16:31:39 barbera
162General code clean-up
163
164Revision 1.9.2.14 2000/10/02 15:43:51 barbera
165General code clean-up (e.g., printf -> cout)
166
167Revision 1.19 2000/09/22 12:13:25 nilsen
168Patches and updates for fixes to this and other routines.
169
170Revision 1.18 2000/07/12 05:32:20 fca
171Correcting several syntax problem with static members
172
173Revision 1.17 2000/07/10 16:07:18 fca
174Release version of ITS code
175
176Revision 1.9.2.3 2000/02/02 13:42:09 barbera
177fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
178
179Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
180//fixed FillModule. Removed fi(fabs(xl)<dx....
181
182Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
183This is the version of the files after the merging done in December 1999.
184See the ReadMe110100.txt file for details
185
186Revision 1.9 1999/11/14 14:33:25 fca
187Correct problems with distructors and pointers, thanks to I.Hrivnacova
188
189Revision 1.8 1999/09/29 09:24:19 fca
190Introduction of the Copyright and cvs Log
191
192*/
193
194///////////////////////////////////////////////////////////////////////////////
195//
196// An overview of the basic philosophy of the ITS code development
197// and analysis is show in the figure below.
198//Begin_Html
199/*
200<img src="picts/ITS/ITS_Analysis_schema.gif">
201</pre>
202<br clear=left>
203<font size=+2 color=red>
204<p>Roberto Barbera is in charge of the ITS Offline code (1999).
205<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
206</font>
207<pre>
208*/
209//End_Html
210//
211// AliITS. Inner Traking System base class.
212// This class contains the base procedures for the Inner Tracking System
213//
214//Begin_Html
215/*
216<img src="picts/ITS/AliITS_Class_Diagram.gif">
217</pre>
218<br clear=left>
219<font size=+2 color=red>
220<p>This show the class diagram of the different elements that are part of
221the AliITS class.
222</font>
223<pre>
224*/
225//End_Html
226//
227// Version: 0
228// Written by Rene Brun, Federico Carminati, and Roberto Barbera
229//
230// Version: 1
231// Modified and documented by Bjorn S. Nilsen
232// July 11 1999
233//
234// Version: 2
235// Modified and documented by A. Bologna
236// October 18 1999
237//
238// AliITS is the general base class for the ITS. Also see AliDetector for
239// futher information.
240//
241///////////////////////////////////////////////////////////////////////////////
242#include <iostream.h>
243#include <iomanip.h>
244#include <fstream.h>
245#include <stdlib.h>
246#include <TMath.h>
247#include <TRandom.h>
248#include <TBranch.h>
249#include <TVector.h>
250#include <TClonesArray.h>
251#include <TROOT.h>
252#include <TObjectTable.h>
253#include <TFile.h>
254#include <TTree.h>
255#include <TString.h>
256
257#include "AliMC.h"
258#include "AliRun.h"
259#include "AliHeader.h"
260
261#include "AliITS.h"
262#include "AliITSDetType.h"
263#include "AliITSresponseSPD.h"
264#include "AliITSresponseSDD.h"
265#include "AliITSresponseSSD.h"
266#include "AliITSsegmentationSPD.h"
267#include "AliITSsegmentationSDD.h"
268#include "AliITSsegmentationSSD.h"
269#include "AliITSsimulationSPD.h"
270#include "AliITSsimulationSDD.h"
271#include "AliITSsimulationSSD.h"
272#include "AliITSClusterFinderSPD.h"
273#include "AliITSClusterFinderSDD.h"
274#include "AliITSClusterFinderSSD.h"
275#include "AliITShit.h"
276#include "AliITSgeom.h"
277#include "AliITSpList.h"
278#include "AliITSdigit.h"
279#include "AliITSmodule.h"
280#include "AliITSRecPoint.h"
281#include "AliITSRawCluster.h"
282
283ClassImp(AliITS)
284
285//______________________________________________________________________
286AliITS::AliITS() : AliDetector() {
287 // Default initializer for ITS
288 // The default constructor of the AliITS class. In addition to
289 // creating the AliITS class it zeros the variables fIshunt (a member
290 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
291 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
292 // is also called.
293 // Inputs:
294 // none.
295 // Outputs:
296 // none.
297 // Return:
298 // Blank ITS class.
299
300 fIshunt = 0; // not zeroed in AliDetector.
301
302 // AliITS variables.
303 fEuclidOut = 0;
304 fITSgeom = 0;
305 fITSmodules = 0;
306 SetDetectors(); // default to fOpt="All". This variable not written out.
307
308 fIdN = 0;
309 fIdName = 0;
310 fIdSens = 0;
311
312 fNDetTypes = kNTYPES;
313 fDetTypes = 0;
314
315 fSDigits = 0;
316 fNSDigits = 0;
317
318 fNdtype = 0;
319 fDtype = 0;
320
321 fCtype = 0;
322 fNctype = 0;
323 fTreeC = 0;
324
325 fRecPoints = 0;
326 fNRecPoints = 0;
327
328 SetMarkerColor(kRed);
329}
330//______________________________________________________________________
331AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
332 // The standard Constructor for the ITS class. In addition to
333 // creating the AliITS class, it allocates memory for the TClonesArrays
334 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
335 // (clusters). It also zeros the variables
336 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
337 // the pointers fIdSens and fIdName. To help in displaying hits via the
338 // ROOT macro display.C AliITS also sets the marker color to red. The
339 // variables passes with this constructor, const char *name and *title,
340 // are used by the constructor of AliDetector class. See AliDetector
341 // class for a description of these parameters and its constructor
342 // functions.
343 // Inputs:
344 // const char *name Detector name. Should always be "ITS"
345 // const char *title Detector title.
346 // Outputs:
347 // none.
348 // Return:
349 // An ITS class.
350
351 fIshunt = 0; // not zeroed in AliDetector
352 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
353 gAlice->AddHitList(fHits); // Not done in AliDetector.
354
355 fEuclidOut = 0;
356 fITSgeom = 0;
357 fITSmodules = 0;
358 SetDetectors(); // default to fOpt="All". This variable not written out.
359
360 fIdN = 0;
361 fIdName = 0;
362 fIdSens = 0;
363
364 fNDetTypes = kNTYPES;
365 fDetTypes = new TObjArray(fNDetTypes);
366
367 fSDigits = new TClonesArray("AliITSpListItem",1000);
368 fNSDigits = 0;
369
370 fNdtype = new Int_t[fNDetTypes];
371 fDtype = new TObjArray(fNDetTypes);
372
373 fCtype = new TObjArray(fNDetTypes);
374 fNctype = new Int_t[fNDetTypes];
375 fTreeC = 0;
376
377 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
378 fNRecPoints = 0;
379
380 Int_t i;
381 for(i=0;i<fNDetTypes;i++) {
382 fDetTypes->AddAt(new AliITSDetType(),i);
383 fNdtype[i] = 0;
384 fNctype[i] = 0;
385 } // end for i
386
387 SetMarkerColor(kRed);
388}
389//______________________________________________________________________
390AliITS::~AliITS(){
391 // Default destructor for ITS.
392 // The default destructor of the AliITS class. In addition to deleting
393 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
394 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
395 // fITSpoints, fDetType and it's contents.
396 // Inputs:
397 // none.
398 // Outputs:
399 // none.
400 // Return:
401 // none.
402
403 delete fHits;
404 delete fSDigits;
405 delete fDigits;
406 delete fRecPoints;
407 if(fIdName!=0) delete[] fIdName; // Array of TStrings
408 if(fIdSens!=0) delete[] fIdSens;
409 if(fITSmodules!=0) {
410 this->ClearModules();
411 delete fITSmodules;
412 }// end if fITSmodules!=0
413
414 if(fDtype) {
415 fDtype->Delete();
416 delete fDtype;
417 } // end if fDtype
418 delete [] fNdtype;
419 if (fCtype) {
420 fCtype->Delete();
421 delete fCtype;
422 } // end if fCtype
423 delete [] fNctype;
424
425 if (fDetTypes) {
426 fDetTypes->Delete();
427 delete fDetTypes;
428 } // end if fDetTypes
429
430 if (fTreeC) delete fTreeC;
431
432 if (fITSgeom) delete fITSgeom;
433}
434//______________________________________________________________________
435AliITS::AliITS(AliITS &source){
436 // Copy constructor. This is a function which is not allowed to be
437 // done to the ITS. It exits with an error.
438 // Inputs:
439 // AliITS &source An AliITS class.
440 // Outputs:
441 // none.
442 // Return:
443 // none.
444
445 if(this==&source) return;
446 Error("Copy constructor",
447 "You are not allowed to make a copy of the AliITS");
448 exit(1);
449}
450//______________________________________________________________________
451AliITS& AliITS::operator=(AliITS &source){
452 // Assignment operator. This is a function which is not allowed to be
453 // done to the ITS. It exits with an error.
454 // Inputs:
455 // AliITS &source An AliITS class.
456 // Outputs:
457 // none.
458 // Return:
459 // none.
460
461 if(this==&source) return *this;
462 Error("operator=","You are not allowed to make a copy of the AliITS");
463 exit(1);
464 return *this; //fake return
465}
466//______________________________________________________________________
467Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
468 // Distance from mouse to ITS on the screen. Dummy routine
469 // A dummy routine used by the ROOT macro display.C to allow for the
470 // use of the mouse (pointing device) in the macro. In general this should
471 // never be called. If it is it returns the number 9999 for any value of
472 // x and y.
473 // Inputs:
474 // Int_t Dummy screen coordinate.
475 // Int_t Dummy screen coordinate.
476 // Outputs:
477 // none.
478 // Return:
479 // Int_t Dummy = 9999 distance to ITS.
480
481 return 9999;
482}
483//______________________________________________________________________
484void AliITS::Init(){
485 // Initializer ITS after it has been built
486 // This routine initializes the AliITS class. It is intended to be
487 // called from the Init function in AliITSv?. Besides displaying a banner
488 // indicating that it has been called it initializes the array fIdSens
489 // and sets the default segmentation, response, digit and raw cluster
490 // classes therefore it should be called after a call to CreateGeometry.
491 // Inputs:
492 // none.
493 // Outputs:
494 // none.
495 // Return:
496 // none.
497 Int_t i;
498
499 SetDefaults();
500 // Array of TStrings
501 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
502}
503//______________________________________________________________________
504void AliITS::SetDefaults(){
505 // sets the default segmentation, response, digit and raw cluster classes.
506 // Inputs:
507 // none.
508 // Outputs:
509 // none.
510 // Return:
511 // none.
512
513 if(fDebug) printf("%s: SetDefaults\n",ClassName());
514
515 AliITSDetType *iDetType;
516
517 //SPD
518 iDetType=DetType(0);
519 if (!iDetType->GetSegmentationModel()) {
520 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
521 SetSegmentationModel(0,seg0);
522 } // end if
523 if (!iDetType->GetResponseModel()) {
524 SetResponseModel(0,new AliITSresponseSPD());
525 } // end if
526 // set digit and raw cluster classes to be used
527
528 const char *kData0=(iDetType->GetResponseModel())->DataType();
529 if (strstr(kData0,"real")) {
530 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
531 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
532
533 // SDD
534 iDetType=DetType(1);
535 if (!iDetType->GetResponseModel()) {
536 SetResponseModel(1,new AliITSresponseSDD());
537 } // end if
538 AliITSresponse *resp1=iDetType->GetResponseModel();
539 if (!iDetType->GetSegmentationModel()) {
540 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
541 SetSegmentationModel(1,seg1);
542 } // end if
543 const char *kData1=(iDetType->GetResponseModel())->DataType();
544 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
545 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
546 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
547 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
548
549 // SSD
550 iDetType=DetType(2);
551 if (!iDetType->GetSegmentationModel()) {
552 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
553 SetSegmentationModel(2,seg2);
554 } // end if
555 if (!iDetType->GetResponseModel()) {
556 SetResponseModel(2,new AliITSresponseSSD());
557 } // end if
558 const char *kData2=(iDetType->GetResponseModel())->DataType();
559 if (strstr(kData2,"real")) {
560 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
561 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
562
563 if (kNTYPES>3) {
564 Warning("SetDefaults",
565 "Only the three basic detector types are initialized!");
566 } // end if
567}
568//______________________________________________________________________
569void AliITS::SetDefaultSimulation(){
570 // sets the default simulation.
571 // Inputs:
572 // none.
573 // Outputs:
574 // none.
575 // Return:
576 // none.
577
578 AliITSDetType *iDetType;
579 iDetType=DetType(0);
580 if (!iDetType->GetSimulationModel()) {
581 AliITSsegmentation *seg0=
582 (AliITSsegmentation*)iDetType->GetSegmentationModel();
583 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
584 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
585 SetSimulationModel(0,sim0);
586 } // end if
587 iDetType=DetType(1);
588 if (!iDetType->GetSimulationModel()) {
589 AliITSsegmentation *seg1=
590 (AliITSsegmentation*)iDetType->GetSegmentationModel();
591 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
592 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
593 SetSimulationModel(1,sim1);
594 } //end if
595 iDetType=DetType(2);
596 if (!iDetType->GetSimulationModel()) {
597 AliITSsegmentation *seg2=
598 (AliITSsegmentation*)iDetType->GetSegmentationModel();
599 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
600 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
601 SetSimulationModel(2,sim2);
602 } // end if
603}
604//______________________________________________________________________
605void AliITS::SetDefaultClusterFinders(){
606 // Sets the default cluster finders. Used in finding RecPoints.
607 // Inputs:
608 // none.
609 // Outputs:
610 // none.
611 // Return:
612 // none.
613
614 MakeTreeC();
615 AliITSDetType *iDetType;
616
617 // SPD
618 iDetType=DetType(0);
619 if (!iDetType->GetReconstructionModel()) {
620 AliITSsegmentation *seg0 =
621 (AliITSsegmentation*)iDetType->GetSegmentationModel();
622 TClonesArray *dig0=DigitsAddress(0);
623 TClonesArray *recp0=ClustersAddress(0);
624 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
625 recp0);
626 SetReconstructionModel(0,rec0);
627 } // end if
628
629 // SDD
630 iDetType=DetType(1);
631 if (!iDetType->GetReconstructionModel()) {
632 AliITSsegmentation *seg1 =
633 (AliITSsegmentation*)iDetType->GetSegmentationModel();
634 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
635 TClonesArray *dig1=DigitsAddress(1);
636 TClonesArray *recp1=ClustersAddress(1);
637 AliITSClusterFinderSDD *rec1 =
638 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
639 SetReconstructionModel(1,rec1);
640 } // end if
641
642 // SSD
643 iDetType=DetType(2);
644 if (!iDetType->GetReconstructionModel()) {
645 AliITSsegmentation *seg2=
646 (AliITSsegmentation*)iDetType->GetSegmentationModel();
647 TClonesArray *dig2=DigitsAddress(2);
648 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
649 SetReconstructionModel(2,rec2);
650 } // end if
651}
652//______________________________________________________________________
653void AliITS::MakeBranch(Option_t* option, const char *file){
654 // Creates Tree branches for the ITS.
655 // Inputs:
656 // Option_t *option String of Tree types S,D, and/or R.
657 // const char *file String of the file name where these branches
658 // are to be stored. If blank then these branches
659 // are written to the same tree as the Hits were
660 // read from.
661 // Outputs:
662 // none.
663 // Return:
664 // none.
665 const char *cS = strstr(option,"S");
666 const char *cD = strstr(option,"D");
667 const char *cR = strstr(option,"R");
668
669 AliDetector::MakeBranch(option,file);
670
671 if(cS) MakeBranchS(file);
672 if(cD) MakeBranchD(file);
673 if(cR) MakeBranchR(file);
674}
675//______________________________________________________________________
676void AliITS::SetTreeAddress(){
677 // Set branch address for the Trees.
678 // Inputs:
679 // none.
680 // Outputs:
681 // none.
682 // Return:
683 // none.
684 TTree *treeS = gAlice->TreeS();
685 TTree *treeD = gAlice->TreeD();
686 TTree *treeR = gAlice->TreeR();
687
688 AliDetector::SetTreeAddress();
689
690 SetTreeAddressS(treeS);
691 SetTreeAddressD(treeD);
692 SetTreeAddressR(treeR);
693}
694//______________________________________________________________________
695AliITSDetType* AliITS::DetType(Int_t id){
696 // Return pointer to id detector type.
697 // Inputs:
698 // Int_t id detector id number.
699 // Outputs:
700 // none.
701 // Return:
702 // returned, a pointer to a AliITSDetType.
703
704 return ((AliITSDetType*) fDetTypes->At(id));
705}
706//______________________________________________________________________
707void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
708 // Set the response model for the id detector type.
709 // Inputs:
710 // Int_t id detector id number.
711 // AliITSresponse* a pointer containing an instance of AliITSresponse
712 // to be stored/owned b y AliITSDetType.
713 // Outputs:
714 // none.
715 // Return:
716 // none.
717
718 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
719}
720//______________________________________________________________________
721void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
722 // Set the segmentation model for the id detector type.
723 // Inputs:
724 // Int_t id detector id number.
725 // AliITSsegmentation* a pointer containing an instance of
726 // AliITSsegmentation to be stored/owned b y
727 // AliITSDetType.
728 // Outputs:
729 // none.
730 // Return:
731 // none.
732
733 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
734}
735//______________________________________________________________________
736void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
737 // Set the simulation model for the id detector type.
738 // Inputs:
739 // Int_t id detector id number.
740 // AliITSresponse* a pointer containing an instance of AliITSresponse
741 // to be stored/owned b y AliITSDetType.
742 // Outputs:
743 // none.
744 // Return:
745 // none.
746
747 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
748
749}
750//______________________________________________________________________
751void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
752 // Set the cluster finder model for the id detector type.
753 // Inputs:
754 // Int_t id detector id number.
755 // AliITSClusterFinder* a pointer containing an instance of
756 // AliITSClusterFinder to be stored/owned b y
757 // AliITSDetType.
758 // Outputs:
759 // none.
760 // Return:
761 // none.
762
763 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
764}
765//______________________________________________________________________
766void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
767 // Set the digit and cluster classes name to be used for the id detector
768 // type.
769 // Inputs:
770 // Int_t id detector id number.
771 // const char *digit Digit class name for detector id.
772 // const char *cluster Cluster class name for detector id.
773 // Outputs:
774 // none.
775 // Return:
776 // none.
777
778 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
779}
780//______________________________________________________________________
781void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
782 // Add an ITS hit
783 // The function to add information to the AliITShit class. See the
784 // AliITShit class for a full description. This function allocates the
785 // necessary new space for the hit information and passes the variable
786 // track, and the pointers *vol and *hits to the AliITShit constructor
787 // function.
788 // Inputs:
789 // Int_t track Track number which produced this hit.
790 // Int_t *vol Array of Integer Hit information. See AliITShit.h
791 // Float_t *hits Array of Floating Hit information. see AliITShit.h
792 // Outputs:
793 // none.
794 // Return:
795 // none.
796
797 TClonesArray &lhits = *fHits;
798 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
799}
800//______________________________________________________________________
801void AliITS::InitModules(Int_t size,Int_t &nmodules){
802 // Initialize the modules array.
803 // Inputs:
804 // Int_t size Size of array of the number of modules to be
805 // created. If size <=0 then the number of modules
806 // is gotten from AliITSgeom class kept in fITSgeom.
807 // Outputs:
808 // Int_t &nmodules The number of modules existing.
809 // Return:
810 // none.
811
812 if(fITSmodules){
813 fITSmodules->Delete();
814 delete fITSmodules;
815 } // end fir fITSmoudles
816
817 Int_t nl,indexMAX,index;
818
819 if(size<=0){ // default to using data stored in AliITSgeom
820 if(fITSgeom==0) {
821 Error("InitModules","fITSgeom not defined");
822 return;
823 } // end if fITSgeom==0
824 nl = fITSgeom->GetNlayers();
825 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
826 fITSgeom->GetNdetectors(nl))+1;
827 nmodules = indexMAX;
828 fITSmodules = new TObjArray(indexMAX);
829 for(index=0;index<indexMAX;index++){
830 fITSmodules->AddAt( new AliITSmodule(index),index);
831 } // end for index
832 }else{
833 fITSmodules = new TObjArray(size);
834 for(index=0;index<size;index++) {
835 fITSmodules->AddAt( new AliITSmodule(index),index);
836 } // end for index
837
838 nmodules = size;
839 } // end i size<=0
840}
841//______________________________________________________________________
842void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
843 Option_t *option,Text_t *filename){
844 // fill the modules with the sorted by module hits; add hits from
845 // background if option=Add.
846 // Inputs:
847 // Int_t evnt Event to be processed.
848 // Int_t bgrev Background Hit tree number.
849 // Int_t nmodules Not used.
850 // Option_t *option String indicating if merging hits or not. To
851 // merge hits set equal to "Add". Otherwise no
852 // background hits are considered.
853 // Test_t *filename File name containing the background hits..
854 // Outputs:
855 // none.
856 // Return:
857 // none.
858 static TTree *trH1; //Tree with background hits
859 static TClonesArray *fHits2; //List of hits for one track only
860 static Bool_t first=kTRUE;
861 static TFile *file;
862 const char *addBgr = strstr(option,"Add");
863
864 if (addBgr ) {
865 if(first) {
866 file=new TFile(filename);
867 fHits2 = new TClonesArray("AliITShit",1000 );
868 } // end if first
869 first=kFALSE;
870 file->cd();
871 file->ls();
872 // Get Hits Tree header from file
873 if(fHits2) fHits2->Clear();
874 if(trH1) delete trH1;
875 trH1=0;
876
877 char treeName[20];
878 sprintf(treeName,"TreeH%d",bgrev);
879 trH1 = (TTree*)gDirectory->Get(treeName);
880 if (!trH1) {
881 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
882 } // end if !trH1
883 // Set branch addresses
884 TBranch *branch;
885 char branchname[20];
886 sprintf(branchname,"%s",GetName());
887 if (trH1 && fHits2) {
888 branch = trH1->GetBranch(branchname);
889 if (branch) branch->SetAddress(&fHits2);
890 } // end if trH1 && fHits
891 } // end if addBgr
892
893 TClonesArray *itsHits = this->Hits();
894 Int_t lay,lad,det,index;
895 AliITShit *itsHit=0;
896 AliITSmodule *mod=0;
897 TTree *iTH = gAlice->TreeH();
898 Int_t ntracks =(Int_t) iTH->GetEntries();
899 Int_t t,h;
900 for(t=0; t<ntracks; t++){
901 gAlice->ResetHits();
902 iTH->GetEvent(t);
903 Int_t nhits = itsHits->GetEntriesFast();
904 if (!nhits) continue;
905 for(h=0; h<nhits; h++){
906 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
907 itsHit->GetDetectorID(lay,lad,det);
908 // temporarily index=det-1 !!!
909 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
910 else index=det-1;
911 //
912 mod = this->GetModule(index);
913 mod->AddHit(itsHit,t,h);
914 } // end loop over hits
915 } // end loop over tracks
916
917 // open the file with background
918
919 if (addBgr ) {
920 Int_t track,i;
921 ntracks =(Int_t)trH1->GetEntries();
922 // Loop over tracks
923 for (track=0; track<ntracks; track++) {
924 if (fHits2) fHits2->Clear();
925 trH1->GetEvent(track);
926 // Loop over hits
927 for(i=0;i<fHits2->GetEntriesFast();++i) {
928 itsHit=(AliITShit*) (*fHits2)[i];
929 itsHit->GetDetectorID(lay,lad,det);
930 // temporarily index=det-1 !!!
931 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
932 else index=det-1;
933 //
934 mod = this->GetModule(index);
935 mod->AddHit(itsHit,track,i);
936 } // end loop over hits
937 } // end loop over tracks
938 TTree *fAli=gAlice->TreeK();
939 TFile *fileAli=0;
940 if (fAli) fileAli =fAli->GetCurrentFile();
941 fileAli->cd();
942 } // end if add
943}
944//______________________________________________________________________
945void AliITS::ClearModules(){
946 // Clear the modules TObjArray.
947 // Inputs:
948 // none.
949 // Outputs:
950 // none.
951
952 if(fITSmodules) fITSmodules->Delete();
953}
954//______________________________________________________________________
955void AliITS::MakeBranchS(const char *fl){
956 // Creates Tree Branch for the ITS summable digits.
957 // Inputs:
958 // cont char *fl File name where SDigits branch is to be written
959 // to. If blank it write the SDigits to the same
960 // file in which the Hits were found.
961 // Outputs:
962 // none.
963 // Return:
964 // none.
965 Int_t buffersize = 4000;
966 char branchname[30];
967
968 // only one branch for SDigits.
969 sprintf(branchname,"%s",GetName());
970 if(fSDigits && gAlice->TreeS()){
971 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
972 } // end if
973}
974//______________________________________________________________________
975void AliITS::SetTreeAddressS(TTree *treeS){
976 // Set branch address for the ITS summable digits Trees.
977 // Inputs:
978 // TTree *treeS Tree containing the SDigits.
979 // Outputs:
980 // none.
981 // Return:
982 // none.
983 char branchname[30];
984
985 if(!treeS) return;
986 TBranch *branch;
987 sprintf(branchname,"%s",GetName());
988 branch = treeS->GetBranch(branchname);
989 if (branch) branch->SetAddress(&fSDigits);
990}
991//______________________________________________________________________
992void AliITS::MakeBranchD(const char *file){
993 // Creates Tree branches for the ITS.
994 // Inputs:
995 // cont char *file File name where Digits branch is to be written
996 // to. If blank it write the SDigits to the same
997 // file in which the Hits were found.
998 // Outputs:
999 // none.
1000 // Return:
1001 // none.
1002 Int_t buffersize = 4000;
1003 char branchname[30];
1004
1005 sprintf(branchname,"%s",GetName());
1006 // one branch for digits per type of detector
1007 const char *det[3] = {"SPD","SDD","SSD"};
1008 char digclass[40];
1009 char clclass[40];
1010 Int_t i;
1011 for (i=0; i<kNTYPES ;i++) {
1012 DetType(i)->GetClassNames(digclass,clclass);
1013 // digits
1014 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1015 else ResetDigits(i);
1016 } // end for i
1017 for (i=0; i<kNTYPES ;i++) {
1018 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1019 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1020 if (fDtype && gAlice->TreeD()) {
1021 MakeBranchInTree(gAlice->TreeD(),
1022 branchname, &((*fDtype)[i]),buffersize,file);
1023 } // end if
1024 } // end for i
1025}
1026//______________________________________________________________________
1027void AliITS::SetTreeAddressD(TTree *treeD){
1028 // Set branch address for the Trees.
1029 // Inputs:
1030 // TTree *treeD Tree containing the Digits.
1031 // Outputs:
1032 // none.
1033 // Return:
1034 // none.
1035 char branchname[30];
1036 const char *det[3] = {"SPD","SDD","SSD"};
1037 TBranch *branch;
1038 char digclass[40];
1039 char clclass[40];
1040 Int_t i;
1041
1042 if(!treeD) return;
1043 for (i=0; i<kNTYPES; i++) {
1044 DetType(i)->GetClassNames(digclass,clclass);
1045 // digits
1046 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1047 else ResetDigits(i);
1048 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1049 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1050 if (fDtype) {
1051 branch = treeD->GetBranch(branchname);
1052 if (branch) branch->SetAddress(&((*fDtype)[i]));
1053 } // end if fDtype
1054 } // end for i
1055}
1056//______________________________________________________________________
1057void AliITS::Hits2SDigits(){
1058 // Standard Hits to summable Digits function.
1059 // Inputs:
1060 // none.
1061 // Outputs:
1062 // none.
1063
1064 return; // Using Hits in place of the larger sDigits.
1065 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1066 // Do the Hits to Digits operation. Use Standard input values.
1067 // Event number from file, no background hit merging , use size from
1068 // AliITSgeom class, option="All", input from this file only.
1069 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1070}
1071//______________________________________________________________________
1072void AliITS::Hits2PreDigits(){
1073 // Standard Hits to summable Digits function.
1074 // Inputs:
1075 // none.
1076 // Outputs:
1077 // none.
1078
1079 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1080 // Do the Hits to Digits operation. Use Standard input values.
1081 // Event number from file, no background hit merging , use size from
1082 // AliITSgeom class, option="All", input from this file only.
1083 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1084}
1085//______________________________________________________________________
1086void AliITS::SDigits2Digits(){
1087 // Standard Summable digits to Digits function.
1088 // Inputs:
1089 // none.
1090 // Outputs:
1091 // none.
1092
1093 Hits2Digits();
1094}
1095//______________________________________________________________________
1096void AliITS::Hits2Digits(){
1097 // Standard Hits to Digits function.
1098 // Inputs:
1099 // none.
1100 // Outputs:
1101 // none.
1102
1103 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1104 // Do the Hits to Digits operation. Use Standard input values.
1105 // Event number from file, no background hit merging , use size from
1106 // AliITSgeom class, option="All", input from this file only.
1107 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1108}
1109//______________________________________________________________________
1110void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1111 Option_t *option, Option_t *opt,Text_t *filename){
1112 // keep galice.root for signal and name differently the file for
1113 // background when add! otherwise the track info for signal will be lost !
1114 // the condition below will disappear when the geom class will be
1115 // initialized for all versions - for the moment it is only for v5 !
1116 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1117 // Digits.
1118 // Inputs:
1119 // Int_t evnt Event to be processed.
1120 // Int_t bgrev Background Hit tree number.
1121 // Int_t nmodules Not used.
1122 // Option_t *option String indicating if merging hits or not. To
1123 // merge hits set equal to "Add". Otherwise no
1124 // background hits are considered.
1125 // Test_t *filename File name containing the background hits..
1126 // Outputs:
1127 // none.
1128 // Return:
1129 // none.
1130 return; // using Hits instead of the larger sdigits.
1131}
1132//______________________________________________________________________
1133void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1134 Option_t *option, Option_t *opt,Text_t *filename){
1135 // Keep galice.root for signal and name differently the file for
1136 // background when add! otherwise the track info for signal will be lost !
1137 // the condition below will disappear when the geom class will be
1138 // initialized for all versions - for the moment it is only for v5 !
1139 // 7 is the SDD beam test version.
1140 // Inputs:
1141 // Int_t evnt Event to be processed.
1142 // Int_t bgrev Background Hit tree number.
1143 // Int_t nmodules Not used.
1144 // Option_t *option String indicating if merging hits or not. To
1145 // merge hits set equal to "Add". Otherwise no
1146 // background hits are considered.
1147 // Test_t *filename File name containing the background hits..
1148 // Outputs:
1149 // none.
1150 // Return:
1151 // none.
1152
1153 if(!GetITSgeom()) return; // need transformations to do digitization.
1154 AliITSgeom *geom = GetITSgeom();
1155
1156 const char *all = strstr(opt,"All");
1157 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1158 strstr(opt,"SSD")};
1159 static Bool_t setDef=kTRUE;
1160 if (setDef) SetDefaultSimulation();
1161 setDef=kFALSE;
1162
1163 Int_t nmodules;
1164 InitModules(size,nmodules);
1165 FillModules(evNumber,bgrev,nmodules,option,filename);
1166
1167 AliITSsimulation *sim = 0;
1168 AliITSDetType *iDetType = 0;
1169 AliITSmodule *mod = 0;
1170 Int_t id,module;
1171 for(module=0;module<geom->GetIndexMax();module++){
1172 id = geom->GetModuleType(module);
1173 if (!all && !det[id]) continue;
1174 iDetType = DetType(id);
1175 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1176 if (!sim) {
1177 Error("HitsToSDigits",
1178 "The simulation class was not instanciated!");
1179 exit(1);
1180 } // end if !sim
1181 mod = (AliITSmodule *)fITSmodules->At(module);
1182 sim->SDigitiseModule(mod,module,evNumber);
1183 // fills all branches - wasted disk space
1184 gAlice->TreeS()->Fill();
1185 ResetSDigits();
1186 } // end for module
1187
1188 ClearModules();
1189
1190 gAlice->TreeS()->GetEntries();
1191
1192 char hname[30];
1193 sprintf(hname,"TreeS%d",evNumber);
1194 gAlice->TreeS()->Write(hname,TObject::kOverwrite);
1195 // reset tree
1196 gAlice->TreeS()->Reset();
1197}
1198//______________________________________________________________________
1199void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1200 Option_t *option, Option_t *opt,Text_t *filename){
1201 // Keep galice.root for signal and name differently the file for
1202 // background when add! otherwise the track info for signal will be lost !
1203 // the condition below will disappear when the geom class will be
1204 // initialized for all versions - for the moment it is only for v5 !
1205 // 7 is the SDD beam test version.
1206 // Inputs:
1207 // Int_t evnt Event to be processed.
1208 // Int_t bgrev Background Hit tree number.
1209 // Int_t nmodules Not used.
1210 // Option_t *option String indicating if merging hits or not. To
1211 // merge hits set equal to "Add". Otherwise no
1212 // background hits are considered.
1213 // Test_t *filename File name containing the background hits..
1214 // Outputs:
1215 // none.
1216 // Return:
1217 // none.
1218
1219 if(!GetITSgeom()) return; // need transformations to do digitization.
1220 AliITSgeom *geom = GetITSgeom();
1221
1222 const char *all = strstr(opt,"All");
1223 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1224 strstr(opt,"SSD")};
1225 static Bool_t setDef=kTRUE;
1226 if (setDef) SetDefaultSimulation();
1227 setDef=kFALSE;
1228
1229 Int_t nmodules;
1230 InitModules(size,nmodules);
1231 FillModules(evNumber,bgrev,nmodules,option,filename);
1232
1233 AliITSsimulation *sim = 0;
1234 AliITSDetType *iDetType = 0;
1235 AliITSmodule *mod = 0;
1236 Int_t id,module;
1237 for(module=0;module<geom->GetIndexMax();module++){
1238 id = geom->GetModuleType(module);
1239 if (!all && !det[id]) continue;
1240 iDetType = DetType(id);
1241 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1242 if (!sim) {
1243 Error("HitsToDigits",
1244 "The simulation class was not instanciated!");
1245 exit(1);
1246 } // end if !sim
1247 mod = (AliITSmodule *)fITSmodules->At(module);
1248 sim->DigitiseModule(mod,module,evNumber);
1249 // fills all branches - wasted disk space
1250 gAlice->TreeD()->Fill();
1251 ResetDigits();
1252 } // end for module
1253
1254 ClearModules();
1255
1256 gAlice->TreeD()->GetEntries();
1257
1258 char hname[30];
1259 sprintf(hname,"TreeD%d",evNumber);
1260 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1261 // reset tree
1262 gAlice->TreeD()->Reset();
1263}
1264//______________________________________________________________________
1265void AliITS::ResetSDigits(){
1266 // Reset the Summable Digits array.
1267 // Inputs:
1268 // none.
1269 // Outputs:
1270 // none.
1271
1272 if (fSDigits) fSDigits->Clear();
1273 fNSDigits = 0;
1274}
1275//______________________________________________________________________
1276void AliITS::ResetDigits(){
1277 // Reset number of digits and the digits array for the ITS detector.
1278 // Inputs:
1279 // none.
1280 // Outputs:
1281 // none.
1282
1283 if (!fDtype) return;
1284
1285 Int_t i;
1286 for (i=0;i<kNTYPES;i++ ) {
1287 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1288 if (fNdtype) fNdtype[i]=0;
1289 } // end for i
1290}
1291//______________________________________________________________________
1292void AliITS::ResetDigits(Int_t i){
1293 // Reset number of digits and the digits array for this branch.
1294 // Inputs:
1295 // none.
1296 // Outputs:
1297 // none.
1298
1299 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1300 if (fNdtype) fNdtype[i]=0;
1301}
1302//______________________________________________________________________
1303void AliITS::AddSumDigit(AliITSpListItem &sdig){
1304 // Adds the a module full of summable digits to the summable digits tree.
1305 // Inputs:
1306 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1307 // Outputs:
1308 // none.
1309 // Return:
1310 // none.
1311
1312 TClonesArray &lsdig = *fSDigits;
1313 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1314}
1315//______________________________________________________________________
1316void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1317 // Add a real digit - as coming from data.
1318 // Inputs:
1319 // Int_t id Detector type number.
1320 // Int_t *digits Integer array containing the digits info. See
1321 // AliITSdigit.h
1322 // Outputs:
1323 // none.
1324 // Return:
1325 // none.
1326
1327 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1328 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1329}
1330//______________________________________________________________________
1331void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1332 // Add a simulated digit.
1333 // Inputs:
1334 // Int_t id Detector type number.
1335 // AliITSdigit *d Digit to be added to the Digits Tree. See
1336 // AliITSdigit.h
1337 // Outputs:
1338 // none.
1339 // Return:
1340 // none.
1341
1342 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1343
1344 switch(id){
1345 case 0:
1346 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1347 break;
1348 case 1:
1349 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1350 break;
1351 case 2:
1352 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1353 break;
1354 } // end switch id
1355}
1356//______________________________________________________________________
1357void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1358 Int_t *hits,Float_t *charges){
1359 // Add a simulated digit to the list.
1360 // Inputs:
1361 // Int_t id Detector type number.
1362 // Float_t phys Physics indicator. See AliITSdigits.h
1363 // Int_t *digits Integer array containing the digits info. See
1364 // AliITSdigit.h
1365 // Int_t *tracks Integer array [3] containing the track numbers that
1366 // contributed to this digit.
1367 // Int_t *hits Integer array [3] containing the hit numbers that
1368 // contributed to this digit.
1369 // Float_t *charge Floating point array of the signals contributed
1370 // to this digit by each track.
1371 // Outputs:
1372 // none.
1373 // Return:
1374 // none.
1375
1376 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1377 switch(id){
1378 case 0:
1379 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1380 break;
1381 case 1:
1382 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1383 hits,charges);
1384 break;
1385 case 2:
1386 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1387 break;
1388 } // end switch id
1389}
1390//______________________________________________________________________
1391void AliITS::MakeTreeC(Option_t *option){
1392 // Create a separate tree to store the clusters.
1393 // Inputs:
1394 // Option_t *option string which must contain "C" otherwise
1395 // no Cluster Tree is created.
1396 // Outputs:
1397 // none.
1398 // Return:
1399 // none.
1400
1401 const char *optC = strstr(option,"C");
1402 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
1403 else return;
1404
1405 Int_t buffersize = 4000;
1406 char branchname[30];
1407 const char *det[3] = {"SPD","SDD","SSD"};
1408 char digclass[40];
1409 char clclass[40];
1410
1411 // one branch for Clusters per type of detector
1412 Int_t i;
1413 for (i=0; i<kNTYPES ;i++) {
1414 AliITSDetType *iDetType=DetType(i);
1415 iDetType->GetClassNames(digclass,clclass);
1416 // clusters
1417 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1418 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1419 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1420 if (fCtype && fTreeC) {
1421 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1422 } // end if fCtype && fTreeC
1423 } // end for i
1424}
1425//______________________________________________________________________
1426void AliITS::GetTreeC(Int_t event){
1427 // Get the clusters tree for this event and set the branch address.
1428 // Inputs:
1429 // Int_t event Event number for the cluster tree.
1430 // Outputs:
1431 // none.
1432 // Return:
1433 // none.
1434 char treeName[20];
1435 char branchname[30];
1436 const char *det[3] = {"SPD","SDD","SSD"};
1437
1438 ResetClusters();
1439 if (fTreeC) {
1440 delete fTreeC;
1441 } // end if fTreeC
1442
1443 sprintf(treeName,"TreeC%d",event);
1444 fTreeC = (TTree*)gDirectory->Get(treeName);
1445
1446 TBranch *branch;
1447
1448 if (fTreeC) {
1449 Int_t i;
1450 char digclass[40];
1451 char clclass[40];
1452 for (i=0; i<kNTYPES; i++) {
1453 AliITSDetType *iDetType=DetType(i);
1454 iDetType->GetClassNames(digclass,clclass);
1455 // clusters
1456 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1457 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1458 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1459 if (fCtype) {
1460 branch = fTreeC->GetBranch(branchname);
1461 if (branch) branch->SetAddress(&((*fCtype)[i]));
1462 } // end if fCtype
1463 } // end for i
1464 } else {
1465 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1466 } // end if fTreeC
1467}
1468//______________________________________________________________________
1469void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1470 // Add a cluster to the list.
1471 // Inputs:
1472 // Int_t id Detector type number.
1473 // AliITSRawCluster *c Cluster class to be added to the tree of
1474 // clusters.
1475 // Outputs:
1476 // none.
1477 // Return:
1478 // none.
1479
1480 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1481
1482 switch(id){
1483 case 0:
1484 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1485 break;
1486 case 1:
1487 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1488 break;
1489 case 2:
1490 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1491 break;
1492 } // end switch id
1493}
1494//______________________________________________________________________
1495void AliITS::ResetClusters(){
1496 // Reset number of clusters and the clusters array for ITS.
1497 // Inputs:
1498 // none.
1499 // Outputs:
1500 // none.
1501
1502 Int_t i;
1503 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1504}
1505//______________________________________________________________________
1506void AliITS::ResetClusters(Int_t i){
1507 // Reset number of clusters and the clusters array for this branch.
1508 // Inputs:
1509 // Int_t i Detector type number.
1510 // Outputs:
1511 // none.
1512 // Return:
1513 // none.
1514
1515 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1516 if (fNctype) fNctype[i]=0;
1517}
1518//______________________________________________________________________
1519void AliITS::MakeBranchR(const char *file){
1520 // Creates Tree branches for the ITS Reconstructed points.
1521 // Inputs:
1522 // cont char *file File name where RecPoints branch is to be written
1523 // to. If blank it write the SDigits to the same
1524 // file in which the Hits were found.
1525 // Outputs:
1526 // none.
1527 // Return:
1528 // none.
1529 Int_t buffsz = 4000;
1530 char branchname[30];
1531
1532 // only one branch for rec points for all detector types
1533 sprintf(branchname,"%sRecPoints",GetName());
1534 if (fRecPoints && gAlice->TreeR()) {
1535 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1536 } // end if
1537}
1538//______________________________________________________________________
1539void AliITS::SetTreeAddressR(TTree *treeR){
1540 // Set branch address for the Reconstructed points Trees.
1541 // Inputs:
1542 // TTree *treeR Tree containing the RecPoints.
1543 // Outputs:
1544 // none.
1545 // Return:
1546 // none.
1547 char branchname[30];
1548
1549 if(!treeR) return;
1550 TBranch *branch;
1551 sprintf(branchname,"%sRecPoints",GetName());
1552 branch = treeR->GetBranch(branchname);
1553 if (branch) branch->SetAddress(&fRecPoints);
1554}
1555//______________________________________________________________________
1556void AliITS::AddRecPoint(const AliITSRecPoint &r){
1557 // Add a reconstructed space point to the list
1558 // Inputs:
1559 // const AliITSRecPoint &r RecPoint class to be added to the tree
1560 // of reconstructed points TreeR.
1561 // Outputs:
1562 // none.
1563 // Return:
1564 // none.
1565
1566 TClonesArray &lrecp = *fRecPoints;
1567 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1568}
1569//______________________________________________________________________
1570void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1571 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1572 // keep galice.root for signal and name differently the file for
1573 // background when add! otherwise the track info for signal will be lost !
1574 // the condition below will disappear when the geom class will be
1575 // initialized for all versions - for the moment it is only for v5 !
1576 // Inputs:
1577 // Int_t evnt Event to be processed.
1578 // Int_t bgrev Background Hit tree number.
1579 // Int_t size Size used by InitModules. See InitModules.
1580 // Option_t *opt0 Option passed to FillModules. See FillModules.
1581 // Option_t *opt1 String indicating if merging hits or not. To
1582 // merge hits set equal to "Add". Otherwise no
1583 // background hits are considered.
1584 // Test_t *flnm File name containing the background hits..
1585 // Outputs:
1586 // none.
1587 // Return:
1588 // none.
1589
1590 if(!GetITSgeom()) return;
1591 AliITSgeom *geom = GetITSgeom();
1592
1593 const char *all = strstr(opt1,"All");
1594 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1595 strstr(opt1,"SSD")};
1596 Int_t nmodules;
1597 InitModules(size,nmodules);
1598 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1599
1600 AliITSsimulation *sim = 0;
1601 AliITSDetType *iDetType = 0;
1602 AliITSmodule *mod = 0;
1603 Int_t id,module;
1604
1605 //m.b. : this change is nothing but a nice way to make sure
1606 //the CPU goes up !
1607 for(module=0;module<geom->GetIndexMax();module++){
1608 id = geom->GetModuleType(module);
1609 if (!all && !det[id]) continue;
1610 iDetType = DetType(id);
1611 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1612 if (!sim) {
1613 Error("HitsToFastPoints",
1614 "The simulation class was not instanciated!");
1615 exit(1);
1616 } // end if !sim
1617 mod = (AliITSmodule *)fITSmodules->At(module);
1618 sim->CreateFastRecPoints(mod,module,gRandom);
1619 gAlice->TreeR()->Fill();
1620 ResetRecPoints();
1621 } // end for module
1622
1623 ClearModules();
1624
1625 char hname[30];
1626 sprintf(hname,"TreeR%d",evNumber);
1627 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1628 // reset tree
1629 gAlice->TreeR()->Reset();
1630}
1631//______________________________________________________________________
1632void AliITS::Digits2Reco(){
1633 // Find clusters and reconstruct space points.
1634 // Inputs:
1635 // none.
1636 // Outputs:
1637 // none.
1638
1639 AliHeader *header=gAlice->GetHeader();
1640 // to Digits to RecPoints for event in file, all digits in file, and
1641 // all ITS detectors.
1642 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1643}
1644//______________________________________________________________________
1645void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1646 // cluster finding and reconstruction of space points
1647 // the condition below will disappear when the geom class will be
1648 // initialized for all versions - for the moment it is only for v5 !
1649 // 7 is the SDD beam test version
1650 // Inputs:
1651 // Int_t evNumber Event number to be processed.
1652 // Int_t lastentry Offset for module when not all of the modules
1653 // are processed.
1654 // Option_t *opt String indicating which ITS sub-detectors should
1655 // be processed. If ="All" then all of the ITS
1656 // sub detectors are processed.
1657 // Outputs:
1658 // none.
1659 // Return:
1660 // none.
1661
1662 if(!GetITSgeom()) return;
1663 AliITSgeom *geom = GetITSgeom();
1664
1665 const char *all = strstr(opt,"All");
1666 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1667 strstr(opt,"SSD")};
1668 static Bool_t setRec=kTRUE;
1669 if (setRec) SetDefaultClusterFinders();
1670 setRec=kFALSE;
1671
1672 TTree *treeC=TreeC();
1673
1674 AliITSClusterFinder *rec = 0;
1675 AliITSDetType *iDetType = 0;
1676 Int_t id,module,first=0;
1677 for(module=0;module<geom->GetIndexMax();module++){
1678 id = geom->GetModuleType(module);
1679 if (!all && !det[id]) continue;
1680 if(det[id]) first = geom->GetStartDet(id);
1681 iDetType = DetType(id);
1682 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1683 TClonesArray *itsDigits = this->DigitsAddress(id);
1684 if (!rec) {
1685 Error("DigitsToRecPoints",
1686 "The reconstruction class was not instanciated!");
1687 exit(1);
1688 } // end if !rec
1689 this->ResetDigits();
1690 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1691 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1692 Int_t ndigits = itsDigits->GetEntriesFast();
1693 if (ndigits) rec->FindRawClusters(module);
1694 gAlice->TreeR()->Fill();
1695 ResetRecPoints();
1696 treeC->Fill();
1697 ResetClusters();
1698 } // end for module
1699
1700 gAlice->TreeR()->GetEntries();
1701 treeC->GetEntries();
1702
1703 char hname[30];
1704 sprintf(hname,"TreeR%d",evNumber);
1705 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1706 // reset tree
1707 gAlice->TreeR()->Reset();
1708
1709 sprintf(hname,"TreeC%d",evNumber);
1710 treeC->Write(hname,TObject::kOverwrite);
1711 treeC->Reset();
1712}
1713//______________________________________________________________________
1714void AliITS::ResetRecPoints(){
1715 // Reset number of rec points and the rec points array.
1716 // Inputs:
1717 // none.
1718 // Outputs:
1719 // none.
1720
1721 if (fRecPoints) fRecPoints->Clear();
1722 fNRecPoints = 0;
1723}