For the first event the number of events is set 1.
[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
3bd79107 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}
3bd79107 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
88cb7938 610
7d62fb64 611 fLoader->UnloadHits();
612 fLoader->UnloadSDigits();
613
85a5290f 614}
615//______________________________________________________________________
7d62fb64 616void AliITS::Hits2Digits(){
617
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){
647 // Keep galice.root for signal and name differently the file for
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
650 // initialized for all versions - for the moment it is only for v5 !
651 // 7 is the SDD beam test version.
4a5bebc2 652 // Inputs:
7d62fb64 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..
4a5bebc2 660 // Outputs:
661 // none.
7d62fb64 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();
85a5290f 672
7d62fb64 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();
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//______________________________________________________________________
2aea926d 742void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
aacedc3e 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.
2aea926d 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
807
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
2aea926d 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
4a5bebc2 825 // initialized for all versions - for the moment it is only for v5 !
4a5bebc2 826 // Inputs:
827 // Int_t evnt Event to be processed.
828 // Int_t bgrev Background Hit tree number.
7d62fb64 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
4a5bebc2 832 // merge hits set equal to "Add". Otherwise no
833 // background hits are considered.
7d62fb64 834 // Test_t *flnm File name containing the background hits..
4a5bebc2 835 // Outputs:
836 // none.
837 // Return:
838 // none.
839
04366a57 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();
885 } // end for module
886
887 ClearModules();
888 fLoader->WriteRecPoints("OVERWRITE");
889 delete ptarray;
2aea926d 890}
7d62fb64 891//_____________________________________________________________________
892Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
893 //------------------------------------------------------------
894 // This function creates ITS clusters
895 //------------------------------------------------------------
896 if(!GetITSgeom()){
897 Error("HitsToPreDigits","fGeom is null!");
898 return 1; // need transformations to do digitization.
899 }
900 AliITSgeom *geom=GetITSgeom();
901 Int_t mmax=geom->GetIndexMax();
902
903 InitModules(-1,mmax);
904 FillModules(hTree,0);
905
7d62fb64 906 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
00a7cc50 907 TBranch *branch=cTree->GetBranch("ITSRecPoints");
908 if (!branch) cTree->Branch("ITSRecPoints",&points);
909 else branch->SetAddress(&points);
7d62fb64 910
911 AliITSsimulationFastPoints sim;
912 Int_t ncl=0;
913 for (Int_t m=0; m<mmax; m++) {
914 AliITSmodule *mod=GetModule(m);
915 sim.CreateFastRecPoints(mod,m,gRandom,points);
00a7cc50 916 ncl+=points->GetEntriesFast();
7d62fb64 917 cTree->Fill();
7d62fb64 918 points->Clear();
919 }
920
921 Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
922
923 //cTree->Write();
924
7d62fb64 925 delete points;
926 return 0;
927}
7d62fb64 928
7d62fb64 929//_____________________________________________________________________
930void AliITS::CheckLabels(Int_t lab[3]) const {
931 //------------------------------------------------------------
932 // Tries to find mother's labels
933 //------------------------------------------------------------
934
935 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
936
937 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
938 for (Int_t i=0;i<3;i++){
939 Int_t label = lab[i];
940 if (label>=0 && label<ntracks) {
941 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
942 if (part->P() < 0.005) {
943 Int_t m=part->GetFirstMother();
944 if (m<0) {
945 continue;
946 }
947 if (part->GetStatusCode()>0) {
948 continue;
949 }
950 lab[i]=m;
951 }
952 }
953 }
954
955}
956
957//______________________________________________________________________
958void AliITS::SDigitsToDigits(Option_t *opt){
ad7f2bfa 959 // Standard Summable digits to Digits function.
960 // Inputs:
961 // none.
962 // Outputs:
963 // none.
964 if (!fDetTypeSim) {
965 AliError("fDetTypeSim is 0!");
966 return;
967 }
7d62fb64 968
ad7f2bfa 969 const char *all = strstr(opt,"All");
970 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
971 strstr(opt,"SSD")};
972
973 // Reset Fast-OR signals for this event
974 fDetTypeSim->ResetFOSignals();
975
976 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
977 SetDefaults();
978 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
979
980 // Add random noise to FO signals
981 if (all || det[0]) { // SPD present
982 fDetTypeSim->ProcessNoiseForFastOr();
983 }
984 // Add Fast-OR signals to event (only one object per event)
985 if (all || det[0]) { // SPD present
986 fDetTypeSim->WriteFOSignals();
987 }
7d62fb64 988}
989
2aea926d 990//______________________________________________________________________
2aea926d 991void AliITS::ResetDigits(){
4a5bebc2 992 // Reset number of digits and the digits array for the ITS detector.
993 // Inputs:
994 // none.
995 // Outputs:
996 // none.
7d62fb64 997 if(!fDetTypeSim) {
998 Error("ResetDigits","fDetTypeSim is 0!");
999 return;
1000 }
1001
1002 fDetTypeSim->ResetDigits();
3bd79107 1003
1004
2aea926d 1005}
1006//______________________________________________________________________
7d62fb64 1007void AliITS::ResetDigits(Int_t branch){
4a5bebc2 1008 // Reset number of digits and the digits array for this branch.
1009 // Inputs:
1010 // none.
1011 // Outputs:
1012 // none.
828e06c7 1013
7d62fb64 1014 if(!fDetTypeSim) {
1015 Error("ResetDigits","fDetTypeSim is 0!");
1016 return;
1017 }
1018
1019 fDetTypeSim->ResetDigits(branch);
1020
2aea926d 1021}
1022//______________________________________________________________________
1023void AliITS::AddSumDigit(AliITSpListItem &sdig){
4a5bebc2 1024 // Adds the a module full of summable digits to the summable digits tree.
1025 // Inputs:
1026 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1027 // Outputs:
1028 // none.
1029 // Return:
1030 // none.
828e06c7 1031
7d62fb64 1032 if(!fDetTypeSim) {
1033 Error("AddSumDigit","fDetTypeSim is 0!");
1034 return;
1035 }
1036 fDetTypeSim->AddSumDigit(sdig);
1037
828e06c7 1038}
2aea926d 1039//______________________________________________________________________
7d62fb64 1040void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
4a5bebc2 1041 // Add a simulated digit.
1042 // Inputs:
1043 // Int_t id Detector type number.
1044 // AliITSdigit *d Digit to be added to the Digits Tree. See
1045 // AliITSdigit.h
1046 // Outputs:
1047 // none.
1048 // Return:
1049 // none.
2aea926d 1050
7d62fb64 1051 if(!fDetTypeSim) {
1052 Error("AddSimDigit","fDetTypeSim is 0!");
1053 return;
1054 }
1055 fDetTypeSim->AddSimDigit(branch,d);
1056
2aea926d 1057}
1058//______________________________________________________________________
7d62fb64 1059void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
83ec5e27 1060 Int_t *hits,Float_t *charges, Int_t sigexpanded){
7f1a504b 1061 // Add a simulated digit to the list.
1062 // Inputs:
1063 // Int_t id Detector type number.
1064 // Float_t phys Physics indicator. See AliITSdigits.h
1065 // Int_t *digits Integer array containing the digits info. See
1066 // AliITSdigit.h
1067 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1068 // containing the track numbers that contributed to
1069 // this digit.
1070 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1071 // containing the hit numbers, from AliITSmodule, that
1072 // contributed to this digit.
1073 // Float_t *charge Floating point array of the signals contributed
1074 // to this digit by each track.
1075 // Outputs:
1076 // none.
1077 // Return:
1078 // none.
2aea926d 1079
7d62fb64 1080 if(!fDetTypeSim) {
1081 Error("AddSimDigit","fDetTypeSim is 0!");
1082 return;
1083 }
83ec5e27 1084 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
7d62fb64 1085
2aea926d 1086}
0421c3d1 1087//______________________________________________________________________
aacedc3e 1088void AliITS::Digits2Raw(){
1089 // convert digits of the current event to raw data
0421c3d1 1090
7d62fb64 1091 if(!fDetTypeSim) {
1092 Error("Digits2Raw","fDetTypeSim is 0!");
1093 return;
1094 }
023ae34b 1095 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 1096 SetDefaults();
1097 fDetTypeSim->GetLoader()->LoadDigits();
1098 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
0421c3d1 1099 if (!digits) {
aacedc3e 1100 Error("Digits2Raw", "no digits tree");
1101 return;
0421c3d1 1102 }
7d62fb64 1103 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
ad7f2bfa 1104
1105 // Get the FO signals for this event
1106 AliITSFOSignalsSPD* foSignals = NULL;
1107 AliRunLoader* runLoader = AliRunLoader::Instance();
1108 AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
1109 if (!itsLoader) {
1110 AliError("ITS loader is NULL.");
1111 }
1112 else {
1113 AliBaseLoader* foLoader = itsLoader->GetFOSignalsLoader();
1114 if (!foLoader) {
1115 AliError("FO signals base loader not retrieved.");
1116 }
1117 else {
1118 foLoader->Load();
1119 foSignals = (AliITSFOSignalsSPD*) foLoader->Get();
1120 }
1121 }
1122 Bool_t deleteFOsignalsLater = kFALSE;
1123 if (!foSignals) {
1124 AliError("FO signals not available. No FO bits will be written.");
1125 foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
1126 deleteFOsignalsLater = kTRUE;
1127 }
1128
1129
979b5a5f 1130 AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
2f8ed7ab 1131 Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
0421c3d1 1132 AliITSDDLRawData rawWriter;
2f8ed7ab 1133 if(isHLTmodeC) rawWriter.SetUseCompressedSDDFormat(kTRUE);
1134 else rawWriter.SetUseCompressedSDDFormat(kFALSE);
0421c3d1 1135 //Verbose level
1136 // 0: Silent
1137 // 1: cout messages
1138 // 2: txt files with digits
1139 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1140 //it is highly suggested to use this mode only for debugging digits files
1141 //reasonably small, because otherwise the size of the txt files can reach
1142 //quickly several MB wasting time and disk space.
1143 rawWriter.SetVerbose(0);
1144
1145 //SILICON PIXEL DETECTOR
1146 Info("Digits2Raw", "Formatting raw data for SPD");
ad7f2bfa 1147 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
1148 if(deleteFOsignalsLater) delete foSignals;
0421c3d1 1149
1150 //SILICON DRIFT DETECTOR
1151 Info("Digits2Raw", "Formatting raw data for SDD");
979b5a5f 1152 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
0421c3d1 1153
1154 //SILICON STRIP DETECTOR
1155 Info("Digits2Raw", "Formatting raw data for SSD");
1156 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1157
1158 fLoader->UnloadDigits();
2aea926d 1159}
04366a57 1160//______________________________________________________________________
aacedc3e 1161AliLoader* AliITS::MakeLoader(const char* topfoldername){
1162 //builds ITSgetter (AliLoader type)
1163 //if detector wants to use castomized getter, it must overload this method
1164
64f311fe 1165 AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1166 topfoldername));
aacedc3e 1167 fLoader = new AliITSLoader(GetName(),topfoldername);
1168 return fLoader;
2aea926d 1169}
ad7f2bfa 1170//______________________________________________________________________
0b5bf101 1171Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1172{
1173 //
1174 // Converts RAW data to SDigits
1175 //
1176 // Get TreeS
1177 //
1178 Int_t last = -1;
1179 Int_t size = GetITSgeom()->GetIndexMax();
1180 TClonesArray** modA = new TClonesArray*[size];
1181 for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1182
33c3c91a 1183 AliLoader* loader = (AliRunLoader::Instance())->GetLoader("ITSLoader");
ad7f2bfa 1184 if (!loader){
0b5bf101 1185 Error("Open","Can not get ITS loader from Run Loader");
1186 return kFALSE;
1187 }
1188
1189 TTree* tree = 0;
1190 tree = loader->TreeS();
ad7f2bfa 1191 if (!tree){
0b5bf101 1192 loader->MakeTree("S");
1193 tree = loader->TreeS();
1194 }
1195 //
1196 // Array for SDigits
1197 //
1198 TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1199 Int_t bufsize = 32000;
1200 tree->Branch("ITS", &itsSDigits, bufsize);
1201 Int_t npx = 0;
1202 //
1203 // SPD
1204 //
1205 AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
6a3ca9e7 1206 if(!segSPD){
1207 AliWarning("Set AliITS defaults");
1208 SetDefaults();
1209 segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1210 }
0b5bf101 1211 npx = segSPD->Npx();
1212 Double_t thr, sigma;
1213
1214 AliITSRawStreamSPD inputSPD(rawReader);
1215 while(1){
1216 Bool_t next = inputSPD.Next();
1217 if (!next) break;
1218
1219 Int_t module = inputSPD.GetModuleID();
1220 Int_t column = inputSPD.GetColumn();
1221 Int_t row = inputSPD.GetRow();
1222 Int_t index = npx * column + row;
1223
1224 if (module >= size) continue;
1225
1226 last = (modA[module])->GetEntries();
1227 TClonesArray& dum = *modA[module];
bb292d31 1228 fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
0b5bf101 1229 thr += 1.;
1230 new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1231 }
1232 rawReader->Reset();
1233
1234 //
1235 // SDD
1236 //
1237 AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1238 npx = segSDD->Npx();
1239 AliITSRawStreamSDD inputSDD(rawReader);
979b5a5f 1240 AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1241 inputSDD.SetDDLModuleMap(ddlmap);
0b5bf101 1242 while(1){
1243 Bool_t next = inputSDD.Next();
1244 if (!next) break;
1245
1246 Int_t module = inputSDD.GetModuleID();
1247 Int_t anode = inputSDD.GetAnode();
1248 Int_t time = inputSDD.GetTime();
6a3ca9e7 1249 Int_t signal10 = inputSDD.GetSignal();
0b5bf101 1250 Int_t index = npx * anode + time;
1251
1252 if (module >= size) continue;
0b5bf101 1253 last = modA[module]->GetEntries();
1254 TClonesArray& dum = *modA[module];
1255 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1256 ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1257
1258 }
1259 rawReader->Reset();
1260
1261 //
1262 // SSD
1263 //
1264 AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1265 npx = segSSD->Npx();
1266 AliITSRawStreamSSD inputSSD(rawReader);
1267 while(1){
1268 Bool_t next = inputSSD.Next();
1269 if (!next) break;
1270
1271 Int_t module = inputSSD.GetModuleID();
1272 Int_t side = inputSSD.GetSideFlag();
1273 Int_t strip = inputSSD.GetStrip();
1274 Int_t signal = inputSSD.GetSignal();
1275 Int_t index = npx * side + strip;
1276
1277 if (module >= size) continue;
1278
1279 last = modA[module]->GetEntries();
1280 TClonesArray& dum = *modA[module];
1281 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1282 }
1283 rawReader->Reset();
1284 AliITSpListItem* sdig = 0;
1285
1286 for (Int_t mod = 0; mod < size; mod++)
1287 {
1288 Int_t nsdig = modA[mod]->GetEntries();
1289 for (Int_t ie = 0; ie < nsdig; ie++) {
1290 sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1291 new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1292 Float_t sig = sdig->GetSignalAfterElect();
1293 if (sig > 0.) {
1294 sdig = (AliITSpListItem*)aSDigits[ie];
1295 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1296 }
1297 }
1298
1299 tree->Fill();
1300 aSDigits.Clear();
1301 modA[mod]->Clear();
1302 }
1303 loader->WriteSDigits("OVERWRITE");
1304 delete modA;
1305 return kTRUE;
1306}
1307
1308
ef7ff1f9 1309//______________________________________________________________________
1310void AliITS::UpdateInternalGeometry(){
1311
ed9289c8 1312 //reads new geometry from TGeo
012f0f4c 1313// AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1314
108bd0fe 1315 AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1316 Int_t minor = 0;
012f0f4c 1317 if(version==kvPPRasymmFMD) minor=2; // default minor version for this geom.
1318 AliITSInitGeometry initgeom;
1319 AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
ef7ff1f9 1320 SetITSgeom(geom);
ef7ff1f9 1321}
ad7f2bfa 1322//______________________________________________________________________
1323AliTriggerDetector* AliITS::CreateTriggerDetector() const {
1324 // create an AliITSTrigger object (and set trigger conditions as input)
1325 return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
1326}
0b5bf101 1327