/[PAMELA software]/PamelaLevel2/doc/examples/My-Selection.cpp
ViewVC logotype

Contents of /PamelaLevel2/doc/examples/My-Selection.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Mon Dec 11 18:26:55 2006 UTC (17 years, 11 months ago) by pam-fi
Branch: MAIN
examples

1 #if !defined(__CINT__) || defined(__MAKECINT__)
2
3
4 #include <TString.h>
5 #include <TH1F.h>
6 #include <TH2F.h>
7 #include <TMath.h>
8 #include <TLine.h>
9 #include <TPolyMarker.h>
10 #include <TSelector.h>
11 #include <TFile.h>
12
13 #include <stdlib.h>
14 #include <iostream>
15 using namespace std;
16
17 #include <PamLevel2.h>
18 #include <CaloAxis.h>
19
20 #endif
21
22
23 //===============================================================================
24 //
25 //
26 //
27 //
28 //===============================================================================
29 Bool_t IsHit(TString what , AcLevel2* ac){
30
31 char* cabl[] = {"CARD4","CAT2","CAS1","ND","CARD2","CAT4","CAS4","ND",
32 "CARD3","CAT3","CAS3","ND","CARD1","CAT1","CAS2","ND"};
33
34 Bool_t answer = kFALSE;
35 for(Int_t ibit=0; ibit<16; ibit++){
36 if( what.Contains( cabl[ibit], TString::kIgnoreCase ) ){
37 if( what.Contains( "M" , TString::kIgnoreCase ) )
38 answer = (Bool_t)((ac->hitmap[0]>>ibit)&1) & (Bool_t)((ac->hitstatus[0]>>ibit)&1);
39 else if( what.Contains( "E" , TString::kIgnoreCase ) )
40 answer = (Bool_t)((ac->hitmap[1]>>ibit)&1) & (Bool_t)((ac->hitstatus[1]>>ibit)&1);
41 else cout << " M-ain or E-xtra not indicated" << endl;
42 return answer;
43 };
44 };
45 cout << " wrong input "<< what << endl;
46 return answer;
47
48 }
49
50 //===============================================================================
51 //
52 //
53 //
54 //
55 //===============================================================================
56 void Dump(AcLevel2* ac){
57
58 cout << "status[0] :"<< hex << ac->status[0] <<endl;
59 cout << "status[1] :"<< hex << ac->status[1] <<endl;
60 cout << "hitmap[0] :"<< hex << ac->hitmap[0] <<endl;
61 cout << "hitmap[1] :"<< hex << ac->hitmap[1] <<endl;
62 cout << "hitstatus[0] :"<< hex << ac->hitstatus[0] <<endl;
63 cout << "hitstatus[1] :"<< hex << ac->hitstatus[1] <<endl;
64 cout << "trigger[0] :"<< hex << ac->trigger[0] <<endl;
65 cout << "trigger[1] :"<< hex << ac->trigger[1] <<endl;
66
67 }
68 void Dump(ToFTrkVar* tof){
69
70 cout << endl<< "n. tdc hits :"<<tof->npmttdc;
71 cout << endl<< "PMTs :";
72 for(Int_t ip=0; ip< tof->npmttdc; ip++)cout << " "<< tof->pmttdc[ip];
73 cout << endl<< "n. adc hits :"<<tof->npmtadc;
74 cout << endl<< "PMTs :";
75 for(Int_t ip=0; ip< tof->npmtadc; ip++)cout << " "<< tof->pmtadc[ip];
76 cout << endl<< "dedx :";
77 for(Int_t ib=0; ib< tof->npmtadc; ib++)cout << " "<< tof->dedx[ib];
78 cout << endl<< "beta :";
79 for(Int_t ib=0; ib<13 ; ib++)cout << " "<< tof->beta[ib];
80 cout << endl<< "xtofpos :";
81 for(Int_t ib=0; ib<3 ; ib++)cout << " "<< tof->xtofpos[ib];
82 cout << endl<< "ytofpos :";
83 for(Int_t ib=0; ib<3 ; ib++)cout << " "<<tof->ytofpos[ib];
84 cout << endl;
85 }
86
87
88 //===============================================================================
89 //
90 //
91 //
92 //
93 //===============================================================================
94 bool Select( PamLevel2* event ){
95
96
97 // cout << event->nstrip << " "<<event->npmt() << " " << event->ntrk()<<endl;
98 // -----------------------------------------
99 // +++++++++++++++++++++++++++++++++++++++++
100 // CALORIMETER CUTS
101 // +++++++++++++++++++++++++++++++++++++++++
102 // -----------------------------------------
103
104 CaloAxis *x_axis = new CaloAxis();
105 CaloAxis *y_axis = new CaloAxis();
106
107 if(event->nstrip<60){
108
109 // --------------------------------
110 // evaluate track axis
111 // --------------------------------
112 float rcil = 1.;// tolerance (cm)
113 if( !x_axis->FitAxis(event->GetCaloLevel1(),0,rcil) )return 0;
114 if( !y_axis->FitAxis(event->GetCaloLevel1(),1,rcil) )return 0;
115
116 if(x_axis->GetN()<4 || y_axis->GetN()<4)return 0;
117
118 float qtrack = x_axis->GetQaxis()+y_axis->GetQaxis();
119 int ntrack = x_axis->GetN()+y_axis->GetN();
120
121 float qstrip = qtrack/ntrack;
122
123 // --------------------------------
124 // evaluate total energy release
125 // --------------------------------
126 float qtot = 0;
127 int ntot = 0;
128 qtot = event->qtot;
129 ntot = event->nstrip;
130
131
132 float nratio = 0;
133 float qratio = 0;
134 if(ntot>0){
135 nratio = (float)ntrack/(float)ntot;
136 qratio = qtrack/qtot;
137 }
138
139 // cout << qtrack << " " << ntrack << " "<< qtot << " "<<ntot<<endl;
140 if(qratio < 0.8)return false;
141
142 }else return false;
143
144 x_axis->Delete();
145 y_axis->Delete();
146
147 // -----------------------------------------
148 // +++++++++++++++++++++++++++++++++++++++++
149 // TOF CUTS
150 // +++++++++++++++++++++++++++++++++++++++++
151 // -----------------------------------------
152
153 // ---------------------------
154 // one hit paddle on S1 and S2
155 // ---------------------------
156 if(
157 event->GetNHitPaddles(0) == 1 &&
158 event->GetNHitPaddles(1) == 1 &&
159 event->GetNHitPaddles(2) == 1 &&
160 event->GetNHitPaddles(3) == 1 &&
161 event->GetNHitPaddles(4) == 1 &&
162 event->GetNHitPaddles(5) == 1 &&
163 true
164 ){;;;
165 }else return false;
166
167 // -----------------------------------------
168 // +++++++++++++++++++++++++++++++++++++++++
169 // AC CUTS
170 // +++++++++++++++++++++++++++++++++++++++++
171 // -----------------------------------------
172 AcLevel2* ac = event->GetAcLevel2();
173
174 if( IsHit("CARD1-M",ac) || IsHit("CARD1-E",ac) )return false;
175 if( IsHit("CARD2-M",ac) || IsHit("CARD2-E",ac) )return false;
176 if( IsHit("CARD3-M",ac) || IsHit("CARD3-E",ac) )return false;
177 if( IsHit("CARD4-M",ac) || IsHit("CARD4-E",ac) )return false;
178
179 if( IsHit("CAT1-M",ac) || IsHit("CAT1-E",ac) )return false;
180 if( IsHit("CAT2-M",ac) || IsHit("CAT2-E",ac) )return false;
181 if( IsHit("CAT3-M",ac) || IsHit("CAT3-E",ac) )return false;
182 if( IsHit("CAT4-M",ac) || IsHit("CAT4-E",ac) )return false;
183
184 if( IsHit("CAS1-M",ac) || IsHit("CAS1-E",ac) )return false;
185 if( IsHit("CAS2-M",ac) || IsHit("CAS2-E",ac) )return false;
186 if( IsHit("CAS3-M",ac) || IsHit("CAS3-E",ac) )return false;
187 if( IsHit("CAS4-M",ac) || IsHit("CAS4-E",ac) )return false;
188
189 return true;
190
191 }
192
193
194
195
196
197

  ViewVC Help
Powered by ViewVC 1.1.23