]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITS.cxx
Remove implicit calls to TString::TString(int) - this constructor was made protected...
[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
143d1056 68#include <stdlib.h>
caf37aec 69#include <TClonesArray.h>
9c74c52b 70#include <TFile.h>
7d62fb64 71#include <TParticle.h>
d5da1ecf 72#include <TString.h>
88cb7938 73#include <TTree.h>
88cb7938 74#include <TVirtualMC.h>
7d62fb64 75#include "AliDetector.h"
3bd79107 76#include "AliITS.h"
7d62fb64 77#include "AliITSDetTypeSim.h"
f77f13c8 78#include "AliITSDDLRawData.h"
88cb7938 79#include "AliITSLoader.h"
88cb7938 80#include "AliITShit.h"
81#include "AliITSmodule.h"
7d62fb64 82#include "AliITSpListItem.h"
83#include "AliITSsimulation.h"
84#include "AliITSsimulationFastPoints.h"
5d12ce38 85#include "AliMC.h"
7d62fb64 86#include "AliITSDigitizer.h"
87#include "AliITSRecPoint.h"
0b5bf101 88#include "AliITSsegmentationSPD.h"
89#include "AliITSsegmentationSDD.h"
90#include "AliITSsegmentationSSD.h"
91#include "AliITSRawStreamSPD.h"
92#include "AliITSRawStreamSSD.h"
93#include "AliITSRawStreamSDD.h"
0b5bf101 94#include "AliRawReader.h"
f77f13c8 95#include "AliRun.h"
7d62fb64 96#include "AliLog.h"
ef7ff1f9 97#include "AliITSInitGeometry.h"
ad7f2bfa 98#include "AliITSFOSignalsSPD.h"
828e06c7 99
3bd79107 100ClassImp(AliITS)
3bd79107 101
2aea926d 102//______________________________________________________________________
ed9289c8 103AliITS::AliITS() : AliDetector(),
104fDetTypeSim(0),
105fEuclidOut(0),
106fOpt("All"),
107fIdN(0),
108fIdSens(0),
109fIdName(0),
012f0f4c 110fITSmodules(0),
111fTiming(kFALSE)
ed9289c8 112{
7d62fb64 113 // Default initializer for ITS
114 // The default constructor of the AliITS class. In addition to
115 // creating the AliITS class it zeros the variables fIshunt (a member
116 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
117 // fIdSens, and fIdName. The AliDetector default constructor
118 // is also called.
119
aa044888 120// SetDetectors(); // default to fOpt="All". This variable not written out.
e939a978 121//PH SetMarkerColor(kRed);
fe4da5cc 122}
2aea926d 123//______________________________________________________________________
012f0f4c 124AliITS::AliITS(const Char_t *title):AliDetector("ITS",title),
125fDetTypeSim(0),
126fEuclidOut(0),
127fOpt("All"),
128fIdN(0),
129fIdSens(0),
130fIdName(0),
131fITSmodules(0),
132fTiming(kFALSE)
133{
134 // The standard Constructor for the ITS class.
135 // It also zeros the variables
136 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
137 // the pointers fIdSens and fIdName. To help in displaying hits via the
138 // ROOT macro display.C AliITS also sets the marker color to red. The
139 // variables passes with this constructor, const char *name and *title,
140 // are used by the constructor of AliDetector class. See AliDetector
141 // class for a description of these parameters and its constructor
142 // functions.
143 // Inputs:
144 // Char_t *title Simulation title for the ITS
145 // Outputs:
146 // none.
147 // Return:
148 // none.
149
150 fHits = new TClonesArray("AliITShit",1560); // from AliDetector
151 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
152 //fNhits=0; //done in AliDetector(name,title)
153 SetDetectors(); // default to fOpt="All". This variable not written out.
154 fDetTypeSim = new AliITSDetTypeSim();
155 //PH SetMarkerColor(kRed);
156 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
157 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
158}
159//______________________________________________________________________
ed9289c8 160AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
161fDetTypeSim(0),
162fEuclidOut(0),
163fOpt("All"),
164fIdN(0),
165fIdSens(0),
166fIdName(0),
012f0f4c 167fITSmodules(0),
168fTiming(kFALSE)
ed9289c8 169{
7d62fb64 170 // The standard Constructor for the ITS class.
171 // It also zeros the variables
172 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
173 // the pointers fIdSens and fIdName. To help in displaying hits via the
174 // ROOT macro display.C AliITS also sets the marker color to red. The
175 // variables passes with this constructor, const char *name and *title,
176 // are used by the constructor of AliDetector class. See AliDetector
177 // class for a description of these parameters and its constructor
178 // functions.
179
7d62fb64 180 fHits = new TClonesArray("AliITShit",1560);
181 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
ed9289c8 182 //fNhits=0; //done in AliDetector(name,title)
7d62fb64 183
7d62fb64 184 SetDetectors(); // default to fOpt="All". This variable not written out.
ed9289c8 185
7d62fb64 186 fDetTypeSim = new AliITSDetTypeSim();
187
e939a978 188 //PH SetMarkerColor(kRed);
023ae34b 189 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
190 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
fe4da5cc 191
3bd79107 192}
2aea926d 193//______________________________________________________________________
58005f18 194AliITS::~AliITS(){
4a5bebc2 195 // Default destructor for ITS.
2aea926d 196 // The default destructor of the AliITS class. In addition to deleting
7d62fb64 197 // the AliITS class it deletes the memory pointed to by
198 // fIdSens, fIdName, fDetTypeSim and it's contents.
4a5bebc2 199 // Inputs:
200 // none.
201 // Outputs:
202 // none.
203 // Return:
204 // none.
023ae34b 205
88cb7938 206 if (fHits) {
207 fHits->Delete();
208 delete fHits;
209 fHits=0;
210 }
88cb7938 211 if(fITSmodules) {
212 this->ClearModules();
213 delete fITSmodules;
279a35d7 214 fITSmodules = 0;
88cb7938 215 }// end if fITSmodules!=0
216
7d62fb64 217 delete[] fIdName; // Array of TStrings
218 delete[] fIdSens;
219
220 if (fDetTypeSim){
221 delete fDetTypeSim;
222 fDetTypeSim = 0;
ad7f2bfa 223 }
3bd79107 224}
2aea926d 225//______________________________________________________________________
aacedc3e 226AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
227 // Creates the AliITSDigitizer in a standard way for use via AliModule.
228 // This function can not be included in the .h file because of problems
229 // with the order of inclusion (recursive).
4a5bebc2 230 // Inputs:
aacedc3e 231 // AliRunDigitizer *manager The Manger class for Digitization
232 // Output:
233 // none.
4a5bebc2 234 // Return:
aacedc3e 235 // A new AliITSRunDigitizer (cast as a AliDigitizer).
3bd79107 236
aacedc3e 237 return new AliITSDigitizer(manager);
3bd79107 238}
2aea926d 239//______________________________________________________________________
240void AliITS::Init(){
4a5bebc2 241 // Initializer ITS after it has been built
2aea926d 242 // This routine initializes the AliITS class. It is intended to be
243 // called from the Init function in AliITSv?. Besides displaying a banner
244 // indicating that it has been called it initializes the array fIdSens
245 // and sets the default segmentation, response, digit and raw cluster
246 // classes therefore it should be called after a call to CreateGeometry.
4a5bebc2 247 // Inputs:
248 // none.
249 // Outputs:
250 // none.
251 // Return:
252 // none.
3bd79107 253 Int_t i;
2aea926d 254 // Array of TStrings
0e73d04c 255 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
7d62fb64 256
7d62fb64 257}
2aea926d 258//______________________________________________________________________
259void AliITS::SetDefaults(){
4a5bebc2 260 // sets the default segmentation, response, digit and raw cluster classes.
261 // Inputs:
262 // none.
263 // Outputs:
264 // none.
265 // Return:
266 // none.
023ae34b 267 AliInfoClass("AliITS::Setting Defaults");
7d62fb64 268 if(!fDetTypeSim) {
269 Error("SetDefaults()","fDetTypeSim is 0!");
270 return;
271 }
272
273 fDetTypeSim->SetDefaults();
274
275
3bd79107 276}
2aea926d 277//______________________________________________________________________
278void AliITS::SetDefaultSimulation(){
4a5bebc2 279 // sets the default simulation.
280 // Inputs:
281 // none.
282 // Outputs:
283 // none.
284 // Return:
285 // none.
7d62fb64 286 if(!fDetTypeSim) {
287 Error("SetDefaultSimulation()","fDetTypeSim is 0!");
288 return;
289 }
290
291 fDetTypeSim->SetDefaultSimulation();
04366a57 292
04366a57 293}
294
295
2aea926d 296//______________________________________________________________________
88cb7938 297void AliITS::MakeBranch(Option_t* option){
2aea926d 298 // Creates Tree branches for the ITS.
4a5bebc2 299 // Inputs:
300 // Option_t *option String of Tree types S,D, and/or R.
301 // const char *file String of the file name where these branches
302 // are to be stored. If blank then these branches
303 // are written to the same tree as the Hits were
304 // read from.
305 // Outputs:
306 // none.
307 // Return:
308 // none.
7d62fb64 309 if(!fDetTypeSim) {
310 Error("MakeBranch","fDetTypeSim is 0!");
311 return;
312 }
04366a57 313
7d62fb64 314 Bool_t cH = (strstr(option,"H")!=0);
315 Bool_t cS = (strstr(option,"S")!=0);
316 Bool_t cD = (strstr(option,"D")!=0);
317
318 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
319 AliDetector::MakeBranch(option);
320
321 if(cS) MakeBranchS(0);
322 if(cD) MakeBranchD(0);
323
324
325}
326//___________________________________________________________________
327void AliITS::MakeBranchS(const char* fl){
328
329 // Creates Tree Branch for the ITS summable digits.
330 // Inputs:
331 // cont char *fl File name where SDigits branch is to be written
332 // to. If blank it write the SDigits to the same
333 // file in which the Hits were found.
334
335
336 if(!fDetTypeSim){
337 Error("MakeBranchS","fDetTypeSim is 0!");
338 }
339 Int_t buffersize = 4000;
340 char branchname[30];
341
342 // only one branch for SDigits.
343 sprintf(branchname,"%s",GetName());
344
345 if(fLoader->TreeS()){
7d62fb64 346 TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
347 MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
348 }
349}
350//______________________________________________________________________
351void AliITS::MakeBranchD(const char* file){
352
353 //Make branch for digits
354 if(!fDetTypeSim) {
355 Warning("MakeBranchD","fDetTypeSim is 0!");
356 return;
357 }
023ae34b 358 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 359 MakeBranchInTreeD(fLoader->TreeD(),file);
360}
361
362//___________________________________________________________________
363void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
364 // Creates Tree branches for the ITS.
365
366 if(!fDetTypeSim){
367 Error("MakeBranchS","fDetTypeSim is 0!");
368 }
023ae34b 369 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 370
371 const Char_t *det[3] = {"SPD","SDD","SSD"};
a6e0ebfe 372 const Char_t* digclass;
7d62fb64 373 Int_t buffersize = 4000;
374 Char_t branchname[30];
375
376 if(!fDetTypeSim->GetDigits()){
377 fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
378 }
379 for(Int_t i=0;i<fgkNTYPES;i++){
380 digclass = fDetTypeSim->GetDigitClassName(i);
381 TString classn = digclass;
382 if(!((fDetTypeSim->GetDigits())->At(i))){
383 (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
384 }
385 else ResetDigits(i);
386 if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
387 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
388 TObjArray* dig = DigitsAddress(i);
389 if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
390 }
2aea926d 391
fe4da5cc 392}
2aea926d 393//______________________________________________________________________
394void AliITS::SetTreeAddress(){
395 // Set branch address for the Trees.
4a5bebc2 396 // Inputs:
397 // none.
398 // Outputs:
399 // none.
400 // Return:
401 // none.
023ae34b 402
7d62fb64 403 if(!fDetTypeSim) {
404 Error("SetTreeAddress","fDetTypeSim is 0!");
405 return;
406 }
407
023ae34b 408 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 409
410 TTree *treeS = fLoader->TreeS();
411 TTree *treeD = fLoader->TreeD();
412 if (fLoader->TreeH() && (fHits == 0x0)) {
413 fHits = new TClonesArray("AliITShit", 1560);
414 }
415 AliDetector::SetTreeAddress();
416
417 fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
418 fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
fe4da5cc 419}
2aea926d 420//______________________________________________________________________
2aea926d 421void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
422 // Add an ITS hit
423 // The function to add information to the AliITShit class. See the
424 // AliITShit class for a full description. This function allocates the
425 // necessary new space for the hit information and passes the variable
426 // track, and the pointers *vol and *hits to the AliITShit constructor
427 // function.
4a5bebc2 428 // Inputs:
429 // Int_t track Track number which produced this hit.
430 // Int_t *vol Array of Integer Hit information. See AliITShit.h
431 // Float_t *hits Array of Floating Hit information. see AliITShit.h
432 // Outputs:
433 // none.
434 // Return:
435 // none.
7d62fb64 436 TClonesArray &lhits = *fHits;
437 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
3bd79107 438}
9c74c52b 439
2aea926d 440//______________________________________________________________________
441void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
8e8eae84 442 Option_t *option, const char *filename){
7d62fb64 443 // fill the modules with the sorted by module hits; add hits from
444 // background if option=Add.
445
446 static TTree *trH1; //Tree with background hits
447 static Bool_t first=kTRUE;
448 static TFile *file;
449 const char *addBgr = strstr(option,"Add");
450
451 evnt = nmodules; // Dummy use of variables to remove warnings
452 if (addBgr ) {
453 if(first) {
454 file=new TFile(filename);
455 } // end if first
456 first=kFALSE;
457 file->cd();
458 file->ls();
459 // Get Hits Tree header from file
460 if(trH1) delete trH1;
461 trH1=0;
462
463 char treeName[20];
464 sprintf(treeName,"TreeH%d",bgrev);
465 trH1 = (TTree*)gDirectory->Get(treeName);
466 if (!trH1) {
467 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
468 } // end if !trH1
469 // Set branch addresses
470 } // end if addBgr
471
472 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
3bd79107 473
7d62fb64 474 if (addBgr ) {
475 FillModules(trH1,10000000); // Default mask 10M.
476 TTree *fAli=fLoader->GetRunLoader()->TreeK();
477 TFile *fileAli=0;
478 if (fAli) fileAli =fAli->GetCurrentFile();
479 fileAli->cd();
480 } // end if add
481
482
3bd79107 483}
2aea926d 484//______________________________________________________________________
b4012daf 485void AliITS::FillModules(TTree *treeH, Int_t mask) {
486 // fill the modules with the sorted by module hits;
487 // can be called many times to do a merging
488 // Inputs:
489 // TTree *treeH The tree containing the hits to be copied into
490 // the modules.
491 // Int_t mask The track number mask to indecate which file
492 // this hits came from.
493 // Outputs:
494 // none.
495 // Return:
496 // none.
497
88cb7938 498 if (treeH == 0x0)
499 {
500 Error("FillModules","Tree is NULL");
501 }
b4012daf 502 Int_t lay,lad,det,index;
503 AliITShit *itsHit=0;
504 AliITSmodule *mod=0;
505 char branchname[20];
506 sprintf(branchname,"%s",GetName());
507 TBranch *branch = treeH->GetBranch(branchname);
508 if (!branch) {
88cb7938 509 Error("FillModules","%s branch in TreeH not found",branchname);
510 return;
b4012daf 511 } // end if !branch
512 branch->SetAddress(&fHits);
513 Int_t nTracks =(Int_t) treeH->GetEntries();
514 Int_t iPrimTrack,h;
515 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
88cb7938 516 ResetHits();
517 Int_t nBytes = treeH->GetEvent(iPrimTrack);
518 if (nBytes <= 0) continue;
519 Int_t nHits = fHits->GetEntriesFast();
520 for(h=0; h<nHits; h++){
521 itsHit = (AliITShit *)fHits->UncheckedAt(h);
522 itsHit->GetDetectorID(lay,lad,det);
7d62fb64 523 if (GetITSgeom()) {
524 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
88cb7938 525 } else {
526 index=det-1; // This should not be used.
527 } // end if [You must have fITSgeom for this to work!]
528 mod = GetModule(index);
529 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
530 mod->AddHit(itsHit,iPrimTrack,h);
531 } // end loop over hits
b4012daf 532 } // end loop over tracks
533}
7d62fb64 534
b4012daf 535//______________________________________________________________________
6f5308d9 536Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){
7d62fb64 537 // Initialize the modules array.
4a5bebc2 538 // Inputs:
7d62fb64 539 // Int_t size Size of array of the number of modules to be
540 // created. If size <=0 then the number of modules
541 // is gotten from AliITSgeom class kept in fITSgeom.
4a5bebc2 542 // Outputs:
7d62fb64 543 // Int_t &nmodules The number of modules existing.
4a5bebc2 544 // Return:
545 // none.
2ab0c725 546
7d62fb64 547 if(fITSmodules){
548 fITSmodules->Delete();
549 delete fITSmodules;
550 } // end fir fITSmoudles
88cb7938 551
7d62fb64 552 if(!fDetTypeSim) {
553 Error("InitModules","fDetTypeSim is null!");
6f5308d9 554 return kFALSE;
7d62fb64 555 }
828e06c7 556
7d62fb64 557 Int_t nl,indexMAX,index;
558
559 if(size<=0){ // default to using data stored in AliITSgeom
560 if(fDetTypeSim->GetITSgeom()==0) {
561 Error("InitModules","fITSgeom not defined");
6f5308d9 562 return kFALSE;
7d62fb64 563 } // end if fITSgeom==0
564 nl = fDetTypeSim->GetITSgeom()->GetNlayers();
565 indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
566 nmodules = indexMAX;
567 fITSmodules = new TObjArray(indexMAX);
568 for(index=0;index<indexMAX;index++){
569 fITSmodules->AddAt( new AliITSmodule(index),index);
570 } // end for index
571 }else{
572 fITSmodules = new TObjArray(size);
573 for(index=0;index<size;index++) {
574 fITSmodules->AddAt( new AliITSmodule(index),index);
575 } // end for index
576
577 nmodules = size;
578 } // end i size<=0
6f5308d9 579 return kTRUE;
2aea926d 580}
581//______________________________________________________________________
582void AliITS::Hits2SDigits(){
583 // Standard Hits to summable Digits function.
4a5bebc2 584 // Inputs:
585 // none.
586 // Outputs:
587 // none.
7d62fb64 588
2aea926d 589
7d62fb64 590 if(!fDetTypeSim) {
591 Error("Hits2SDigits","fDetTypeSim is null!");
ad7f2bfa 592 return;
7d62fb64 593 }
594
595 SetDefaults();
596 fLoader->LoadHits("read");
597 fLoader->LoadSDigits("recreate");
598 AliRunLoader* rl = fLoader->GetRunLoader();
023ae34b 599 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 600 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
aacedc3e 601 // Do the Hits to Digits operation. Use Standard input values.
602 // Event number from file, no background hit merging , use size from
603 // AliITSgeom class, option="All", input from this file only.
7d62fb64 604 rl->GetEvent(iEvent);
605 if (!fLoader->TreeS()) fLoader->MakeTree("S");
606 MakeBranch("S");
607 SetTreeAddress();
608 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
609 } // end for iEvent
e0fc0305 610
7d62fb64 611 fLoader->UnloadHits();
612 fLoader->UnloadSDigits();
613
2aea926d 614}
615//______________________________________________________________________
616void AliITS::Hits2Digits(){
2aea926d 617
7d62fb64 618 //Conversion from hits to digits
619 if(!fDetTypeSim) {
620 Error("Hits2SDigits","fDetTypeSim is 0!");
621 return;
622 }
623
023ae34b 624 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 625 SetDefaults();
626
627 fLoader->LoadHits("read");
628 fLoader->LoadDigits("recreate");
629 AliRunLoader* rl = fLoader->GetRunLoader();
630 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
631 rl->GetEvent(iEvent);
632 if (!fLoader->TreeD()) fLoader->MakeTree("D");
633 MakeBranch("D");
634 SetTreeAddress();
635 HitsToDigits(iEvent,0,-1," ",fOpt," ");
636 }
637
638 fLoader->UnloadHits();
639 fLoader->UnloadDigits();
640
2aea926d 641}
7d62fb64 642
2aea926d 643//______________________________________________________________________
7d62fb64 644void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
645 Option_t *option,Option_t *opt,
646 const char *filename){
4a5bebc2 647 // Keep galice.root for signal and name differently the file for
2aea926d 648 // background when add! otherwise the track info for signal will be lost !
649 // the condition below will disappear when the geom class will be
4a5bebc2 650 // initialized for all versions - for the moment it is only for v5 !
651 // 7 is the SDD beam test version.
652 // Inputs:
653 // Int_t evnt Event to be processed.
654 // Int_t bgrev Background Hit tree number.
655 // Int_t nmodules Not used.
656 // Option_t *option String indicating if merging hits or not. To
657 // merge hits set equal to "Add". Otherwise no
658 // background hits are considered.
659 // Test_t *filename File name containing the background hits..
660 // Outputs:
661 // none.
662 // Return:
663 // none.
2aea926d 664
7d62fb64 665 if(!fDetTypeSim) {
666 Error("HitsToDigits","fDetTypeSim is null!");
667 return;
668 }
023ae34b 669 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 670 if(!GetITSgeom()) return; // need transformations to do digitization.
671 AliITSgeom *geom = GetITSgeom();
672
673 const char *all = strstr(opt,"All");
674 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
675 strstr(opt,"SSD")};
676 static Bool_t setDef=kTRUE;
677 if (setDef) SetDefaultSimulation();
678 setDef=kFALSE;
679
680 Int_t nmodules;
681 InitModules(size,nmodules);
682 FillModules(evNumber,bgrev,nmodules,option,filename);
ad7f2bfa 683
684 // Reset Fast-OR signals for this event
685 fDetTypeSim->ResetFOSignals();
7d62fb64 686
687 AliITSsimulation *sim = 0;
688 AliITSmodule *mod = 0;
689 Int_t id;
690 for(Int_t module=0;module<geom->GetIndexMax();module++){
691 id = geom->GetModuleType(module);
692 if (!all && !det[id]) continue;
693 sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
694 if (!sim) {
695 Error("HitsToDigits","The simulation class was not "
696 "instanciated for module %d type %s!",module,
697 geom->GetModuleTypeName(module));
698 exit(1);
699 } // end if !sim
700 mod = (AliITSmodule *)fITSmodules->At(module);
701 sim->DigitiseModule(mod,module,evNumber);
702 // fills all branches - wasted disk space
703 fLoader->TreeD()->Fill();
704 ResetDigits();
705 } // end for module
706
707 ClearModules();
a0d76912 708
ad7f2bfa 709 // Add random noise to FO signals
710 if (all || det[0]) { // SPD present
711 fDetTypeSim->ProcessNoiseForFastOr();
712 }
713
714 // Add Fast-OR signals to event (only one object per event)
715 if (all || det[0]) { // SPD present
716 fDetTypeSim->WriteFOSignals();
717 }
718
719
7d62fb64 720 fLoader->TreeD()->GetEntries();
721 fLoader->TreeD()->AutoSave();
722 // reset tree
723 fLoader->TreeD()->Reset();
2aea926d 724}
7d62fb64 725//_____________________________________________________________________
726void AliITS::Hits2PreDigits(){
727 // Turn hits into SDigits
728
729 if(!fDetTypeSim) {
730 Error("Hits2SDigits","fDetTypeSim is 0!");
731 return;
732 }
733
023ae34b 734 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 735 SetDefaults();
736
737 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
738 0,-1," ",fOpt," ");
739}
740
2aea926d 741//______________________________________________________________________
7d62fb64 742void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
743 Option_t *option,Option_t *opt,
744 const char *filename){
4a5bebc2 745 // Keep galice.root for signal and name differently the file for
2aea926d 746 // background when add! otherwise the track info for signal will be lost !
747 // the condition below will disappear when the geom class will be
4a5bebc2 748 // initialized for all versions - for the moment it is only for v5 !
749 // 7 is the SDD beam test version.
750 // Inputs:
751 // Int_t evnt Event to be processed.
752 // Int_t bgrev Background Hit tree number.
753 // Int_t nmodules Not used.
754 // Option_t *option String indicating if merging hits or not. To
755 // merge hits set equal to "Add". Otherwise no
756 // background hits are considered.
757 // Test_t *filename File name containing the background hits..
758 // Outputs:
759 // none.
760 // Return:
761 // none.
762
7d62fb64 763
764 if(!fDetTypeSim) {
765 Error("HitsToPreDigits","fDetTypeSim is null!");
766 return;
767 }
023ae34b 768 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 769
770 if(!GetITSgeom()){
771 Error("HitsToPreDigits","fGeom is null!");
772 return; // need transformations to do digitization.
773 }
774 AliITSgeom *geom = GetITSgeom();
775
776 const char *all = strstr(opt,"All");
777 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
778 strstr(opt,"SSD")};
779 static Bool_t setDef=kTRUE;
780 if (setDef) SetDefaultSimulation();
781 setDef=kFALSE;
782
783 Int_t nmodules;
784 InitModules(size,nmodules);
785 FillModules(evNumber,bgrev,nmodules,option,filename);
786
787
788 AliITSsimulation *sim = 0;
789 AliITSmodule *mod = 0;
790 Int_t id,module;
791 for(module=0;module<geom->GetIndexMax();module++){
792 id = geom->GetModuleType(module);
793 if (!all && !det[id]) continue;
794 sim = (AliITSsimulation*)GetSimulationModel(id);
795 if (!sim) {
796 Error("HitsToPreDigits","The simulation class was not "
797 "instanciated for module %d type %s!",module,
798 geom->GetModuleTypeName(module));
799 exit(1);
800 } // end if !sim
801 mod = (AliITSmodule *)fITSmodules->At(module);
802 sim->SDigitiseModule(mod,module,evNumber);
803 // fills all branches - wasted disk space
804 fLoader->TreeS()->Fill();
805 fDetTypeSim->ResetSDigits();
806 } // end for module
04366a57 807
7d62fb64 808 ClearModules();
809
810
811 fLoader->TreeS()->GetEntries();
812 fLoader->TreeS()->AutoSave();
813 fLoader->WriteSDigits("OVERWRITE");
814 // reset tree
815 fLoader->TreeS()->Reset();
2aea926d 816}
7d62fb64 817
818//_____________________________________________________________________
819void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
820 Option_t *opt0,Option_t *opt1,
821 const char *flnm){
822 // keep galice.root for signal and name differently the file for
823 // background when add! otherwise the track info for signal will be lost !
824 // the condition below will disappear when the geom class will be
825 // initialized for all versions - for the moment it is only for v5 !
826 // Inputs:
827 // Int_t evnt Event to be processed.
828 // Int_t bgrev Background Hit tree number.
829 // Int_t size Size used by InitModules. See InitModules.
830 // Option_t *opt0 Option passed to FillModules. See FillModules.
831 // Option_t *opt1 String indicating if merging hits or not. To
832 // merge hits set equal to "Add". Otherwise no
833 // background hits are considered.
834 // Test_t *flnm File name containing the background hits..
835 // Outputs:
836 // none.
837 // Return:
838 // none.
839
840
00a7cc50 841
7d62fb64 842 if(!GetITSgeom()){
843 Error("HitsToPreDigits","fGeom is null!");
844 return; // need transformations to do digitization.
845 }
846 AliITSgeom *geom = GetITSgeom();
847
848 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
849
850 const char *all = strstr(opt1,"All");
851 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
852 strstr(opt1,"SSD")};
853 Int_t nmodules;
854 InitModules(size,nmodules);
855 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
856
857 AliITSsimulation *sim = 0;
858 AliITSmodule *mod = 0;
859 Int_t id,module;
860
861 TTree *lTR = pITSloader->TreeR();
00a7cc50 862 if(!lTR) {
863 pITSloader->MakeTree("R");
864 lTR = pITSloader->TreeR();
865 }
866
7d62fb64 867 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
00a7cc50 868 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
869 branch->SetAddress(&ptarray);
7d62fb64 870 //m.b. : this change is nothing but a nice way to make sure
023ae34b 871 //the CPU goes up !
7d62fb64 872 for(module=0;module<geom->GetIndexMax();module++){
873 id = geom->GetModuleType(module);
874 if (!all && !det[id]) continue;
875 sim = (AliITSsimulation*)GetSimulationModel(id);
876 if (!sim) {
877 Error("HitsToFastPoints","The simulation class was not "
878 "instanciated for module %d type %x!",module,
879 geom->GetModuleTypeName(module));
880 exit(1);
881 } // end if !sim
882 mod = (AliITSmodule *)fITSmodules->At(module);
883 sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
884 lTR->Fill();
f1bfe73f 885 ptarray->Clear();
7d62fb64 886 } // end for module
887
888 ClearModules();
889 fLoader->WriteRecPoints("OVERWRITE");
890 delete ptarray;
891}
892//_____________________________________________________________________
893Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
894 //------------------------------------------------------------
895 // This function creates ITS clusters
896 //------------------------------------------------------------
897 if(!GetITSgeom()){
898 Error("HitsToPreDigits","fGeom is null!");
899 return 1; // need transformations to do digitization.
900 }
901 AliITSgeom *geom=GetITSgeom();
902 Int_t mmax=geom->GetIndexMax();
903
904 InitModules(-1,mmax);
905 FillModules(hTree,0);
906
7d62fb64 907 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
00a7cc50 908 TBranch *branch=cTree->GetBranch("ITSRecPoints");
909 if (!branch) cTree->Branch("ITSRecPoints",&points);
910 else branch->SetAddress(&points);
7d62fb64 911
912 AliITSsimulationFastPoints sim;
913 Int_t ncl=0;
914 for (Int_t m=0; m<mmax; m++) {
915 AliITSmodule *mod=GetModule(m);
916 sim.CreateFastRecPoints(mod,m,gRandom,points);
00a7cc50 917 ncl+=points->GetEntriesFast();
7d62fb64 918 cTree->Fill();
7d62fb64 919 points->Clear();
920 }
921
15e6a32c 922 AliDebug(1,Form("Number of found fast clusters : %d",ncl));
7d62fb64 923
924 //cTree->Write();
925
7d62fb64 926 delete points;
927 return 0;
928}
7d62fb64 929
7d62fb64 930//_____________________________________________________________________
931void AliITS::CheckLabels(Int_t lab[3]) const {
932 //------------------------------------------------------------
933 // Tries to find mother's labels
934 //------------------------------------------------------------
935
936 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
937
938 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
939 for (Int_t i=0;i<3;i++){
940 Int_t label = lab[i];
941 if (label>=0 && label<ntracks) {
942 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
943 if (part->P() < 0.005) {
944 Int_t m=part->GetFirstMother();
945 if (m<0) {
946 continue;
947 }
948 if (part->GetStatusCode()>0) {
949 continue;
950 }
951 lab[i]=m;
952 }
953 }
954 }
955
956}
957
958//______________________________________________________________________
959void AliITS::SDigitsToDigits(Option_t *opt){
ad7f2bfa 960 // Standard Summable digits to Digits function.
961 // Inputs:
962 // none.
963 // Outputs:
964 // none.
965 if (!fDetTypeSim) {
966 AliError("fDetTypeSim is 0!");
967 return;
968 }
7d62fb64 969
ad7f2bfa 970 const char *all = strstr(opt,"All");
971 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
972 strstr(opt,"SSD")};
973
974 // Reset Fast-OR signals for this event
975 fDetTypeSim->ResetFOSignals();
976
977 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
978 SetDefaults();
979 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
980
981 // Add random noise to FO signals
982 if (all || det[0]) { // SPD present
983 fDetTypeSim->ProcessNoiseForFastOr();
984 }
985 // Add Fast-OR signals to event (only one object per event)
986 if (all || det[0]) { // SPD present
987 fDetTypeSim->WriteFOSignals();
988 }
7d62fb64 989}
990
2aea926d 991//______________________________________________________________________
2aea926d 992void AliITS::ResetDigits(){
4a5bebc2 993 // Reset number of digits and the digits array for the ITS detector.
994 // Inputs:
995 // none.
996 // Outputs:
997 // none.
7d62fb64 998 if(!fDetTypeSim) {
999 Error("ResetDigits","fDetTypeSim is 0!");
1000 return;
1001 }
1002
1003 fDetTypeSim->ResetDigits();
3bd79107 1004
1005
2aea926d 1006}
1007//______________________________________________________________________
7d62fb64 1008void AliITS::ResetDigits(Int_t branch){
4a5bebc2 1009 // Reset number of digits and the digits array for this branch.
1010 // Inputs:
1011 // none.
1012 // Outputs:
1013 // none.
828e06c7 1014
7d62fb64 1015 if(!fDetTypeSim) {
1016 Error("ResetDigits","fDetTypeSim is 0!");
1017 return;
1018 }
1019
1020 fDetTypeSim->ResetDigits(branch);
1021
2aea926d 1022}
1023//______________________________________________________________________
1024void AliITS::AddSumDigit(AliITSpListItem &sdig){
4a5bebc2 1025 // Adds the a module full of summable digits to the summable digits tree.
1026 // Inputs:
1027 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1028 // Outputs:
1029 // none.
1030 // Return:
1031 // none.
828e06c7 1032
7d62fb64 1033 if(!fDetTypeSim) {
1034 Error("AddSumDigit","fDetTypeSim is 0!");
1035 return;
1036 }
1037 fDetTypeSim->AddSumDigit(sdig);
1038
2aea926d 1039}
1040//______________________________________________________________________
7d62fb64 1041void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
4a5bebc2 1042 // Add a simulated digit.
1043 // Inputs:
1044 // Int_t id Detector type number.
1045 // AliITSdigit *d Digit to be added to the Digits Tree. See
1046 // AliITSdigit.h
1047 // Outputs:
1048 // none.
1049 // Return:
1050 // none.
2aea926d 1051
7d62fb64 1052 if(!fDetTypeSim) {
1053 Error("AddSimDigit","fDetTypeSim is 0!");
1054 return;
1055 }
1056 fDetTypeSim->AddSimDigit(branch,d);
1057
2aea926d 1058}
1059//______________________________________________________________________
7d62fb64 1060void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
83ec5e27 1061 Int_t *hits,Float_t *charges, Int_t sigexpanded){
7f1a504b 1062 // Add a simulated digit to the list.
1063 // Inputs:
1064 // Int_t id Detector type number.
1065 // Float_t phys Physics indicator. See AliITSdigits.h
1066 // Int_t *digits Integer array containing the digits info. See
1067 // AliITSdigit.h
1068 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1069 // containing the track numbers that contributed to
1070 // this digit.
1071 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1072 // containing the hit numbers, from AliITSmodule, that
1073 // contributed to this digit.
1074 // Float_t *charge Floating point array of the signals contributed
1075 // to this digit by each track.
1076 // Outputs:
1077 // none.
1078 // Return:
1079 // none.
2aea926d 1080
7d62fb64 1081 if(!fDetTypeSim) {
1082 Error("AddSimDigit","fDetTypeSim is 0!");
1083 return;
1084 }
83ec5e27 1085 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
7d62fb64 1086
2aea926d 1087}
0421c3d1 1088//______________________________________________________________________
aacedc3e 1089void AliITS::Digits2Raw(){
1090 // convert digits of the current event to raw data
0421c3d1 1091
7d62fb64 1092 if(!fDetTypeSim) {
1093 Error("Digits2Raw","fDetTypeSim is 0!");
1094 return;
1095 }
023ae34b 1096 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 1097 SetDefaults();
1098 fDetTypeSim->GetLoader()->LoadDigits();
1099 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
0421c3d1 1100 if (!digits) {
aacedc3e 1101 Error("Digits2Raw", "no digits tree");
1102 return;
0421c3d1 1103 }
7d62fb64 1104 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
ad7f2bfa 1105
1106 // Get the FO signals for this event
1107 AliITSFOSignalsSPD* foSignals = NULL;
1108 AliRunLoader* runLoader = AliRunLoader::Instance();
1109 AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
1110 if (!itsLoader) {
1111 AliError("ITS loader is NULL.");
1112 }
a0d76912 1113 else {
1114 if(!itsLoader->TreeD()) AliError(" !!! No TreeD available !!!");
1115 foSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD");
1116 if(!foSignals) AliError("FO signals not retrieved");
1117 }
1118
ad7f2bfa 1119 Bool_t deleteFOsignalsLater = kFALSE;
1120 if (!foSignals) {
1121 AliError("FO signals not available. No FO bits will be written.");
1122 foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
1123 deleteFOsignalsLater = kTRUE;
1124 }
1125
1126
979b5a5f 1127 AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
2f8ed7ab 1128 Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
0421c3d1 1129 AliITSDDLRawData rawWriter;
2f8ed7ab 1130 if(isHLTmodeC) rawWriter.SetUseCompressedSDDFormat(kTRUE);
1131 else rawWriter.SetUseCompressedSDDFormat(kFALSE);
0421c3d1 1132 //Verbose level
1133 // 0: Silent
1134 // 1: cout messages
1135 // 2: txt files with digits
1136 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1137 //it is highly suggested to use this mode only for debugging digits files
1138 //reasonably small, because otherwise the size of the txt files can reach
1139 //quickly several MB wasting time and disk space.
1140 rawWriter.SetVerbose(0);
1141
1142 //SILICON PIXEL DETECTOR
15e6a32c 1143 AliDebug(1,"Formatting raw data for SPD");
ad7f2bfa 1144 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
1145 if(deleteFOsignalsLater) delete foSignals;
0421c3d1 1146
1147 //SILICON DRIFT DETECTOR
15e6a32c 1148 AliDebug(1,"Formatting raw data for SDD");
979b5a5f 1149 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
0421c3d1 1150
1151 //SILICON STRIP DETECTOR
15e6a32c 1152 AliDebug(1,"Formatting raw data for SSD");
0421c3d1 1153 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1154
1155 fLoader->UnloadDigits();
2aea926d 1156}
2aea926d 1157//______________________________________________________________________
aacedc3e 1158AliLoader* AliITS::MakeLoader(const char* topfoldername){
1159 //builds ITSgetter (AliLoader type)
1160 //if detector wants to use castomized getter, it must overload this method
1161
64f311fe 1162 AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1163 topfoldername));
aacedc3e 1164 fLoader = new AliITSLoader(GetName(),topfoldername);
1165 return fLoader;
2aea926d 1166}
ad7f2bfa 1167//______________________________________________________________________
0b5bf101 1168Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1169{
1170 //
1171 // Converts RAW data to SDigits
1172 //
1173 // Get TreeS
1174 //
1175 Int_t last = -1;
1176 Int_t size = GetITSgeom()->GetIndexMax();
1177 TClonesArray** modA = new TClonesArray*[size];
1178 for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1179
33c3c91a 1180 AliLoader* loader = (AliRunLoader::Instance())->GetLoader("ITSLoader");
ad7f2bfa 1181 if (!loader){
0b5bf101 1182 Error("Open","Can not get ITS loader from Run Loader");
1183 return kFALSE;
1184 }
1185
1186 TTree* tree = 0;
1187 tree = loader->TreeS();
ad7f2bfa 1188 if (!tree){
0b5bf101 1189 loader->MakeTree("S");
1190 tree = loader->TreeS();
1191 }
1192 //
1193 // Array for SDigits
1194 //
1195 TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1196 Int_t bufsize = 32000;
1197 tree->Branch("ITS", &itsSDigits, bufsize);
1198 Int_t npx = 0;
1199 //
1200 // SPD
1201 //
1202 AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
6a3ca9e7 1203 if(!segSPD){
1204 AliWarning("Set AliITS defaults");
1205 SetDefaults();
1206 segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1207 }
0b5bf101 1208 npx = segSPD->Npx();
1209 Double_t thr, sigma;
1210
1211 AliITSRawStreamSPD inputSPD(rawReader);
1212 while(1){
1213 Bool_t next = inputSPD.Next();
1214 if (!next) break;
1215
1216 Int_t module = inputSPD.GetModuleID();
1217 Int_t column = inputSPD.GetColumn();
1218 Int_t row = inputSPD.GetRow();
1219 Int_t index = npx * column + row;
1220
1221 if (module >= size) continue;
1222
1223 last = (modA[module])->GetEntries();
1224 TClonesArray& dum = *modA[module];
bb292d31 1225 fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
0b5bf101 1226 thr += 1.;
1227 new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1228 }
1229 rawReader->Reset();
1230
1231 //
1232 // SDD
1233 //
1234 AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1235 npx = segSDD->Npx();
1236 AliITSRawStreamSDD inputSDD(rawReader);
979b5a5f 1237 AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1238 inputSDD.SetDDLModuleMap(ddlmap);
0b5bf101 1239 while(1){
1240 Bool_t next = inputSDD.Next();
1241 if (!next) break;
1242
1243 Int_t module = inputSDD.GetModuleID();
1244 Int_t anode = inputSDD.GetAnode();
1245 Int_t time = inputSDD.GetTime();
6a3ca9e7 1246 Int_t signal10 = inputSDD.GetSignal();
0b5bf101 1247 Int_t index = npx * anode + time;
1248
1249 if (module >= size) continue;
0b5bf101 1250 last = modA[module]->GetEntries();
1251 TClonesArray& dum = *modA[module];
1252 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1253 ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1254
1255 }
1256 rawReader->Reset();
1257
1258 //
1259 // SSD
1260 //
1261 AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1262 npx = segSSD->Npx();
1263 AliITSRawStreamSSD inputSSD(rawReader);
1264 while(1){
1265 Bool_t next = inputSSD.Next();
1266 if (!next) break;
1267
1268 Int_t module = inputSSD.GetModuleID();
1269 Int_t side = inputSSD.GetSideFlag();
1270 Int_t strip = inputSSD.GetStrip();
1271 Int_t signal = inputSSD.GetSignal();
1272 Int_t index = npx * side + strip;
1273
1274 if (module >= size) continue;
1275
1276 last = modA[module]->GetEntries();
1277 TClonesArray& dum = *modA[module];
1278 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1279 }
1280 rawReader->Reset();
1281 AliITSpListItem* sdig = 0;
1282
1283 for (Int_t mod = 0; mod < size; mod++)
1284 {
1285 Int_t nsdig = modA[mod]->GetEntries();
1286 for (Int_t ie = 0; ie < nsdig; ie++) {
1287 sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1288 new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1289 Float_t sig = sdig->GetSignalAfterElect();
1290 if (sig > 0.) {
1291 sdig = (AliITSpListItem*)aSDigits[ie];
1292 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1293 }
1294 }
1295
1296 tree->Fill();
1297 aSDigits.Clear();
1298 modA[mod]->Clear();
1299 }
1300 loader->WriteSDigits("OVERWRITE");
1301 delete modA;
1302 return kTRUE;
1303}
1304
1305
ef7ff1f9 1306//______________________________________________________________________
1307void AliITS::UpdateInternalGeometry(){
1308
ed9289c8 1309 //reads new geometry from TGeo
012f0f4c 1310// AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1311
108bd0fe 1312 AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1313 Int_t minor = 0;
012f0f4c 1314 if(version==kvPPRasymmFMD) minor=2; // default minor version for this geom.
1315 AliITSInitGeometry initgeom;
1316 AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
ef7ff1f9 1317 SetITSgeom(geom);
ef7ff1f9 1318}
ad7f2bfa 1319//______________________________________________________________________
1320AliTriggerDetector* AliITS::CreateTriggerDetector() const {
1321 // create an AliITSTrigger object (and set trigger conditions as input)
1322 return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
1323}
0b5bf101 1324