00001
00002
00003
00004
00005
00006
00007
00010 #include "TofPatternCut.h"
00011
00012 int TofPatternCut::Check(PamLevel2 *event) {
00013
00014 if (!event)
00015 return (0);
00016
00017 ToFLevel2 *tofl2 = event->GetToFLevel2();
00018 if (!tofl2)
00019 return (0);
00020 ToFTrkVar *tof = 0;
00021 if (!_standalone && _notrk >= 0 && _notrk < event->GetTrkLevel2()->GetNTracks())
00022 tof = event->GetTrack(_notrk)->GetToFTrack();
00023 if (_standalone)
00024 tof = event->GetToFStoredTrack(-1);
00025 if (!tof)
00026 return (0);
00027
00028 #ifdef DEBUGPAMCUT
00029 cout << ">>> TofPatternCut CHECK <<<" << endl;
00030 #endif
00031
00032 bool TOF__OK = false;
00033
00034 #ifdef DEBUGPAMCUT
00035 cout << "Check topology:" << endl;
00036 for (int ip = 0; ip < 6; ip++)
00037 cout << "plane " << ip << " n.hit paddles " << tofl2->GetNHitPaddles(ip) << endl;
00038 for (int ip = 0; ip < 6; ip++)
00039 cout << "plane " << ip << " n.hit PMTs outside track " << GetNHitPMTsOutsideTrack(event, ip) << endl;
00040 #endif
00041
00042
00043
00044
00045 if (
00046
00047
00048
00049 tofl2 && tofl2->GetNHitPaddles(0) <= 1 &&
00050 tofl2->GetNHitPaddles(1) <= 1 &&
00051 tofl2->GetNHitPaddles(2) <= 1 &&
00052 tofl2->GetNHitPaddles(3) <= 1 &&
00053
00054
00055
00056
00057
00058 (tofl2->GetNHitPaddles(0) == 1 || tofl2->GetNHitPaddles(1) == 1) &&
00059 (tofl2->GetNHitPaddles(2) == 1 || tofl2->GetNHitPaddles(3) == 1) &&
00060
00061
00062
00063
00064
00065
00066
00067
00068 GetNHitPMTsOutsideTrack(event, 0) < 3 &&
00069 GetNHitPMTsOutsideTrack(event, 1) < 3 &&
00070
00071
00072 true)
00073 TOF__OK = true;
00074
00075 if (!TOF__OK) {
00076 #ifdef DEBUGPAMCUT
00077 cout << "(((DISCARDED)))" << endl;
00078 #endif
00079 return (0);
00080 };
00081
00082 #ifdef DEBUGPAMCUT
00083 cout << "--> OK" << endl;
00084 cout << "Check track concistency:" << endl;
00085 #endif
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 int hitplane[] = { 0, 0, 0, 0, 0, 0 };
00098 int hitpaddle[] = { -1, -1, -1, -1, -1, -1 };
00099 for (Int_t ip = 0; ip < tof->npmttdc; ip++) {
00100 Int_t iplane = -1;
00101 Int_t ipaddle = -1;
00102 Int_t ipmt = -1;
00103 Int_t id = tof->pmttdc[ip];
00104 tofl2->GetPMTName(id, iplane, ipaddle, ipmt);
00105 if (tof->tdcflag[ip] == 0) {
00106 hitplane[iplane] = 1;
00107 #ifdef DEBUGPAMCUT
00108 if (hitpaddle[iplane] >= 0 && hitpaddle[iplane] != ipaddle)
00109 cout << "ORRORE!!!!" << endl;
00110 #endif
00111 hitpaddle[iplane] = ipaddle;
00112
00113
00114
00115 if (tofl2->GetNHitPaddles(iplane) > 0 &&
00116 !tofl2->HitPaddle(iplane, hitpaddle[iplane]) &&
00117 true) {
00118 #ifdef DEBUGPAMCUT
00119 cout << "hit plane " << iplane << " -- track PMT " << hitpaddle[iplane] << " is not hit " << endl;
00120 cout << "(((DISCARDED)))" << endl;
00121 #endif
00122 return (0);
00123 }
00124 }
00125 };
00126
00127
00128
00129
00130 for (int iplane = 0; iplane < 4; iplane++) {
00131 if (hitplane[iplane] == 0 &&
00132 tofl2->GetNHitPaddles(iplane) > 0 &&
00133 true) {
00134 #ifdef DEBUGPAMCUT
00135 cout << "hit plane " << iplane << " has no PMTs associated to the track " << endl;
00136 cout << "(((DISCARDED)))" << endl;
00137 #endif
00138 return (0);
00139 }
00140 }
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 #ifdef DEBUGPAMCUT
00169 cout << "--> OK" << endl;
00170 #endif
00171
00172 return CUTOK;
00173
00174 }
00175
00176
00177
00178
00179
00180
00181
00182 int TofPatternCut::GetNHitPMTsOutsideTrack(PamLevel2 *event, int plane) {
00183
00184 if (!event)
00185 return (0);
00186
00187 ToFLevel2 *tofl2 = event->GetToFLevel2();
00188 if (!tofl2)
00189 return (0);
00190 ToFTrkVar *tof = 0;
00191 if (!_standalone && _notrk >= 0 && _notrk < event->GetTrkLevel2()->GetNTracks())
00192 tof = event->GetTrack(_notrk)->GetToFTrack();
00193 if (_standalone)
00194 tof = event->GetToFStoredTrack(-1);
00195 if (!tof)
00196 return (0);
00197
00198 int nn = 0;
00199
00200 for (int ip = 0; ip < tofl2->npmt(); ip++) {
00201 Int_t iplane = -1;
00202 Int_t ipaddle = -1;
00203 Int_t ipmt = -1;
00204 Int_t id = tofl2->GetToFPMT(ip)->pmt_id;
00205 tofl2->GetPMTName(id, iplane, ipaddle, ipmt);
00206
00207 if (iplane != plane)
00208 continue;
00209
00210 float tdc = tofl2->GetToFPMT(ip)->tdc;
00211 if (tdc >= 4095.)
00212 continue;
00213
00214
00215
00216
00217
00218
00219
00220 int iht = -1;
00221 for (iht = 0; iht < tof->npmttdc; iht++)
00222 if (id == tof->pmttdc[iht])
00223 break;
00224 if (iht >= 0 && iht < tof->npmttdc)
00225 continue;
00226
00227
00228
00229
00230
00231 nn++;
00232
00233
00234 }
00235 return nn;
00236
00237 }
00238