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