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 "AliITSsimulation.h"
42 ClassImp(AliITSDigitizer)
44 //______________________________________________________________________
45 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(),
52 // Default constructor. Assign fITS since it is never written out from
55 // Option_t * opt Not used
59 // A blank AliITSDigitizer class.
62 //______________________________________________________________________
63 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr),
70 // Standard constructor. Assign fITS since it is never written out from
73 // Option_t * opt Not used
77 // An AliItSDigitizer class.
82 //______________________________________________________________________
83 AliITSDigitizer::~AliITSDigitizer(){
84 // Default destructor.
86 // Option_t * opt Not used
91 fITS = 0; // don't delete fITS. Done else where.
92 if(fModActive) delete[] fModActive;
94 //______________________________________________________________________
95 Bool_t AliITSDigitizer::Init(){
96 // Initialization. Set up region of interest, if switched on, and
97 // loads ITS and ITSgeom.
105 fInit = kTRUE; // Assume for now init will work.
110 Warning("Init","gAlice not found");
113 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
117 Warning("Init","ITS not found");
119 } else if(fITS->GetITSgeom()){
120 //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
121 fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
125 Warning("Init","ITS geometry not found");
128 // fModActive needs to be set to a default all kTRUE value
129 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
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[20] = {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 sprintf(name,"%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");
190 outRL->GetEvent(event);
191 outgime = outRL->GetLoader(loadname);
194 Error("Exec","Can not get Output ITS Loader");
198 outgime->LoadDigits("update");
199 if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
202 fITS->MakeBranchInTreeD(outgime->TreeD());
204 AliDebug(1,"Region of Interest digitization selected");
207 AliDebug(1,"No Region of Interest selected. Digitizing everything");
209 if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts.
211 for(ifiles=0; ifiles<nfiles; ifiles++ )
213 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
214 ingime = inRL->GetLoader(loadname);
215 if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
218 for(module=0; module<size; module++ )
220 if(fModActive && fRoif!=0) if(!fModActive[module]) continue;
221 id = fITS->GetITSgeom()->GetModuleType(module);
222 if(!all && !det[id]) continue;
223 sim = (AliITSsimulation*)fITS->GetSimulationModel(id);
225 Error( "Exec", "The simulation class was not instanciated!" );
228 // Fill the module with the sum of SDigits
229 sim->InitSimulationModule(module, event);
230 //cout << "Module=" << module;
231 for(ifiles=0; ifiles<nfiles; ifiles++ )
233 if(fRoif!=0) if(!fModActive[module]) continue;
235 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
236 ingime = inRL->GetLoader(loadname);
238 TTree *treeS = ingime->TreeS();
239 fITS->SetTreeAddress();
241 if( !treeS ) continue;
242 TBranch *brchSDigits = treeS->GetBranch( name );
245 brchSDigits->SetAddress( &sdig );
247 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
250 } // end if brchSDigits
252 mask = GetManager()->GetMask(ifiles);
253 // add summable digits to module
254 brchSDigits->GetEvent( module );
255 lmod = sim->AddSDigitsToModule(sdig,mask);
256 if(fRegionOfInterest && (ifiles==0))
258 fModActive[module] = lmod;
261 //cout << " end ifiles loop" << endl;
262 // Digitize current module sum(SDigits)->Digits
263 sim->FinishSDigitiseModule();
265 // fills all branches - wasted disk space
266 outgime->TreeD()->Fill();
270 outgime->TreeD()->AutoSave();
271 outgime->WriteDigits("OVERWRITE");
272 outgime->UnloadDigits();
273 for(ifiles=0; ifiles<nfiles; ifiles++ )
275 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
276 ingime = inRL->GetLoader(loadname);
277 ingime->UnloadSDigits();
283 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
288 //______________________________________________________________________
289 void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
290 // Scans through the ITS branch of the SDigits tree, ts, for modules
291 // which have SDigits in them. For these modules, a flag is set to
292 // digitize only these modules. The value of fRoif determines how many
293 // neighboring modules will also be turned on. fRoif=0 will turn on only
294 // those modules with SDigits in them. fRoif=1 will turn on, in addition,
295 // those modules that are +-1 module from the one with the SDigits. And
296 // So on. This last feature is not supported yet.
298 // TTree *ts The tree in which the existing SDigits will define the
299 // region of interest.
308 TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
309 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
310 //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
313 brchSDigits->SetAddress( &sdig );
315 Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
317 } // end if brchSDigits
319 nm = fITS->GetITSgeom()->GetIndexMax();
321 //cout << " fModActive["<<m<<"]=";
322 fModActive[m] = kFALSE; // Not active by default
324 brchSDigits->GetEvent(m);
325 if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
326 // activate the necessary modules
327 if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
328 fModActive[m] = kTRUE;
331 } // end if. end for i.
332 //cout << fModActive[m];
335 AliDebug(1,"Digitization by Region of Interest selected");