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 **************************************************************************/
18 Revision 1.3 2001/03/05 23:57:44 morsch
19 Writing of digit tree moved to macro.
21 Revision 1.2 2001/03/05 08:40:25 morsch
22 Method SortTracks(..) imported from AliMUON.
24 Revision 1.1 2001/02/02 14:11:53 morsch
25 AliMUONMerger prototype to be called by the merge manager.
31 #include <TObjArray.h>
33 #include <TDirectory.h>
36 #include "AliFMDMerger.h"
38 #include "AliFMDSDigitizer.h"
39 #include "AliFMDhit.h"
40 #include "AliFMDdigit.h"
49 ClassImp(AliFMDMerger)
51 //___________________________________________
52 AliFMDMerger::AliFMDMerger()
54 // Default constructor
61 //------------------------------------------------------------------------
62 AliFMDMerger::~AliFMDMerger()
74 //------------------------------------------------------------------------
75 void AliFMDMerger::Init()
78 if (fMerge) fBgrFile = InitBgr();
84 //------------------------------------------------------------------------
85 TFile* AliFMDMerger::InitBgr()
87 // Initialise background event
88 TFile *file = new TFile(fFnBgr);
89 // add error checking later
90 printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr);
94 //------------------------------------------------------------------------
95 void AliFMDMerger::Digitise()
98 // keep galice.root for signal and name differently the file for
99 // background when add! otherwise the track info for signal will be lost !
104 cout<<"ALiFMD::>SDigits2Digits start...\n";
107 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
109 Int_t chargeSum[10][20][150];
111 Int_t ivol, iSector, iRing;
114 TTree *TK = gAlice->TreeK();
115 if (TK) f1 = TK->GetCurrentFile();
117 gAlice->GetEvent(fEvNrSig) ;
119 if(gAlice->TreeD() == 0)
120 gAlice->MakeTree("D") ;
121 gAlice->TreeD()->Reset();
124 ReadDigit( chargeSum, fEvNrSig);
128 // gAlice->TreeS()->Reset();
129 gAlice = (AliRun*)fBgrFile->Get("gAlice");
130 Int_t chargeBgr[10][20][150];
131 ReadDigit( chargeBgr,fEvNrBgr);
132 for ( ivol=1; ivol<=5; ivol++)
133 for ( iSector=1; iSector<=16; iSector++)
134 for ( iRing=1; iRing<=128; iRing++)
135 chargeSum[ivol][iSector][iRing]=
136 chargeBgr[ivol][iSector][iRing]+
137 chargeSum[ivol][iSector][iRing];
142 // Put noise and make ADC signal
143 for ( ivol=1; ivol<=5; ivol++){
144 for ( iSector=1; iSector<=16; iSector++){
145 for ( iRing=1; iRing<=128; iRing++){
149 digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]);
150 if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500;
152 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
154 Float_t channelWidth=(22400*50)/1024;
155 digit[4]=Int_t(digit[3]/channelWidth);
156 if (digit[4]>1024) digit[4]=1024;
158 FMD->AddDigit(digit);
166 //Make branch for digits
167 FMD->MakeBranch("D");
169 gAlice->TreeD()->Reset();
170 gAlice->TreeD()->Fill();
172 fDigits = FMD->Digits();
174 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
176 gAlice->ResetDigits();
180 //---------------------------------------------------------------------
182 void AliFMDMerger::ReadDigit(Int_t chargeSum[][20][150], Int_t iEvNum)
184 AliFMDdigit *fmddigit;
186 for (Int_t i=0; i<10; i++)
187 for(Int_t j=0; j<20; j++)
188 for(Int_t ij=0; ij<150; ij++)
189 chargeSum[i][j][ij]=0;
191 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
193 gAlice->GetEvent(iEvNum) ;
194 if(gAlice->TreeS()==0) {
195 cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
199 gAlice->ResetDigits();
200 gAlice->TreeS()->GetEvent(iEvNum);
201 TClonesArray * FMDdigits = FMD->SDigits();
203 ndig=FMDdigits->GetEntries();
205 for (k=0; k<ndig; k++) {
206 fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k);
208 Int_t iVolume=fmddigit->Volume();
209 Int_t iNumberOfSector =fmddigit->NumberOfSector();
210 Int_t iNumberOfRing=fmddigit->NumberOfRing();
211 chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge();