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