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 **************************************************************************/
16 //_________________________________________________________________________
17 // This is a TTask that constructs SDigits out of Hits
18 // A Summable Digits is the sum of all hits in a cell
19 // A threshold is applied
21 //-- Author: Alla Maevskaia(INR)
22 //////////////////////////////////////////////////////////////////////////////
24 // --- ROOT system ---
29 // --- Standard library ---
31 // --- AliRoot header files ---
33 #include "AliFMDdigit.h"
34 #include "AliFMDhit.h"
37 #include "AliFMDSDigitizer.h"
39 #include "AliDetector.h"
48 ClassImp(AliFMDSDigitizer)
51 //____________________________________________________________________________
52 AliFMDSDigitizer::AliFMDSDigitizer():TTask("AliFMDSDigitizer","")
54 fNevents = 0 ; // Number of events to digitize, 0 means all evens in current file
55 // add Task to //root/Tasks folder
56 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
57 roottasks->Add(this) ;
59 //____________________________________________________________________________
60 AliFMDSDigitizer::AliFMDSDigitizer(char* HeaderFile, char *SDigitsFile):TTask("AliFMDSDigitizer","")
63 fNevents = 0 ; // Number of events to digitize, 0 means all events in current file
64 fSDigitsFile = SDigitsFile ;
65 fHeadersFile = HeaderFile ;
66 //add Task to //root/Tasks folder
67 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
68 roottasks->Add(this) ;
72 //____________________________________________________________________________
73 AliFMDSDigitizer::~AliFMDSDigitizer()
79 //____________________________________________________________________________
80 void AliFMDSDigitizer::Exec(Option_t *option) {
81 //Collects all hits in the same active volume into digit
82 TClonesArray * sdigits = new TClonesArray("AliFMDdigit",1000) ;
85 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
88 fNevents = (Int_t) gAlice->TreeE()->GetEntries() ;
90 cout<<"AliFMDSDigitizer-> Nevents"<<fNevents<<endl;
91 for(Int_t ievent = 0; ievent < fNevents; ievent++){
92 gAlice->GetEvent(ievent) ;
93 if(gAlice->TreeH()==0) return ;
95 if(gAlice->TreeS() == 0)
96 gAlice->MakeTree("S") ;
98 TClonesArray * FMDhits = FMD->Hits() ;
106 sprintf(branchname,"%s",FMD->GetName());
108 Int_t bufferSize = 16000 ;
110 if(!fSDigitsFile.IsNull())
111 file = (char*) fSDigitsFile.Data() ; //ievent ;
113 if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
114 file = new char[30] ;
115 sprintf(file,"FMD.SDigits.root") ;
116 cout<<"CONFIG_SPLIT_FILE "<<file<<endl;
120 cout<<" FILE =0 "<<endl;}
121 cout<<"After CONFIG_SPLIT_FILE "<<file<<endl;
123 gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,&sdigits,bufferSize,file);
125 Int_t splitlevel = 0 ;
126 sprintf(branchname,"AliFMDSDigitizer");
127 AliFMDSDigitizer * sd = this ;
128 gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,"AliFMDSDigitizer",&sd, bufferSize, splitlevel,file);
131 //Now made SDigits from hits, for PHOS it is the same
132 Int_t volume,sector,ring,charge;
134 Float_t de[10][20][150];
135 Int_t ivol,isec,iring;
141 // Event ------------------------- LOOP
143 for (ivol=1; ivol<=6; ivol++)
144 for(isec=0; isec<16; isec++)
145 for(iring=0; iring<128; iring++)
146 de[ivol][isec][iring]=0;
149 FMDhits = FMD->Hits();
150 TTree *TH = gAlice->TreeH();
151 Stat_t ntracks = TH->GetEntries();
153 for (Int_t track=0; track<ntracks;track++) {
155 nbytes += TH->GetEvent(track);
156 particle=gAlice->Particle(track);
157 Int_t nhits =FMDhits->GetEntriesFast();
159 for (hit=0;hit<nhits;hit++) {
160 fmdHit = (AliFMDhit*)FMDhits->UncheckedAt(hit);
162 volume = fmdHit->Volume();
163 sector = fmdHit->NumberOfSector();
164 ring = fmdHit->NumberOfRing();
166 de[volume][sector][ring]=de[volume][sector][ring]+e;
172 Float_t I=1.664*0.04*2.33/22400; // = 0.69e-6;
173 for(ivol=1; ivol<=6; ivol++){
174 for(isec=0; isec<16; isec++){
175 for(iring=0; iring<128; iring++){
176 if(de[ivol][isec][iring]>0.){
180 charge=Int_t (de[ivol][isec][iring]/I);
183 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
185 Float_t channelWidth=(22400*30)/1024;
186 digit[4]=Int_t(digit[3]/channelWidth);
188 new((*sdigits)[nSdigits++]) AliFMDdigit(digit) ;
198 gAlice->TreeS()->Fill() ;
199 TFile *f1 = new TFile(file,"RECREATE");
201 gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
209 //__________________________________________________________________
210 void AliFMDSDigitizer::SetSDigitsFile(char * file ){
211 if(!fSDigitsFile.IsNull())
212 cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ;
215 //__________________________________________________________________
216 void AliFMDSDigitizer::Print(Option_t* option)const{
217 cout << "------------------- "<< GetName() << " -------------" << endl ;
218 if(fSDigitsFile.IsNull())
219 cout << " Writing SDigitis to file galice.root "<< endl ;
221 cout << " Writing SDigitis to file " << (char*) fSDigitsFile.Data() << endl ;