1 //____________________________________________________________________
3 // This is a class that constructs AliFMDRecPoint objects from of Digits
4 // This class reads either digits from a TClonesArray or raw data from
5 // a DDL file (or similar), and stores the read ADC counts in an
6 // internal cache (fAdcs). The rec-points are made via the naiive
9 //-- Authors: Evgeny Karpechev(INR) and Alla Maevsksia
10 // Latest changes by Christian Holm Christensen <cholm@nbi.dk>
13 //____________________________________________________________________
14 /**************************************************************************
15 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
17 * Author: The ALICE Off-line Project. *
18 * Contributors are mentioned in the code where appropriate. *
20 * Permission to use, copy, modify and distribute this software and its *
21 * documentation strictly for non-commercial purposes is hereby granted *
22 * without fee, provided that the above copyright notice appears in all *
23 * copies and that both the copyright notice and this permission notice *
24 * appear in the supporting documentation. The authors make no claims *
25 * about the suitability of this software for any purpose. It is *
26 * provided "as is" without express or implied warranty. *
27 **************************************************************************/
30 * @file AliFMDReconstructor.cxx
31 * @author Christian Holm Christensen <cholm@nbi.dk>
32 * @date Mon Mar 27 12:47:09 2006
33 * @brief FMD reconstruction
36 // #include <AliLog.h> // ALILOG_H
37 // #include <AliRun.h> // ALIRUN_H
38 #include "AliFMDDebug.h"
39 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
40 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
41 #include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
42 #include "AliFMDDigit.h" // ALIFMDDIGIT_H
43 #include "AliFMDSDigit.h" // ALIFMDDIGIT_H
44 #include "AliFMDReconstructor.h" // ALIFMDRECONSTRUCTOR_H
45 #include "AliFMDRecoParam.h" // ALIFMDRECOPARAM_H
46 #include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
47 #include "AliFMDRecPoint.h" // ALIFMDMULTNAIIVE_H
48 #include "AliESDEvent.h" // ALIESDEVENT_H
49 #include "AliESDVertex.h" // ALIESDVERTEX_H
50 #include "AliESDTZERO.h" // ALIESDVERTEX_H
51 #include <AliESDFMD.h> // ALIESDFMD_H
57 #include "AliFMDESDRevertexer.h"
62 //____________________________________________________________________
63 ClassImp(AliFMDReconstructor)
65 ; // This is here to keep Emacs for indenting the next line
68 //____________________________________________________________________
69 AliFMDReconstructor::AliFMDReconstructor()
78 fVertexType(kNoVertex),
89 // Make a new FMD reconstructor object - default CTOR.
92 if (AliDebugLevel() > 0) fDiagnostics = kTRUE;
93 for(Int_t det = 1; det<=3; det++) {
99 //____________________________________________________________________
100 AliFMDReconstructor::~AliFMDReconstructor()
103 if (fMult) fMult->Delete();
104 if (fMult) delete fMult;
105 if (fESDObj) delete fESDObj;
108 //____________________________________________________________________
110 AliFMDReconstructor::Init()
112 // Initialize the reconstructor
114 // Initialize the geometry
115 AliFMDGeometry* geom = AliFMDGeometry::Instance();
117 geom->InitTransformations();
119 // Initialize the parameters
120 AliFMDParameters* param = AliFMDParameters::Instance();
121 if (param->Init() != 0) {
122 AliError("Failed to initialize parameters, making zombie");
128 // Current vertex position
130 // Create array of reconstructed strip multiplicities
131 // fMult = new TClonesArray("AliFMDRecPoint", 51200);
132 // Create ESD output object
133 fESDObj = new AliESDFMD;
135 // Check if we need diagnostics histograms
136 if (!fDiagnostics) return;
137 AliInfo("Making diagnostics histograms");
139 fDiagStep1 = new TH2I("diagStep1", "Read ADC vs. Noise surpressed ADC",
140 1024, -.5, 1023.5, 1024, -.5, 1023.5);
141 fDiagStep1->SetDirectory(0);
142 fDiagStep1->GetXaxis()->SetTitle("ADC (read)");
143 fDiagStep1->GetYaxis()->SetTitle(Form("ADC (noise surpressed %4.f)",
147 fDiagStep2 = new TH2F("diagStep2", "ADC vs Edep deduced",
148 1024, -.5, 1023.5, 100, 0, 2);
149 fDiagStep2->SetDirectory(0);
150 fDiagStep2->GetXaxis()->SetTitle("ADC (noise surpressed)");
151 fDiagStep2->GetYaxis()->SetTitle("#Delta E [GeV]");
154 fDiagStep3 = new TH2F("diagStep3", "Edep vs Edep path corrected",
155 100, 0., 2., 100, 0., 2.);
156 fDiagStep3->SetDirectory(0);
157 fDiagStep3->GetXaxis()->SetTitle("#Delta E [GeV]");
158 fDiagStep3->GetYaxis()->SetTitle("#Delta E/#Delta x #times #delta x [GeV]");
161 fDiagStep4 = new TH2F("diagStep4", "Edep vs Multiplicity deduced",
162 100, 0., 2., 100, -.1, 19.9);
163 fDiagStep4->SetDirectory(0);
164 fDiagStep4->GetXaxis()->SetTitle("#Delta E/#Delta x #times #delta x [GeV]");
165 fDiagStep4->GetYaxis()->SetTitle("Multiplicity");
166 fDiagAll = new TH2F("diagAll", "Read ADC vs Multiplicity deduced",
167 1024, -.5, 1023.5, 100, -.1, 19.9);
170 fDiagAll->SetDirectory(0);
171 fDiagAll->GetXaxis()->SetTitle("ADC (read)");
172 fDiagAll->GetYaxis()->SetTitle("Multiplicity");
176 //____________________________________________________________________
178 AliFMDReconstructor::ConvertDigits(AliRawReader* reader,
179 TTree* digitsTree) const
181 // Convert Raw digits to AliFMDDigit's in a tree
183 AliWarning("I'm a zombie - cannot do anything");
186 AliFMDDebug(1, ("Reading raw data into digits tree"));
188 AliError("No digits tree passed");
191 static TClonesArray* array = 0;
192 if (!array) array = new TClonesArray("AliFMDDigit");
193 digitsTree->Branch("FMD", &array);
196 AliFMDRawReader rawRead(reader, digitsTree);
197 // rawRead.SetSampleRate(fFMD->GetSampleRate());
199 rawRead.ReadAdcs(array);
201 Int_t nWrite = digitsTree->Fill();
202 AliDebugF(1, "Got a grand total of %d digits, wrote %d bytes to tree",
203 array->GetEntriesFast(), nWrite);
206 AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
207 for (UShort_t i = 1; i <= 3; i++) {
208 fZS[i-1] = rawRead.IsZeroSuppressed(map->Detector2DDL(i));
209 fZSFactor[i-1] = rawRead.NoiseFactor(map->Detector2DDL(i));
210 AliDebugF(2, "Noise factor for FMD%hu: %d", i, fZSFactor[i-1]);
214 //____________________________________________________________________
216 AliFMDReconstructor::GetVertex(AliESDEvent* esd) const
218 // Return the vertex to use.
219 // This is obtained from the ESD object.
220 // If not found, a warning is issued.
221 fVertexType = kNoVertex;
225 const AliESDVertex* vertex = esd->GetPrimaryVertex();
226 if (!vertex) vertex = esd->GetPrimaryVertexSPD();
227 if (!vertex) vertex = esd->GetPrimaryVertexTPC();
228 if (!vertex) vertex = esd->GetVertex();
231 AliFMDDebug(2, ("Got %s (%s) from ESD: %f",
232 vertex->GetName(), vertex->GetTitle(), vertex->GetZv()));
233 fCurrentVertex = vertex->GetZv();
234 fVertexType = kESDVertex;
237 else if (esd->GetESDTZERO()) {
238 AliFMDDebug(2, ("Got primary vertex from T0: %f", esd->GetT0zVertex()));
239 fCurrentVertex = esd->GetT0zVertex();
240 fVertexType = kESDVertex;
243 AliWarning("Didn't get any vertex from ESD or generator");
246 //____________________________________________________________________
248 AliFMDReconstructor::GetIdentifier() const
250 // Get the detector identifier.
251 // Note the actual value is cached so that we do not
252 // need to do many expensive string comparisons.
253 static Int_t idx = AliReconstruction::GetDetIndex(GetDetectorName());
257 //____________________________________________________________________
258 const AliFMDRecoParam*
259 AliFMDReconstructor::GetParameters() const
261 // Get the reconstruction parameters.
264 // Pointer to reconstruction parameters or null if not found or wrong type
265 Int_t iDet = GetIdentifier(); // Was 12 - but changed on Cvetans request
266 const AliDetectorRecoParam* params = AliReconstructor::GetRecoParam(iDet);
267 if (!params || params->IsA() != AliFMDRecoParam::Class()) return 0;
268 return static_cast<const AliFMDRecoParam*>(params);
271 //____________________________________________________________________
273 AliFMDReconstructor::UseRecoParam(Bool_t set) const
276 // Set-up reconstructor to use values from reconstruction
277 // parameters, if present, for this event. If the argument @a set
278 // is @c false, then restore preset values.
283 static Float_t savedNoiseFactor = fNoiseFactor;
284 static Bool_t savedAngleCorrect = fAngleCorrect;
286 const AliFMDRecoParam* params = GetParameters();
288 fNoiseFactor = params->NoiseFactor();
289 fAngleCorrect = params->AngleCorrect();
293 fNoiseFactor = savedNoiseFactor;
294 fAngleCorrect = savedAngleCorrect;
298 //____________________________________________________________________
300 AliFMDReconstructor::MarkDeadChannels(AliESDFMD* esd) const
302 // Loop over all entries of the ESD and mark
303 // those that are dead as such
304 // - otherwise put in the zero signal.
305 AliFMDParameters* param = AliFMDParameters::Instance();
307 for (UShort_t d = 1; d <= 3; d++) {
308 UShort_t nR = (d == 1 ? 1 : 2);
310 for (UShort_t q = 0; q < nR; q++) {
311 Char_t r = (q == 0 ? 'I' : 'O');
312 UShort_t nS = (q == 0 ? 20 : 40);
313 UShort_t nT = (q == 0 ? 512 : 256);
315 for (UShort_t s = 0; s < nS; s++) {
316 for (UShort_t t = 0; t < nT; t++) {
317 // A strip can be marked `bad' for two reasons:
319 // - The raw reader fails to read the value
320 // - The strip is marked in OCDB as bad (IsDead)
322 // Hence, a dead strip will always be marked kInvalid here,
323 // while a non-dead bad-read strip will be filled with 0.
324 if (fBad(d, r, s, t)) {
325 AliDebugF(5, "Marking FMD%d%c[%2d,%3d] as bad", d, r, s, t);
326 esd->SetMultiplicity(d, r, s, t, AliESDFMD::kInvalidMult);
328 if (param->IsDead(d, r, s, t)) {
329 AliDebugF(5, "Marking FMD%d%c[%2d,%3d] as dead", d, r, s, t);
330 esd->SetMultiplicity(d, r, s, t, AliESDFMD::kInvalidMult);
331 // esd->SetEta(d, r, s, t, AliESDFMD::kInvalidEta);
333 else if (esd->Multiplicity(d, r, s, t) == AliESDFMD::kInvalidMult) {
334 AliDebugF(20, "Setting null signal in FMD%d%c[%2d,%3d]",
336 esd->SetMultiplicity(d, r, s, t, 0);
339 AliDebugF(10, "Setting FMD%d%c[%2d,%3d]=%f",d,r,s,t,
340 esd->Multiplicity(d, r, s, t));
348 //____________________________________________________________________
350 AliFMDReconstructor::PreReconstruct() const
352 AliFMDDebug(1, ("Before reoconstructing"));
354 AliWarning("I'm a zombie - cannot do anything");
364 // Reset the output ESD
368 // Pre-set eta values
369 for (UShort_t d=1; d<=3; d++) {
370 UShort_t nQ = (d == 1 ? 1 : 2);
371 for (UShort_t q=0; q<nQ; q++) {
372 UShort_t nStr = (q == 0 ? 512 : 256);
373 Char_t r = (q == 0 ? 'I' : 'O');
375 for (UShort_t t = 0; t < nStr; t++) {
377 // Always use sector 0
378 PhysicalCoordinates(d, r, 0, t, eta, phi);
379 fESDObj->SetEta(d, r, 0, t, eta);
389 //____________________________________________________________________
391 AliFMDReconstructor::Reconstruct(AliFMDRawReader& rawReader) const
393 // Reconstruct directly from raw data (no intermediate output on
394 // digit tree or rec point tree).
397 // rawReader FMD Raw event reader
398 AliFMDDebug(1, ("Reconstructing from FMD raw reader"));
399 if (!PreReconstruct()) return;
401 UShort_t det, sec, str, fac;
402 Short_t adc, oldDet = -1;
407 while (rawReader.NextSignal(det, rng, sec, str, adc, zs, fac)) {
410 fZSFactor[det-1] = fac;
413 ProcessSignal(det, rng, sec, str, adc);
415 UseRecoParam(kFALSE);
419 //____________________________________________________________________
421 AliFMDReconstructor::Reconstruct(AliRawReader* reader, TTree*) const
423 // Reconstruct directly from raw data (no intermediate output on
424 // digit tree or rec point tree).
427 // reader Raw event reader
428 // ctree Not used - 'cluster tree' to store rec-points in.
429 AliFMDDebug(1, ("Reconstructing from raw reader"));
431 AliWarning("I'm a zombie - cannot do anything");
434 AliFMDRawReader rawReader(reader, 0);
435 Reconstruct(rawReader);
438 //____________________________________________________________________
440 AliFMDReconstructor::Digitize(AliRawReader* reader, TClonesArray* sdigits) const
442 // Reconstruct directly from raw data (no intermediate output on
443 // digit tree or rec point tree).
446 // reader Raw event reader
449 AliWarning("I'm a zombie - cannot do anything");
452 AliFMDRawReader rawReader(reader, 0);
454 UShort_t det, sec, str, sam, rat, fac;
455 Short_t adc, oldDet = -1;
460 while (rawReader.NextSample(det, rng, sec, str, sam, rat, adc, zs, fac)) {
461 if (!rawReader.SelectSample(sam, rat)) continue;
464 fZSFactor[det-1] = fac;
467 DigitizeSignal(sdigits, det, rng, sec, str, sam, adc);
469 UseRecoParam(kFALSE);
472 //____________________________________________________________________
474 AliFMDReconstructor::Reconstruct(TTree* digitsTree,
475 TTree* clusterTree) const
477 // Reconstruct event from digits in tree
478 // Get the FMD branch holding the digits.
479 // FIXME: The vertex may not be known yet, so we may have to move
480 // some of this to FillESD.
483 // digitsTree Pointer to a tree containing digits
484 // clusterTree Pointer to output tree
486 if (!PreReconstruct()) return;
488 if (!fMult) fMult = new TClonesArray("AliFMDRecPoint");
490 AliFMDDebug(1, ("Reconstructing from digits in a tree"));
492 // Get the digitis array
493 static TClonesArray* digits = new TClonesArray("AliFMDDigit");
494 TBranch* digitBranch = digitsTree->GetBranch("FMD");
496 Error("Exec", "No digit branch for the FMD found");
499 digitBranch->SetAddress(&digits);
501 if (digits) digits->Clear();
502 if (fMult) fMult->Clear();
504 // Create rec-point output branch
506 fTreeR = clusterTree;
507 fTreeR->Branch("FMD", &fMult);
509 AliDebug(5, "Getting entry 0 from digit branch");
510 digitBranch->GetEntry(0);
512 AliDebugF(5, "Processing %d digits", digits->GetEntriesFast());
514 ProcessDigits(digits);
515 UseRecoParam(kFALSE);
517 Int_t written = clusterTree->Fill();
518 AliFMDDebug(10, ("Filled %d bytes into cluster tree", written));
524 //____________________________________________________________________
526 AliFMDReconstructor::ProcessDigits(TClonesArray* digits,
527 const AliFMDRawReader& rawRead) const
529 // For each digit, find the pseudo rapdity, azimuthal angle, and
530 // number of corrected ADC counts, and pass it on to the algorithms
534 // digits Array of digits
537 AliWarning("I'm a zombie - cannot do anything");
540 AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
541 for (size_t i = 1; i <= 3; i++) {
542 fZS[i-1] = rawRead.IsZeroSuppressed(map->Detector2DDL(i));
543 fZSFactor[i-1] = rawRead.NoiseFactor(map->Detector2DDL(i));
546 ProcessDigits(digits);
547 UseRecoParam(kFALSE);
550 //____________________________________________________________________
552 AliFMDReconstructor::ProcessDigits(TClonesArray* digits) const
554 // For each digit, find the pseudo rapdity, azimuthal angle, and
555 // number of corrected ADC counts, and pass it on to the algorithms
559 // digits Array of digits
561 Int_t nDigits = digits->GetEntries();
562 AliFMDDebug(2, ("Got %d digits", nDigits));
563 fESDObj->SetNoiseFactor(fNoiseFactor);
564 fESDObj->SetAngleCorrected(fAngleCorrect);
566 for (Int_t i = 0; i < nDigits; i++) {
567 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
568 if (!digit) continue;
573 //____________________________________________________________________
575 AliFMDReconstructor::ProcessDigit(AliFMDDigit* digit) const
578 // Process a single digit
581 // digit Digiti to process
583 UShort_t det = digit->Detector();
584 Char_t rng = digit->Ring();
585 UShort_t sec = digit->Sector();
586 UShort_t str = digit->Strip();
587 Short_t adc = digit->Counts();
588 // if (AliLog::GetDebugLevel("FMD","")>3) digit->Print();
589 ProcessSignal(det, rng, sec, str, adc);
592 //____________________________________________________________________
594 AliFMDReconstructor::ProcessSignal(UShort_t det,
600 // Process the signal from a single strip
609 Int_t dbg = AliLog::GetDebugLevel("FMD","");
610 Bool_t dhr = dbg > 3 && dbg < 10;
611 if (dhr) printf("FMD%d%c[%2d,%3d] adc=%4d ", det, rng, sec, str, adc);
613 if (adc >= AliFMDRawReader::kBadSignal) {
614 AliFMDDebug(10, ("FMD%d%c[%2d,%3d] is marked bad", det, rng, sec, str));
615 if (dhr) Printf("bad");
616 fBad(det,rng,sec,str) = true;
620 // Check that the strip is not marked as dead
621 AliFMDParameters* param = AliFMDParameters::Instance();
622 if (param->IsDead(det, rng, sec, str)) {
623 AliFMDDebug(10, ("FMD%d%c[%2d,%3d] is dead", det, rng, sec, str));
624 if (dhr) Printf("dead");
625 fBad(det,rng,sec,str) = true;
631 Float_t eta = fESDObj->Eta(det, rng, 0, str);
633 // Substract pedestal.
634 UShort_t counts = SubtractPedestal(det, rng, sec, str, adc);
635 if(counts == USHRT_MAX) {
636 if (dhr) Printf("invalid");
639 if (dhr) printf("counts=%4d ", counts);
641 // Gain match digits.
642 Double_t edep = Adc2Energy(det, rng, sec, str, eta, counts);
643 // Get rid of nonsense energy
645 if (dhr) Printf("zero");
648 if (dhr) printf("edep=%f ", edep);
650 // Make rough multiplicity
651 Double_t mult = Energy2Multiplicity(det, rng, sec, str, edep);
652 // Get rid of nonsense mult
654 // AliWarning(Form("The mutliplicity in FMD%d%c[%2d,%3d]=%f > 20 "
655 // "(ADC: %d, Energy: %f)", det, rng, sec, str, mult,
659 if (dhr) Printf("not hit");
663 if (dhr) Printf("mult=%f ", mult);
664 AliFMDDebug(10, ("FMD%d%c[%2d,%3d]: "
665 "ADC: %d, Counts: %d, Energy: %f, Mult: %f",
666 det, rng, sec, str, adc, counts, edep, mult));
668 // Create a `RecPoint' on the output branch.
671 PhysicalCoordinates(det, rng, sec, str, eta, phi);
674 new ((*fMult)[fNMult]) AliFMDRecPoint(det, rng, sec, str,
675 eta, phi, edep, mult);
676 (void)m; // Suppress warnings about unused variables.
680 fESDObj->SetMultiplicity(det, rng, sec, str, mult);
681 // fESDObj->SetEta(det, rng, sec, str, eta);
683 if (fDiagAll) fDiagAll->Fill(adc, mult);
687 //____________________________________________________________________
689 AliFMDReconstructor::DigitizeSignal(TClonesArray* sdigits,
697 // Process the signal from a single strip
706 AliFMDParameters* param = AliFMDParameters::Instance();
707 // Check that the strip is not marked as dead
708 if (param->IsDead(det, rng, sec, str)) {
709 AliFMDDebug(10, ("FMD%d%c[%2d,%3d] is dead", det, rng, sec, str));
713 // Substract pedestal.
714 UShort_t counts = SubtractPedestal(det, rng, sec, str, adc);
715 if(counts == USHRT_MAX || counts == 0) return;
717 // Gain match digits.
718 Double_t edep = Adc2Energy(det, rng, sec, str, counts);
719 // Get rid of nonsense energy
722 Int_t n = sdigits->GetEntriesFast();
723 // AliFMDSDigit* sdigit =
725 AliFMDSDigit(det, rng, sec, str, edep, counts, counts, counts, counts);
726 // sdigit->SetCount(sam, counts);
729 //____________________________________________________________________
731 AliFMDReconstructor::SubtractPedestal(UShort_t det,
738 UShort_t zsNoiseFactor) const
741 // Subtract the pedestal off the ADC counts.
744 // det Detector number
745 // rng Ring identifier
749 // noiseFactor If pedestal substracted pedestal is less then
750 // this times the noise, then consider this to be 0.
751 // zsEnabled Whether zero-suppression is on.
752 // zsNoiseFactor Noise factor used in on-line pedestal
756 // The pedestal subtracted ADC counts (possibly 0), or @c
757 // USHRT_MAX in case of problems.
759 AliFMDParameters* param = AliFMDParameters::Instance();
760 Float_t ped = (zsEnabled ? 0 :
761 param->GetPedestal(det, rng, sec, str));
762 Float_t noise = param->GetPedestalWidth(det, rng, sec, str);
763 if (ped < 0 || noise < 0) {
764 AliWarningClass(Form("Invalid pedestal (%f) or noise (%f) "
765 "for FMD%d%c[%02d,%03d]",
766 ped, noise, det, rng, sec, str));
769 AliDebugClass(10, Form("Subtracting pedestal for FMD%d%c[%2d,%3d]=%4d "
770 "(%s w/factor %d, noise factor %f, "
771 "pedestal %8.2f+/-%8.2f)",
772 det, rng, sec, str, adc,
773 (zsEnabled ? "zs'ed" : "straight"),
774 zsNoiseFactor, noiseFactor, ped, noise));
776 Int_t counts = adc + Int_t(zsEnabled ? zsNoiseFactor * noise : - ped);
777 counts = TMath::Max(Int_t(counts), 0);
778 // Calculate the noise factor for suppressing remenants of the noise
779 // peak. If we have done on-line zero suppression, we only check
780 // for noise signals that are larger than the suppressed noise. If
781 // the noise factor used on line is larger than the factor used
782 // here, we do not do this check at all.
785 // Online factor | Read factor | Result
786 // ---------------+--------------+-------------------------------
787 // 2 | 3 | Check if signal > 1 * noise
788 // 3 | 3 | Check if signal > 0
789 // 3 | 2 | Check if signal > 0
791 // In this way, we make sure that we do not suppress away too much
792 // data, and that the read-factor is the most stringent cut.
793 Float_t nf = zsNoiseFactor; // TMath::Max(0.F, noiseFactor - (zsEnabled ? zsNoiseFactor : 0));
794 if (counts <= noise * nf) counts = 0;
795 if (counts > 0) AliDebugClass(15, "Got a hit strip");
797 UShort_t ret = counts < 0 ? 0 : counts;
802 //____________________________________________________________________
804 AliFMDReconstructor::SubtractPedestal(UShort_t det,
810 // Member function to subtract the pedestal from a digit
817 // adc # of ADC counts
819 // Pedestal subtracted signal or USHRT_MAX in case of problems
821 UShort_t counts = SubtractPedestal(det, rng, sec, str, adc,
822 fNoiseFactor, fZS[det-1],
824 if (fDiagStep1) fDiagStep1->Fill(adc, counts);
829 //____________________________________________________________________
831 AliFMDReconstructor::Adc2Energy(UShort_t det,
835 UShort_t count) const
837 // Converts number of ADC counts to energy deposited.
838 // Note, that this member function can be overloaded by derived
839 // classes to do strip-specific look-ups in databases or the like,
840 // to find the proper gain for a strip.
842 // In the first simple version, we calculate the energy deposited as
844 // EnergyDeposited = cos(theta) * gain * count
849 // gain = ----------------- * Energy_deposited_per_MIP
852 // is constant and the same for all strips.
854 // For the production we use the conversion measured in the NBI lab.
855 // The total conversion is then:
860 // => energy = ----------------
868 // counts Number of ADC counts over pedestal
870 // The energy deposited in a single strip, or -1 in case of problems
872 if (count <= 0) return 0;
873 AliFMDParameters* param = AliFMDParameters::Instance();
874 Float_t gain = param->GetPulseGain(det, rng, sec, str);
875 // 'Tagging' bad gains as bad energy
877 AliDebugF(10, "Invalid gain (%f) for FMD%d%c[%02d,%03d]",
878 gain, det, rng, sec, str);
881 AliDebugF(10, "Converting counts %d to energy (factor=%f, DAC2MIP=%f)",
882 count, gain,param->GetDACPerMIP());
884 Double_t edep = ((count * param->GetEdepMip())
885 / (gain * param->GetDACPerMIP()));
889 //____________________________________________________________________
891 AliFMDReconstructor::Adc2Energy(UShort_t det,
896 UShort_t count) const
898 // Converts number of ADC counts to energy deposited.
899 // Note, that this member function can be overloaded by derived
900 // classes to do strip-specific look-ups in databases or the like,
901 // to find the proper gain for a strip.
903 // In the first simple version, we calculate the energy deposited as
905 // EnergyDeposited = cos(theta) * gain * count
910 // gain = ----------------- * Energy_deposited_per_MIP
913 // is constant and the same for all strips.
915 // For the production we use the conversion measured in the NBI lab.
916 // The total conversion is then:
921 // => energy = ----------------
929 // eta Psuedo-rapidity
930 // counts Number of ADC counts over pedestal
932 // The energy deposited in a single strip, or -1 in case of problems
934 Double_t edep = Adc2Energy(det, rng, sec, str, count);
936 if (fDiagStep2) fDiagStep2->Fill(count, edep);
938 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
939 Double_t corr = TMath::Abs(TMath::Cos(theta));
940 Double_t cedep = corr * edep;
941 AliDebugF(10, "correcting for path %f * %f = %f (eta=%f, theta=%f)",
942 edep, corr, cedep, eta, theta);
943 if (fDiagStep3) fDiagStep3->Fill(edep, cedep);
949 //____________________________________________________________________
951 AliFMDReconstructor::Energy2Multiplicity(UShort_t /*det*/,
957 // Converts an energy signal to number of particles.
958 // Note, that this member function can be overloaded by derived
959 // classes to do strip-specific look-ups in databases or the like,
960 // to find the proper gain for a strip.
962 // In this simple version, we calculate the multiplicity as
964 // multiplicity = Energy_deposited / Energy_deposited_per_MIP
968 // Energy_deposited_per_MIP = 1.664 * SI_density * SI_thickness
970 // is constant and the same for all strips
977 // edep Energy deposited in a single strip
979 // The "bare" multiplicity corresponding to the energy deposited
980 AliFMDParameters* param = AliFMDParameters::Instance();
981 Double_t edepMIP = param->GetEdepMip();
982 Float_t mult = edep / edepMIP;
985 AliFMDDebug(15, ("Translating energy %f to multiplicity via "
986 "divider %f->%f", edep, edepMIP, mult));
988 if (fDiagStep4) fDiagStep4->Fill(edep, mult);
992 //____________________________________________________________________
994 AliFMDReconstructor::PhysicalCoordinates(UShort_t det,
1001 // Get the eta and phi of a digit
1008 // eta On return, contains the psuedo-rapidity of the strip
1009 // phi On return, contains the azimuthal angle of the strip
1011 AliFMDGeometry* geom = AliFMDGeometry::Instance();
1012 Double_t x, y, z, r, theta, deta, dphi;
1013 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
1015 // Correct for vertex offset.
1016 z -= fCurrentVertex;
1017 AliFMDGeometry::XYZ2REtaPhiTheta(x, y, z, r, deta, dphi, theta);
1023 class ESDPrinter : public AliESDFMD::ForOne
1027 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t,
1028 Float_t m, Float_t e)
1030 if (m > 0 && m != AliESDFMD::kInvalidMult)
1031 printf(" FMD%d%c[%2d,%3d] = %6.3f / %6.3f\n", d, r, s, t, m, e);
1038 //____________________________________________________________________
1040 AliFMDReconstructor::FillESD(TTree* /* digitsTree */,
1041 TTree* /* clusterTree */,
1042 AliESDEvent* esd) const
1044 // nothing to be done
1045 // FIXME: The vertex may not be known when Reconstruct is executed,
1046 // so we may have to move some of that member function here.
1047 AliFMDDebug(2, ("Calling FillESD with two trees and one ESD"));
1049 AliWarning("I'm a zombie - cannot do anything");
1052 // fESDObj->Print();
1054 // Fix up ESD so that only truely dead channels get the kInvalidMult flag.
1055 MarkDeadChannels(fESDObj);
1057 Double_t oldVz = fCurrentVertex;
1059 if (fVertexType != kNoVertex) {
1060 AliFMDDebug(2, ("Revertexing the ESD data to vz=%f (was %f)",
1061 fCurrentVertex, oldVz));
1062 AliFMDESDRevertexer revertexer;
1063 revertexer.Revertex(fESDObj, fCurrentVertex);
1066 if (AliDebugLevel() > 10) {
1068 fESDObj->ForEach(p);
1072 AliFMDDebug(2, ("Writing FMD data to ESD tree"));
1073 esd->SetFMDData(fESDObj);
1076 if (!fDiagnostics || !esd) return;
1077 static bool first = true;
1078 // This is most likely NOT the event number you'd like to use. It
1079 // has nothing to do with the 'real' event number.
1080 // - That's OK. We just use it for the name of the directory -
1081 // nothing else. Christian
1082 Int_t evno = esd->GetEventNumberInFile();
1083 AliFMDDebug(3, ("Writing diagnostics histograms to FMD.Diag.root/%03d",evno));
1084 TFile f("FMD.Diag.root", (first ? "RECREATE" : "UPDATE"));
1087 TDirectory* d = f.mkdir(Form("%03d", evno),
1088 Form("Diagnostics histograms for event # %d", evno));
1090 if (fDiagStep1) fDiagStep1->Write();
1091 if (fDiagStep2) fDiagStep2->Write();
1092 if (fDiagStep3) fDiagStep3->Write();
1093 if (fDiagStep4) fDiagStep4->Write();
1094 if (fDiagAll) fDiagAll->Write();
1099 if (fDiagStep1) fDiagStep1->Reset();
1100 if (fDiagStep2) fDiagStep2->Reset();
1101 if (fDiagStep3) fDiagStep3->Reset();
1102 if (fDiagStep4) fDiagStep4->Reset();
1103 if (fDiagAll) fDiagAll->Reset();
1106 //____________________________________________________________________
1108 AliFMDReconstructor::FillESD(AliRawReader*, TTree* clusterTree,
1109 AliESDEvent* esd) const
1112 // Forwards to above member function
1115 AliWarning("I'm a zombie - cannot do anything");
1119 FillESD(dummy, clusterTree, esd);
1121 //____________________________________________________________________