1 /**************************************************************************
2 * Copyright(c) 1998-2000, 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 **************************************************************************/
15 //Piotr.Skowronski@cern.ch
16 //Fast fixes to be able to compile with new Folder and I/O structure
17 //To be implemented correctly by the responsible person
19 //PH 20/05/2003 It seems this class is obsolete and not used anymore
23 #include "AliFMDMerger.h"
28 #include <TObjArray.h>
30 #include <TDirectory.h>
32 #include "AliDetector.h"
33 #include "AliRunLoader.h"
34 #include "AliLoader.h"
37 #include "AliFMDSDigitizer.h"
38 #include "AliFMDhit.h"
39 #include "AliFMDdigit.h"
45 #include <Riostream.h>
46 #include <Riostream.h>
48 ClassImp(AliFMDMerger)
50 //___________________________________________
51 AliFMDMerger::AliFMDMerger()
53 // Default constructor
66 //------------------------------------------------------------------------
67 AliFMDMerger::~AliFMDMerger()
78 //---------------------------------------------------------------------
79 void AliFMDMerger::SetRingsSi1(Int_t ringsSi1)
83 void AliFMDMerger::SetSectorsSi1(Int_t sectorsSi1)
85 fSectorsSi1=sectorsSi1;
87 void AliFMDMerger::SetRingsSi2(Int_t ringsSi2)
91 void AliFMDMerger::SetSectorsSi2(Int_t sectorsSi2)
93 fSectorsSi2=sectorsSi2;
95 //---------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 void AliFMDMerger::Init()
101 if (fMerge) fBgrFile = InitBgr();
106 //------------------------------------------------------------------------
107 TFile* AliFMDMerger::InitBgr()
109 // Initialise background event
110 fBgrLoader= AliRunLoader::Open(fFnBgr);
111 TFile *file = TFile::Open(fFnBgr);
112 // add error checking later
113 printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr);
117 //------------------------------------------------------------------------
118 void AliFMDMerger::Digitise()
121 // keep galice.root for signal and name differently the file for
122 // background when add! otherwise the track info for signal will be lost !
127 cout<<"ALiFMDMerger::>SDigits2Digits start...\n";
129 if (fBgrLoader == 0x0)
131 cerr<<"AliFMDMerger::Digitise : Background Run Loader is NULL"<<endl;
135 fBgrLoader->LoadgAlice();
136 fBgrLoader->LoadHeader();
137 fBgrLoader->LoadKinematics();
139 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
141 Int_t chargeSum[10][30][150];
143 Int_t ivol, iSector, iRing;
145 Int_t NumberOfRings[5]=
146 {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1};
147 Int_t NumberOfSectors[5]=
148 {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1};
151 TTree *TK = fBgrLoader->TreeK();
152 if (TK) f1 = TK->GetCurrentFile();
154 //just patches to be able to compile
157 fBgrLoader->GetEvent(fEvNrSig) ;
158 AliLoader* loader = fBgrLoader->GetLoader("FMDLoader");
161 cerr<<"AliFMDMerger::Digitise : Can not find loader for FMD. Exiting"<<endl;
166 retval = loader->LoadDigits("UPDATE");
169 cerr<<"AliFMDMerger::Digitise : Error occured while loading digits. Exiting"<<endl;
173 if(loader->TreeD() == 0)
174 loader->MakeTree("D") ;
176 loader->TreeD()->Reset();
179 ReadDigit( chargeSum, fEvNrSig);
183 // gAlice->TreeS()->Reset();
184 gAlice = fBgrLoader->GetAliRun();
185 Int_t chargeBgr[10][30][150];
186 ReadDigit( chargeBgr,fEvNrBgr);
187 for ( ivol=1; ivol<=5; ivol++)
188 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++)
189 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++)
190 chargeSum[ivol][iSector][iRing]=
191 chargeBgr[ivol][iSector][iRing]+
192 chargeSum[ivol][iSector][iRing];
197 // Put noise and make ADC signal
198 for ( ivol=1; ivol<=5; ivol++){
199 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){
200 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){
204 digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]);
205 if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500;
207 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
209 Float_t channelWidth=(22400*50)/1024;
210 digit[4]=Int_t(digit[3]/channelWidth);
211 if (digit[4]>1024) digit[4]=1024;
213 FMD->AddDigit(digit);
221 //Make branch for digits
222 FMD->MakeBranch("D");
224 loader->TreeD()->Reset();
225 loader->TreeD()->Fill();
227 fDigits = FMD->Digits();//should be moved to specialized loader (AliFMDLoader)
229 loader->WriteDigits("OVERWRITE");
231 gAlice->ResetDigits();
235 //---------------------------------------------------------------------
237 void AliFMDMerger::ReadDigit(Int_t chargeSum[][30][150], Int_t iEvNum)
239 AliFMDdigit *fmddigit;
241 for (Int_t i=0; i<10; i++)
242 for(Int_t j=0; j<30; j++)
243 for(Int_t ij=0; ij<150; ij++)
244 chargeSum[i][j][ij]=0;
246 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
248 gAlice->GetEvent(iEvNum) ;
249 if(gAlice->TreeS()==0) {
250 cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
254 gAlice->ResetDigits();
255 gAlice->TreeS()->GetEvent(iEvNum);
256 TClonesArray * FMDdigits = FMD->SDigits();
258 ndig=FMDdigits->GetEntries();
260 for (k=0; k<ndig; k++) {
261 fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k);
263 Int_t iVolume=fmddigit->Volume();
264 Int_t iNumberOfSector =fmddigit->NumberOfSector();
265 Int_t iNumberOfRing=fmddigit->NumberOfRing();
266 chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge();