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