#include "AliRunDigitizer.h"
#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliLoader.h"
#include "AliPDG.h"
#include <stdlib.h>
-#include <iostream.h>
-#include <fstream.h>
+#include <Riostream.h>
ClassImp(AliTOFDigitizer)
sprintf (branchname, "%s", tof->GetName ());
fDigits=new TClonesArray("AliTOFdigit",4000);
-
- TTree* treeD = fManager->GetTreeD();
+
+ AliRunLoader* outrl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+ if (outrl == 0x0)
+ {
+ Error("Exec","Can not find Run Loader in output folder.");
+ return;
+ }
+
+ AliLoader* outgime = outrl->GetLoader("TOFLoader");
+ if (outgime == 0x0)
+ {
+ Error("Exec","Can not get TOF Loader from Output Run Loader.");
+ return;
+ }
+
+ TTree* treeD = outgime->TreeD();
+ if (treeD == 0x0)
+ {
+ outgime->MakeTree("D");
+ treeD = outgime->TreeD();
+ }
//Make branch for digits (to be created in Init())
tof->MakeBranchInTree(treeD,branchname,&fDigits,4000);
for (Int_t inputFile=0; inputFile<fManager->GetNinputs();
inputFile++) {
ReadSDigit(inputFile);
- }
+ }
// create digits
CreateDigits();
fSDigitsArray->Delete();
treeD->Fill();
- fManager->GetTreeD()->AutoSave(); // to fit with the framework
+ outgime->WriteDigits("OVERWRITE");
+ outgime->UnloadDigits();
fDigits->Delete();
delete fDigits;
tracknum[1]=tofsdigit->GetTrack(islot,1);
tracknum[2]=tofsdigit->GetTrack(islot,2);
-
+ // new with placement must be used
// adding a TOF digit for each slot
- AliTOFdigit* newDigit=new AliTOFdigit(tracknum, vol, digit);
- fDigits->Add(newDigit);
+ TClonesArray &aDigits = *fDigits;
+ Int_t last=fDigits->GetEntriesFast();
+ new (aDigits[last]) AliTOFdigit(tracknum, vol, digit);
+
}
} // end loop on sdigits - end digitizing all collected sdigits
// be created with the same simulation parameters.
// get the treeS from manager
- TTree* currentTreeS=fManager->GetInputTreeS(inputFile);
-
+ AliRunLoader* rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+ if (rl == 0x0)
+ {
+ Error("ReadSDigit","Can not find Run Loader in input %d folder.",inputFile);
+ return;
+ }
+
+ AliLoader* gime = rl->GetLoader("TOFLoader");
+ if (gime == 0x0)
+ {
+ Error("ReadSDigit","Can not get TOF Loader from Input %d Run Loader.",inputFile);
+ return;
+ }
+
+ TTree* currentTreeS=gime->TreeS();
+ if (currentTreeS == 0x0)
+ {
+ Int_t retval = gime->LoadSDigits();
+ if (retval)
+ {
+ Error("ReadSDigit","Error occured while loading S. Digits for Input %d",inputFile);
+ return;
+ }
+ currentTreeS=gime->TreeS();
+ if (currentTreeS == 0x0)
+ {
+ Error("ReadSDigit","Can not get S. Digits Tree for Input %d",inputFile);
+ return;
+ }
+ }
// get the branch TOF inside the treeS
TClonesArray * sdigitsDummyContainer= new TClonesArray("AliTOFSDigit", 1000);
void AliTOFDigitizer::CollectSDigit(AliTOFSDigit * sdigit)
{
//
- // Add a TOF digit
- // new with placement used
- AliTOFSDigit sdigitCopy=AliTOFSDigit(*sdigit); // make a copy of the current sdigit
- fSDigitsArray->Add(&sdigitCopy); // put it into tmp array
+ // Add a TOF sdigit in container
+ // new with placement must be used
+ TClonesArray &aSDigitsArray = *fSDigitsArray;
+ Int_t last=fSDigitsArray->GetEntriesFast();
+ // make a copy of the current sdigit and
+ // put it into tmp array
+ new (aSDigitsArray[last]) AliTOFSDigit(*sdigit);
}