/* * TofDedxVsBetaHistoAction.cpp * * Created on: 25-giu-2009 * Author: Nicola Mori */ /*! @file TofDedxVsBetaHistoAction.cpp The TofDedxVsBetaHistoAction class implementation file. */ #include "TofDedxVsBetaHistoAction.h" TofDedxVsBetaHistoAction::TofDedxVsBetaHistoAction(const char *actionName, TString outFileName, unsigned int layers, TString mode, float minDedx, float maxDedx, unsigned int nBinsDedx, float minBeta, float maxBeta, unsigned int nBinsBeta) : CollectionAction(actionName), _outFileName(outFileName), _layers(layers), _nLayers(0), _badEvents(0), _histo(), _mode(mode) { _histo.SetName(GetName()); TString title = "TOF dE/dx ("; if ((_layers & S11) == S11) { title += "S11"; _nLayers++; } if ((_layers & S12) == S12) { if (_nLayers > 0) title += ","; title += "S12"; _nLayers++; } if ((_layers & S21) == S21) { if (_nLayers > 0) title += ","; title += "S21"; _nLayers++; } if ((_layers & S22) == S22) { if (_nLayers > 0) title += ","; title += "S22"; _nLayers++; } if ((_layers & S31) == S31) { if (_nLayers > 0) title += ","; title += "S31"; _nLayers++; } if ((_layers & S32) == S32) { if (_nLayers > 0) title += ","; title += "S32"; _nLayers++; } title += ") Vs Beta"; _histo.SetTitle(title); _histo.GetXaxis()->SetTitle("Beta"); _histo.GetYaxis()->SetTitle("dE/dx (MIP)"); _histo.SetBins(nBinsBeta, minBeta, maxBeta, nBinsDedx, minDedx, maxDedx); } void TofDedxVsBetaHistoAction::OnGood(PamLevel2 *event) { float dEdx = 0.; float dEdxLayer = 0.; unsigned int badLayers = 0; int trkSeqNo = event->GetTrack(0)->GetToFTrack()->trkseqno; if ((_layers & S11) == S11) { dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 0, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S12) == S12) { dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 1, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S21) == S21) { dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 2, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S22) == S22) { dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 3, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S31) == S31) { dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 4, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S32) == S32) { dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 5, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if (badLayers == 0) { dEdx /= _nLayers-badLayers; _histo.Fill(event->GetTrack(0)->GetToFTrack()->beta[12], dEdx); } else _badEvents++; } void TofDedxVsBetaHistoAction::Finalize() { TFile outFile(_outFileName, _mode); outFile.cd(); _histo.Write(); outFile.Close(); }