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