#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();
// free used memory for Hit Map in current event
delete fhitMap;
fSDigitsArray->Delete();
+ delete fSDigitsArray;
+
treeD->Fill();
- fManager->GetTreeD()->AutoSave(); // to fit with the framework
+ outgime->WriteDigits("OVERWRITE");
+ outgime->UnloadDigits();
fDigits->Delete();
delete fDigits;
// loop on sdigits container to fill the AliTOFdigit TClonesArray
// start digitizing all the collected sdigits
- Int_t ndump=15; // dump the first ndump created digits for each event
+ Int_t ndump=0; // dump the first ndump created digits for each event
// get the total number of collected sdigits
Int_t ndig = fSDigitsArray->GetEntriesFast();
for (Int_t k = 0; k < ndig; k++) {
- Int_t vol[5]; // location for a digit
+ Int_t vol[5]; // location for a digit
+ for (Int_t i=0; i<5; i++) vol[i] = -1;
// Get the information for this digit
AliTOFSDigit *tofsdigit = (AliTOFSDigit *) fSDigitsArray->UncheckedAt(k);
// for current sdigit
// TOF sdigit volumes (always the same for all slots)
- Int_t sector = tofsdigit->GetSector(); // range [1-18]
- Int_t plate = tofsdigit->GetPlate(); // range [1- 5]
- Int_t strip = tofsdigit->GetStrip(); // range [1-20]
- Int_t padz = tofsdigit->GetPadz(); // range [1- 2]
- Int_t padx = tofsdigit->GetPadx(); // range [1-48]
+ Int_t sector = tofsdigit->GetSector(); // range [0-17]
+ Int_t plate = tofsdigit->GetPlate(); // range [0- 4]
+ Int_t strip = tofsdigit->GetStrip(); // range [0-19]
+ Int_t padz = tofsdigit->GetPadz(); // range [0- 1]
+ Int_t padx = tofsdigit->GetPadx(); // range [0-47]
vol[0] = sector;
vol[1] = plate;
//--------------------- QA section ----------------------
// in the while, I perform QA
- Bool_t isSDigitBad = (sector<1 || sector>18 || plate<1 || plate >5 || padz<1 || padz>2 || padx<1 || padx>48);
+ Bool_t isSDigitBad = (sector<0 || sector>17 || plate<0 || plate >4 || padz<0 || padz>1 || padx<0 || padx>47);
if (isSDigitBad) {
cout << "<AliTOFSDigits2Digits> strange sdigit found" << endl;
// 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);
Int_t nEntries = (Int_t)tofBranch->GetEntries();
// Loop through all entries in the tree
- Int_t nbytes;
+ Int_t nbytes = 0;
for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
for (Int_t k=0; k<ndig; k++) {
AliTOFSDigit *tofSdigit= (AliTOFSDigit*) sdigitsDummyContainer->UncheckedAt(k);
- Int_t vol[5]; // location for a sdigit
-
+ Int_t vol[5]; // location for a sdigit
+ for (Int_t i=0; i<5; i++) vol[i] = -1;
+
// check the sdigit volume
vol[0] = tofSdigit->GetSector();
vol[1] = tofSdigit->GetPlate();
} // if (hitMap->TestHit(vol) != kEmpty)
} // for (Int_t k=0; k<ndig; k++)
+ sdigitsDummyContainer->Delete();
} // end loop on entries
- sdigitsDummyContainer->Delete();
- sdigitsDummyContainer=0;
+ delete sdigitsDummyContainer;
}