--- PamCut/CollectionActions/Histo2DActions/TofDedxVsBetaHistoAction/TofDedxVsBetaHistoAction.cpp 2010/08/12 15:14:31 1.3 +++ PamCut/CollectionActions/Histo2DActions/TofDedxVsBetaHistoAction/TofDedxVsBetaHistoAction.cpp 2012/01/03 08:57:21 1.5 @@ -11,8 +11,8 @@ TofDedxVsBetaHistoAction::TofDedxVsBetaHistoAction(const char *actionName, unsigned int layers, bool standAlone, TString outFileBase, TString mode, bool outRoot, bool outText, TString title) : - Histo2DAction (actionName, title, outFileBase, mode, outRoot, outText), _layers(layers), _nLayers(0), - _badEvents(0), _standAlone(standAlone) { + Histo2DAction(actionName, title, outFileBase, mode, outRoot, outText), _layers(layers), _nLayers(0), _badEvents( + 0), _standAlone(standAlone) { bool buildTitle = false; if (title == "") { @@ -78,53 +78,75 @@ static unsigned int badLayers; static int trkSeqNo; + static int idx; if (_standAlone) - trkSeqNo = 0; + trkSeqNo = -1; else - for (int i = 0; i < event->GetToFLevel2()->ntrk(); i++) { - if (event->GetToFLevel2()->GetToFTrkVar(i)->trkseqno == event->GetTrack(0)->GetTrkTrack()->GetSeqNo()) - trkSeqNo = i; - } + trkSeqNo = event->GetTrack(0)->GetTrkTrack()->GetSeqNo(); + + for (int i = 0; i < event->GetToFLevel2()->ntrk(); i++) { + if (event->GetToFLevel2()->GetToFTrkVar(i)->trkseqno == trkSeqNo) + idx = i; + } dEdx = 0.; badLayers = 0; if ((_layers & S11) == S11) { - dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 0, 100); + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 0, 100); + // Patch to exclude S115b + ToFTrkVar *tofTrk = event->GetToFLevel2()->GetToFTrkVar(idx); + bool has8 = false, has9 = false; + float dedx9 = 0.; + for (Int_t ib = 0; ib < tofTrk->npmtadc; ib++) { + if (tofTrk->pmtadc[ib] == 8) { + has8 = true; + } + if (tofTrk->pmtadc[ib] == 9) { + has9 = true; + dedx9 = tofTrk->dedx[ib]; + } + } + + if (has9) { + dEdxLayer -= (dedx9 / ((int) has8 + 1)); + dEdxLayer *= 2.; + } + //End of patch if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S12) == S12) { - dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 1, 100); + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 1, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S21) == S21) { - dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 2, 100); + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 2, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S22) == S22) { - dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 3, 100); + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 3, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S31) == S31) { - dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 4, 100); + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 4, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else badLayers++; } if ((_layers & S32) == S32) { - dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 5, 100); + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 5, 100); if (dEdxLayer > 0. && dEdxLayer < 4090) dEdx += dEdxLayer; else @@ -132,7 +154,7 @@ } if (badLayers == 0) { dEdx /= _nLayers; - Fill(event->GetToFLevel2()->GetToFTrkVar(trkSeqNo)->beta[12], dEdx); + Fill(event->GetToFLevel2()->GetToFTrkVar(idx)->beta[12], dEdx); } else _badEvents++;