2 |
* DataQualCut.cpp |
* DataQualCut.cpp |
3 |
* |
* |
4 |
* Created on: 10-mar-2009 |
* Created on: 10-mar-2009 |
5 |
* Author: Sergio Ricciarini, Nicola Mori |
* Author: S. Ricciarini, N. Mori, E. Mocchiutti |
6 |
*/ |
*/ |
7 |
|
|
8 |
/*! @file DataQualCut.cpp The DataQualCut class implementation file */ |
/*! @file DataQualCut.cpp The DataQualCut class implementation file */ |
9 |
|
|
10 |
#include "DataQualCut.h" |
#include "DataQualCut.h" |
11 |
|
|
12 |
|
Bool_t DataQualCut::CL1IsGood(CaloLevel1 *cl1, CaloLevel2 *cl2){ |
13 |
|
// |
14 |
|
// variables |
15 |
|
// |
16 |
|
Int_t view = 0; |
17 |
|
Int_t plane = 0; |
18 |
|
Int_t strip = 0; |
19 |
|
Int_t sview = 0; |
20 |
|
Int_t splane = 0; |
21 |
|
Int_t sstrip = 0; |
22 |
|
Float_t mip = 0.; |
23 |
|
Int_t nstrip = 0; |
24 |
|
// |
25 |
|
// 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 |
26 |
|
// any incongruence in this order means that the CaloLevel1 event is corrupted |
27 |
|
// the nstrip calculated with CaloLevel1 (excluding plane 18X) must be equal to nstrip in CaloLevel2 (which is not affected by the bug) |
28 |
|
// if they don't match the CaloLevel1 event is corrupted |
29 |
|
// 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 |
30 |
|
// hence it is good if you are not using plane 18X |
31 |
|
// |
32 |
|
for (Int_t i=0; i<cl1->istrip; i++){ |
33 |
|
mip=cl1->DecodeEstrip(i,view,plane,strip); |
34 |
|
if ( view < 0 || view > 1 ) return(false); |
35 |
|
if ( plane < 0 || plane > 21 ) return(false); |
36 |
|
if ( strip < 0 || strip > 95 ) return(false); |
37 |
|
if ( i > 0 ){ |
38 |
|
if ( view < sview ) return(false); |
39 |
|
if ( view == sview ){ |
40 |
|
if ( plane < splane ) return(false); |
41 |
|
if ( plane == splane ){ |
42 |
|
if ( strip <= sstrip ) return(false); |
43 |
|
}; |
44 |
|
}; |
45 |
|
}; |
46 |
|
if ( !(view==0 && plane==18) ) nstrip++; |
47 |
|
sview = view; |
48 |
|
splane = plane; |
49 |
|
sstrip = strip; |
50 |
|
}; |
51 |
|
if ( nstrip != cl2->nstrip ) return(false); |
52 |
|
return(true); |
53 |
|
} |
54 |
|
|
55 |
int DataQualCut::Check(PamLevel2 *event){ |
int DataQualCut::Check(PamLevel2 *event){ |
56 |
|
|
|
//cout << "DataQualCut::Check: "; |
|
57 |
// ++++++++++ TRK ++++++++++ |
// ++++++++++ TRK ++++++++++ |
|
|
|
58 |
if ((_cutMask & TRK) == TRK) { |
if ((_cutMask & TRK) == TRK) { |
59 |
if (event->GetTrkLevel2()) { |
if (event->GetTrkLevel2()) { |
60 |
for (Int_t i=0; i<12; i++) { // check done for each DSP |
for (Int_t i=0; i<12; i++) { // check done for each DSP |
67 |
return TRK; |
return TRK; |
68 |
} |
} |
69 |
} |
} |
|
//cout << "TRK "; |
|
70 |
|
|
71 |
// ++++++++++ CALO LEVEL 2++++++++++ |
// ++++++++++ CALO LEVEL 2 ++++++++++ |
72 |
if ((_cutMask & CALO) == CALO) { |
if ((_cutMask & CALO) == CALO) { |
73 |
if (event->GetCaloLevel2()) { |
if (event->GetCaloLevel2()) { |
74 |
if (!event->GetCaloLevel2()->IsGood(true)) { |
if (!event->GetCaloLevel2()->IsGood(true)) { |
79 |
return CALO; |
return CALO; |
80 |
} |
} |
81 |
} |
} |
|
//cout << "CALO "; |
|
82 |
|
|
83 |
// ++++++++++ CALO LEVEL 1++++++++++ |
// ++++++++++ CALO LEVEL 1 ++++++++++ |
84 |
if ((_cutMask & CALO_L1) == CALO_L1) { |
if ((_cutMask & CALO_L1) == CALO_L1) { |
85 |
if (! (event->GetCaloLevel1() ) ) { |
if (! (event->GetCaloLevel1() ) ) { |
86 |
return CALO; |
return CALO_L1; |
87 |
|
} |
88 |
|
if (! CL1IsGood(event->GetCaloLevel1(),event->GetCaloLevel2()) ){ |
89 |
|
return CALO_L1; |
90 |
} |
} |
91 |
} |
} |
92 |
|
|
101 |
return TOF; |
return TOF; |
102 |
} |
} |
103 |
} |
} |
|
//cout << "TOF "; |
|
104 |
|
|
105 |
// ++++++++++ AC ++++++++++ |
// ++++++++++ ANT ++++++++++ |
106 |
if ((_cutMask & AC) == AC) { |
if ((_cutMask & ANT) == ANT) { |
107 |
if (event->GetAcLevel2()) { |
if (event->GetAcLevel2()) { |
108 |
if (event->GetAcLevel2()->unpackError || ((event->GetAcLevel2()->status[0] >> 2) & 1) |
if (event->GetAcLevel2()->unpackError || ((event->GetAcLevel2()->status[0] >> 2) & 1) |
109 |
|| ((event->GetAcLevel2()->status[1] >> 2) & 1)) { |
|| ((event->GetAcLevel2()->status[1] >> 2) & 1)) { |
110 |
return AC; |
//cout << "ANT" << endl; |
111 |
|
return ANT; |
112 |
} |
} |
113 |
} |
} |
114 |
else { |
else { |
115 |
return AC; |
return ANT; |
116 |
} |
} |
117 |
} |
} |
|
//cout << "AC "; |
|
118 |
|
|
119 |
// ++++++++++ TRIG ++++++++++ |
// ++++++++++ TRG ++++++++++ |
120 |
if ((_cutMask & TRIG) == TRIG) { |
if ((_cutMask & TRG) == TRG) { |
121 |
if (event->GetTrigLevel2()) { |
if (event->GetTrigLevel2()) { |
122 |
if (event->GetTrigLevel2()->unpackError) { |
if (event->GetTrigLevel2()->unpackError) { |
123 |
return TRIG; |
return TRG; |
124 |
|
} |
125 |
|
} |
126 |
|
else { |
127 |
|
return TRG; |
128 |
|
} |
129 |
|
} |
130 |
|
|
131 |
|
// ++++++++++ ND ++++++++++ |
132 |
|
if ((_cutMask & ND) == ND) { |
133 |
|
if (event->GetNDLevel2()) { |
134 |
|
if (event->GetNDLevel2()->unpackError) { |
135 |
|
//cout << "ND" << endl; |
136 |
|
return ND; |
137 |
} |
} |
138 |
} |
} |
139 |
else { |
else { |
140 |
return TRIG; |
//cout << "ND" << endl; |
141 |
|
return ND; |
142 |
} |
} |
143 |
} |
} |
|
//cout << "TRIG "; |
|
144 |
|
|
|
//TODO: vedere se si puo' controllare anche l'unpack error per ORB (sembra di no...) |
|
145 |
// ++++++++++ ORB ++++++++++ |
// ++++++++++ ORB ++++++++++ |
146 |
if ((_cutMask & ORB) == ORB) { |
if ((_cutMask & ORB) == ORB) { |
147 |
if (!event->GetOrbitalInfo()) { |
if (!event->GetOrbitalInfo()) { |
148 |
return ORB; |
return ORB; |
149 |
} |
} |
150 |
} |
} |
|
//cout << "ORB"; |
|
|
//cout << endl; |
|
151 |
|
|
152 |
return CUTOK; |
return CUTOK; |
153 |
} |
} |