/[PAMELA software]/PamCut/TofCuts/TofPatternCut/TofPatternCut.cpp
ViewVC logotype

Contents of /PamCut/TofCuts/TofPatternCut/TofPatternCut.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed May 27 13:30:09 2009 UTC (15 years, 6 months ago) by pam-fi
Branch: MAIN
Branch point for: DEV
Initial revision

1 /*
2 * TofPatternCut.cpp
3 *
4 * Created on: 12-mar-2009
5 * Author: Elena Vannuccini
6 */
7
8 /*! @file TofPatternCut.cpp The ToFPatternCut class implementation file */
9
10 #include "TofPatternCut.h"
11
12 int TofPatternCut::Check(PamLevel2 *event) {
13
14 if (!event)
15 return (0);
16 //
17 ToFLevel2 *tofl2 = event->GetToFLevel2();
18 if (!tofl2)
19 return (0);
20 ToFTrkVar *tof = 0;
21 if (!_standalone && _notrk >= 0 && _notrk < event->GetTrkLevel2()->GetNTracks())
22 tof = event->GetTrack(_notrk)->GetToFTrack();
23 if (_standalone)
24 tof = event->GetToFStoredTrack(-1);
25 if (!tof)
26 return (0);
27
28 #ifdef DEBUGPAMCUT
29 cout << ">>> TofPatternCut CHECK <<<" << endl;
30 #endif
31
32 bool TOF__OK = false;
33
34 #ifdef DEBUGPAMCUT
35 cout << "Check topology:" << endl;
36 for (int ip = 0; ip < 6; ip++)
37 cout << "plane " << ip << " n.hit paddles " << tofl2->GetNHitPaddles(ip) << endl;
38 for (int ip = 0; ip < 6; ip++)
39 cout << "plane " << ip << " n.hit PMTs outside track " << GetNHitPMTsOutsideTrack(event, ip) << endl;
40 #endif
41
42 // -----------------------------------------
43 // at least one hit paddle on both S1 and S2
44 // -----------------------------------------
45 if (
46 //-----------------------------------
47 // not more than 1 paddle per layer
48 //-----------------------------------
49 tofl2 && tofl2->GetNHitPaddles(0) <= 1 && //S11
50 tofl2->GetNHitPaddles(1) <= 1 && //S12
51 tofl2->GetNHitPaddles(2) <= 1 && //S21
52 tofl2->GetNHitPaddles(3) <= 1 && //S22
53 // tofl2->GetNHitPaddles(4) <= 1 && //S31
54 // tofl2->GetNHitPaddles(5) <= 1 && //S32
55 //-----------------------------------
56 // at least 1 paddle per plane
57 //-----------------------------------
58 (tofl2->GetNHitPaddles(0) == 1 || tofl2->GetNHitPaddles(1) == 1) && //S1
59 (tofl2->GetNHitPaddles(2) == 1 || tofl2->GetNHitPaddles(3) == 1) && //S2
60 // (tofl2->GetNHitPaddles(4)==1 || tofl2->GetNHitPaddles(5)==1) && //S3
61 //-----------------------------------
62 // n.hit pmts outside track
63 //-----------------------------------
64 // GetHitPMTsOutsideTrack(event,0)<2 && //S11 //troppo (puo` succedere )
65 // GetHitPMTsOutsideTrack(event,1)<2 && //S12
66 // GetHitPMTsOutsideTrack(event,2)<2 && //S21
67 // GetHitPMTsOutsideTrack(event,3)<2 && //S22
68 GetNHitPMTsOutsideTrack(event, 0) < 3 && //S11
69 GetNHitPMTsOutsideTrack(event, 1) < 3 && //S12
70 // GetHitPMTsOutsideTrack(event,2)<3 && //S21
71 // GetHitPMTsOutsideTrack(event,3)<3 && //S22
72 true)
73 TOF__OK = true;
74
75 if (!TOF__OK) {
76 #ifdef DEBUGPAMCUT
77 cout << "(((DISCARDED)))" << endl;
78 #endif
79 return (0);
80 };
81
82 #ifdef DEBUGPAMCUT
83 cout << "--> OK" << endl;
84 cout << "Check track concistency:" << endl;
85 #endif
86
87 // -----------------------------------------------
88 // the hit paddles MUST be associated to the track
89 // (in collaborazione con wolfgang)
90 // -----------------------------------------------
91 //
92 // first build the map of hit PMTs along the track
93 // and discard the event if there is an hit paddle,
94 // but it is not the one associated to the track
95 //
96
97 int hitplane[] = { 0, 0, 0, 0, 0, 0 };
98 int hitpaddle[] = { -1, -1, -1, -1, -1, -1 };
99 for (Int_t ip = 0; ip < tof->npmttdc; ip++) {//loop over tdc hits associated to the track
100 Int_t iplane = -1;
101 Int_t ipaddle = -1;
102 Int_t ipmt = -1;
103 Int_t id = tof->pmttdc[ip];//pmt id
104 tofl2->GetPMTName(id, iplane, ipaddle, ipmt);
105 if (tof->tdcflag[ip] == 0) {
106 hitplane[iplane] = 1; //there is a true tdc signal associated to the track
107 #ifdef DEBUGPAMCUT
108 if (hitpaddle[iplane] >= 0 && hitpaddle[iplane] != ipaddle)
109 cout << "ORRORE!!!!" << endl;
110 #endif
111 hitpaddle[iplane] = ipaddle;//store the id of the paddle associated to the track
112 //
113 //
114 //
115 if (tofl2->GetNHitPaddles(iplane) > 0 && //if there is a hit paddle in this plane...
116 !tofl2->HitPaddle(iplane, hitpaddle[iplane]) && //... and the paddle associated to the track is not hit
117 true) {
118 #ifdef DEBUGPAMCUT
119 cout << "hit plane " << iplane << " -- track PMT " << hitpaddle[iplane] << " is not hit " << endl;
120 cout << "(((DISCARDED)))" << endl;
121 #endif
122 return (0);//discard the event
123 }
124 }
125 };
126 //
127 // hence check the planes with no PMTs associated to the track:
128 // the event is discarded if there is a hit paddle
129 //
130 for (int iplane = 0; iplane < 4; iplane++) {//loop over S11/S12/S21/S22
131 if (hitplane[iplane] == 0 && //if there are no PMTs associated to the track...
132 tofl2->GetNHitPaddles(iplane) > 0 && //...and the plane has hit paddles
133 true) {
134 #ifdef DEBUGPAMCUT
135 cout << "hit plane " << iplane << " has no PMTs associated to the track " << endl;
136 cout << "(((DISCARDED)))" << endl;
137 #endif
138 return (0);//discard the event
139 }
140 }
141
142 //
143 // forse non c'e` bisogno di tutto cio`?
144 //
145 // for(int iplane=0; iplane<4; iplane++){//loop over S11/S12/S21/S22
146 // //retrieve the id of the paddle traversed by the track
147 // // (...there is some tolerance...)
148 // int ipaddle = tofl2->GetPaddleIdOfTrack(tof->xtr_tof[iplane],tof->ytr_tof[iplane],iplane);
149 // //check if the traversed paddle is hit
150 // bool OK = true;
151 // if(
152 // tofl2->GetNHitPaddles(iplane)>0 &&//if there is a hit paddle in this plane...
153 // !tofl2->HitPaddle(iplane,ipaddle) && //...and the paddle traversed by the track is not hit
154 // true)OK = false;//..discard the event
155 // /// hence try to recover some events...
156 // if(
157 // tofl2->GetNHitPaddles(iplane)>0 &&//if there is a hit paddle...
158 // ipaddle==-1 &&//...and the track does not traverse any paddle...
159 // tofl2->HitPaddle(iplane,hitpaddle[iplane]) &&//... BUT there are tdc signals belonging to a hit paddle
160 // true)OK=true;//recover
161
162 // if(!OK)return (0);
163
164 // }
165
166 // if( !TOF__OK )return (0);
167
168 #ifdef DEBUGPAMCUT
169 cout << "--> OK" << endl;
170 #endif
171
172 return CUTOK; //good pattern
173
174 }
175 //===========================================================
176 //
177 //
178 //
179 //
180 //
181 //===========================================================
182 int TofPatternCut::GetNHitPMTsOutsideTrack(PamLevel2 *event, int plane) {
183
184 if (!event)
185 return (0);
186 //
187 ToFLevel2 *tofl2 = event->GetToFLevel2();
188 if (!tofl2)
189 return (0);
190 ToFTrkVar *tof = 0;
191 if (!_standalone && _notrk >= 0 && _notrk < event->GetTrkLevel2()->GetNTracks())
192 tof = event->GetTrack(_notrk)->GetToFTrack();
193 if (_standalone)
194 tof = event->GetToFStoredTrack(-1);
195 if (!tof)
196 return (0);
197
198 int nn = 0;
199 // cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
200 for (int ip = 0; ip < tofl2->npmt(); ip++) { //loop over ALL PMTs
201 Int_t iplane = -1;
202 Int_t ipaddle = -1;
203 Int_t ipmt = -1;
204 Int_t id = tofl2->GetToFPMT(ip)->pmt_id; //PMT id
205 tofl2->GetPMTName(id, iplane, ipaddle, ipmt);
206
207 if (iplane != plane)
208 continue;
209 // cout << endl<<plane << " -- "<<id;
210 float tdc = tofl2->GetToFPMT(ip)->tdc;
211 if (tdc >= 4095.)
212 continue;///to avoid adc pile-up
213 // spiegazione:
214 // quando c'e` adc pile-up, succede che un pmt abbia un segnale adc (adc<4095) ma NON tdc (tdc==4095),
215 // che e` il contrario di quanto avviene di solito. quindi, se nel livello 2 c'e` un pmt colpito
216 // e questo ha tdc==4095, implica che c'e` solo il segnale adc e che probabilmente non e` un vero segnale,
217 // ma e` il pile-up dell'evento precedente
218
219 // loop over TDC hits along the track
220 int iht = -1;
221 for (iht = 0; iht < tof->npmttdc; iht++)
222 if (id == tof->pmttdc[iht])
223 break; //match
224 if (iht >= 0 && iht < tof->npmttdc)
225 continue;
226 // loop over ADC hits along the track (credo sia inutile...)
227 // int iha = -1;
228 // for(iha=0; iha<tof->npmtadc; iha++)if(id==tof->pmtadc[iha])break; //match
229 // if( iha>=0 && iha <tof->npmtadc )continue;
230 // get here if outside track
231 nn++;
232
233 // cout << " OUTSIDE ";
234 }
235 return nn;
236
237 }
238

  ViewVC Help
Powered by ViewVC 1.1.23