/[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.2 - (show annotations) (download)
Thu Mar 18 14:44:11 2010 UTC (14 years, 8 months ago) by pam-fi
Branch: MAIN
CVS Tags: Root_V8, MergedToHEAD_1, nuclei_reproc, MergedFromV8_1, BeforeMergingFromV8_1, V9, HEAD
Branch point for: V8
Changes since 1.1: +8 -79 lines
Comments improved.

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 bool TOF__OK = false;
29
30 if (
31 //-----------------------------------
32 // (1) no more than 1 paddle on S11, S12, S21, S22
33 //-----------------------------------
34 tofl2 && tofl2->GetNHitPaddles(0) <= 1 && //S11
35 tofl2->GetNHitPaddles(1) <= 1 && //S12
36 tofl2->GetNHitPaddles(2) <= 1 && //S21
37 tofl2->GetNHitPaddles(3) <= 1 && //S22
38 // tofl2->GetNHitPaddles(4) <= 1 && //S31
39 // tofl2->GetNHitPaddles(5) <= 1 && //S32
40 //-----------------------------------
41 // (2) at least 1 hit paddle on S1, S2
42 //-----------------------------------
43 (tofl2->GetNHitPaddles(0) == 1 || tofl2->GetNHitPaddles(1) == 1) && //S1
44 (tofl2->GetNHitPaddles(2) == 1 || tofl2->GetNHitPaddles(3) == 1) && //S2
45 // (tofl2->GetNHitPaddles(4)==1 || tofl2->GetNHitPaddles(5)==1) && //S3
46 //-----------------------------------
47 // (3) less than 3 hit pmts outside track on S11,S12
48 //-----------------------------------
49 GetNHitPMTsOutsideTrack(event, 0) < 3 && //S11
50 GetNHitPMTsOutsideTrack(event, 1) < 3 && //S12
51 // GetHitPMTsOutsideTrack(event,2)<3 && //S21
52 // GetHitPMTsOutsideTrack(event,3)<3 && //S22
53 true)
54 TOF__OK = true;
55
56 if (!TOF__OK) {
57 return (0);
58 };
59
60 // -----------------------------------------------
61 // (4) for S11,S12,S21,S22: if there is a hit paddle, it MUST be associated to the track (done with Wolfgang help)
62 // -----------------------------------------------
63 //
64 // first build the map of hit PMTs along the track
65 // and discard the event if there is a hit paddle,
66 // but it is not the one associated to the track
67 //
68 int hitplane[] = { 0, 0, 0, 0, 0, 0 };
69 int hitpaddle[] = { -1, -1, -1, -1, -1, -1 };
70 for (Int_t ip = 0; ip < tof->npmttdc; ip++) {//loop over tdc hits associated to the track
71 Int_t iplane = -1;
72 Int_t ipaddle = -1;
73 Int_t ipmt = -1;
74 Int_t id = tof->pmttdc[ip];//pmt id
75 tofl2->GetPMTName(id, iplane, ipaddle, ipmt);
76 if (tof->tdcflag[ip] == 0) {
77 hitplane[iplane] = 1; //there is a true tdc signal associated to the track
78 hitpaddle[iplane] = ipaddle;//store the id of the paddle associated to the track
79 //
80 //
81 //
82 if (tofl2->GetNHitPaddles(iplane) > 0 && //if there is a hit paddle in this plane...
83 !tofl2->HitPaddle(iplane, hitpaddle[iplane]) && //... and the paddle associated to the track is not hit
84 true) {
85 return (0);//discard the event
86 }
87 }
88 };
89 //
90 // hence check the planes with no PMTs associated to the track:
91 // the event is discarded if there is a hit paddle
92 //
93 for (int iplane = 0; iplane < 4; iplane++) {//loop over S11/S12/S21/S22
94 if (hitplane[iplane] == 0 && //if there are no PMTs associated to the track...
95 tofl2->GetNHitPaddles(iplane) > 0 && //...and the plane has hit paddles
96 true) {
97 return (0);//discard the event
98 }
99 }
100
101 return CUTOK; //good pattern
102
103 }
104 //===========================================================
105 //
106 //
107 //
108 //
109 //
110 //===========================================================
111 int TofPatternCut::GetNHitPMTsOutsideTrack(PamLevel2 *event, int plane) {
112
113 if (!event)
114 return (0);
115 //
116 ToFLevel2 *tofl2 = event->GetToFLevel2();
117 if (!tofl2)
118 return (0);
119 ToFTrkVar *tof = 0;
120 if (!_standalone && _notrk >= 0 && _notrk < event->GetTrkLevel2()->GetNTracks())
121 tof = event->GetTrack(_notrk)->GetToFTrack();
122 if (_standalone)
123 tof = event->GetToFStoredTrack(-1);
124 if (!tof)
125 return (0);
126
127 int nn = 0;
128 // cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
129 for (int ip = 0; ip < tofl2->npmt(); ip++) { //loop over ALL PMTs
130 Int_t iplane = -1;
131 Int_t ipaddle = -1;
132 Int_t ipmt = -1;
133 Int_t id = tofl2->GetToFPMT(ip)->pmt_id; //PMT id
134 tofl2->GetPMTName(id, iplane, ipaddle, ipmt);
135
136 if (iplane != plane)
137 continue;
138 // cout << endl<<plane << " -- "<<id;
139 float tdc = tofl2->GetToFPMT(ip)->tdc;
140 if (tdc >= 4095.)
141 continue;///to avoid adc pile-up
142 // spiegazione:
143 // quando c'e` adc pile-up, succede che un pmt abbia un segnale adc (adc<4095) ma NON tdc (tdc==4095),
144 // che e` il contrario di quanto avviene di solito. quindi, se nel livello 2 c'e` un pmt colpito
145 // e questo ha tdc==4095, implica che c'e` solo il segnale adc e che probabilmente non e` un vero segnale,
146 // ma e` il pile-up dell'evento precedente
147
148 // loop over TDC hits along the track
149 int iht = -1;
150 for (iht = 0; iht < tof->npmttdc; iht++)
151 if (id == tof->pmttdc[iht])
152 break; //match
153 if (iht >= 0 && iht < tof->npmttdc)
154 continue;
155 // loop over ADC hits along the track (credo sia inutile...)
156 // int iha = -1;
157 // for(iha=0; iha<tof->npmtadc; iha++)if(id==tof->pmtadc[iha])break; //match
158 // if( iha>=0 && iha <tof->npmtadc )continue;
159 // get here if outside track
160 nn++;
161
162 // cout << " OUTSIDE ";
163 }
164 return nn;
165
166 }
167

  ViewVC Help
Powered by ViewVC 1.1.23