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