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