--- PamCut/TofCuts/TofDedxS1Cut/TofDedxS1Cut.cpp 2009/05/27 13:30:09 1.1 +++ PamCut/TofCuts/TofDedxS1Cut/TofDedxS1Cut.cpp 2012/01/03 08:57:21 1.3 @@ -3,6 +3,8 @@ * * Created on: 13-mar-2009 * Author: Sergio Ricciarini, Nicola Mori + * Reworked on: 21-jul-2011 + * Author: Nicola Mori, Valeria Di Felice */ /*! @file TofDedxS1Cut.cpp The TofDedxS1Cut class implementation file */ @@ -11,38 +13,62 @@ int TofDedxS1Cut::Check(PamLevel2 *event) { - int iTrackTof=0; // index initialized to 0 (TOF stand-alone track) - if (! (_trackTof==0) ) { - iTrackTof=*_trackTof; - } - - // for each layer of S1: check that there is one and only one hit paddle and identify it; if this condition is satisfied, do the check on DeDx for the paddle (otherwise no check is done) - - for (int ipl=0; ipl<2; ipl++) { - - int nhitpad = 0; // number of hit paddles - int ihitpad = 100; // identifier of hit paddle; maximum valid value is 24 (taking into account each possible TOF layer) - float dedxpad; - - for (int ipad=0; ipadGetToFLevel2()->HitPaddle(ipl,ipad)) { // HitPaddle is true if and only if there are both TDC signal for that pad AND they are both 'good' - ihitpad=event->GetToFLevel2()->GetPaddleid(ipl,ipad); - nhitpad++; - } - } + int idx = 0; + for (int i = 0; i < event->GetToFLevel2()->ntrk(); i++) { + if (event->GetToFLevel2()->GetToFTrkVar(i)->trkseqno == event->GetTrack(0)->GetTrkTrack()->GetSeqNo()) + idx = i; + } - if (nhitpad == 1) { // there is one and only one hit pad in the layer - int satwarnpad; - event->GetToFLevel2()->GetdEdxPaddle(iTrackTof,ihitpad,100,dedxpad,satwarnpad); - // NOTE: if dedxpad=0 then there is no dE/dL signal (i.e. no ADC signals to evaluate dE/dL): this means that ADC signals are under threshold and therefore event is good - if ( ! (dedxpad < _maxDedxS1) ) { -// cout << "return on check " << ipl << " hitpad " << ihitpad << " track id " << *_trackTof << " dedxpad " << dedxpad << endl; - return ipl; - } + float dEdx = 0; + int nLayers = 0; + float 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; + nLayers++; + } + dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 1, 100); + if (dEdxLayer > 0. && dEdxLayer < 4090) { + dEdx += dEdxLayer; + nLayers++; + } + + if (nLayers > 0) { + dEdx /= nLayers; + + float R = event->GetTrack(0)->GetTrkTrack()->GetRigidity(); + + if (dEdx >= (3.102 - 2.6 * TMath::Log(R)) * (R < 1.05) + 3. * (R >= 1.05)) + return 0; + + return CUTOK; +// if (dEdx < (3.102 - 2.6 * TMath::Log(R)) * (R < 1.05) + 3. * (R >= 1.05)) +// return 0; +// +// return CUTOK; + } + else { + return 0; } - return CUTOK; - }