* provided "as is" without express or implied warranty. *
**************************************************************************/
-
#include <TTree.h>
#include <TVector.h>
#include <TObjArray.h>
//___________________________________________
AliTOFMerger::AliTOFMerger()
{
-// Default constructor
+// Default ctor
+ fNDigits = 0;
fEvNrSig = 0;
fEvNrBgr = 0;
fMerge =kDigitize;
//------------------------------------------------------------------------
AliTOFMerger::~AliTOFMerger()
{
-// Destructor
+// Dtor
if(fSDigits) {
fSDigits->Delete();
delete fSDigits ;
//------------------------------------------------------------------------
void AliTOFMerger::Digitise()
{
+// as in FMD
+// keep galice.root for signal and name differently the file for
+// background when add! otherwise the track info for signal will be lost !
+
+
#ifdef DEBUG
cout<<"ALiTOFMerger::>SDigits2Digits start...\n";
#endif
+
+ AliTOF* TOF = (AliTOF *) gAlice->GetDetector("TOF") ;
+
+
+ TFile *f1 =0;
+ TTree *TK = gAlice->TreeK();
+ if (TK) f1 = TK->GetCurrentFile();
+
+ gAlice->GetEvent(fEvNrSig) ;
+
+ if(gAlice->TreeD() == 0)
+ gAlice->MakeTree("D") ;
+ gAlice->TreeD()->Reset();
+
+ // read and write digits for signal
+ ReadWriteDigit(fEvNrSig);
+
+ if(fMerge){
+ // bgr file
+ fBgrFile->cd();
+ // gAlice->TreeS()->Reset();
+ gAlice = (AliRun*)fBgrFile->Get("gAlice");
+ ReadWriteDigit(fEvNrBgr);
+ } //if merge
+
+
+ f1->cd();
+
+ //Make branch for digits
+ TOF->MakeBranch("D");
+
+ gAlice->TreeD()->Reset();
+ gAlice->TreeD()->Fill();
+
+ fDigits = TOF->Digits();
+
+ gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
+
+ gAlice->ResetDigits();
+
+}
+
+//---------------------------------------------------------------------
+
+void AliTOFMerger::ReadWriteDigit(Int_t iEvNum)
+{
+//
+// Read Sdigits from the current file and write them in the TreeD
+//
+ AliTOFdigit* tofsdigit;
+
+ AliTOF * tofinfile = (AliTOF *) gAlice->GetDetector("TOF") ;
+
+ gAlice->GetEvent(iEvNum) ;
+ if(gAlice->TreeS()==0) {
+ cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
+ return ;}
+
+ Int_t ndig, k;
+ Int_t tracks[3]; // track info
+ Int_t vol[5]; // location for a digit
+ Float_t digit[2]; // TOF digit variables
+
+ gAlice->ResetDigits();
+ gAlice->TreeS()->GetEvent(iEvNum);
+ TClonesArray * TOFdigits = tofinfile->SDigits();
+
+ ndig=TOFdigits->GetEntries();
+
+ for (k=0; k<ndig; k++) {
+ tofsdigit= (AliTOFdigit*) TOFdigits->UncheckedAt(k);
+
+ tracks[0] = tofsdigit->GetTrack(0);
+ tracks[1] = tofsdigit->GetTrack(1);
+ tracks[2] = tofsdigit->GetTrack(2);
+
+ vol[0] = tofsdigit->GetSector();
+ vol[1] = tofsdigit->GetPlate();
+ vol[2] = tofsdigit->GetPadx();
+ vol[3] = tofsdigit->GetPadz();
+ vol[4] = tofsdigit->GetStrip();
+
+ digit[0] = tofsdigit->GetTdc();
+ digit[1] = tofsdigit->GetAdc();
+
+ new ((*fDigits)[fNDigits++]) AliTOFdigit(tracks, vol, digit);
+ } // end loop on sdigits in the current file
}
+
+
+
// #include "AliMergable.h"
#include "TRandom.h"
#include "AliDetector.h"
+#include "AliTOF.h"
typedef enum {kDigitize=0, kMerge = 1} MergeMode_t;
// Do the main work
void Digitise() ;
- // Int_t PutEdgeEffect(Int_t charge){return (Int_t)(gRandom->Gaus(charge,500));}
TClonesArray *SDigits() const {return fSDigits;}
- // void ReadDigit(Int_t a[][30][150], Int_t);
+ void ReadWriteDigit(Int_t);
// Setters -> Later Communication with gAlice
void SetSignalEventNumber(Int_t i) {fEvNrSig = i;}
void SetSignalFileName(char* file) {fFnSig = file;}
void SetMode(MergeMode_t mode) {fMerge = mode;}
-
enum {kBgTag = -1};
private:
private:
TClonesArray *fDigits; // ! array with digits
TClonesArray *fSDigits ; // List of summable digits
+ Int_t fNDigits; // number of digits
Int_t fEvNrSig; // signal event number
Int_t fEvNrBgr; // background event number
MergeMode_t fMerge; // merging type kDigitize, kMerge
};
#endif
-
-