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