X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=FMD%2FAliFMDDigitizer.cxx;h=c67b30c068e3ad1f05cecab4474d2a679b98c84b;hb=232daaa876bddda00ffd27548c7cc84f7f228929;hp=1d0dd1149dcf780d5e5b2194cd51c65076aec4f2;hpb=42f1b2f58c7412f4914c2eeaaf691707aeac83b7;p=u%2Fmrichter%2FAliRoot.git diff --git a/FMD/AliFMDDigitizer.cxx b/FMD/AliFMDDigitizer.cxx index 1d0dd1149dc..c67b30c068e 100644 --- a/FMD/AliFMDDigitizer.cxx +++ b/FMD/AliFMDDigitizer.cxx @@ -22,7 +22,7 @@ ////////////////////////////////////////////////////////////////////////////// // // This class contains the procedures simulation ADC signal for the -// Forward Multiplicity detector : Hits->Digits +// Forward Multiplicity detector : SDigits->Digits // // Digits consists of // - Detector # @@ -31,6 +31,14 @@ // - Strip # // - ADC count in this channel // +// Digits consists of +// - Detector # +// - Ring ID +// - Sector # +// - Strip # +// - Total energy deposited in the strip +// - ADC count in this channel +// // As the Digits and SDigits have so much in common, the classes // AliFMDDigitizer and AliFMDSDigitizer are implemented via a base // class AliFMDBaseDigitizer. @@ -45,6 +53,10 @@ // +-----------------+ +------------------+ // | AliFMDDigitizer | | AliFMDSDigitizer | // +-----------------+ +------------------+ +// | +// +-------------------+ +// | AliFMDSSDigitizer | +// +-------------------+ // // These classes has several paramters: // @@ -72,7 +84,6 @@ // we'd like have the option, and so it should be reflected in // the code. // -// These parameters are fetched from OCDB via the mananger AliFMDParameters. // // The shaping function of the VA1_ALICE is generally given by // @@ -190,10 +201,11 @@ // #include // ROOT_TTree -#include // ROOT_TRandom -#include "AliFMDDebug.h" // Better debug macros -#include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H +#include +#include "AliFMDDebug.h" // Better debug macros +#include "AliFMDDigitizer.h" // ALIFMDSSDIGITIZER_H #include "AliFMD.h" // ALIFMD_H +#include "AliFMDSDigit.h" // ALIFMDDIGIT_H #include "AliFMDDigit.h" // ALIFMDDIGIT_H #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H #include // ALIRUNDIGITIZER_H @@ -203,107 +215,216 @@ //==================================================================== ClassImp(AliFMDDigitizer) +#if 0 +; +#endif //____________________________________________________________________ -void -AliFMDDigitizer::OutputTree(AliLoader* outFMD, AliFMD* fmd) +Bool_t +AliFMDDigitizer::Init() { - // Load digits from the tree - outFMD->LoadDigits("update"); - - // Get the tree of digits - TTree* digitTree = outFMD->TreeD(); - if (!digitTree) { - outFMD->MakeTree("D"); - digitTree = outFMD->TreeD(); - } - digitTree->Reset(); + // Initialisation + if (!AliFMDBaseDigitizer::Init()) return kFALSE; - // Get the digits - TClonesArray* digits = fmd->Digits(); - if (!digits) { - AliError("Failed to get digits"); - return; +#if 0 + // Get the AliRun object + AliRun* run = fRunLoader->GetAliRun(); + if (!run) { + AliWarning("Loading gAlice"); + fRunLoader->LoadgAlice(); + if (!run) { + AliError("Can not get Run from Run Loader"); + return kFALSE; + } } - AliFMDDebug(1, ("Got a total of %5d digits", digits->GetEntries())); - - // Make a branch in the tree - fmd->MakeBranchInTree(digitTree, fmd->GetName(), &(digits), 4000, 0); - // TBranch* digitBranch = digitTree->GetBranch(fmd->GetName()); - // Fill the tree - Int_t write = 0; - write = digitTree->Fill(); - AliFMDDebug(1, ("Wrote %d bytes to digit tree", write)); - // Write the digits to disk - outFMD->WriteDigits("OVERWRITE"); - outFMD->UnloadHits(); - outFMD->UnloadDigits(); - - // Reset the digits in the AliFMD object - fmd->ResetDigits(); + // Get the AliFMD object + fFMD = static_cast(run->GetDetector("FMD")); + if (!fFMD) { + AliError("Can not get FMD from gAlice"); + return kFALSE; + } +#endif + return kTRUE; } -//____________________________________________________________________ -UShort_t -AliFMDDigitizer::MakePedestal(UShort_t detector, - Char_t ring, - UShort_t sector, - UShort_t strip) const -{ - // Make a pedestal - AliFMDParameters* param =AliFMDParameters::Instance(); - Float_t mean =param->GetPedestal(detector,ring,sector,strip); - Float_t width =param->GetPedestalWidth(detector,ring,sector,strip); - return UShort_t(TMath::Max(gRandom->Gaus(mean, width), 0.)); -} //____________________________________________________________________ void -AliFMDDigitizer::AddDigit(AliFMD* fmd, - UShort_t detector, - Char_t ring, - UShort_t sector, - UShort_t strip, - Float_t /* edep */, - UShort_t count1, - Short_t count2, - Short_t count3, - Short_t count4) const +AliFMDDigitizer::Exec(Option_t*) { - // Add a digit - fmd->AddDigitByFields(detector, ring, sector, strip, - count1, count2, count3, count4); + if (!fManager) { + AliError("No digitisation manager defined"); + return; + } + + // Clear array of deposited energies + fEdep.Reset(); + + AliRunLoader* runLoader = 0; + if (!gAlice) { + TString folderName(fManager->GetInputFolderName(0)); + runLoader = AliRunLoader::GetRunLoader(folderName.Data()); + if (!runLoader) { + AliError(Form("Failed at getting run loader from %s", + folderName.Data())); + return; + } + if (!runLoader->GetAliRun()) runLoader->LoadgAlice(); + runLoader->GetAliRun(); + } + if (!gAlice) { + AliError("Can not get Run from Run Loader"); + return; + } + + // Get the AliFMD object + fFMD = static_cast(gAlice->GetDetector("FMD")); + if (!fFMD) { + AliError("Can not get FMD from gAlice"); + return; + } + + + // Loop over input files + Int_t nFiles= fManager->GetNinputs(); + AliFMDDebug(1, (" Digitizing event number %d, got %d inputs", + fManager->GetOutputEventNr(), nFiles)); + for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) { + AliFMDDebug(5, ("Now reading input # %d", inputFile)); + // Get the current loader + AliRunLoader* currentLoader = + AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); + if (!currentLoader) { + Error("Exec", Form("no run loader for input file # %d", inputFile)); + continue; + } + + // Cache contriutions + AliFMDDebug(5, ("Now summing the contributions from input # %d",inputFile)); + + // Get the FMD loader + AliLoader* inFMD = currentLoader->GetLoader("FMDLoader"); + // And load the summable digits + inFMD->LoadSDigits("READ"); + + // Get the tree of summable digits + TTree* sdigitsTree = inFMD->TreeS(); + if (!sdigitsTree) { + AliError("No sdigit tree from manager"); + continue; + } + if (AliLog::GetDebugLevel("FMD","") >= 10) { + TFile* file = sdigitsTree->GetCurrentFile(); + if (!file) { + AliWarning("Input tree has no file!"); + } + else { + AliFMDDebug(10, ("Input tree file %s content:", file->GetName())); + file->ls(); + } + // AliFMDDebug(5, ("Input tree %s file structure:", + // sdigitsTree->GetName())); + // sdigitsTree->Print(); + } + + // Get the FMD branch + TBranch* sdigitsBranch = sdigitsTree->GetBranch("FMD"); + if (!sdigitsBranch) { + AliError("Failed to get sdigit branch"); + return; + } + + // Set the branch addresses + fFMD->SetTreeAddress(); + + // Sum contributions from the sdigits + AliFMDDebug(3, ("Will now sum contributions from SDigits")); + SumContributions(sdigitsBranch); + + // Unload the sdigits + inFMD->UnloadSDigits(); + } + + TString outFolder(fManager->GetOutputFolderName()); + AliRunLoader* out = AliRunLoader::GetRunLoader(outFolder.Data()); + AliLoader* outFMD = out->GetLoader("FMDLoader"); + if (!outFMD) { + AliError("Cannot get the FMDLoader output folder"); + return; + } + TTree* outTree = MakeOutputTree(outFMD); + if (!outTree) { + AliError("Failed to get output tree"); + return; + } + // Set the branch address + fFMD->SetTreeAddress(); + + // And digitize the cached data + DigitizeHits(); + + // Fill the tree + Int_t write = outTree->Fill(); + AliFMDDebug(5, ("Wrote %d bytes to digit tree", write)); + + // Store the digits + StoreDigits(outFMD); } //____________________________________________________________________ void -AliFMDDigitizer::CheckDigit(AliFMDDigit* digit, - UShort_t nhits, - const TArrayI& counts) +AliFMDDigitizer::SumContributions(TBranch* sdigitsBranch) { - // Check that digit is consistent - AliFMDParameters* param = AliFMDParameters::Instance(); - UShort_t det = digit->Detector(); - Char_t ring = digit->Ring(); - UShort_t sec = digit->Sector(); - UShort_t str = digit->Strip(); - Float_t mean = param->GetPedestal(det,ring,sec,str); - Float_t width = param->GetPedestalWidth(det,ring,sec,str); - UShort_t range = param->GetVA1MipRange(); - UShort_t size = param->GetAltroChannelSize(); - Int_t integral = counts[0]; - if (counts[1] >= 0) integral += counts[1]; - if (counts[2] >= 0) integral += counts[2]; - if (counts[3] >= 0) integral += counts[3]; - integral -= Int_t(mean + 2 * width); - if (integral < 0) integral = 0; + // Sum energy deposited contributions from each sdigits in a cache + // (fEdep). + AliFMDDebug(3, ("Runnin our version of SumContributions")); + + // Get a list of hits from the FMD manager + TClonesArray *fmdSDigits = fFMD->SDigits(); - Float_t convF = Float_t(range) / size; - Float_t mips = integral * convF; - if (mips > Float_t(nhits) + .5 || mips < Float_t(nhits) - .5) - Warning("CheckDigit", "Digit -> %4.2f MIPS != %d +/- .5 hits", - mips, nhits); + // Get number of entries in the tree + Int_t nevents = Int_t(sdigitsBranch->GetEntries()); + + Int_t read = 0; + // Loop over the events in the + for (Int_t event = 0; event < nevents; event++) { + // Read in entry number `event' + read += sdigitsBranch->GetEntry(event); + + // Get the number of sdigits + Int_t nsdigits = fmdSDigits->GetEntries (); + AliFMDDebug(3, ("Got %5d SDigits", nsdigits)); + for (Int_t sdigit = 0; sdigit < nsdigits; sdigit++) { + // Get the sdigit number `sdigit' + AliFMDSDigit* fmdSDigit = + static_cast(fmdSDigits->UncheckedAt(sdigit)); + + AliFMDDebug(5, ("Adding contribution of %d tracks", + fmdSDigit->GetNTrack())); + AliFMDDebug(15, ("Contrib from FMD%d%c[%2d,%3d] (%s) from track %d", + fmdSDigit->Detector(), + fmdSDigit->Ring(), + fmdSDigit->Sector(), + fmdSDigit->Strip(), + fmdSDigit->GetName(), + fmdSDigit->GetTrack(0))); + + // Extract parameters + AddContribution(fmdSDigit->Detector(), + fmdSDigit->Ring(), + fmdSDigit->Sector(), + fmdSDigit->Strip(), + fmdSDigit->Edep(), + kTRUE, + fmdSDigit->GetNTrack(), + fmdSDigit->GetTracks()); + } // sdigit loop + } // event loop + + + AliFMDDebug(3, ("Size of cache: %d bytes, read %d bytes", + int(sizeof(fEdep)), read)); } //____________________________________________________________________