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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////
18 //Piotr.Skowronski@cern.ch : //
19 //Corrections applied in order to compile (only) //
20 // with new I/O and folder structure //
21 //To be implemented correctly by responsible //
23 // Class used to steer //
24 // the digitization for ITS //
26 ///////////////////////////////////////////////////////////////////////////
29 #include <TClonesArray.h>
34 #include "AliRunLoader.h"
35 #include "AliLoader.h"
37 #include "AliRunDigitizer.h"
38 #include "AliITSDigitizer.h"
39 #include "AliITSgeom.h"
40 #include "AliITSgeomTGeo.h"
41 #include "AliITSsimulation.h"
43 ClassImp(AliITSDigitizer)
45 //______________________________________________________________________
46 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(),
53 // Default constructor. Assign fITS since it is never written out from
56 // Option_t * opt Not used
60 // A blank AliITSDigitizer class.
61 fModActive = new Bool_t[AliITSgeomTGeo::GetNModules()];
62 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
65 //______________________________________________________________________
66 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr),
73 // Standard constructor. Assign fITS since it is never written out from
76 // Option_t * opt Not used
80 // An AliItSDigitizer class.
81 fModActive = new Bool_t[AliITSgeomTGeo::GetNModules()];
82 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
86 //______________________________________________________________________
87 AliITSDigitizer::~AliITSDigitizer(){
88 // Default destructor.
90 // Option_t * opt Not used
95 fITS = 0; // don't delete fITS. Done else where.
96 if(fModActive) delete[] fModActive;
98 //______________________________________________________________________
99 Bool_t AliITSDigitizer::Init(){
100 // Initialization. Set up region of interest, if switched on, and
101 // loads ITS and ITSgeom.
109 fInit = kTRUE; // Assume for now init will work.
114 Warning("Init","gAlice not found");
117 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
121 Warning("Init","ITS not found");
124 if(!fITS->GetITSgeom()){
127 Warning("Init","ITS geometry not found");
132 //______________________________________________________________________
133 void AliITSDigitizer::Exec(Option_t* opt){
134 // Main digitization function.
136 // Option_t * opt list of sub detector to digitize. =0 all.
142 char name[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
144 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
146 if( !det[0] && !det[1] && !det[2] ) all = "All";
148 Int_t nfiles = GetManager()->GetNinputs();
149 Int_t event = GetManager()->GetOutputEventNr();
150 AliITSsimulation *sim = 0;
153 fITS->SetDefaultSimulation();
157 Error("Exec","Init not successful, aborting.");
161 snprintf(name,20,"%s",fITS->GetName());
163 Int_t size = fITS->GetITSgeom()->GetIndexMax();
164 Int_t module,id,ifiles,mask;
166 Int_t *fl = new Int_t[nfiles];
169 for(id=0;id<nfiles;id++)
172 // just in case fRoiifile!=0.
176 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
178 TString loadname(name);
181 AliRunLoader *inRL = 0x0, *outRL = 0x0;
182 AliLoader *ingime = 0x0, *outgime = 0x0;
184 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
187 Error("Exec","Can not get Output Run Loader");
191 outRL->GetEvent(event);
192 outgime = outRL->GetLoader(loadname);
195 Error("Exec","Can not get Output ITS Loader");
200 outgime->LoadDigits("update");
201 if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
204 fITS->MakeBranchInTreeD(outgime->TreeD());
206 AliDebug(1,"Region of Interest digitization selected");
209 AliDebug(1,"No Region of Interest selected. Digitizing everything");
213 for(ifiles=0; ifiles<nfiles; ifiles++ )
215 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
216 ingime = inRL->GetLoader(loadname);
217 if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
220 for(module=0; module<size; module++ )
222 if(fRoif!=0) if(!fModActive[module]) continue;
223 id = fITS->GetITSgeom()->GetModuleType(module);
224 if(!all && !det[id]) continue;
225 sim = (AliITSsimulation*)fITS->GetSimulationModel(id);
227 Error( "Exec", "The simulation class was not instanciated!" );
230 // Fill the module with the sum of SDigits
231 sim->InitSimulationModule(module, event);
232 //cout << "Module=" << module;
233 for(ifiles=0; ifiles<nfiles; ifiles++ )
235 if(fRoif!=0) if(!fModActive[module]) continue;
237 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
238 ingime = inRL->GetLoader(loadname);
240 TTree *treeS = ingime->TreeS();
241 fITS->SetTreeAddress();
243 if( !treeS ) continue;
244 TBranch *brchSDigits = treeS->GetBranch( name );
247 brchSDigits->SetAddress( &sdig );
249 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
253 } // end if brchSDigits
255 mask = GetManager()->GetMask(ifiles);
256 // add summable digits to module
257 brchSDigits->GetEvent( module );
258 lmod = sim->AddSDigitsToModule(sdig,mask);
259 if(fRegionOfInterest && (ifiles==0))
261 fModActive[module] = lmod;
264 //cout << " end ifiles loop" << endl;
265 // Digitize current module sum(SDigits)->Digits
266 sim->FinishSDigitiseModule();
268 // fills all branches - wasted disk space
269 outgime->TreeD()->Fill();
273 outgime->TreeD()->AutoSave();
274 outgime->WriteDigits("OVERWRITE");
275 outgime->UnloadDigits();
276 for(ifiles=0; ifiles<nfiles; ifiles++ )
278 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
279 ingime = inRL->GetLoader(loadname);
280 ingime->UnloadSDigits();
286 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
291 //______________________________________________________________________
292 void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
293 // Scans through the ITS branch of the SDigits tree, ts, for modules
294 // which have SDigits in them. For these modules, a flag is set to
295 // digitize only these modules. The value of fRoif determines how many
296 // neighboring modules will also be turned on. fRoif=0 will turn on only
297 // those modules with SDigits in them. fRoif=1 will turn on, in addition,
298 // those modules that are +-1 module from the one with the SDigits. And
299 // So on. This last feature is not supported yet.
301 // TTree *ts The tree in which the existing SDigits will define the
302 // region of interest.
311 TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
312 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
313 //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
316 brchSDigits->SetAddress( &sdig );
318 Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
320 } // end if brchSDigits
322 nm = fITS->GetITSgeom()->GetIndexMax();
324 fModActive[m] = kFALSE; // Not active by default
326 brchSDigits->GetEvent(m);
327 if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
328 // activate the necessary modules
329 if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
330 fModActive[m] = kTRUE;
333 } // end if. end for i.
334 //cout << fModActive[m];
337 AliDebug(1,"Digitization by Region of Interest selected");