--- PamCut/CollectionActions/Histo2DActions/TofDedxVsRigHistoAction/TofDedxVsRigHistoAction.cpp 2011/07/28 13:27:46 1.1.2.1 +++ PamCut/CollectionActions/Histo2DActions/TofDedxVsRigHistoAction/TofDedxVsRigHistoAction.cpp 2011/11/30 17:01:32 1.1.2.2 @@ -0,0 +1,137 @@ +/* + * TofDedxVsRigHistoAction.cpp + * + * Created on: 22-jul-2011 + * Author: Nicola Mori + */ + +/*! @file TofDedxVsRigHistoAction.cpp The TofDedxVsRigHistoAction class implementation file. */ + +#include "TofDedxVsRigHistoAction.h" + +TofDedxVsRigHistoAction::TofDedxVsRigHistoAction(const char *actionName, unsigned int layers, TString outFileBase, + TString mode, bool outRoot, bool outText, TString title) : + Histo2DAction(actionName, title, outFileBase, mode, outRoot, outText), _layers(layers), _nLayers(0), _badEvents( + 0) { + + bool buildTitle = false; + if (title == "") { + buildTitle = true; + title = "TOF dE/dx ("; + } + if ((_layers & S11) == S11) { + if (buildTitle) + title += "S11"; + _nLayers++; + } + if ((_layers & S12) == S12) { + if (buildTitle) { + if (_nLayers > 0) + title += ","; + title += "S12"; + } + _nLayers++; + } + if ((_layers & S21) == S21) { + if (buildTitle) { + if (_nLayers > 0) + title += ","; + title += "S21"; + } + _nLayers++; + } + if ((_layers & S22) == S22) { + if (buildTitle) { + if (_nLayers > 0) + title += ","; + title += "S22"; + } + _nLayers++; + } + if ((_layers & S31) == S31) { + if (buildTitle) { + if (_nLayers > 0) + title += ","; + title += "S31"; + } + _nLayers++; + } + if ((_layers & S32) == S32) { + if (buildTitle) { + if (_nLayers > 0) + title += ","; + title += "S32"; + } + _nLayers++; + } + if (buildTitle) + title += ") Vs Beta"; + + SetTitle(title); + +} + +void TofDedxVsRigHistoAction::OnGood(PamLevel2 *event) { + + static float dEdx; + static float dEdxLayer; + static unsigned int badLayers; + + int trkSeqNo = 0; + for (int i = 0; i < event->GetToFLevel2()->ntrk(); i++) { + if (event->GetToFLevel2()->GetToFTrkVar(i)->trkseqno == event->GetTrack(0)->GetTrkTrack()->GetSeqNo()) + trkSeqNo = i; + } + + dEdx = 0.; + badLayers = 0; + 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; + Fill(event->GetTrack(0)->GetTrkTrack()->GetRigidity(), dEdx); + } + else + _badEvents++; +} +