+ // rawRead.Exec();
+ rawRead.ReadAdcs(array);
+
+ Int_t nWrite = digitsTree->Fill();
+ AliDebugF(1, "Got a grand total of %d digits, wrote %d bytes to tree",
+ array->GetEntriesFast(), nWrite);
+
+
+ AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
+ for (UShort_t i = 1; i <= 3; i++) {
+ fZS[i-1] = rawRead.IsZeroSuppressed(map->Detector2DDL(i));
+ fZSFactor[i-1] = rawRead.NoiseFactor(map->Detector2DDL(i));
+ AliDebugF(2, "Noise factor for FMD%hu: %d", i, fZSFactor[i-1]);
+ }
+}
+
+//____________________________________________________________________
+void
+AliFMDReconstructor::GetVertex(AliESDEvent* esd) const
+{
+ // Return the vertex to use.
+ // This is obtained from the ESD object.
+ // If not found, a warning is issued.
+ fVertexType = kNoVertex;
+ fCurrentVertex = 0;
+ if (!esd) return;
+
+ const AliESDVertex* vertex = esd->GetPrimaryVertex();
+ if (!vertex) vertex = esd->GetPrimaryVertexSPD();
+ if (!vertex) vertex = esd->GetPrimaryVertexTPC();
+ if (!vertex) vertex = esd->GetVertex();
+
+ if (vertex) {
+ AliFMDDebug(2, ("Got %s (%s) from ESD: %f",
+ vertex->GetName(), vertex->GetTitle(), vertex->GetZv()));
+ fCurrentVertex = vertex->GetZv();
+ fVertexType = kESDVertex;
+ return;
+ }
+ else if (esd->GetESDTZERO()) {
+ AliFMDDebug(2, ("Got primary vertex from T0: %f", esd->GetT0zVertex()));
+ fCurrentVertex = esd->GetT0zVertex();
+ fVertexType = kESDVertex;
+ return;
+ }
+ AliWarning("Didn't get any vertex from ESD or generator");
+}
+
+//____________________________________________________________________
+Int_t
+AliFMDReconstructor::GetIdentifier() const
+{
+ // Get the detector identifier.
+ // Note the actual value is cached so that we do not
+ // need to do many expensive string comparisons.
+ static Int_t idx = AliReconstruction::GetDetIndex(GetDetectorName());
+ return idx;
+}
+
+//____________________________________________________________________
+const AliFMDRecoParam*
+AliFMDReconstructor::GetParameters() const
+{
+ // Get the reconstruction parameters.
+ //
+ // Return:
+ // Pointer to reconstruction parameters or null if not found or wrong type
+ Int_t iDet = GetIdentifier(); // Was 12 - but changed on Cvetans request
+ const AliDetectorRecoParam* params = AliReconstructor::GetRecoParam(iDet);
+ if (!params || params->IsA() != AliFMDRecoParam::Class()) return 0;
+ return static_cast<const AliFMDRecoParam*>(params);
+}
+
+//____________________________________________________________________
+void
+AliFMDReconstructor::UseRecoParam(Bool_t set) const
+{
+ //
+ // Set-up reconstructor to use values from reconstruction
+ // parameters, if present, for this event. If the argument @a set
+ // is @c false, then restore preset values.
+ //
+ // Parameters:
+ // set
+ //
+ static Float_t savedNoiseFactor = fNoiseFactor;
+ static Bool_t savedAngleCorrect = fAngleCorrect;
+ if (set) {
+ const AliFMDRecoParam* params = GetParameters();
+ if (params) {
+ fNoiseFactor = params->NoiseFactor();
+ fAngleCorrect = params->AngleCorrect();
+ }
+ return;
+ }
+ fNoiseFactor = savedNoiseFactor;
+ fAngleCorrect = savedAngleCorrect;
+}
+
+
+//____________________________________________________________________
+void
+AliFMDReconstructor::MarkDeadChannels(AliESDFMD* esd) const
+{
+ // Loop over all entries of the ESD and mark
+ // those that are dead as such
+ // - otherwise put in the zero signal.
+ AliFMDParameters* param = AliFMDParameters::Instance();
+
+ for (UShort_t d = 1; d <= 3; d++) {
+ UShort_t nR = (d == 1 ? 1 : 2);
+
+ for (UShort_t q = 0; q < nR; q++) {
+ Char_t r = (q == 0 ? 'I' : 'O');
+ UShort_t nS = (q == 0 ? 20 : 40);
+ UShort_t nT = (q == 0 ? 512 : 256);
+
+ for (UShort_t s = 0; s < nS; s++) {
+ for (UShort_t t = 0; t < nT; t++) {
+ // A strip can be marked `bad' for two reasons:
+ //
+ // - The raw reader fails to read the value
+ // - The strip is marked in OCDB as bad (IsDead)
+ //
+ // Hence, a dead strip will always be marked kInvalid here,
+ // while a non-dead bad-read strip will be filled with 0.
+ if (fBad(d, r, s, t)) {
+ AliDebugF(5, "Marking FMD%d%c[%2d,%3d] as bad", d, r, s, t);
+ esd->SetMultiplicity(d, r, s, t, AliESDFMD::kInvalidMult);
+ }
+ if (param->IsDead(d, r, s, t)) {
+ AliDebugF(5, "Marking FMD%d%c[%2d,%3d] as dead", d, r, s, t);
+ esd->SetMultiplicity(d, r, s, t, AliESDFMD::kInvalidMult);
+ // esd->SetEta(d, r, s, t, AliESDFMD::kInvalidEta);
+ }
+ else if (esd->Multiplicity(d, r, s, t) == AliESDFMD::kInvalidMult) {
+ AliDebugF(20, "Setting null signal in FMD%d%c[%2d,%3d]",
+ d, r, s, t);
+ esd->SetMultiplicity(d, r, s, t, 0);
+ }
+ else {
+ AliDebugF(10, "Setting FMD%d%c[%2d,%3d]=%f",d,r,s,t,
+ esd->Multiplicity(d, r, s, t));
+ }
+ }
+ }
+ }
+ }
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDReconstructor::PreReconstruct() const
+{
+ AliFMDDebug(1, ("Before reoconstructing"));
+ if (fZombie) {
+ AliWarning("I'm a zombie - cannot do anything");
+ return false;
+ }
+
+ // Get our vertex
+ GetVertex(fESD);
+
+ // Reset bad flags
+ fBad.Reset(false);
+
+ // Reset the output ESD
+ if (fESDObj) {
+ fESDObj->Clear();
+
+ // Pre-set eta values
+ for (UShort_t d=1; d<=3; d++) {
+ UShort_t nQ = (d == 1 ? 1 : 2);
+ for (UShort_t q=0; q<nQ; q++) {
+ UShort_t nStr = (q == 0 ? 512 : 256);
+ Char_t r = (q == 0 ? 'I' : 'O');
+
+ for (UShort_t t = 0; t < nStr; t++) {
+ Float_t eta, phi;
+ // Always use sector 0
+ PhysicalCoordinates(d, r, 0, t, eta, phi);
+ fESDObj->SetEta(d, r, 0, t, eta);
+ }
+ }
+ }
+ }
+
+
+ return true;
+}
+
+//____________________________________________________________________
+void
+AliFMDReconstructor::Reconstruct(AliFMDRawReader& rawReader) const
+{
+ // Reconstruct directly from raw data (no intermediate output on
+ // digit tree or rec point tree).
+ //
+ // Parameters:
+ // rawReader FMD Raw event reader
+ AliFMDDebug(1, ("Reconstructing from FMD raw reader"));
+ if (!PreReconstruct()) return;
+
+ UShort_t det, sec, str, fac;
+ Short_t adc, oldDet = -1;
+ Bool_t zs;
+ Char_t rng;
+
+ UseRecoParam(kTRUE);
+ while (rawReader.NextSignal(det, rng, sec, str, adc, zs, fac)) {
+ if (det != oldDet) {
+ fZS[det-1] = zs;
+ fZSFactor[det-1] = fac;
+ oldDet = det;
+ }
+ ProcessSignal(det, rng, sec, str, adc);
+ }
+ UseRecoParam(kFALSE);
+
+}
+
+//____________________________________________________________________
+void
+AliFMDReconstructor::Reconstruct(AliRawReader* reader, TTree*) const
+{
+ // Reconstruct directly from raw data (no intermediate output on
+ // digit tree or rec point tree).
+ //
+ // Parameters:
+ // reader Raw event reader
+ // ctree Not used - 'cluster tree' to store rec-points in.
+ AliFMDDebug(1, ("Reconstructing from raw reader"));
+ if (fZombie) {
+ AliWarning("I'm a zombie - cannot do anything");
+ return;
+ }
+ AliFMDRawReader rawReader(reader, 0);
+ Reconstruct(rawReader);
+}
+
+//____________________________________________________________________
+void
+AliFMDReconstructor::Digitize(AliRawReader* reader, TClonesArray* sdigits) const
+{
+ // Reconstruct directly from raw data (no intermediate output on
+ // digit tree or rec point tree).
+ //
+ // Parameters:
+ // reader Raw event reader
+ // ctree Not used.
+ if (fZombie) {
+ AliWarning("I'm a zombie - cannot do anything");
+ return;
+ }
+ AliFMDRawReader rawReader(reader, 0);
+
+ UShort_t det, sec, str, sam, rat, fac;
+ Short_t adc, oldDet = -1;
+ Bool_t zs;
+ Char_t rng;
+
+ UseRecoParam(kTRUE);
+ while (rawReader.NextSample(det, rng, sec, str, sam, rat, adc, zs, fac)) {
+ if (!rawReader.SelectSample(sam, rat)) continue;
+ if (det != oldDet) {
+ fZS[det-1] = zs;
+ fZSFactor[det-1] = fac;
+ oldDet = det;
+ }
+ DigitizeSignal(sdigits, det, rng, sec, str, sam, adc);
+ }
+ UseRecoParam(kFALSE);