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>
36 #include <AliRunDigitizer.h>
37 #include "AliITSDigitizer.h"
38 #include "AliITSgeom.h"
39 #include "AliITSsimulation.h"
41 ClassImp(AliITSDigitizer)
43 //______________________________________________________________________
44 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
45 // Default constructor. Assign fITS since it is never written out from
48 // Option_t * opt Not used
52 // A blank AliITSDigitizer class.
60 //______________________________________________________________________
61 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
62 // Standard constructor. Assign fITS since it is never written out from
65 // Option_t * opt Not used
69 // An AliItSDigitizer class.
78 //______________________________________________________________________
79 AliITSDigitizer::AliITSDigitizer(const AliITSDigitizer &/*rec*/):AliDigitizer(/*rec*/){
82 Error("Copy constructor","Copy constructor not allowed");
85 //______________________________________________________________________
86 AliITSDigitizer& AliITSDigitizer::operator=(const AliITSDigitizer& /*source*/){
87 // Assignment operator. This is a function which is not allowed to be
89 Error("operator=","Assignment operator not allowed\n");
93 //______________________________________________________________________
94 AliITSDigitizer::~AliITSDigitizer(){
95 // Default destructor.
97 // Option_t * opt Not used
103 fITS = 0; // don't delete fITS. Done else where.
104 if(fModActive) delete[] fModActive;
106 //______________________________________________________________________
107 Bool_t AliITSDigitizer::Init(){
108 // Initialization. Set up region of interest, if switched on, and
109 // loads ITS and ITSgeom.
117 fInit = kTRUE; // Assume for now init will work.
122 Warning("Init","gAlice not found");
125 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
129 Warning("Init","ITS not found");
131 } else if(fITS->GetITSgeom()){
132 //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
133 fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
137 Warning("Init","ITS geometry not found");
140 // fModActive needs to be set to a default all kTRUE value
141 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
144 //______________________________________________________________________
145 void AliITSDigitizer::Exec(Option_t* opt){
146 // Main digitization function.
148 // Option_t * opt list of sub detector to digitize. =0 all.
154 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
156 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
158 if( !det[0] && !det[1] && !det[2] ) all = "All";
160 AliITSsimulation *sim = 0;
162 fITS->SetDefaultSimulation();
164 Error("Exec","Init not succesfull, aborting.");
168 sprintf(name,"%s",fITS->GetName());
170 Int_t nfiles = GetManager()->GetNinputs();
171 Int_t event = GetManager()->GetOutputEventNr();
172 Int_t size = fITS->GetITSgeom()->GetIndexMax();
173 Int_t module,id,ifiles,mask;
175 Int_t *fl = new Int_t[nfiles];
178 for(id=0;id<nfiles;id++)
181 // just in case fRoiifile!=0.
185 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
187 TString loadname(name);
190 AliRunLoader *inRL = 0x0, *outRL = 0x0;
191 AliLoader *ingime = 0x0, *outgime = 0x0;
193 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
196 Error("Exec","Can not get Output Run Loader");
199 outRL->GetEvent(event);
200 outgime = outRL->GetLoader(loadname);
203 Error("Exec","Can not get Output ITS Loader");
207 outgime->LoadDigits("update");
208 if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
211 fITS->MakeBranchInTreeD(outgime->TreeD());
212 if(fRoif!=0) Info("AliITSDigitizer","Region of Interest digitization selected");
213 else Info("AliITSDigitizer","No Region of Interest selected. Digitizing everything");
214 //cout <<"fModActive="<<fModActive<<" fRoif="<<fRoif;
215 if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts.
216 //cout <<" fRoif="<<fRoif<<endl;
218 for(ifiles=0; ifiles<nfiles; ifiles++ )
220 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
221 ingime = inRL->GetLoader(loadname);
222 if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
225 for(module=0; module<size; module++ )
227 if(fModActive && fRoif!=0) if(!fModActive[module]) continue;
228 id = fITS->GetITSgeom()->GetModuleType(module);
229 if(!all && !det[id]) continue;
230 sim = (AliITSsimulation*)fITS->GetSimulationModel(id);
232 Error( "Exec", "The simulation class was not instanciated!" );
235 // Fill the module with the sum of SDigits
236 sim->InitSimulationModule(module, event);
237 //cout << "Module=" << module;
238 for(ifiles=0; ifiles<nfiles; ifiles++ )
240 if(fRoif!=0) if(!fModActive[module]) continue;
242 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
243 ingime = inRL->GetLoader(loadname);
245 TTree *treeS = ingime->TreeS();
246 fITS->SetTreeAddress();
248 if( !(treeS && fITS->GetSDigits()) ) continue;
249 TBranch *brchSDigits = treeS->GetBranch( name );
252 brchSDigits->SetAddress( &sdig );
254 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
257 } // end if brchSDigits
259 mask = GetManager()->GetMask(ifiles);
260 // add summable digits to module
261 brchSDigits->GetEvent( module );
262 lmod = sim->AddSDigitsToModule(sdig,mask);
263 if(fRegionOfInterest && (ifiles==0))
265 fModActive[module] = lmod;
268 //cout << " end ifiles loop" << endl;
269 // Digitize current module sum(SDigits)->Digits
270 sim->FinishSDigitiseModule();
272 // fills all branches - wasted disk space
273 outgime->TreeD()->Fill();
277 outgime->TreeD()->AutoSave();
278 outgime->WriteDigits("OVERWRITE");
279 outgime->UnloadDigits();
280 for(ifiles=0; ifiles<nfiles; ifiles++ )
282 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
283 ingime = inRL->GetLoader(loadname);
284 ingime->UnloadSDigits();
290 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
295 //______________________________________________________________________
296 void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
297 // Scans through the ITS branch of the SDigits tree, ts, for modules
298 // which have SDigits in them. For these modules, a flag is set to
299 // digitize only these modules. The value of fRoif determines how many
300 // neighboring modules will also be turned on. fRoif=0 will turn on only
301 // those modules with SDigits in them. fRoif=1 will turn on, in addition,
302 // those modules that are +-1 module from the one with the SDigits. And
303 // So on. This last feature is not supported yet.
305 // TTree *ts The tree in which the existing SDigits will define the
306 // region of interest.
315 TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
316 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
317 //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
320 brchSDigits->SetAddress( &sdig );
322 Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
324 } // end if brchSDigits
326 nm = fITS->GetITSgeom()->GetIndexMax();
328 //cout << " fModActive["<<m<<"]=";
329 fModActive[m] = kFALSE; // Not active by default
331 brchSDigits->GetEvent(m);
332 if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
333 // activate the necessary modules
334 if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
335 fModActive[m] = kTRUE;
338 } // end if. end for i.
339 //cout << fModActive[m];
342 Info("AliITSDigitizer","Digitization by Region of Interest selected");