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 #include <TObjArray.h>
20 #include <TDirectory.h>
23 #include "AliTOFMerger.h"
25 #include "AliTOFSDigitizer.h"
26 #include "AliTOFhit.h"
27 #include "AliTOFdigit.h"
36 ClassImp(AliTOFMerger)
38 //___________________________________________
39 AliTOFMerger::AliTOFMerger()
53 //------------------------------------------------------------------------
54 AliTOFMerger::~AliTOFMerger()
75 //------------------------------------------------------------------------
76 void AliTOFMerger::Init()
79 if (fMerge) fBgrFile = InitBgr();
85 //------------------------------------------------------------------------
86 TFile* AliTOFMerger::InitBgr()
88 // Initialise background event
89 TFile *file = new TFile(fFnBgr);
90 // add error checking later
91 printf("\n AliTOFMerger has opened %s file with background event \n", fFnBgr);
95 //------------------------------------------------------------------------
96 void AliTOFMerger::Digitise()
99 // keep galice.root for signal and name differently the file for
100 // background when add! otherwise the track info for signal will be lost !
105 cout<<"ALiTOFMerger::>SDigits2Digits start...\n";
108 AliTOF* TOF = (AliTOF *) gAlice->GetDetector("TOF") ;
112 TTree *TK = gAlice->TreeK();
113 if (TK) f1 = TK->GetCurrentFile();
115 gAlice->GetEvent(fEvNrSig) ;
117 if(gAlice->TreeD() == 0)
118 gAlice->MakeTree("D") ;
119 gAlice->TreeD()->Reset();
121 // read and write digits for signal
122 ReadWriteDigit(fEvNrSig);
127 // gAlice->TreeS()->Reset();
128 gAlice = (AliRun*)fBgrFile->Get("gAlice");
129 ReadWriteDigit(fEvNrBgr);
135 //Make branch for digits
136 TOF->MakeBranch("D");
138 gAlice->TreeD()->Reset();
139 gAlice->TreeD()->Fill();
141 fDigits = TOF->Digits();
143 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
145 gAlice->ResetDigits();
149 //---------------------------------------------------------------------
151 void AliTOFMerger::ReadWriteDigit(Int_t iEvNum)
154 // Read Sdigits from the current file and write them in the TreeD
156 AliTOFdigit* tofsdigit;
158 AliTOF * tofinfile = (AliTOF *) gAlice->GetDetector("TOF") ;
160 gAlice->GetEvent(iEvNum) ;
161 if(gAlice->TreeS()==0) {
162 cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
166 Int_t tracks[3]; // track info
167 Int_t vol[5]; // location for a digit
168 Float_t digit[2]; // TOF digit variables
170 gAlice->ResetDigits();
171 gAlice->TreeS()->GetEvent(iEvNum);
172 TClonesArray * TOFdigits = tofinfile->SDigits();
174 ndig=TOFdigits->GetEntries();
176 for (k=0; k<ndig; k++) {
177 tofsdigit= (AliTOFdigit*) TOFdigits->UncheckedAt(k);
179 tracks[0] = tofsdigit->GetTrack(0);
180 tracks[1] = tofsdigit->GetTrack(1);
181 tracks[2] = tofsdigit->GetTrack(2);
183 vol[0] = tofsdigit->GetSector();
184 vol[1] = tofsdigit->GetPlate();
185 vol[2] = tofsdigit->GetStrip();
186 vol[3] = tofsdigit->GetPadx();
187 vol[4] = tofsdigit->GetPadz();
189 digit[0] = tofsdigit->GetTdc();
190 digit[1] = tofsdigit->GetAdc();
192 new ((*fDigits)[fNDigits++]) AliTOFdigit(tracks, vol, digit);
193 } // end loop on sdigits in the current file