+ //
+ // Parameters:
+ // det Detector ID
+ // rng Ring ID
+ // sec Sector ID
+ // rng Strip ID
+ // adc # of ADC counts
+ // Return:
+ // Pedestal subtracted signal or USHRT_MAX in case of problems
+ //
+ UShort_t counts = SubtractPedestal(det, rng, sec, str, adc,
+ fNoiseFactor, fZS[det-1],
+ fZSFactor[det-1]);
+ if (fDiagStep1) fDiagStep1->Fill(adc, counts);
+
+ return counts;
+}
+
+//____________________________________________________________________
+Float_t
+AliFMDReconstructor::Adc2Energy(UShort_t det,
+ Char_t rng,
+ UShort_t sec,
+ UShort_t str,
+ UShort_t count) const
+{
+ // Converts number of ADC counts to energy deposited.
+ // Note, that this member function can be overloaded by derived
+ // classes to do strip-specific look-ups in databases or the like,
+ // to find the proper gain for a strip.
+ //
+ // In the first simple version, we calculate the energy deposited as
+ //
+ // EnergyDeposited = cos(theta) * gain * count
+ //
+ // where
+ //
+ // Pre_amp_MIP_Range
+ // gain = ----------------- * Energy_deposited_per_MIP
+ // ADC_channel_size
+ //
+ // is constant and the same for all strips.
+ //
+ // For the production we use the conversion measured in the NBI lab.
+ // The total conversion is then:
+ //
+ // gain = ADC / DAC
+ //
+ // EdepMip * count
+ // => energy = ----------------
+ // gain * DACPerADC
+ //
+ // Parameters:
+ // det Detector ID
+ // rng Ring ID
+ // sec Sector ID
+ // rng Strip ID
+ // counts Number of ADC counts over pedestal
+ // Return
+ // The energy deposited in a single strip, or -1 in case of problems
+ //
+ if (count <= 0) return 0;
+ AliFMDParameters* param = AliFMDParameters::Instance();
+ Float_t gain = param->GetPulseGain(det, rng, sec, str);
+ // 'Tagging' bad gains as bad energy
+ if (gain < 0) {
+ AliWarning(Form("Invalid gain (%f) for FMD%d%c[%02d,%03d]",
+ gain, det, rng, sec, str));
+ return -1;
+ }
+ AliFMDDebug(5, ("Converting counts %d to energy (factor=%f, DAC2MIP=%f)",
+ count, gain,param->GetDACPerMIP()));
+
+ Double_t edep = ((count * param->GetEdepMip())
+ / (gain * param->GetDACPerMIP()));
+ return edep;
+}
+
+//____________________________________________________________________
+Float_t
+AliFMDReconstructor::Adc2Energy(UShort_t det,
+ Char_t rng,
+ UShort_t sec,
+ UShort_t str,
+ Float_t eta,
+ UShort_t count) const
+{
+ // Converts number of ADC counts to energy deposited.
+ // Note, that this member function can be overloaded by derived
+ // classes to do strip-specific look-ups in databases or the like,
+ // to find the proper gain for a strip.
+ //
+ // In the first simple version, we calculate the energy deposited as
+ //
+ // EnergyDeposited = cos(theta) * gain * count
+ //
+ // where
+ //
+ // Pre_amp_MIP_Range
+ // gain = ----------------- * Energy_deposited_per_MIP
+ // ADC_channel_size
+ //
+ // is constant and the same for all strips.
+ //
+ // For the production we use the conversion measured in the NBI lab.
+ // The total conversion is then:
+ //
+ // gain = ADC / DAC
+ //
+ // EdepMip * count
+ // => energy = ----------------
+ // gain * DACPerADC
+ //
+ // Parameters:
+ // det Detector ID
+ // rng Ring ID
+ // sec Sector ID
+ // rng Strip ID
+ // eta Psuedo-rapidity
+ // counts Number of ADC counts over pedestal
+ // Return
+ // The energy deposited in a single strip, or -1 in case of problems
+ //
+ Double_t edep = Adc2Energy(det, rng, sec, str, count);
+
+ if (fDiagStep2) fDiagStep2->Fill(count, edep);
+ if (fAngleCorrect) {
+ Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
+ Double_t corr = TMath::Abs(TMath::Cos(theta));
+ Double_t cedep = corr * edep;
+ AliFMDDebug(10, ("correcting for path %f * %f = %f (eta=%f, theta=%f)",
+ edep, corr, cedep, eta, theta));
+ if (fDiagStep3) fDiagStep3->Fill(edep, cedep);
+ edep = cedep;
+ }
+ return edep;
+}
+
+//____________________________________________________________________
+Float_t
+AliFMDReconstructor::Energy2Multiplicity(UShort_t /*det*/,
+ Char_t /*rng*/,
+ UShort_t /*sec*/,
+ UShort_t /*str*/,
+ Float_t edep) const
+{
+ // Converts an energy signal to number of particles.
+ // Note, that this member function can be overloaded by derived
+ // classes to do strip-specific look-ups in databases or the like,
+ // to find the proper gain for a strip.
+ //
+ // In this simple version, we calculate the multiplicity as
+ //
+ // multiplicity = Energy_deposited / Energy_deposited_per_MIP
+ //
+ // where
+ //
+ // Energy_deposited_per_MIP = 1.664 * SI_density * SI_thickness
+ //
+ // is constant and the same for all strips
+ //
+ // Parameters:
+ // det Detector ID
+ // rng Ring ID
+ // sec Sector ID
+ // rng Strip ID
+ // edep Energy deposited in a single strip
+ // Return
+ // The "bare" multiplicity corresponding to the energy deposited
+ AliFMDParameters* param = AliFMDParameters::Instance();
+ Double_t edepMIP = param->GetEdepMip();
+ Float_t mult = edep / edepMIP;
+#if 0
+ if (edep > 0)
+ AliFMDDebug(15, ("Translating energy %f to multiplicity via "
+ "divider %f->%f", edep, edepMIP, mult));
+#endif
+ if (fDiagStep4) fDiagStep4->Fill(edep, mult);
+ return mult;