From 42f1b2f58c7412f4914c2eeaaf691707aeac83b7 Mon Sep 17 00:00:00 2001 From: cholm Date: Mon, 18 Aug 2008 00:33:20 +0000 Subject: [PATCH] Fixes for SDigit generation. First attempt at making SDigit->Digit conversion, by introducing class AliFMDSSDigitizer. --- FMD/AliFMD.cxx | 56 +++++++++++++++-- FMD/AliFMD.h | 7 +++ FMD/AliFMDBaseDigitizer.cxx | 122 +++++++++++++++++++++++++++++++++--- FMD/AliFMDBaseDigitizer.h | 17 ++++- FMD/AliFMDDetector.cxx | 2 +- FMD/AliFMDDigitizer.cxx | 89 +++++--------------------- FMD/AliFMDDigitizer.h | 12 ++-- FMD/AliFMDDisplay.cxx | 44 +++++++++++-- FMD/AliFMDDisplay.h | 4 ++ FMD/AliFMDInput.cxx | 52 ++++++++++++--- FMD/AliFMDInput.h | 6 +- FMD/AliFMDParameters.cxx | 14 ++--- FMD/AliFMDPattern.cxx | 3 + FMD/AliFMDSDigitizer.cxx | 86 +++++++++++++++---------- FMD/AliFMDSDigitizer.h | 20 +++--- FMD/FMDsimLinkDef.h | 2 + FMD/libFMDsim.pkg | 1 + FMD/scripts/PatternDigits.C | 2 + FMD/scripts/PatternHits.C | 2 + 19 files changed, 382 insertions(+), 159 deletions(-) diff --git a/FMD/AliFMD.cxx b/FMD/AliFMD.cxx index 19191149f09..9ee54f22086 100644 --- a/FMD/AliFMD.cxx +++ b/FMD/AliFMD.cxx @@ -113,6 +113,10 @@ #include "AliFMDRing.h" // ALIFMDRING_H #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H #include "AliFMDSDigitizer.h" // ALIFMDSDIGITIZER_H +// #define USE_SSDIGITIZER +#ifdef USE_SSDIGITIZER +# include "AliFMDSSDigitizer.h" // ALIFMDSDIGITIZER_H +#endif // #include "AliFMDGeometryBuilder.h" #include "AliFMDRawWriter.h" // ALIFMDRAWWRITER_H #include "AliFMDPoints.h" // ALIFMDPOINTS_H @@ -756,6 +760,13 @@ AliFMD::SetHitsAddressBranch(TBranch *b) // Set the TClonesArray to read hits into. b->SetAddress(&fHits); } +//____________________________________________________________________ +void +AliFMD::SetSDigitsAddressBranch(TBranch *b) +{ + // Set the TClonesArray to read hits into. + b->SetAddress(&fSDigits); +} //____________________________________________________________________ void @@ -982,6 +993,7 @@ AliFMD::AddSDigitByFields(UShort_t detector, // count3 ADC count (a 10-bit word), or -1 if not used // TClonesArray& a = *(SDigitsArray()); + // AliFMDDebug(0, ("Adding sdigit # %d", fNsdigits)); new (a[fNsdigits++]) AliFMDSDigit(detector, ring, sector, strip, edep, @@ -1046,13 +1058,14 @@ AliFMD::Hits2Digits() // Create AliFMDDigit's from AliFMDHit's. This is done by making a // AliFMDDigitizer, and executing that code. // +#if 0 Warning("Hits2Digits", "Try not to use this method.\n" "Instead, use AliSimulator"); +#endif AliRunDigitizer* manager = new AliRunDigitizer(1, 1); manager->SetInputStream(0, "galice.root"); - manager->SetOutputFile("H2Dfile"); - - /* AliDigitizer* dig =*/ CreateDigitizer(manager); + manager->SetOutputFile("H2Dfile.root"); + new AliFMDDigitizer(manager); manager->Exec(""); delete manager; } @@ -1064,9 +1077,25 @@ AliFMD::Hits2SDigits() // Create AliFMDSDigit's from AliFMDHit's. This is done by creating // an AliFMDSDigitizer object, and executing it. // + +#if 0 + Warning("Hits2SDigits", "Try not to use this method.\n" + "Instead, use AliSimulator"); + // Create AliFMDSDigit's from AliFMDHit's. This is done by creating + // an AliFMDSDigitizer object, and executing it. + // AliFMDSDigitizer* digitizer = new AliFMDSDigitizer("galice.root"); digitizer->Exec(""); delete digitizer; +#endif + AliRunDigitizer* manager = new AliRunDigitizer(1, 1); + manager->SetInputStream(0, "galice.root"); + // manager->SetOutputFile("H2Sfile.root"); + + new AliFMDSDigitizer(manager); + manager->Exec(""); + // Hmm! + delete manager; } @@ -1075,7 +1104,26 @@ AliDigitizer* AliFMD::CreateDigitizer(AliRunDigitizer* manager) const { // Create a digitizer object - AliFMDDigitizer* digitizer = new AliFMDDigitizer(manager); + + /* This is what we probably _should_ do */ + AliFMDBaseDigitizer* digitizer = 0; + +#ifdef USE_SSDIGITIZER + digitizer = new AliFMDSSDigitizer(manager); +#else + /* This is what we actually do, and will work */ + AliInfo("SDigit->Digit conversion not really supported, " + "doing Hit->Digit conversion instead"); + digitizer = new AliFMDDigitizer(manager); +#endif + return digitizer; +} +//____________________________________________________________________ +AliDigitizer* +AliFMD::CreateSDigitizer(AliRunDigitizer* manager) const +{ + // Create a digitizer object + AliFMDSDigitizer* digitizer = new AliFMDSDigitizer(manager); return digitizer; } diff --git a/FMD/AliFMD.h b/FMD/AliFMD.h index da763b25927..87fff7825e3 100644 --- a/FMD/AliFMD.h +++ b/FMD/AliFMD.h @@ -362,6 +362,9 @@ public: /** Set the TClonesArray to read hits into. @param b The branch to containn the hits */ virtual void SetHitsAddressBranch(TBranch *b); + /** Set the TClonesArray to read sdigits into. + @param b The branch to containn the sdigits */ + virtual void SetSDigitsAddressBranch(TBranch *b); /** Set branch address for the Hits, Digits, and SDigits Tree. */ virtual void SetTreeAddress(); /** Get the array of summable digits @@ -483,6 +486,10 @@ public: @param manager Digitization manager @return a newly allocated AliFMDDigitizer */ virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const; + /** Create a digitizer object + @param manager Digitization manager + @return a newly allocated AliFMDSDigitizer */ + virtual AliDigitizer* CreateSDigitizer(AliRunDigitizer* manager) const; /** Create AliFMDDigit's from AliFMDHit's. This is done by creating an AliFMDDigitizer object, and executing it. */ virtual void Hits2Digits(); diff --git a/FMD/AliFMDBaseDigitizer.cxx b/FMD/AliFMDBaseDigitizer.cxx index 4bc8ecacf20..bda9c775b8d 100644 --- a/FMD/AliFMDBaseDigitizer.cxx +++ b/FMD/AliFMDBaseDigitizer.cxx @@ -212,6 +212,7 @@ // #include // ALIRUNDIGITIZER_H //#include // ALIRUN_H #include // ALILOADER_H +#include // ALILOADER_H #include // ALIRUNLOADER_H //==================================================================== @@ -229,6 +230,7 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer() AliFMDMap::kMaxStrips), fShapingTime(6) { + AliFMDDebug(1, ("Constructed")); // Default ctor - don't use it } @@ -243,7 +245,7 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer(AliRunDigitizer* manager) fShapingTime(6) { // Normal CTOR - AliFMDDebug(1, (" processed")); + AliFMDDebug(1, ("Constructed")); SetShapingTime(); } @@ -259,7 +261,7 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer(const Char_t* name, fShapingTime(6) { // Normal CTOR - AliFMDDebug(1, (" processed")); + AliFMDDebug(1, (" Constructed")); SetShapingTime(); } @@ -279,7 +281,100 @@ AliFMDBaseDigitizer::Init() AliFMDParameters::Instance()->Print("ALL"); return kTRUE; } - + +//____________________________________________________________________ +void +AliFMDBaseDigitizer::Exec(Option_t* /*option*/) +{ + AliFMDDebug(1, ("Executing digitizer")); + AliFMD* fmd = 0; + AliLoader* outFMD = 0; + if (!SetupLoaders(fmd, outFMD)) return; + if (!LoopOverInput(fmd)) return; + + // Digitize the event + DigitizeHits(fmd); + + // Make the output + AliFMDDebug(5, ("Calling output tree")); + OutputTree(outFMD, fmd); +} + + +//____________________________________________________________________ +Bool_t +AliFMDBaseDigitizer::SetupLoaders(AliFMD*& fmd, AliLoader*& outFMD) +{ + // Set-up input/output loaders. + AliFMDDebug(5, ("Setting up run-loaders")); + + // Get the output manager and the FMD output manager + TString outFolder(fManager->GetOutputFolderName()); + AliRunLoader* out = AliRunLoader::GetRunLoader(outFolder.Data()); + outFMD = out->GetLoader("FMDLoader"); + if (!outFMD) { + AliError("Cannot get the FMDLoader output folder"); + return kFALSE; + } + + // Get the input loader + TString inFolder(fManager->GetInputFolderName(0)); + fRunLoader = AliRunLoader::GetRunLoader(inFolder.Data()); + if (!fRunLoader) { + AliError("Can not find Run Loader for input stream 0"); + return kFALSE; + } + + // Get the AliRun object + if (!fRunLoader->GetAliRun()) { + AliWarning("Loading gAlice"); + fRunLoader->LoadgAlice(); + } + + // Get the AliRun object + AliRun* run = fRunLoader->GetAliRun(); + if (!run) { + AliError("Can not get Run from Run Loader"); + return kFALSE; + } + + // Get the AliFMD object + fmd = static_cast(run->GetDetector("FMD")); + if (!fmd) { + AliError("Can not get FMD from gAlice"); + return kFALSE; + } + return kTRUE; +} + +//____________________________________________________________________ +Bool_t +AliFMDBaseDigitizer::LoopOverInput(AliFMD* fmd) +{ + if (!fManager) { + AliError("No digitisation manager defined"); + return kFALSE; + } + + 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 + fRunLoader = + AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); + if (!fRunLoader) { + Error("Exec", Form("no run loader for input file # %d", inputFile)); + return kFALSE; + } + // Cache contriutions + AliFMDDebug(5, ("Now summing the contributions from input # %d",inputFile)); + SumContributions(fmd); + } + return kTRUE; +} + //____________________________________________________________________ UShort_t @@ -307,26 +402,33 @@ AliFMDBaseDigitizer::SumContributions(AliFMD* fmd) // Get the FMD loader AliLoader* inFMD = fRunLoader->GetLoader("FMDLoader"); // And load the hits + AliFMDDebug(5, ("Will read hits")); inFMD->LoadHits("READ"); // Get the tree of hits + AliFMDDebug(5, ("Will get hit tree")); TTree* hitsTree = inFMD->TreeH(); if (!hitsTree) { // Try again + AliFMDDebug(5, ("First attempt failed, try again")); inFMD->LoadHits("READ"); hitsTree = inFMD->TreeH(); } // Get the FMD branch + AliFMDDebug(5, ("Will now get the branch")); TBranch* hitsBranch = hitsTree->GetBranch("FMD"); if (hitsBranch) fmd->SetHitsAddressBranch(hitsBranch); else AliFatal("Branch FMD hit not found"); // Get a list of hits from the FMD manager + AliFMDDebug(5, ("Get array of FMD hits")); TClonesArray *fmdHits = fmd->Hits(); // Get number of entries in the tree + AliFMDDebug(5, ("Get # of tracks")); Int_t ntracks = Int_t(hitsTree->GetEntries()); + AliFMDDebug(5, ("We got %d tracks", ntracks)); AliFMDParameters* param = AliFMDParameters::Instance(); Int_t read = 0; @@ -348,16 +450,16 @@ AliFMDBaseDigitizer::SumContributions(AliFMD* fmd) UShort_t sector = fmdHit->Sector(); UShort_t strip = fmdHit->Strip(); Float_t edep = fmdHit->Edep(); - // UShort_t minstrip = param->GetMinStrip(detector, ring, sector, strip); - // UShort_t maxstrip = param->GetMaxStrip(detector, ring, sector, strip); - // Check if strip is `dead' - AliFMDDebug(2, ("Hit in FMD%d%c[%2d,%3d]=%f", + AliFMDDebug(10, ("Hit in FMD%d%c[%2d,%3d]=%f", detector, ring, sector, strip, edep)); + // Check if strip is `dead' if (param->IsDead(detector, ring, sector, strip)) { AliFMDDebug(1, ("FMD%d%c[%2d,%3d] is marked as dead", detector, ring, sector, strip)); continue; } + // UShort_t minstrip = param->GetMinStrip(detector, ring, sector, strip); + // UShort_t maxstrip = param->GetMaxStrip(detector, ring, sector, strip); // Check if strip is out-side read-out range // if (strip < minstrip || strip > maxstrip) { // AliFMDDebug(5, ("FMD%d%c[%2d,%3d] is outside range [%3d,%3d]", @@ -376,8 +478,9 @@ AliFMDBaseDigitizer::SumContributions(AliFMD* fmd) // Add this to the energy deposited for this strip } // hit loop } // track loop - AliFMDDebug(1, ("Size of cache: %d bytes, read %d bytes", + AliFMDDebug(5, ("Size of cache: %d bytes, read %d bytes", sizeof(fEdep), read)); + inFMD->UnloadHits(); } //____________________________________________________________________ @@ -388,6 +491,7 @@ AliFMDBaseDigitizer::DigitizeHits(AliFMD* fmd) const // the energy signal to ADC counts, and store the created digit in // the digits array (AliFMD::fDigits) // + AliFMDDebug(5, ("Will now digitize all the summed signals")); AliFMDGeometry* geometry = AliFMDGeometry::Instance(); TArrayI counts(4); @@ -523,7 +627,7 @@ AliFMDBaseDigitizer::ConvertToCount(Float_t edep, Float_t a = edep * convF + ped; if (a < 0) a = 0; counts[0] = UShort_t(TMath::Min(a, Float_t(maxAdc))); - AliFMDDebug(2, ("FMD%d%c[%2d,%3d]: converting ELoss %f to " + AliFMDDebug(10, ("FMD%d%c[%2d,%3d]: converting ELoss %f to " "ADC %4d (%f,%d)", detector,ring,sector,strip,edep,counts[0],convF,ped)); return; diff --git a/FMD/AliFMDBaseDigitizer.h b/FMD/AliFMDBaseDigitizer.h index 9e904fe5e6a..695cdf53568 100644 --- a/FMD/AliFMDBaseDigitizer.h +++ b/FMD/AliFMDBaseDigitizer.h @@ -170,7 +170,9 @@ public: /** Initialize */ virtual Bool_t Init(); - + /** Run this task */ + virtual void Exec(Option_t* option=""); + /** The response shape of the VA1 shaping circuit is approximently given by @f[ @@ -185,6 +187,19 @@ public: /** @return Get the shaping time */ Float_t GetShapingTime() const { return fShapingTime; } protected: + /** Set-up loaders, etc. + @param fmd On return, contains pointer to loaded AliFMD object. + @param outFMD On return, contains pointer to loaded loader. + @return kTRUE on success, kFALSE otherwise */ + virtual Bool_t SetupLoaders(AliFMD*& fmd, AliLoader*& outFMD); + /** Set-up loaders, etc. + @param fmd Pointer to loaded AliFMD object + @return kFALSE on failures. */ + virtual Bool_t LoopOverInput(AliFMD* fmd); + /** Output to disk + @param outFMD Loader + @param fmd AliFMD object */ + virtual void OutputTree(AliLoader* outFMD, AliFMD* fmd) = 0; /** Sum energy deposited contributions from each hit in a cache @param fmd Pointer to detector */ virtual void SumContributions(AliFMD* fmd); diff --git a/FMD/AliFMDDetector.cxx b/FMD/AliFMDDetector.cxx index 9b0741c4a31..6baf3a32ec1 100644 --- a/FMD/AliFMDDetector.cxx +++ b/FMD/AliFMDDetector.cxx @@ -235,7 +235,7 @@ AliFMDDetector::InitTransformations() // Get transformation matrix for this node, and store it. TGeoMatrix* t = new TGeoHMatrix(*pm); trans->AddAt(t, base+imod); - AliFMDDebug(1, ("Found matrix for path \"%s\": %p",path.Data(),pm)); + AliFMDDebug(5, ("Found matrix for path \"%s\": %p",path.Data(),pm)); } } } diff --git a/FMD/AliFMDDigitizer.cxx b/FMD/AliFMDDigitizer.cxx index bd421ec7b8d..1d0dd1149dc 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 and Hits->SDigits +// Forward Multiplicity detector : Hits->Digits // // Digits consists of // - Detector # @@ -31,14 +31,6 @@ // - 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. @@ -80,6 +72,7 @@ // 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 // @@ -198,14 +191,9 @@ #include // ROOT_TTree #include // ROOT_TRandom -// #include // ALILOG_H -#include "AliFMDDebug.h" // Better debug macros +#include "AliFMDDebug.h" // Better debug macros #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H #include "AliFMD.h" // ALIFMD_H -// #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H -// #include "AliFMDDetector.h" // ALIFMDDETECTOR_H -// #include "AliFMDRing.h" // ALIFMDRING_H -// #include "AliFMDHit.h" // ALIFMDHIT_H #include "AliFMDDigit.h" // ALIFMDDIGIT_H #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H #include // ALIRUNDIGITIZER_H @@ -217,66 +205,12 @@ ClassImp(AliFMDDigitizer) //____________________________________________________________________ -AliFMDDigitizer::AliFMDDigitizer() - : AliFMDBaseDigitizer() -{ - // Default ctor - don't use it -} - -//____________________________________________________________________ -AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager) - : AliFMDBaseDigitizer(manager) -{ - // Normal CTOR - AliFMDDebug(1, (" processed")); -} - -//____________________________________________________________________ -void -AliFMDDigitizer::Exec(Option_t*) +void +AliFMDDigitizer::OutputTree(AliLoader* outFMD, AliFMD* fmd) { - // Get the output manager - TString outFolder(fManager->GetOutputFolderName()); - AliRunLoader* out = - AliRunLoader::GetRunLoader(outFolder.Data()); - // Get the FMD output manager - AliLoader* outFMD = out->GetLoader("FMDLoader"); - - // Get the input loader - TString inFolder(fManager->GetInputFolderName(0)); - fRunLoader = - AliRunLoader::GetRunLoader(inFolder.Data()); - if (!fRunLoader) { - AliError("Can not find Run Loader for input stream 0"); - return; - } - // Get the AliRun object - if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); - - // Get the AliFMD object - AliFMD* fmd = - static_cast(fRunLoader->GetAliRun()->GetDetector("FMD")); - if (!fmd) { - AliError("Can not get FMD from gAlice"); - return; - } - - Int_t nFiles= fManager->GetNinputs(); - for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) { - AliFMDDebug(1, (" Digitizing event number %d", - fManager->GetOutputEventNr())); - // Get the current loader - fRunLoader = - AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); - if (!fRunLoader) Fatal("Exec", "no run loader"); - // Cache contriutions - SumContributions(fmd); - } - // Digitize the event - DigitizeHits(fmd); - // Load digits from the tree outFMD->LoadDigits("update"); + // Get the tree of digits TTree* digitTree = outFMD->TreeD(); if (!digitTree) { @@ -284,8 +218,16 @@ AliFMDDigitizer::Exec(Option_t*) digitTree = outFMD->TreeD(); } digitTree->Reset(); + + // Get the digits + TClonesArray* digits = fmd->Digits(); + if (!digits) { + AliError("Failed to get digits"); + return; + } + AliFMDDebug(1, ("Got a total of %5d digits", digits->GetEntries())); + // Make a branch in the tree - TClonesArray* digits = fmd->Digits(); fmd->MakeBranchInTree(digitTree, fmd->GetName(), &(digits), 4000, 0); // TBranch* digitBranch = digitTree->GetBranch(fmd->GetName()); // Fill the tree @@ -302,7 +244,6 @@ AliFMDDigitizer::Exec(Option_t*) fmd->ResetDigits(); } - //____________________________________________________________________ UShort_t AliFMDDigitizer::MakePedestal(UShort_t detector, diff --git a/FMD/AliFMDDigitizer.h b/FMD/AliFMDDigitizer.h index 384d725c6f0..c2e8f64cdc0 100644 --- a/FMD/AliFMDDigitizer.h +++ b/FMD/AliFMDDigitizer.h @@ -51,16 +51,18 @@ class AliFMDDigitizer : public AliFMDBaseDigitizer { public: /** CTOR */ - AliFMDDigitizer(); + AliFMDDigitizer() : AliFMDBaseDigitizer() {} /** CTOR @param manager Manager of digitization */ - AliFMDDigitizer(AliRunDigitizer * manager); + AliFMDDigitizer(AliRunDigitizer * manager) + : AliFMDBaseDigitizer(manager) {} /** DTOR */ virtual ~AliFMDDigitizer() {} - /** Do everything - @param option Not used */ - virtual void Exec(Option_t* option=0); protected: + /** Output to disk + @param outFMD Loader + @param fmd AliFMD object */ + virtual void OutputTree(AliLoader* outFMD, AliFMD* fmd); /** Add a digit to output. @param fmd Pointer to detector object @param detector Detector # diff --git a/FMD/AliFMDDisplay.cxx b/FMD/AliFMDDisplay.cxx index 5e51ff8c538..09cbafd2654 100644 --- a/FMD/AliFMDDisplay.cxx +++ b/FMD/AliFMDDisplay.cxx @@ -50,6 +50,7 @@ #include "AliFMDDisplay.h" // ALIFMDDISPLAY_H #include "AliFMDHit.h" // ALIFMDHIT_H #include "AliFMDDigit.h" // ALIFMDDIGIT_H +#include "AliFMDSDigit.h" // ALIFMDSDIGIT_H #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H @@ -126,6 +127,8 @@ AliFMDDisplay::AliFMDDisplay(Bool_t onlyFMD, const char* gAliceFile) // Constructor of an FMD display object. // Must be called // before Instance + SetName("AliFMDDisplay"); + SetTitle("3D Display of various kinds of FMD data"); AddLoad(kGeometry); if (fgInstance) delete fgInstance; fgInstance = this; @@ -142,7 +145,9 @@ AliFMDDisplay::MakeCanvas(const char** which) // gStyle->SetCanvasPreferGL(kTRUE); Double_t y1 = .10; Int_t w = 700; - fCanvas = new TCanvas("gldisplay", "Display", w, Int_t(w / (1-y1))); + fCanvas = new TCanvas(Form("gl%s", GetName()), + Form("%s - Display", GetTitle()), + w, Int_t(w / (1-y1))); fCanvas->SetFillColor(1); fCanvas->ToggleEventStatus(); fCanvas->cd(); @@ -175,9 +180,10 @@ AliFMDDisplay::MakeCanvas(const char** which) "lower limit"); } } - if (TESTBIT(fTreeMask, kHits) || - TESTBIT(fTreeMask, kESD) || - TESTBIT(fTreeMask, kDigits) || + if (TESTBIT(fTreeMask, kHits) || + TESTBIT(fTreeMask, kESD) || + TESTBIT(fTreeMask, kDigits) || + TESTBIT(fTreeMask, kSDigits) || TESTBIT(fTreeMask, kRaw)) { yb = .05; fSlider = new TSlider("genCut", "Multiplicity cut", 0, 0, xb, yb); @@ -544,7 +550,7 @@ AliFMDDisplay::ChangeFactor() // The factor depends on what is // drawn in the AUX canvas AliInfo(Form("Noise factor is now %4.1f, pedestal factor %3.1f", - fFactor->GetMinimum()*10,fFactor->GetMaximum())); + 10*fFactor->GetMinimum(),fFactor->GetMaximum())); Redisplay(); } @@ -702,6 +708,34 @@ AliFMDDisplay::ProcessDigit(AliFMDDigit* digit) return kTRUE; } +//____________________________________________________________________ +Bool_t +AliFMDDisplay::ProcessSDigit(AliFMDSDigit* sdigit) +{ + // Process a sdigit + // Parameters: + // sdigit Digit information + + static const Float_t rMin = 0; + static const Float_t rMax = 1023; + if (!sdigit) { AliError("No sdigit"); return kFALSE; } + + UShort_t det = sdigit->Detector(); + Char_t ring = sdigit->Ring(); + UShort_t sec = sdigit->Sector(); + UShort_t str = sdigit->Strip(); + Float_t counts = sdigit->Counts(); + + if (fHits) fHits->Add(sdigit); + if (fSpec) fSpec->Fill(counts); + if (!InsideCut(counts, rMin, rMax)) return kTRUE; + if (fSpecCut) fSpecCut->Fill(counts); + + + AddMarker(det, ring, sec, str, sdigit, counts, rMin, rMax); + return kTRUE; +} + //____________________________________________________________________ Bool_t AliFMDDisplay::ProcessRaw(AliFMDDigit* digit) diff --git a/FMD/AliFMDDisplay.h b/FMD/AliFMDDisplay.h index 80a7448aef7..937db3ff24d 100644 --- a/FMD/AliFMDDisplay.h +++ b/FMD/AliFMDDisplay.h @@ -94,6 +94,10 @@ public: @param digit Digit to draw @return @c false on error */ virtual Bool_t ProcessDigit(AliFMDDigit* digit); + /** Visualize a summable digit + @param sdigit Summable digit to draw + @return @c false on error */ + virtual Bool_t ProcessSDigit(AliFMDSDigit* sdigit); /** Visualize a raw digit @param digit Raw digit. @return @c false on error */ diff --git a/FMD/AliFMDInput.cxx b/FMD/AliFMDInput.cxx index 18e0b4bbc7a..a48cb97cc94 100644 --- a/FMD/AliFMDInput.cxx +++ b/FMD/AliFMDInput.cxx @@ -71,7 +71,8 @@ ClassImp(AliFMDInput) //____________________________________________________________________ AliFMDInput::AliFMDInput() - : fGAliceFile(""), + : TNamed("AliFMDInput", "Input handler for various FMD data"), + fGAliceFile(""), fLoader(0), fRun(0), fStack(0), @@ -111,7 +112,8 @@ AliFMDInput::AliFMDInput() //____________________________________________________________________ AliFMDInput::AliFMDInput(const char* gAliceFile) - : fGAliceFile(gAliceFile), + : TNamed("AliFMDInput", "Input handler for various FMD data"), + fGAliceFile(gAliceFile), fLoader(0), fRun(0), fStack(0), @@ -293,14 +295,14 @@ AliFMDInput::Begin(Int_t event) // Possibly load global kinematics information if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) { // AliInfo("Getting kinematics"); - if (fLoader->LoadKinematics()) return kFALSE; + if (fLoader->LoadKinematics("READ")) return kFALSE; fStack = fLoader->Stack(); } // Possibly load FMD Hit information if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) { // AliInfo("Getting FMD hits"); - if (!fFMDLoader || fFMDLoader->LoadHits()) return kFALSE; + if (!fFMDLoader || fFMDLoader->LoadHits("READ")) return kFALSE; fTreeH = fFMDLoader->TreeH(); if (!fArrayH) fArrayH = fFMD->Hits(); } @@ -315,7 +317,7 @@ AliFMDInput::Begin(Int_t event) // Possibly load FMD Digit information if (TESTBIT(fTreeMask, kDigits)) { // AliInfo("Getting FMD digits"); - if (!fFMDLoader || fFMDLoader->LoadDigits()) return kFALSE; + if (!fFMDLoader || fFMDLoader->LoadDigits("READ")) return kFALSE; fTreeD = fFMDLoader->TreeD(); if (fTreeD) { if (!fArrayD) fArrayD = fFMD->Digits(); @@ -329,7 +331,7 @@ AliFMDInput::Begin(Int_t event) // Possibly load FMD Sdigit information if (TESTBIT(fTreeMask, kSDigits)) { // AliInfo("Getting FMD summable digits"); - if (!fFMDLoader || fFMDLoader->LoadSDigits()) return kFALSE; + if (!fFMDLoader || fFMDLoader->LoadSDigits("READ")) return kFALSE; fTreeS = fFMDLoader->TreeS(); if (!fArrayS) fArrayS = fFMD->SDigits(); } @@ -337,7 +339,7 @@ AliFMDInput::Begin(Int_t event) // Possibly load FMD RecPoints information if (TESTBIT(fTreeMask, kRecPoints)) { // AliInfo("Getting FMD reconstructed points"); - if (!fFMDLoader || fFMDLoader->LoadRecPoints()) return kFALSE; + if (!fFMDLoader || fFMDLoader->LoadRecPoints("READ")) return kFALSE; fTreeR = fFMDLoader->TreeR(); if (!fArrayR) fArrayR = new TClonesArray("AliFMDRecPoint"); fTreeR->SetBranchAddress("FMD", &fArrayR); @@ -495,11 +497,21 @@ AliFMDInput::ProcessDigits() { // Read the digit tree, and pass each digit to the member function // ProcessDigit. + if (!fTreeD) { + AliError("No digit tree defined"); + return kFALSE; + } + if (!fArrayD) { + AliError("No digit array defined"); + return kFALSE; + } + Int_t nEv = fTreeD->GetEntries(); for (Int_t i = 0; i < nEv; i++) { Int_t digitRead = fTreeD->GetEntry(i); if (digitRead <= 0) continue; Int_t nDigit = fArrayD->GetEntries(); + AliFMDDebug(0, ("Got %5d digits for this event", nDigit)); if (nDigit <= 0) continue; for (Int_t j = 0; j < nDigit; j++) { AliFMDDigit* digit = static_cast(fArrayD->At(j)); @@ -516,11 +528,21 @@ AliFMDInput::ProcessSDigits() { // Read the summable digit tree, and pass each sumable digit to the // member function ProcessSdigit. - Int_t nEv = fTreeD->GetEntries(); + if (!fTreeS) { + AliWarning("No sdigit tree defined"); + return kTRUE; // Empty SDigits is fine + } + if (!fArrayS) { + AliWarning("No sdigit array defined"); + return kTRUE; // Empty SDigits is fine + } + + Int_t nEv = fTreeS->GetEntries(); for (Int_t i = 0; i < nEv; i++) { Int_t sdigitRead = fTreeS->GetEntry(i); if (sdigitRead <= 0) continue; Int_t nSdigit = fArrayS->GetEntries(); + AliFMDDebug(0, ("Got %5d digits for this event", nSdigit)); if (nSdigit <= 0) continue; for (Int_t j = 0; j < nSdigit; j++) { AliFMDSDigit* sdigit = static_cast(fArrayS->At(j)); @@ -537,6 +559,11 @@ AliFMDInput::ProcessRawDigits() { // Read the digit tree, and pass each digit to the member function // ProcessDigit. + if (!fArrayA) { + AliError("No raw digit array defined"); + return kFALSE; + } + Int_t nDigit = fArrayA->GetEntries(); if (nDigit <= 0) return kTRUE; for (Int_t j = 0; j < nDigit; j++) { @@ -553,6 +580,15 @@ AliFMDInput::ProcessRecPoints() { // Read the reconstrcted points tree, and pass each reconstruction // object (AliFMDRecPoint) to either ProcessRecPoint. + if (!fTreeR) { + AliError("No recpoint tree defined"); + return kFALSE; + } + if (!fArrayR) { + AliError("No recpoints array defined"); + return kFALSE; + } + Int_t nEv = fTreeR->GetEntries(); for (Int_t i = 0; i < nEv; i++) { Int_t recRead = fTreeR->GetEntry(i); diff --git a/FMD/AliFMDInput.h b/FMD/AliFMDInput.h index 234892e58e4..58873024584 100644 --- a/FMD/AliFMDInput.h +++ b/FMD/AliFMDInput.h @@ -26,7 +26,7 @@ classes for customized class that do some sort of analysis on the various types of data produced by the FMD. */ -#include +#include #ifndef ROOT_TString # include #endif @@ -98,7 +98,7 @@ class TChain; various scripts in @c FMD/scripts. @ingroup FMD_util */ -class AliFMDInput : public TObject +class AliFMDInput : public TNamed { public: /** The kinds of data that can be read in. */ @@ -242,7 +242,7 @@ protected: /** Copy ctor @param o Object to copy from */ AliFMDInput(const AliFMDInput& o) - : TObject(o), + : TNamed(o), fGAliceFile(""), fLoader(0), fRun(0), diff --git a/FMD/AliFMDParameters.cxx b/FMD/AliFMDParameters.cxx index 2c4b243d36d..f6e85983c47 100644 --- a/FMD/AliFMDParameters.cxx +++ b/FMD/AliFMDParameters.cxx @@ -497,7 +497,7 @@ AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp) AliCDBEntry* gain = GetEntry(fgkPulseGain, pp); if (!gain) return; - AliFMDDebug(1, ("Got gain from CDB")); + AliFMDDebug(5, ("Got gain from CDB")); fPulseGain = dynamic_cast(gain->GetObject()); if (!fPulseGain) AliFatal("Invalid pulser gain object from CDB"); } @@ -509,7 +509,7 @@ AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp) AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp); if (!pedestal) return; - AliFMDDebug(1, ("Got pedestal from CDB")); + AliFMDDebug(5, ("Got pedestal from CDB")); fPedestal = dynamic_cast(pedestal->GetObject()); if (!fPedestal) AliFatal("Invalid pedestal object from CDB"); } @@ -522,7 +522,7 @@ AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp) AliCDBEntry* deadMap = GetEntry(fgkDead, pp); if (!deadMap) return; - AliFMDDebug(1, ("Got dead map from CDB")); + AliFMDDebug(5, ("Got dead map from CDB")); fDeadMap = dynamic_cast(deadMap->GetObject()); if (!fDeadMap) AliFatal("Invalid dead map object from CDB"); } @@ -534,7 +534,7 @@ AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp) // Get 0-suppression from CDB AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp); if (!zeroSup) return; - AliFMDDebug(1, ("Got zero suppression from CDB")); + AliFMDDebug(5, ("Got zero suppression from CDB")); fZeroSuppression = dynamic_cast(zeroSup->GetObject()); if (!fZeroSuppression)AliFatal("Invalid zero suppression object from CDB"); @@ -547,7 +547,7 @@ AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp) // get Sample rate from CDB AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp); if (!sampRat) return; - AliFMDDebug(1, ("Got zero suppression from CDB")); + AliFMDDebug(5, ("Got zero suppression from CDB")); fSampleRate = dynamic_cast(sampRat->GetObject()); if (!fSampleRate) AliFatal("Invalid zero suppression object from CDB"); } @@ -564,7 +564,7 @@ AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp) AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE); if (!hwMap) return; - AliFMDDebug(1, ("Got ALTRO map from CDB")); + AliFMDDebug(5, ("Got ALTRO map from CDB")); fAltroMap = dynamic_cast(hwMap->GetObject()); if (!fAltroMap) { AliFatal("Invalid ALTRO map object from CDB"); @@ -579,7 +579,7 @@ AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp) // Get strips read-out from CDB AliCDBEntry* range = GetEntry(fgkStripRange, pp); if (!range) return; - AliFMDDebug(1, ("Got strip range from CDB")); + AliFMDDebug(5, ("Got strip range from CDB")); fStripRange = dynamic_cast(range->GetObject()); if (!fStripRange) AliFatal("Invalid strip range object from CDB"); } diff --git a/FMD/AliFMDPattern.cxx b/FMD/AliFMDPattern.cxx index ea935f0a931..847ad7e8210 100644 --- a/FMD/AliFMDPattern.cxx +++ b/FMD/AliFMDPattern.cxx @@ -224,6 +224,9 @@ AliFMDPattern::AliFMDPattern(const char* gAliceFile) // gAliceFile The galice.root file to use - if any. // + SetName("AliFMDPattern"); + SetName("2D display of FMD data"); + // RemoveLoad(kGeometry); fEvent.SetBit(TLatex::kTextNDC); fFMD1Sum.SetBit(TLatex::kTextNDC); diff --git a/FMD/AliFMDSDigitizer.cxx b/FMD/AliFMDSDigitizer.cxx index b6ff8111aec..ffd3c2af9ac 100644 --- a/FMD/AliFMDSDigitizer.cxx +++ b/FMD/AliFMDSDigitizer.cxx @@ -22,16 +22,9 @@ ////////////////////////////////////////////////////////////////////////////// // // This class contains the procedures simulation ADC signal for the -// Forward Multiplicity detector : Hits->Digits and Hits->SDigits +// Forward Multiplicity detector : Hits->SDigits // -// Digits consists of -// - Detector # -// - Ring ID -// - Sector # -// - Strip # -// - ADC count in this channel -// -// Digits consists of +// SDigits consists of // - Detector # // - Ring ID // - Sector # @@ -80,6 +73,7 @@ // 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 // @@ -196,19 +190,10 @@ // -1 + B + exp(-B) // -// #include // ROOT_TTree -//#include // ROOT_TRandom -// #include // ALILOG_H #include "AliFMDDebug.h" // Better debug macros #include "AliFMDSDigitizer.h" // ALIFMDDIGITIZER_H #include "AliFMD.h" // ALIFMD_H -// #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H -// #include "AliFMDDetector.h" // ALIFMDDETECTOR_H -// #include "AliFMDRing.h" // ALIFMDRING_H #include "AliFMDHit.h" // ALIFMDHIT_H -// #include "AliFMDDigit.h" // ALIFMDDIGIT_H -// #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H -// #include // ALIRUNDIGITIZER_H #include // ALIRUN_H #include // ALILOADER_H #include // ALIRUNLOADER_H @@ -216,41 +201,34 @@ //==================================================================== ClassImp(AliFMDSDigitizer) -//____________________________________________________________________ -AliFMDSDigitizer::AliFMDSDigitizer() -{ - // Default ctor - don't use it -} - +#if 0 //____________________________________________________________________ AliFMDSDigitizer::AliFMDSDigitizer(const Char_t* headerFile, - const Char_t* /* sdigfile */) + const Char_t* /* sdigfile */) : AliFMDBaseDigitizer("FMDSDigitizer", "FMD SDigitizer") { // Normal CTOR - AliFMDDebug(1, (" processed")); + AliFMDDebug(1, ("Constructed")); fRunLoader = AliRunLoader::GetRunLoader(); // Open(headerFile); if (!fRunLoader) Fatal("AliFMDSDigitizer", "cannot open session, header file '%s'", - headerFile); + headerFile); AliLoader* loader = fRunLoader->GetLoader("FMDLoader"); if (!loader) Fatal("AliFMDSDigitizer", "cannot find FMD loader in specified event"); // Add task to tasks folder loader->PostSDigitizer(this); - } - //____________________________________________________________________ AliFMDSDigitizer::~AliFMDSDigitizer() { // Destructor AliLoader* loader = fRunLoader->GetLoader("FMDLoader"); loader->CleanSDigitizer(); + AliFMDDebug(1, ("Destructed")); } - //____________________________________________________________________ void AliFMDSDigitizer::Exec(Option_t*) @@ -296,6 +274,48 @@ AliFMDSDigitizer::Exec(Option_t*) } } +#endif + +//____________________________________________________________________ +void +AliFMDSDigitizer::OutputTree(AliLoader* outFMD, AliFMD* fmd) +{ + // Load sdigits from the tree + outFMD->LoadSDigits("update"); + + // Get the tree of sdigits + TTree* sdigitTree = outFMD->TreeS(); + if (!sdigitTree) { + outFMD->MakeTree("S"); + sdigitTree = outFMD->TreeS(); + } + sdigitTree->Reset(); + + // Get the sdigits + TClonesArray* sdigits = fmd->SDigits(); + if (!sdigits) { + AliError("Failed to get sdigits"); + return; + } + AliFMDDebug(5, ("Got a total of %5d sdigits", sdigits->GetEntries())); + + // Make a branch in the tree + fmd->MakeBranchInTree(sdigitTree, fmd->GetName(), &(sdigits), 4000, 0); + // TBranch* sdigitBranch = sdigitTree->GetBranch(fmd->GetName()); + // Fill the tree + Int_t write = 0; + write = sdigitTree->Fill(); + AliFMDDebug(1, ("Wrote %d bytes to sdigit tree", write)); + + // Write the sdigits to disk + outFMD->WriteSDigits("OVERWRITE"); + outFMD->UnloadHits(); + outFMD->UnloadSDigits(); + + // Reset the sdigits in the AliFMD object + fmd->ResetSDigits(); +} + //____________________________________________________________________ void AliFMDSDigitizer::AddDigit(AliFMD* fmd, @@ -311,9 +331,9 @@ AliFMDSDigitizer::AddDigit(AliFMD* fmd, { // Add a summable digit if (count1 == 0 && - count1 == count2 && - count2 == count3 && - count3 == count4) + count2 <= 0 && + count3 <= 0 && + count4 <= 0) return; fmd->AddSDigitByFields(detector, ring, sector, strip, edep, count1, count2, count3, count4); diff --git a/FMD/AliFMDSDigitizer.h b/FMD/AliFMDSDigitizer.h index c006e8df99c..52ebbf79bf2 100644 --- a/FMD/AliFMDSDigitizer.h +++ b/FMD/AliFMDSDigitizer.h @@ -42,17 +42,19 @@ class AliFMDSDigitizer : public AliFMDBaseDigitizer { public: /** CTOR */ - AliFMDSDigitizer(); - /** CTOR - @param headerFile Where to write headings - @param sdigFile Where to write digits. */ - AliFMDSDigitizer(const Char_t* headerFile, const Char_t* sdigFile=""); + AliFMDSDigitizer() : AliFMDBaseDigitizer() {} + /** CTOR + @param manager Manager of digitization */ + AliFMDSDigitizer(AliRunDigitizer * manager) + : AliFMDBaseDigitizer(manager) + {} /** DTOR */ - virtual ~AliFMDSDigitizer(); - /** Do it all - @param option Not used */ - virtual void Exec(Option_t* option=0); + virtual ~AliFMDSDigitizer() {} protected: + /** Output to disk + @param outFMD Loader + @param fmd AliFMD object */ + virtual void OutputTree(AliLoader* outFMD, AliFMD* fmd); /** Add a digit to output. @param fmd Pointer to detector object @param detector Detector # diff --git a/FMD/FMDsimLinkDef.h b/FMD/FMDsimLinkDef.h index 5d0fb4499a0..a6ed4ce2a90 100644 --- a/FMD/FMDsimLinkDef.h +++ b/FMD/FMDsimLinkDef.h @@ -28,11 +28,13 @@ #pragma link C++ class AliFMDBaseDigitizer+; #pragma link C++ class AliFMDDigitizer+; #pragma link C++ class AliFMDSDigitizer+; +#pragma link C++ class AliFMDSSDigitizer+; #pragma link C++ class AliFMDRawWriter+; #pragma link C++ class AliFMDQADataMakerSim+; #else # error Not for compilation + #endif // // EOF diff --git a/FMD/libFMDsim.pkg b/FMD/libFMDsim.pkg index 131a8d8b139..e802cbc8025 100644 --- a/FMD/libFMDsim.pkg +++ b/FMD/libFMDsim.pkg @@ -10,6 +10,7 @@ SRCS = AliFMD.cxx \ AliFMDBaseDigitizer.cxx \ AliFMDDigitizer.cxx \ AliFMDSDigitizer.cxx \ + AliFMDSSDigitizer.cxx \ AliFMDEdepMap.cxx \ AliFMDRawWriter.cxx \ AliFMDQADataMakerSim.cxx diff --git a/FMD/scripts/PatternDigits.C b/FMD/scripts/PatternDigits.C index 5866b164f56..1faed8e94dd 100644 --- a/FMD/scripts/PatternDigits.C +++ b/FMD/scripts/PatternDigits.C @@ -18,6 +18,8 @@ PatternDigits() gSystem->Load("libFMDutil.so"); AliFMDPattern* d = new AliFMDPattern; d->AddLoad(AliFMDInput::kDigits); + d->SetName("digit"); + d->SetTitle("Digits"); // d->AddLoad(AliFMDInput::kKinematics); d->Run(); } diff --git a/FMD/scripts/PatternHits.C b/FMD/scripts/PatternHits.C index 625ac1d8675..6107df800bf 100644 --- a/FMD/scripts/PatternHits.C +++ b/FMD/scripts/PatternHits.C @@ -15,6 +15,8 @@ PatternHits() gSystem->Load("libFMDutil.so"); AliFMDPattern* d = new AliFMDPattern; d->AddLoad(AliFMDInput::kHits); + d->SetName("hit"); + d->SetTitle("Hits"); // d->AddLoad(AliFMDInput::kKinematics); d->Run(); } -- 2.43.5