Transition to NewIO
[u/mrichter/AliRoot.git] / ITS / AliITSFDigitizer.cxx
CommitLineData
7dab88d3 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
16/*
17$Log$
88cb7938 18Revision 1.3.4.1 2002/11/26 16:58:52 hristov
19Merging NewIO with v3-09-04
20
21Revision 1.3 2002/10/22 14:45:34 alibrary
22Introducing Riostream.h
23
4ae5bbc4 24Revision 1.2 2002/10/14 14:57:00 hristov
25Merging the VirtualMC branch to the main development branch (HEAD)
26
b9d0a01d 27Revision 1.1.2.1 2002/07/24 09:27:50 alibrary
28Updating on VirtualMC
29
30Revision 1.1 2002/06/10 17:32:17 nilsen
31New Fastpoint merger added.
32
7dab88d3 33*/
34
35#include <stdlib.h>
4ae5bbc4 36#include <Riostream.h>
7dab88d3 37#include <TObjArray.h>
38#include <TClonesArray.h>
39#include <TTree.h>
40#include <TBranch.h>
41#include <TFile.h>
42
43#include <AliRun.h>
88cb7938 44#include <AliRunLoader.h>
45#include <AliLoader.h>
7dab88d3 46#include <AliRunDigitizer.h>
47
48#include "AliITSFDigitizer.h"
49// #include "AliITSpList.h"
50#include "AliITSmodule.h"
51#include "AliITSgeom.h"
52#include "AliITSsimulationFastPoints.h"
53
54ClassImp(AliITSFDigitizer)
55
56//______________________________________________________________________
57AliITSFDigitizer::AliITSFDigitizer() : AliDigitizer(){
58//
59// Default constructor.
60//
61 fITS = 0;
62 fInit = kFALSE;
63}
64//______________________________________________________________________
65AliITSFDigitizer::AliITSFDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
66//
67// Standard constructor.
68//
69 fITS = 0;
70 fInit = kFALSE;
71}
72//______________________________________________________________________
73AliITSFDigitizer::~AliITSFDigitizer(){
74//
75// Default destructor.
76//
77 fITS = 0; // don't delete fITS. Done else where.
78}
79//______________________________________________________________________
80Bool_t AliITSFDigitizer::Init(){
81//
82// Initialization.
83// loads ITS and ITSgeom.
84// Inputs:
85// none.
86// Outputs:
87// none.
88
89
90 fInit = kFALSE;
91 if(!gAlice) {
92 fITS = 0;
93 Warning("Init","gAlice not found");
94 return fInit;
95 }
96 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
97 if(!fITS){
98 Warning("Init","ITS not found");
99 return fInit;
100 }
101 if(!fITS->GetITSgeom()){
102 Warning("Init","ITS geometry not found");
103 return fInit;
104 }
105 return fInit = kTRUE;
106}
107////////////////////////////////////////////////////////////////////////
108void AliITSFDigitizer::Exec(Option_t* opt){
109//
110// Main digitization function.
111// Inputs:
112// Option_t * opt "deb" ... more verbose output
113//
114
115 AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
88cb7938 116 AliRunLoader* outrl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
117 if (outrl == 0x0)
118 {
119 Error("Exec","Can not find Run Loader in output folder.");
120 return;
121 }
122
123 AliLoader* outgime = outrl->GetLoader("ITSLoader");
124 if (outgime == 0x0)
125 {
126 Error("Exec","Can not get TOF Loader from Output Run Loader.");
127 return;
128 }
129
130 TTree* outputTreeR = outgime->TreeR();
131 if (outputTreeR == 0x0)
132 {
133 outgime->MakeTree("R");
134 outputTreeR = outgime->TreeR();
135 }
7dab88d3 136
7dab88d3 137 TClonesArray *recPoints = fITS->RecPoints();
138// TBranch *branch =
88cb7938 139 fITS->MakeBranchInTree(outputTreeR,"ITSRecPointsF",&recPoints,4000,0);
7dab88d3 140
141 Int_t nModules;
142 fITS->InitModules(-1,nModules);
143
144// load hits into modules
88cb7938 145 for (Int_t iFile = 0; iFile < fManager->GetNinputs(); iFile++)
146 {
147 AliRunLoader* rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iFile));
148 if (rl == 0x0)
149 {
150 Error("Exec","Can not find Run Loader in input %d folder.",iFile);
151 return;
152 }
7dab88d3 153
88cb7938 154 AliLoader* gime = rl->GetLoader("ITSLoader");
155 if (gime == 0x0)
156 {
157 Error("Exec","Can not get TOF Loader from Input %d Run Loader.",iFile);
158 return;
159 }
160
161 gime->LoadHits();
162 fITS->FillModules(gime->TreeH(),fManager->GetMask(iFile));
163 gime->UnloadHits();
164 }
7dab88d3 165
166// transform hits to fast rec points
167
168 AliITSgeom *geom = fITS->GetITSgeom();
169 for(Int_t moduleIndex = 0; moduleIndex < geom->GetIndexMax(); moduleIndex++){
170 sim->CreateFastRecPoints(moduleIndex);
171// branch->Fill();
172 outputTreeR->Fill();
173 fITS->ResetRecPoints();
174 }
88cb7938 175 outrl->WriteRecPoints("OVERWRITE");
176// outputTreeR->AutoSave();
7dab88d3 177}
178////////////////////////////////////////////////////////////////////////