--- PamCut/MiscCuts/DataQualCut/DataQualCut.cpp 2009/05/27 13:30:09 1.1 +++ PamCut/MiscCuts/DataQualCut/DataQualCut.cpp 2011/07/28 13:29:24 1.5 @@ -2,18 +2,59 @@ * DataQualCut.cpp * * Created on: 10-mar-2009 - * Author: Sergio Ricciarini, Nicola Mori + * Author: S. Ricciarini, N. Mori, E. Mocchiutti */ /*! @file DataQualCut.cpp The DataQualCut class implementation file */ #include "DataQualCut.h" +Bool_t DataQualCut::CL1IsGood(CaloLevel1 *cl1, CaloLevel2 *cl2){ + // + // variables + // + Int_t view = 0; + Int_t plane = 0; + Int_t strip = 0; + Int_t sview = 0; + Int_t splane = 0; + Int_t sstrip = 0; + Float_t mip = 0.; + Int_t nstrip = 0; + // + // values in calolevel1 are stored following this order: view X first, view Y second / for each view from plane 0 to plane 21 / for each plane from strip 0 to strip 95 + // any incongruence in this order means that the CaloLevel1 event is corrupted + // the nstrip calculated with CaloLevel1 (excluding plane 18X) must be equal to nstrip in CaloLevel2 (which is not affected by the bug) + // if they don't match the CaloLevel1 event is corrupted + // if the vector in CaloLevel1 is ordered and nstrip from CaloLevel1 and CaloLevel2 matches then the CaloLevel1 event can only be corrupted on the values of plane 18X + // hence it is good if you are not using plane 18X + // + for (Int_t i=0; iistrip; i++){ + mip=cl1->DecodeEstrip(i,view,plane,strip); + if ( view < 0 || view > 1 ) return(false); + if ( plane < 0 || plane > 21 ) return(false); + if ( strip < 0 || strip > 95 ) return(false); + if ( i > 0 ){ + if ( view < sview ) return(false); + if ( view == sview ){ + if ( plane < splane ) return(false); + if ( plane == splane ){ + if ( strip <= sstrip ) return(false); + }; + }; + }; + if ( !(view==0 && plane==18) ) nstrip++; + sview = view; + splane = plane; + sstrip = strip; + }; + if ( nstrip != cl2->nstrip ) return(false); + return(true); +} + int DataQualCut::Check(PamLevel2 *event){ - //cout << "DataQualCut::Check: "; // ++++++++++ TRK ++++++++++ - if ((_cutMask & TRK) == TRK) { if (event->GetTrkLevel2()) { for (Int_t i=0; i<12; i++) { // check done for each DSP @@ -26,9 +67,8 @@ return TRK; } } - //cout << "TRK "; - // ++++++++++ CALO LEVEL 2++++++++++ + // ++++++++++ CALO LEVEL 2 ++++++++++ if ((_cutMask & CALO) == CALO) { if (event->GetCaloLevel2()) { if (!event->GetCaloLevel2()->IsGood(true)) { @@ -39,12 +79,14 @@ return CALO; } } - //cout << "CALO "; - // ++++++++++ CALO LEVEL 1++++++++++ + // ++++++++++ CALO LEVEL 1 ++++++++++ if ((_cutMask & CALO_L1) == CALO_L1) { if (! (event->GetCaloLevel1() ) ) { - return CALO; + return CALO_L1; + } + if (! CL1IsGood(event->GetCaloLevel1(),event->GetCaloLevel2()) ){ + return CALO_L1; } } @@ -59,44 +101,53 @@ return TOF; } } - //cout << "TOF "; - // ++++++++++ AC ++++++++++ - if ((_cutMask & AC) == AC) { + // ++++++++++ ANT ++++++++++ + if ((_cutMask & ANT) == ANT) { if (event->GetAcLevel2()) { if (event->GetAcLevel2()->unpackError || ((event->GetAcLevel2()->status[0] >> 2) & 1) || ((event->GetAcLevel2()->status[1] >> 2) & 1)) { - return AC; + //cout << "ANT" << endl; + return ANT; } } else { - return AC; + return ANT; } } - //cout << "AC "; - // ++++++++++ TRIG ++++++++++ - if ((_cutMask & TRIG) == TRIG) { + // ++++++++++ TRG ++++++++++ + if ((_cutMask & TRG) == TRG) { if (event->GetTrigLevel2()) { if (event->GetTrigLevel2()->unpackError) { - return TRIG; + return TRG; + } + } + else { + return TRG; + } + } + + // ++++++++++ ND ++++++++++ + if ((_cutMask & ND) == ND) { + if (event->GetNDLevel2()) { + if (event->GetNDLevel2()->unpackError) { + //cout << "ND" << endl; + return ND; } } else { - return TRIG; + //cout << "ND" << endl; + return ND; } } - //cout << "TRIG "; - //TODO: vedere se si puo' controllare anche l'unpack error per ORB (sembra di no...) // ++++++++++ ORB ++++++++++ if ((_cutMask & ORB) == ORB) { if (!event->GetOrbitalInfo()) { return ORB; } } - //cout << "ORB"; - //cout << endl; return CUTOK; }