]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITS.cxx
Automatic streamer used and forward declarations added
[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$
d5da1ecf 18Revision 1.9.2.14 2000/10/02 15:43:51 barbera
19General code clean-up (e.g., printf -> cout)
20
21Revision 1.19 2000/09/22 12:13:25 nilsen
22Patches and updates for fixes to this and other routines.
23
9c74c52b 24Revision 1.18 2000/07/12 05:32:20 fca
25Correcting several syntax problem with static members
26
b669392e 27Revision 1.17 2000/07/10 16:07:18 fca
28Release version of ITS code
29
3bd79107 30Revision 1.9.2.3 2000/02/02 13:42:09 barbera
31fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
32
33Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
34//fixed FillModule. Removed fi(fabs(xl)<dx....
35
36Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
37This is the version of the files after the merging done in December 1999.
38See the ReadMe110100.txt file for details
c9a71be1 39
1cedd08a 40Revision 1.9 1999/11/14 14:33:25 fca
41Correct problems with distructors and pointers, thanks to I.Hrivnacova
42
6c854497 43Revision 1.8 1999/09/29 09:24:19 fca
44Introduction of the Copyright and cvs Log
45
4c039060 46*/
47
fe4da5cc 48///////////////////////////////////////////////////////////////////////////////
58005f18 49//
50// An overview of the basic philosophy of the ITS code development
51// and analysis is show in the figure below.
fe4da5cc 52//Begin_Html
53/*
a92b2b7d 54<img src="picts/ITS/ITS_Analysis_schema.gif">
fe4da5cc 55</pre>
56<br clear=left>
57<font size=+2 color=red>
58005f18 58<p>Roberto Barbera is in charge of the ITS Offline code (1999).
fe4da5cc 59<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
60</font>
61<pre>
62*/
63//End_Html
58005f18 64//
65// AliITS. Inner Traking System base class.
66// This class contains the base procedures for the Inner Tracking System
67//
68//Begin_Html
69/*
a92b2b7d 70<img src="picts/ITS/AliITS_Class_Diagram.gif">
58005f18 71</pre>
72<br clear=left>
73<font size=+2 color=red>
74<p>This show the class diagram of the different elements that are part of
75the AliITS class.
76</font>
77<pre>
78*/
79//End_Html
80//
81// Version: 0
82// Written by Rene Brun, Federico Carminati, and Roberto Barbera
83//
84// Version: 1
85// Modified and documented by Bjorn S. Nilsen
86// July 11 1999
87//
3bd79107 88// Version: 2
89// Modified and documented by A. Bologna
90// October 18 1999
91//
58005f18 92// AliITS is the general base class for the ITS. Also see AliDetector for
93// futher information.
94//
fe4da5cc 95///////////////////////////////////////////////////////////////////////////////
96
97#include <TMath.h>
98#include <TRandom.h>
9c74c52b 99#include <TBranch.h>
fe4da5cc 100#include <TVector.h>
3bd79107 101#include <TObjArray.h>
3bd79107 102#include <TROOT.h>
103#include <TObjectTable.h>
9c74c52b 104#include <TFile.h>
105#include <TTree.h>
d5da1ecf 106#include <TString.h>
3bd79107 107
108
bb8ac1e0 109
fe4da5cc 110#include "AliRun.h"
3bd79107 111#include "AliITS.h"
112#include "AliITSMap.h"
e8189707 113#include "AliITSDetType.h"
3bd79107 114#include "AliITSClusterFinder.h"
115#include "AliITSsimulation.h"
3bd79107 116#include "AliITSsegmentationSPD.h"
117#include "AliITSresponseSPD.h"
118#include "AliITSsegmentationSDD.h"
119#include "AliITSresponseSDD.h"
120#include "AliITSsegmentationSSD.h"
121#include "AliITSresponseSSD.h"
9c74c52b 122#include "AliITShit.h"
123#include "AliITSgeom.h"
124#include "AliITSdigit.h"
125#include "AliITSmodule.h"
126#include "AliITSRecPoint.h"
127#include "AliITSRawCluster.h"
e8189707 128
b669392e 129const Int_t AliITS::fgkNTYPES=3;
c9a71be1 130
3bd79107 131ClassImp(AliITS)
132
fe4da5cc 133//_____________________________________________________________________________
3bd79107 134AliITS::AliITS() : AliDetector() {
fe4da5cc 135 //
136 // Default initialiser for ITS
58005f18 137 // The default constructor of the AliITS class. In addition to
138 // creating the AliITS class it zeros the variables fIshunt (a member
139 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
3bd79107 140 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
141 // is also called.
fe4da5cc 142 //
3bd79107 143
9c74c52b 144
58005f18 145 fIshunt = 0;
146 fEuclidOut = 0;
e8189707 147
148 //fNDetTypes = fgkNTYPES;
58005f18 149 fIdN = 0;
150 fIdName = 0;
151 fIdSens = 0;
6c854497 152 fITSmodules = 0;
3bd79107 153 //
154 fDetTypes = 0;
3bd79107 155 //
156 fDtype = 0;
157 fNdtype = 0;
158 fCtype = 0;
159 fNctype = 0;
160 fRecPoints = 0;
161 fNRecPoints = 0;
e8189707 162 fTreeC = 0;
3bd79107 163 //
164 fITSgeom=0;
fe4da5cc 165}
3bd79107 166
fe4da5cc 167//_____________________________________________________________________________
58005f18 168AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
fe4da5cc 169 //
170 // Default initialiser for ITS
58005f18 171 // The constructor of the AliITS class. In addition to creating the
172 // AliITS class, it allocates memory for the TClonesArrays fHits and
173 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
174 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
175 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
176 // macro display.C AliITS also sets the marker color to red. The variables
177 // passes with this constructor, const char *name and *title, are used by
178 // the constructor of AliDetector class. See AliDetector class for a
179 // description of these parameters and its constructor functions.
fe4da5cc 180 //
58005f18 181
9c74c52b 182
58005f18 183 fHits = new TClonesArray("AliITShit", 1560);
1cedd08a 184 gAlice->AddHitList(fHits);
3bd79107 185
e8189707 186 //fNDetTypes = fgkNTYPES;
187
188 fNdtype = new Int_t[fgkNTYPES];
189 fDtype = new TObjArray(fgkNTYPES);
190
191 fNctype = new Int_t[fgkNTYPES];
192 fCtype = new TObjArray(fgkNTYPES);
3bd79107 193
3bd79107 194
195 fRecPoints = 0;
196 fNRecPoints = 0;
197
e8189707 198 fTreeC = 0;
3bd79107 199
200 fITSmodules = 0;
58005f18 201
202 fIshunt = 0;
203 fEuclidOut = 0;
204 fIdN = 0;
205 fIdName = 0;
206 fIdSens = 0;
3bd79107 207
e8189707 208 fDetTypes = new TObjArray(fgkNTYPES);
3bd79107 209
210 Int_t i;
e8189707 211 for(i=0;i<fgkNTYPES;i++) {
3bd79107 212 (*fDetTypes)[i]=new AliITSDetType();
e8189707 213 fNdtype[i]=0;
214 fNctype[i]=0;
3bd79107 215 }
216 //
58005f18 217
fe4da5cc 218 SetMarkerColor(kRed);
58005f18 219
3bd79107 220 fITSgeom=0;
221}
222//___________________________________________________________________________
223AliITS::AliITS(AliITS &source){
e8189707 224 // copy constructor
3bd79107 225 if(this==&source) return;
d5da1ecf 226 Error("AliITS::Copy constructor",
227 "You are not allowed to make a copy of the AliITS");
3bd79107 228 exit(1);
fe4da5cc 229}
3bd79107 230//____________________________________________________________________________
231AliITS& AliITS::operator=(AliITS &source){
e8189707 232 // assignment operator
3bd79107 233 if(this==&source) return *this;
d5da1ecf 234 Error("AliITS::operator=",
235 "You are not allowed to make a copy of the AliITS");
3bd79107 236 exit(1);
e8189707 237 return *this; //fake return
3bd79107 238}
239//____________________________________________________________________________
240void AliITS::ClearModules(){
241 //clear the modules TObjArray
3bd79107 242
9c74c52b 243 if(fITSmodules) fITSmodules->Delete();
fe4da5cc 244
3bd79107 245}
fe4da5cc 246//_____________________________________________________________________________
58005f18 247AliITS::~AliITS(){
fe4da5cc 248 //
249 // Default distructor for ITS
58005f18 250 // The default destructor of the AliITS class. In addition to deleting
251 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
252 // fIdSens, fIdName, and fITSpoints.
fe4da5cc 253 //
3bd79107 254
255
fe4da5cc 256 delete fHits;
257 delete fDigits;
3bd79107 258 delete fRecPoints;
58005f18 259 if(fIdName!=0) delete[] fIdName;
260 if(fIdSens!=0) delete[] fIdSens;
3bd79107 261 if(fITSmodules!=0) {
262 this->ClearModules();
263 delete fITSmodules;
264 }// end if fITSmodules!=0
fe4da5cc 265
fe4da5cc 266 //
3bd79107 267 if(fDtype) {
9c74c52b 268 fDtype->Delete();
269 delete fDtype;
3bd79107 270 }
9c74c52b 271 delete [] fNdtype;
272 if (fCtype) {
273 fCtype->Delete();
274 delete fCtype;
3bd79107 275 }
9c74c52b 276 delete [] fNctype;
fe4da5cc 277 //
3bd79107 278
279 if (fDetTypes) {
280 fDetTypes->Delete();
281 delete fDetTypes;
282 }
283
284 if (fTreeC) delete fTreeC;
e8189707 285
9c74c52b 286 if (fITSgeom) delete fITSgeom;
287
3bd79107 288}
289
290//___________________________________________
291AliITSDetType* AliITS::DetType(Int_t id)
292{
293 //return pointer to id detector type
294 return ((AliITSDetType*) (*fDetTypes)[id]);
295
296}
297//___________________________________________
e8189707 298void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
3bd79107 299{
300 //set the digit and cluster classes to be used for the id detector type
301 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
302
303}
304//___________________________________________
305void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
306{
307 //set the response model for the id detector type
308
309 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
310
fe4da5cc 311}
312
3bd79107 313//___________________________________________
314void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
315{
316 //set the segmentation model for the id detector type
317
318 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
319
320}
321
322//___________________________________________
323void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
324{
325 //set the simulation model for the id detector type
326
327 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
328
329}
330//___________________________________________
331void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
332{
333 //set the cluster finder model for the id detector type
334
335 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
58005f18 336
58005f18 337}
338
fe4da5cc 339//_____________________________________________________________________________
58005f18 340void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
fe4da5cc 341 //
342 // Add an ITS hit
58005f18 343 // The function to add information to the AliITShit class. See the
344 // AliITShit class for a full description. This function allocates the
345 // necessary new space for the hit information and passes the variable
346 // track, and the pointers *vol and *hits to the AliITShit constructor
347 // function.
fe4da5cc 348 //
349 TClonesArray &lhits = *fHits;
350 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
351}
3bd79107 352//_____________________________________________________________________________
353void AliITS::AddRealDigit(Int_t id, Int_t *digits)
354{
355 // add a real digit - as coming from data
356
357 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
358 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
359
360}
361//_____________________________________________________________________________
e8189707 362void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
3bd79107 363{
364
365 // add a simulated digit
366
3bd79107 367 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
368
369 switch(id)
370 {
371 case 0:
372 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
373 break;
374 case 1:
375 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
376 break;
377 case 2:
378 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
379 break;
380 }
381
382}
383
384//_____________________________________________________________________________
e8189707 385void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
3bd79107 386
387 // add a simulated digit to the list
388
389 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
390 switch(id)
391 {
392 case 0:
e8189707 393 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
3bd79107 394 break;
395 case 1:
e8189707 396 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
3bd79107 397 break;
398 case 2:
e8189707 399 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
3bd79107 400 break;
401 }
402
403}
404
405//_____________________________________________________________________________
406void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
407{
408
409 // add a cluster to the list
410
3bd79107 411 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
412
413 switch(id)
414 {
415 case 0:
416 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
417 break;
418 case 1:
419 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
420 break;
421 case 2:
422 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
423 break;
424 }
425
426}
427
428
429//_____________________________________________________________________________
430void AliITS::AddRecPoint(const AliITSRecPoint &r)
431{
432 //
433 // Add a reconstructed space point to the list
434 //
435 TClonesArray &lrecp = *fRecPoints;
436 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
437}
438
439
440//____________________________________________
441void AliITS::ResetDigits()
442{
443 //
9c74c52b 444 // Reset number of digits and the digits array for the ITS detector
3bd79107 445 //
446
447 if (!fDtype) return;
448
449 Int_t i;
e8189707 450 for (i=0;i<fgkNTYPES;i++ ) {
3bd79107 451 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
452 if (fNdtype) fNdtype[i]=0;
453 }
454}
455
456//____________________________________________
457void AliITS::ResetDigits(Int_t i)
458{
459 //
460 // Reset number of digits and the digits array for this branch
461 //
e8189707 462 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
463 if (fNdtype) fNdtype[i]=0;
3bd79107 464}
e8189707 465
466
3bd79107 467//____________________________________________
468void AliITS::ResetClusters()
469{
470 //
471 // Reset number of clusters and the clusters array for ITS
472 //
473
474 Int_t i;
e8189707 475 for (i=0;i<fgkNTYPES;i++ ) {
3bd79107 476 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
477 if (fNctype) fNctype[i]=0;
478 }
479
480}
e8189707 481
3bd79107 482//____________________________________________
483void AliITS::ResetClusters(Int_t i)
484{
485 //
486 // Reset number of clusters and the clusters array for this branch
487 //
488 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
489 if (fNctype) fNctype[i]=0;
490
491}
492
493
494//____________________________________________
495void AliITS::ResetRecPoints()
496{
497 //
498 // Reset number of rec points and the rec points array
499 //
3bd79107 500 if (fRecPoints) fRecPoints->Clear();
9c74c52b 501 fNRecPoints = 0;
3bd79107 502
503}
504
fe4da5cc 505//_____________________________________________________________________________
58005f18 506Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
fe4da5cc 507 //
508 // Distance from mouse to ITS on the screen. Dummy routine
58005f18 509 // A dummy routine used by the ROOT macro display.C to allow for the
510 // use of the mouse (pointing device) in the macro. In general this should
511 // never be called. If it is it returns the number 9999 for any value of
512 // x and y.
fe4da5cc 513 //
514 return 9999;
515}
516
517//_____________________________________________________________________________
58005f18 518void AliITS::Init(){
fe4da5cc 519 //
520 // Initialise ITS after it has been built
58005f18 521 // This routine initializes the AliITS class. It is intended to be called
522 // from the Init function in AliITSv?. Besides displaying a banner
3bd79107 523 // indicating that it has been called it initializes the array fIdSens
524 // and sets the default segmentation, response, digit and raw cluster classes
58005f18 525 // Therefore it should be called after a call to CreateGeometry.
fe4da5cc 526 //
3bd79107 527
528
529 SetDefaults();
530
fe4da5cc 531 Int_t i;
d5da1ecf 532 cout << endl;
533 for(i=0;i<30;i++) cout << "*";cout << " ITS_INIT ";
534 for(i=0;i<30;i++) cout << "*";cout << endl;
58005f18 535 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
fe4da5cc 536 //
d5da1ecf 537 for(i=0;i<70;i++) cout << "*";
538 cout << endl;
fe4da5cc 539}
540
3bd79107 541//_____________________________________________________________________________
542void AliITS::SetDefaults()
543{
544 // sets the default segmentation, response, digit and raw cluster classes
545
d5da1ecf 546 cout << "AliITS::SetDefaults" << endl;
3bd79107 547
548 AliITSDetType *iDetType;
549
550 //SPD
551
552 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
553 AliITSresponseSPD *resp0=new AliITSresponseSPD();
554 iDetType=DetType(0);
555 if (!iDetType->GetSegmentationModel()) SetSegmentationModel(0,seg0);
556 if (!iDetType->GetResponseModel()) SetResponseModel(0,resp0);
557 // set digit and raw cluster classes to be used
e8189707 558 const char *kData0=resp0->DataType();
559 if (strstr(kData0,"real")) {
3bd79107 560 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
561 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
562
563 // SDD //
564 AliITSresponseSDD *resp1=new AliITSresponseSDD();
565 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
566 iDetType=DetType(1);
d5da1ecf 567 //printf("SetDefaults: iDetType %p\n",iDetType);
3bd79107 568 if (!iDetType->GetSegmentationModel()) SetSegmentationModel(1,seg1);
d5da1ecf 569 //printf("SetDefaults: segm %p\n",iDetType->GetSegmentationModel());
3bd79107 570 if (!iDetType->GetResponseModel()) SetResponseModel(1,resp1);
d5da1ecf 571 //printf("SetDefaults: resp %p\n",iDetType->GetResponseModel());
e8189707 572 const char *kData1=resp1->DataType();
573 const char *kopt=resp1->ZeroSuppOption();
574 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
3bd79107 575 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
576 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
577
578 // SSD
579 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
580 AliITSresponseSSD *resp2=new AliITSresponseSSD();
581 iDetType=DetType(2);
582 if (!iDetType->GetSegmentationModel()) SetSegmentationModel(2,seg2);
583 if (!iDetType->GetResponseModel()) SetResponseModel(2,resp2);
e8189707 584 const char *kData2=resp2->DataType();
585 if (strstr(kData2,"real")) {
3bd79107 586 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
587 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
588
e8189707 589 if (fgkNTYPES>3) {
3bd79107 590 Warning("SetDefaults","Only the three basic detector types are initialised!");
591 }
592
593}
e8189707 594//_____________________________________________________________________________
595void AliITS::SetDefaultSimulation()
596{
597 // to be written
598
599}
600//_____________________________________________________________________________
601void AliITS::SetDefaultClusterFinders()
602{
603 // to be written
604
605}
3bd79107 606//_____________________________________________________________________________
607
608void AliITS::MakeTreeC(Option_t *option)
609{
610 // create a separate tree to store the clusters
611
d5da1ecf 612 cout << "AliITS::MakeTreeC" << endl;
9c74c52b 613
3bd79107 614 char *optC = strstr(option,"C");
615 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
9c74c52b 616 else return;
3bd79107 617
618 Int_t buffersize = 4000;
619 char branchname[30];
620
621 char *det[3] = {"SPD","SDD","SSD"};
622
623 // one branch for Clusters per type of detector
624 Int_t i;
e8189707 625 for (i=0; i<fgkNTYPES ;i++) {
626 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
3bd79107 627 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
628 if (fCtype && fTreeC) {
629 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
d5da1ecf 630 cout << "Making Branch " << branchname;
631 cout << " for Clusters of detector type " << i+1 << endl;
3bd79107 632 }
633 }
634
635}
636
637//_____________________________________________________________________________
638void AliITS::GetTreeC(Int_t event)
639{
640
d5da1ecf 641 cout << "AliITS::GetTreeC" << endl;
9c74c52b 642
3bd79107 643 // get the clusters tree for this event and set the branch address
644 char treeName[20];
645 char branchname[30];
646
647 char *det[3] = {"SPD","SDD","SSD"};
648
649 ResetClusters();
650 if (fTreeC) {
651 delete fTreeC;
652 }
653
654 sprintf(treeName,"TreeC%d",event);
655 fTreeC = (TTree*)gDirectory->Get(treeName);
656
657
658 TBranch *branch;
659 if (fTreeC) {
660 Int_t i;
e8189707 661 for (i=0; i<fgkNTYPES; i++) {
662 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
663 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
664 if (fCtype) {
3bd79107 665 branch = fTreeC->GetBranch(branchname);
666 if (branch) branch->SetAddress(&((*fCtype)[i]));
667 }
668 }
669 } else {
d5da1ecf 670 Error("AliITS::GetTreeC",
671 "cannot find Clusters Tree for event:%d\n",event);
3bd79107 672 }
673
674}
fe4da5cc 675//_____________________________________________________________________________
58005f18 676void AliITS::MakeBranch(Option_t* option){
fe4da5cc 677 //
3bd79107 678 // Creates Tree branches for the ITS.
fe4da5cc 679 //
3bd79107 680
681
fe4da5cc 682 Int_t buffersize = 4000;
3bd79107 683 char branchname[30];
fe4da5cc 684 sprintf(branchname,"%s",GetName());
685
686 AliDetector::MakeBranch(option);
687
fe4da5cc 688
3bd79107 689// one branch for digits per type of detector
690
691 char *det[3] = {"SPD","SDD","SSD"};
692
e8189707 693 char digclass[40];
694 char clclass[40];
3bd79107 695
696 Int_t i;
e8189707 697 for (i=0; i<fgkNTYPES ;i++) {
3bd79107 698 AliITSDetType *iDetType=DetType(i);
e8189707 699 iDetType->GetClassNames(digclass,clclass);
700 //printf("i, digclass, recclass %d %s %s\n",i,digclass,clclass);
3bd79107 701 // digits
e8189707 702 (*fDtype)[i] = new TClonesArray(digclass,10000);
3bd79107 703 // clusters
e8189707 704 (*fCtype)[i] = new TClonesArray(clclass,10000);
3bd79107 705 }
706
707
e8189707 708 for (i=0; i<fgkNTYPES ;i++) {
709 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
3bd79107 710 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
711
712 if (fDtype && gAlice->TreeD()) {
713 gAlice->TreeD()->Branch(branchname,&((*fDtype)[i]), buffersize);
d5da1ecf 714 cout << "Making Branch " << branchname;
715 cout << " for digits of type "<< i+1 << endl;
3bd79107 716 }
717 }
718
719 // only one branch for rec points for all detector types
720 sprintf(branchname,"%sRecPoints",GetName());
721
e8189707 722 fRecPoints=new TClonesArray("AliITSRecPoint",10000);
3bd79107 723
724 if (fRecPoints && gAlice->TreeR()) {
725 gAlice->TreeR()->Branch(branchname,&fRecPoints, buffersize);
d5da1ecf 726 cout << "Making Branch " << branchname;
727 cout << " for reconstructed space points" << endl;
3bd79107 728 }
729
730
731}
732
733//___________________________________________
734void AliITS::SetTreeAddress()
735{
736
737 // Set branch address for the Trees.
738
739 char branchname[30];
740 AliDetector::SetTreeAddress();
741
742 char *det[3] = {"SPD","SDD","SSD"};
743
744 TBranch *branch;
745 TTree *treeD = gAlice->TreeD();
746 TTree *treeR = gAlice->TreeR();
747
748 Int_t i;
749 if (treeD) {
e8189707 750 for (i=0; i<fgkNTYPES; i++) {
751 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
3bd79107 752 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
753 if (fDtype) {
754 branch = treeD->GetBranch(branchname);
755 if (branch) branch->SetAddress(&((*fDtype)[i]));
756 }
757 }
758 }
759
760
761 if (treeR) {
762 sprintf(branchname,"%sRecPoints",GetName());
763 if (fRecPoints) {
764 branch = treeR->GetBranch(branchname);
765 if (branch) branch->SetAddress(&fRecPoints);
766 }
767 }
768
769
770}
771
772//____________________________________________________________________________
773void AliITS::InitModules(Int_t size,Int_t &nmodules){
774
775 //initialize the modules array
776
e8189707 777 if(fITSmodules){
9c74c52b 778 fITSmodules->Delete();
e8189707 779 delete fITSmodules;
780 }
781
3bd79107 782 Int_t nl,indexMAX,index;
3bd79107 783
784 if(size<=0){ // default to using data stored in AliITSgeom
785 if(fITSgeom==0) {
d5da1ecf 786 Error("AliITS::InitModules",
787 "in AliITS::InitModule fITSgeom not defined\n");
3bd79107 788 return;
789 } // end if fITSgeom==0
790 nl = fITSgeom->GetNlayers();
791 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
792 fITSgeom->GetNdetectors(nl))+1;
793 nmodules = indexMAX;
794 fITSmodules = new TObjArray(indexMAX);
3bd79107 795 for(index=0;index<indexMAX;index++){
3bd79107 796 fITSmodules->AddAt( new AliITSmodule(index),index);
3bd79107 797 } // end for index
798 }else{
799 fITSmodules = new TObjArray(size);
9c74c52b 800 for(index=0;index<size;index++) {
801 fITSmodules->AddAt( new AliITSmodule(index),index);
802 }
803
3bd79107 804 nmodules = size;
805 } // end i size<=0
806}
807
808//____________________________________________________________________________
e8189707 809void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
3bd79107 810
811 // fill the modules with the sorted by module hits; add hits from background
812 // if option=Add
813
9c74c52b 814
3bd79107 815 static TTree *trH1; //Tree with background hits
816 static TClonesArray *fHits2; //List of hits for one track only
817
818 static Bool_t first=kTRUE;
819 static TFile *file;
e8189707 820 char *addBgr = strstr(option,"Add");
3bd79107 821
822
e8189707 823 if (addBgr ) {
3bd79107 824 if(first) {
825 cout<<"filename "<<filename<<endl;
826 file=new TFile(filename);
827 cout<<"I have opened "<<filename<<" file "<<endl;
828 fHits2 = new TClonesArray("AliITShit",1000 );
829 }
830 first=kFALSE;
831 file->cd();
832 file->ls();
833 // Get Hits Tree header from file
834 if(fHits2) fHits2->Clear();
835 if(trH1) delete trH1;
836 trH1=0;
837
838 char treeName[20];
839 sprintf(treeName,"TreeH%d",bgrev);
840 trH1 = (TTree*)gDirectory->Get(treeName);
841 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
842
843 if (!trH1) {
d5da1ecf 844 Error("AliITS::FillModules",
845 "cannot find Hits Tree for event:%d\n",bgrev);
3bd79107 846 }
847 // Set branch addresses
848 TBranch *branch;
849 char branchname[20];
850 sprintf(branchname,"%s",GetName());
851 if (trH1 && fHits2) {
852 branch = trH1->GetBranch(branchname);
853 if (branch) branch->SetAddress(&fHits2);
854 }
855
856 // test
857 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
858 //printf("background - ntracks1 - %d\n",ntracks1);
859 }
860
3bd79107 861 Int_t npart = gAlice->GetEvent(evnt);
862 if(npart<=0) return;
863 TClonesArray *itsHits = this->Hits();
864 Int_t lay,lad,det,index;
865 AliITShit *itsHit=0;
866 AliITSmodule *mod=0;
867
868 TTree *iTH = gAlice->TreeH();
869 Int_t ntracks =(Int_t) iTH->GetEntries();
870
871 Int_t t,h;
872 for(t=0; t<ntracks; t++){
873 gAlice->ResetHits();
874 iTH->GetEvent(t);
875 Int_t nhits = itsHits->GetEntriesFast();
9c74c52b 876 //printf("nhits %d\n",nhits);
3bd79107 877 if (!nhits) continue;
3bd79107 878 for(h=0; h<nhits; h++){
879 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
880 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 881 // temporarily index=det-1 !!!
882 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
883 else index=det-1;
884 //
3bd79107 885 mod = this->GetModule(index);
9c74c52b 886 mod->AddHit(itsHit,t,h);
3bd79107 887 } // end loop over hits
888 } // end loop over tracks
889
890 // open the file with background
891
e8189707 892 if (addBgr ) {
893 Int_t track,i;
3bd79107 894 ntracks =(Int_t)trH1->GetEntries();
895 //printf("background - ntracks1 %d\n",ntracks);
896 //printf("background - Start loop over tracks \n");
897 // Loop over tracks
898
e8189707 899 for (track=0; track<ntracks; track++) {
3bd79107 900
901 if (fHits2) fHits2->Clear();
902 trH1->GetEvent(track);
903 // Loop over hits
904 for(i=0;i<fHits2->GetEntriesFast();++i) {
905
906 itsHit=(AliITShit*) (*fHits2)[i];
907 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 908 // temporarily index=det-1 !!!
909 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
910 else index=det-1;
911 //
3bd79107 912 mod = this->GetModule(index);
9c74c52b 913 mod->AddHit(itsHit,track,i);
3bd79107 914 } // end loop over hits
915 } // end loop over tracks
916
917 TTree *fAli=gAlice->TreeK();
918 TFile *fileAli=0;
919
920 if (fAli) fileAli =fAli->GetCurrentFile();
9c74c52b 921 fileAli->cd();
3bd79107 922
923 } // end if add
924
3bd79107 925 //gObjectTable->Print();
926
927}
928
929
930//____________________________________________________________________________
e8189707 931void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
3bd79107 932{
933 // keep galice.root for signal and name differently the file for
934 // background when add! otherwise the track info for signal will be lost !
935
9c74c52b 936 // the condition below will disappear when the geom class will be
937 // initialised for all versions - for the moment it is only for v5 !
938 // 7 is the SDD beam test version
939 Int_t ver = this->IsVersion();
940 if(ver!=5 && ver!=7) return;
941
3bd79107 942 char *all = strstr(opt,"All");
943 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
3bd79107 944
945 Int_t nmodules;
946 InitModules(size,nmodules);
e8189707 947 FillModules(evNumber,bgrev,nmodules,option,filename);
3bd79107 948
9c74c52b 949 //TBranch *branch;
3bd79107 950 AliITSsimulation* sim;
9c74c52b 951 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
3bd79107 952 AliITSgeom *geom = GetITSgeom();
953
954 Int_t id,module;
9c74c52b 955 Int_t first,last;
e8189707 956 for (id=0;id<fgkNTYPES;id++) {
3bd79107 957 if (!all && !det[id]) continue;
9c74c52b 958 //branch = (TBranch*)branches->UncheckedAt(id);
3bd79107 959 AliITSDetType *iDetType=DetType(id);
960 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
961 if (!sim) {
962 Error("HitsToDigits","The simulation class was not instantiated!");
963 exit(1);
e8189707 964 // or SetDefaultSimulation();
3bd79107 965 }
9c74c52b 966 if(geom) {
967 first = geom->GetStartDet(id);
968 last = geom->GetLastDet(id);
969 } else first=last=0;
d5da1ecf 970 cout << "det type " << id << " first, last "<< first << last << endl;
3bd79107 971 for(module=first;module<=last;module++) {
972 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
973 sim->DigitiseModule(mod,module,evNumber);
974 // fills all branches - wasted disk space
975 gAlice->TreeD()->Fill();
976 ResetDigits();
977 // try and fill only the branch
978 //branch->Fill();
979 //ResetDigits(id);
980 } // loop over modules
981 } // loop over detector types
982
3bd79107 983 ClearModules();
984
e8189707 985 Int_t nentries=(Int_t)gAlice->TreeD()->GetEntries();
d5da1ecf 986 cout << "nentries in TreeD" << nentries << endl;
3bd79107 987
988 char hname[30];
989 sprintf(hname,"TreeD%d",evNumber);
990 gAlice->TreeD()->Write(hname);
991 // reset tree
992 gAlice->TreeD()->Reset();
993
994}
995
996
997//____________________________________________________________________________
998void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
999{
e8189707 1000 // cluster finding and reconstruction of space points
3bd79107 1001
9c74c52b 1002 // the condition below will disappear when the geom class will be
1003 // initialised for all versions - for the moment it is only for v5 !
1004 // 7 is the SDD beam test version
1005 Int_t ver = this->IsVersion();
1006 if(ver!=5 && ver!=7) return;
1007
3bd79107 1008 char *all = strstr(opt,"All");
1009 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1010
1011 static Bool_t first=kTRUE;
1012 if (first) {
1013 MakeTreeC("C");
1014 first=kFALSE;
1015 }
3bd79107 1016
9c74c52b 1017 TTree *iTC=TreeC();
1018
1019 //TBranch *branch;
3bd79107 1020 AliITSClusterFinder* rec;
1021
9c74c52b 1022 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
3bd79107 1023 AliITSgeom *geom = GetITSgeom();
1024
1025 Int_t id,module;
e8189707 1026 for (id=0;id<fgkNTYPES;id++) {
3bd79107 1027 if (!all && !det[id]) continue;
9c74c52b 1028 //branch = (TBranch*)branches->UncheckedAt(id);
3bd79107 1029 AliITSDetType *iDetType=DetType(id);
1030 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1031 if (!rec) {
1032 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1033 exit(1);
e8189707 1034 // or SetDefaultClusterFinders();
3bd79107 1035 }
1036 TClonesArray *itsDigits = this->DigitsAddress(id);
1037
9c74c52b 1038 Int_t first,last;
1039 if(geom) {
1040 first = geom->GetStartDet(id);
1041 last = geom->GetLastDet(id);
1042 } else first=last=0;
1043 //printf("first last %d %d\n",first,last);
3bd79107 1044 for(module=first;module<=last;module++) {
3bd79107 1045 this->ResetDigits();
1046 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1047 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1048 Int_t ndigits = itsDigits->GetEntriesFast();
1049 if (ndigits) rec->FindRawClusters();
1050 gAlice->TreeR()->Fill();
1051 ResetRecPoints();
1052 iTC->Fill();
1053 ResetClusters();
1054 // try and fill only the branch
1055 //branch->Fill();
1056 //ResetRecPoints(id);
1057 } // loop over modules
1058 } // loop over detector types
1059
1060
e8189707 1061 Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1062 Int_t ncentries=(Int_t)iTC->GetEntries();
d5da1ecf 1063 cout << " nentries ncentries " << nentries << ncentries << endl;
3bd79107 1064
1065 char hname[30];
1066 sprintf(hname,"TreeR%d",evNumber);
1067 gAlice->TreeR()->Write(hname);
1068 // reset tree
1069 gAlice->TreeR()->Reset();
1070
1071 sprintf(hname,"TreeC%d",evNumber);
1072 iTC->Write(hname);
1073 iTC->Reset();
1074}
1075
1076
1077//____________________________________________________________________________
e8189707 1078void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
3bd79107 1079Option_t *option,Option_t *opt,Text_t *filename)
1080{
1081 // keep galice.root for signal and name differently the file for
1082 // background when add! otherwise the track info for signal will be lost !
1083
9c74c52b 1084
1085 // the condition below will disappear when the geom class will be
1086 // initialised for all versions - for the moment it is only for v5 !
1087 Int_t ver = this->IsVersion();
1088 if(ver!=5) return;
1089
3bd79107 1090 char *all = strstr(opt,"All");
1091 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1092
1093 Int_t nmodules;
e8189707 1094 InitModules(size,nmodules);
1095 FillModules(evNumber,bgrev,nmodules,option,filename);
3bd79107 1096
1097
e8189707 1098 AliITSsimulation* sim;
3bd79107 1099 AliITSgeom *geom = GetITSgeom();
1100
e8189707 1101 TRandom *random=new TRandom[9];
1102 random[0].SetSeed(111);
1103 random[1].SetSeed(222);
1104 random[2].SetSeed(333);
1105 random[3].SetSeed(444);
1106 random[4].SetSeed(555);
1107 random[5].SetSeed(666);
1108 random[6].SetSeed(777);
1109 random[7].SetSeed(888);
1110 random[8].SetSeed(999);
1111
1112
3bd79107 1113 Int_t id,module;
e8189707 1114 for (id=0;id<fgkNTYPES;id++) {
3bd79107 1115 if (!all && !det[id]) continue;
e8189707 1116 AliITSDetType *iDetType=DetType(id);
1117 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1118 if (!sim) {
1119 Error("HitsToFastPoints","The simulation class was not instantiated!");
1120 exit(1);
1121 // or SetDefaultSimulation();
1122 }
3bd79107 1123 Int_t first = geom->GetStartDet(id);
1124 Int_t last = geom->GetLastDet(id);
1125 for(module=first;module<=last;module++) {
1126 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
e8189707 1127 sim->CreateFastRecPoints(mod,module,random);
3bd79107 1128 gAlice->TreeR()->Fill();
1129 ResetRecPoints();
1130 } // loop over modules
1131 } // loop over detector types
1132
1133
1134 ClearModules();
1135
1136 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1137
1138 char hname[30];
1139 sprintf(hname,"TreeR%d",evNumber);
1140 gAlice->TreeR()->Write(hname);
1141 // reset tree
1142 gAlice->TreeR()->Reset();
1143
e8189707 1144 delete [] random;
1145
fe4da5cc 1146}
1147
d5da1ecf 1148
e8189707 1149//____________________________________________________________________________
1150void AliITS::Streamer(TBuffer &R__b){
58005f18 1151 // Stream an object of class AliITS.
3bd79107 1152
e8189707 1153 Int_t i;
3bd79107 1154
58005f18 1155 if (R__b.IsReading()) {
235841d0 1156 Version_t R__v = R__b.ReadVersion();
1157 if (R__v) {
1158 AliDetector::Streamer(R__b);
e8189707 1159 R__b >> fIdN;
1160 R__b.ReadArray(fIdSens);
1161 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
235841d0 1162 R__b >> fITSgeom;
1163 R__b >> fITSmodules;
1164 R__b >> fEuclidOut;
235841d0 1165 R__b >> fMajorVersion;
1166 R__b >> fMinorVersion;
1167 R__b >> fDetTypes;
235841d0 1168 R__b >> fDtype;
1169 delete []fNdtype;
e8189707 1170 fNdtype = new Int_t[fgkNTYPES];
1171 R__b.ReadFastArray(fNdtype,fgkNTYPES);
235841d0 1172 R__b >> fCtype;
1173 delete []fNctype;
e8189707 1174 fNctype = new Int_t[fgkNTYPES];
1175 R__b.ReadFastArray(fNctype,fgkNTYPES);
235841d0 1176 R__b >> fRecPoints;
1177 R__b >> fNRecPoints;
235841d0 1178 R__b >> fTreeC;
1179 } // end if R__v
1180 } else { // writing
58005f18 1181 R__b.WriteVersion(AliITS::IsA());
1182 AliDetector::Streamer(R__b);
e8189707 1183 R__b << fIdN;
1184 R__b.WriteArray(fIdSens,fIdN);
1185 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
58005f18 1186 R__b << fITSgeom;
2b2439bd 1187 R__b << fITSmodules;
58005f18 1188 R__b << fEuclidOut;
58005f18 1189 R__b << fMajorVersion;
1190 R__b << fMinorVersion;
3bd79107 1191 R__b << fDetTypes;
2b2439bd 1192 R__b << fDtype;
e8189707 1193 R__b.WriteFastArray(fNdtype,fgkNTYPES);
2b2439bd 1194 R__b << fCtype;
e8189707 1195 R__b.WriteFastArray(fNctype,fgkNTYPES);
3bd79107 1196 R__b << fRecPoints;
1197 R__b << fNRecPoints;
2b2439bd 1198 R__b << fTreeC;
235841d0 1199 } // end if
e8189707 1200
fe4da5cc 1201}
3bd79107 1202
3bd79107 1203