1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.1 2001/11/27 16:27:28 nilsen
19 Adding AliITSDigitizer class to do merging and digitization . Based on the
20 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
21 file. The following files required minor changes. AliITS, added functions
22 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
23 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
24 the original Root Directory in function Compress1D. Now it uses gDirectory.
30 #include <TObjArray.h>
35 #include <AliRunDigitizer.h>
37 #include "AliITSDigitizer.h"
38 #include "AliITShit.h"
39 #include "AliITSmodule.h"
40 #include "AliITSsimulation.h"
41 #include "AliITSDetType.h"
42 #include "AliITSgeom.h"
44 ClassImp(AliITSDigitizer)
46 //______________________________________________________________________
47 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
48 // Default constructor. Assign fITS since it is never written out from
51 // Option_t * opt Not used
55 // A blank AliITSDigitizer class.
59 //______________________________________________________________________
60 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
61 // Standard constructor. Assign fITS since it is never written out from
64 // Option_t * opt Not used
68 // An AliItSDigitizer class.
72 //______________________________________________________________________
73 AliITSDigitizer::~AliITSDigitizer(){
74 // Default destructor.
76 // Option_t * opt Not used
82 fITS = 0; // don't delete fITS. Done else where.
85 //______________________________________________________________________
86 Bool_t AliITSDigitizer::Init(){
95 // if(GetHits()) fITS->fHits = new TClonesArray("AliITSHit",1000);
98 //______________________________________________________________________
99 void AliITSDigitizer::Exec(Option_t* opt){
100 // Main digitizing function.
102 // Option_t * opt list of subdetector to digitize. =0 all.
107 Int_t size=0,ifls=0,trk=0,ntracks=0,h=0,nhit=0;
111 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
113 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
115 if(!det[0] && !det[1] && !det[2]) all = "All";
117 AliITSsimulation *sim = 0;
118 AliITSDetType *iDetType = 0;
119 AliITSmodule *mod = 0;
120 Int_t id=0,module=0,nfls=0,mask=0;
121 static Bool_t setDef=kTRUE;
123 if(!fITS) fITS = (AliITS*)(gAlice->GetDetector("ITS"));
124 if(!(fITS->GetITSgeom())){
125 Warning("Exec","Need ITS geometry to be properly defined first.");
126 return; // need transformations to do digitization.
127 } // end if !GetITSgeom()
128 if (setDef) fITS->SetDefaultSimulation();
130 sprintf(name,"%s",fITS->GetName());
132 fITS->InitModules(0,size);
135 nfls = GetManager()->GetNinputs();
136 for(ifls=0;ifls<nfls;ifls++){
137 treeH = GetManager()->GetInputTreeH(ifls);
138 if(!(treeH && GetHits())) continue;
139 brchHits = treeH->GetBranch(name);
142 fITS->SetHitsAddressBranch(brchHits);
144 Error("Exec","branch ITS not found");
147 ntracks = (Int_t) treeH->GetEntries();
148 for(trk=0;trk<ntracks;trk++){
150 brchHits->GetEntry(trk);
151 nhit = GetHits()->GetEntries();
152 mask = GetManager()->GetMask(ifls);
155 mod = GetModule(itsHit->GetModule());
156 id = fITS->GetITSgeom()->GetModuleType(module);
157 if (!all && !det[id]) continue;
158 mod->AddHit(itsHit,trk+mask,h);
164 fITS->MakeBranchInTreeD(GetManager()->GetTreeD());
165 for(module=0;module<size;module++){
166 id = fITS->GetITSgeom()->GetModuleType(module);
167 if (!all && !det[id]) continue;
168 iDetType = fITS->DetType(id);
169 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
171 Error("Exec","The simulation class was not instanciated!");
174 mod = GetModule(module);
175 sim->DigitiseModule(mod,module,0);
176 // fills all branches - wasted disk space
177 GetManager()->GetTreeD()->Fill();
181 fITS->ClearModules();
183 GetManager()->GetTreeD()->GetEntries();
184 GetManager()->GetTreeD()->Write(0,TObject::kOverwrite);
186 GetManager()->GetTreeD()->Reset();