/[PAMELA software]/DarthVader/TriggerLevel2/src/TrigLevel2.cpp
ViewVC logotype

Annotation of /DarthVader/TriggerLevel2/src/TrigLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Thu Apr 12 12:27:16 2012 UTC (12 years, 7 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, v10REDr01, HEAD
Changes since 1.6: +171 -0 lines
New TrigLevel2, ToFLevel2, OrbitalInfo classes, new order in DV processing (trigger first), ToF bugs fixed, new tof calibration, new variables in ToF and OrbitalInfo

1 mocchiut 1.1 #include <TObject.h>
2     #include <TrigLevel2.h>
3     ClassImp(TrigLevel2);
4    
5     TrigLevel2::TrigLevel2() {
6 mocchiut 1.5 this->Clear();
7 mocchiut 1.1 }
8 mocchiut 1.2
9 mocchiut 1.6 void TrigLevel2::Clear(Option_t *t){
10 mocchiut 1.2 evcount = 0;
11 mocchiut 1.4 memset(pmtpl, 0, 3*sizeof(Int_t));
12     memset(patternbusy, 0, 3*sizeof(Int_t));
13     memset(trigrate, 0, 6*sizeof(Int_t));
14     memset(patterntrig, 0, 6*sizeof(Int_t));
15     memset(dltime, 0, 2*sizeof(Int_t));
16     memset(s4calcount, 0, 2*sizeof(Int_t));
17     memset(pmtcount1, 0, 24*sizeof(Int_t));
18     memset(pmtcount2, 0, 24*sizeof(Int_t));
19 mocchiut 1.2 trigconf = 0;
20 mocchiut 1.5 unpackError = 0;
21 mocchiut 1.2 }
22 pam-fi 1.3
23     /**
24     * Fills a struct cTrigLevel2 with values from a TrigLevel2 object (to put data into a F77 common).
25     */
26     void TrigLevel2::GetLevel2Struct(cTrigLevel2 *l2) const{
27    
28     l2->evcount = evcount;
29     l2->trigconf = trigconf;
30    
31     for(int i=0;i<2;i++){
32     l2->s4calcount[i] = s4calcount[i];
33     l2->dltime[i] = dltime[i];
34     }
35    
36     for(int i=0;i<3;i++){
37     l2->pmtpl[i] = pmtpl[i];
38     l2->patternbusy[i] = patternbusy[i];
39     }
40    
41     for(int i=0;i<6;i++){
42     l2->trigrate[i] = trigrate[i];
43     l2->patterntrig[i] = patterntrig[i];
44     }
45    
46     for(int i=0;i<24;i++){
47     l2->pmtcount1[i] = pmtcount1[i];
48     l2->pmtcount2[i] = pmtcount2[i];
49     }
50     }
51    
52     void TrigLevel2::SetFromLevel2Struct(cTrigLevel2 *l2){
53    
54     evcount = l2->evcount;
55     trigconf = l2->trigconf;
56    
57     for(int i=0;i<2;i++){
58     s4calcount[i] = l2->s4calcount[i];
59     dltime[i] = l2->dltime[i];
60     }
61    
62     for(int i=0;i<3;i++){
63     pmtpl[i] = l2->pmtpl[i];
64     patternbusy[i] = l2->patternbusy[i];
65     }
66    
67     for(int i=0;i<6;i++){
68     trigrate[i] = l2->trigrate[i];
69     patterntrig[i] = l2->patterntrig[i];
70     }
71    
72     for(int i=0;i<24;i++){
73     pmtcount1[i] = l2->pmtcount1[i];
74     pmtcount2[i] = l2->pmtcount2[i];
75     }
76     }
77 mocchiut 1.7
78     bool TrigLevel2::bit(int decimal, char pos){
79     return( (decimal>>pos)%2 );
80     }
81    
82     void TrigLevel2::printpatterntrig(){
83     UInt_t *patterntrig = this->patterntrig;
84     //S3
85     if ( this->bit(patterntrig[2],0) ) printf(" S31_1A \n");
86     if ( this->bit(patterntrig[2],1) ) printf(" S31_2A \n");
87     if ( this->bit(patterntrig[2],2) ) printf(" S31_3A \n");
88     if ( this->bit(patterntrig[2],3) ) printf(" S31_1B\n");
89     if ( this->bit(patterntrig[2],4) ) printf(" S31_2B\n");
90     if ( this->bit(patterntrig[2],5) ) printf(" S31_3B\n");
91    
92     if ( this->bit(patterntrig[2],6) ) printf(" S32_1A \n");
93     if ( this->bit(patterntrig[2],7) ) printf(" S32_2A \n");
94     if ( this->bit(patterntrig[2],8) ) printf(" S32_3A \n");
95     if ( this->bit(patterntrig[2],9) ) printf(" S32_1B\n");
96     if ( this->bit(patterntrig[2],10) ) printf(" S32_2B\n");
97     if ( this->bit(patterntrig[2],11) ) printf(" S32_3B\n");
98    
99     //S2
100     if ( this->bit(patterntrig[3],0) ) printf(" S21_1A \n");
101     if ( this->bit(patterntrig[3],1) ) printf(" S21_2A \n");
102     if ( this->bit(patterntrig[3],2) ) printf(" S21_1B\n");
103     if ( this->bit(patterntrig[3],3) ) printf(" S21_2B\n");
104    
105     if ( this->bit(patterntrig[3],4) ) printf(" S22_1A \n");
106     if ( this->bit(patterntrig[3],5) ) printf(" S22_2A \n");
107     if ( this->bit(patterntrig[3],6) ) printf(" S22_1B\n");
108     if ( this->bit(patterntrig[3],7) ) printf(" S22_2B\n");
109    
110     //S12
111     if ( this->bit(patterntrig[4],0) ) printf(" S12_1A \n");
112     if ( this->bit(patterntrig[4],1) ) printf(" S12_2A \n");
113     if ( this->bit(patterntrig[4],2) ) printf(" S12_3A \n");
114     if ( this->bit(patterntrig[4],3) ) printf(" S12_4A \n");
115     if ( this->bit(patterntrig[4],4) ) printf(" S12_5A \n");
116     if ( this->bit(patterntrig[4],5) ) printf(" S12_6A \n");
117    
118     if ( this->bit(patterntrig[4],6) ) printf(" S12_1A \n");
119     if ( this->bit(patterntrig[4],7) ) printf(" S12_2A \n");
120     if ( this->bit(patterntrig[4],8) ) printf(" S12_3A \n");
121     if ( this->bit(patterntrig[4],9) ) printf(" S12_4B\n");
122     if ( this->bit(patterntrig[4],10) ) printf(" S12_5B\n");
123     if ( this->bit(patterntrig[4],11) ) printf(" S12_6B\n");
124    
125     //S11
126     if ( this->bit(patterntrig[5],0) ) printf(" S11_1A \n");
127     if ( this->bit(patterntrig[5],1) ) printf(" S11_2A \n");
128     if ( this->bit(patterntrig[5],2) ) printf(" S11_3A \n");
129     if ( this->bit(patterntrig[5],3) ) printf(" S11_4A \n");
130     if ( this->bit(patterntrig[5],4) ) printf(" S11_5A \n");
131     if ( this->bit(patterntrig[5],5) ) printf(" S11_6A \n");
132     if ( this->bit(patterntrig[5],6) ) printf(" S11_7A \n");
133     if ( this->bit(patterntrig[5],7) ) printf(" S11_8A \n");
134    
135     if ( this->bit(patterntrig[5],8) ) printf(" S11_1B\n");
136     if ( this->bit(patterntrig[5],9) ) printf(" S11_2B\n");
137     if ( this->bit(patterntrig[5],10) ) printf(" S11_3B\n");
138     if ( this->bit(patterntrig[5],11) ) printf(" S11_4B\n");
139     if ( this->bit(patterntrig[5],12) ) printf(" S11_5B\n");
140     if ( this->bit(patterntrig[5],13) ) printf(" S11_6B\n");
141     if ( this->bit(patterntrig[5],14) ) printf(" S11_7B\n");
142     if ( this->bit(patterntrig[5],15) ) printf(" S11_8B\n");
143    
144     }
145    
146     bool TrigLevel2::checkPMTpatterntrig(){
147     UInt_t *patterntrig = this->patterntrig;
148     int S11 = 0;
149     int S12 = 0;
150     int S21 = 0;
151     int S22 = 0;
152     int S31 = 0;
153     int S32 = 0;
154    
155     //S3
156     if ( this->bit(patterntrig[2],0) ) S31 = 1;
157     if ( this->bit(patterntrig[2],1) ) S31 = 1;
158     if ( this->bit(patterntrig[2],2) ) S31 = 1;
159     if ( this->bit(patterntrig[2],3) ) S31 = 1;
160     if ( this->bit(patterntrig[2],4) ) S31 = 1;
161     if ( this->bit(patterntrig[2],5) ) S31 = 1;
162     if ( this->bit(patterntrig[2],6) ) S32 = 1;
163     if ( this->bit(patterntrig[2],7) ) S32 = 1;
164     if ( this->bit(patterntrig[2],8) ) S32 = 1;
165     if ( this->bit(patterntrig[2],9) ) S32 = 1;
166     if ( this->bit(patterntrig[2],10) ) S32 = 1;
167     if ( this->bit(patterntrig[2],11) ) S32 = 1;
168     //S2
169     if ( this->bit(patterntrig[3],0) ) S21 = 1;
170     if ( this->bit(patterntrig[3],1) ) S21 = 1;
171     if ( this->bit(patterntrig[3],2) ) S21 = 1;
172     if ( this->bit(patterntrig[3],3) ) S21 = 1;
173     if ( this->bit(patterntrig[3],4) ) S22 = 1;
174     if ( this->bit(patterntrig[3],5) ) S22 = 1;
175     if ( this->bit(patterntrig[3],6) ) S22 = 1;
176     if ( this->bit(patterntrig[3],7) ) S22 = 1;
177     //S12
178     if ( this->bit(patterntrig[4],0) ) S12 = 1;
179     if ( this->bit(patterntrig[4],1) ) S12 = 1;
180     if ( this->bit(patterntrig[4],2) ) S12 = 1;
181     if ( this->bit(patterntrig[4],3) ) S12 = 1;
182     if ( this->bit(patterntrig[4],4) ) S12 = 1;
183     if ( this->bit(patterntrig[4],5) ) S12 = 1;
184     if ( this->bit(patterntrig[4],6) ) S12 = 1;
185     if ( this->bit(patterntrig[4],7) ) S12 = 1;
186     if ( this->bit(patterntrig[4],8) ) S12 = 1;
187     if ( this->bit(patterntrig[4],9) ) S12 = 1;
188     if ( this->bit(patterntrig[4],10) ) S12 = 1;
189     if ( this->bit(patterntrig[4],11) ) S12 = 1;
190     //S11
191     if ( this->bit(patterntrig[5],0) ) S11 = 1;
192     if ( this->bit(patterntrig[5],1) ) S11 = 1;
193     if ( this->bit(patterntrig[5],2) ) S11 = 1;
194     if ( this->bit(patterntrig[5],3) ) S11 = 1;
195     if ( this->bit(patterntrig[5],4) ) S11 = 1;
196     if ( this->bit(patterntrig[5],5) ) S11 = 1;
197     if ( this->bit(patterntrig[5],6) ) S11 = 1;
198     if ( this->bit(patterntrig[5],7) ) S11 = 1;
199     if ( this->bit(patterntrig[5],8) ) S11 = 1;
200     if ( this->bit(patterntrig[5],9) ) S11 = 1;
201     if ( this->bit(patterntrig[5],10) ) S11 = 1;
202     if ( this->bit(patterntrig[5],11) ) S11 = 1;
203     if ( this->bit(patterntrig[5],12) ) S11 = 1;
204     if ( this->bit(patterntrig[5],13) ) S11 = 1;
205     if ( this->bit(patterntrig[5],14) ) S11 = 1;
206     if ( this->bit(patterntrig[5],15) ) S11 = 1;
207    
208     // trigger configuration for the event from patterntrig
209     int TOF1 = (S11 + S12) * (S21 + S22) * (S31 + S32);
210     int TOF2 = (S11 * S12) * (S21 * S22) * (S31 * S32);
211    
212     int TOF3 = (S21 + S22) * (S31 + S32);
213     int TOF4 = (S21 * S22) * (S31 * S32);
214    
215     int TOF5 = S12 * (S21 * S22);
216    
217     int TOF6 = (S11 + S12) * (S31 + S32);
218     int TOF7 = (S11 * S12) * (S31 * S32);
219    
220     // trigger configuration of the run
221     bool TCTOF1 = false;
222     bool TCTOF2 = false;
223     bool TCTOF3 = false;
224     bool TCTOF4 = false;
225     bool TCTOF5 = false;
226     bool TCTOF6 = false;
227     bool TCTOF7 = false;
228     if ( this->trigconf & (1<<0) ) TCTOF1 = true;
229     if ( this->trigconf & (1<<1) ) TCTOF2 = true;
230     if ( this->trigconf & (1<<2) ) TCTOF3 = true;
231     if ( this->trigconf & (1<<3) ) TCTOF4 = true;
232     if ( this->trigconf & (1<<4) ) TCTOF5 = true;
233     if ( this->trigconf & (1<<5) ) TCTOF6 = true;
234     if ( this->trigconf & (1<<6) ) TCTOF7 = true;
235    
236     // do patterntrig pmts match the trigger configuration?
237     bool patterntrig_trigconf_match = true;
238     if ( TOF1 == 0 && TCTOF1 ) patterntrig_trigconf_match = false;
239     if ( TOF2 == 0 && TCTOF2 ) patterntrig_trigconf_match = false;
240     if ( TOF3 == 0 && TCTOF3 ) patterntrig_trigconf_match = false;
241     if ( TOF4 == 0 && TCTOF4 ) patterntrig_trigconf_match = false;
242     if ( TOF5 == 0 && TCTOF5 ) patterntrig_trigconf_match = false;
243     if ( TOF6 == 0 && TCTOF6 ) patterntrig_trigconf_match = false;
244     if ( TOF7 == 0 && TCTOF7 ) patterntrig_trigconf_match = false;
245    
246     return patterntrig_trigconf_match;
247     }

  ViewVC Help
Powered by ViewVC 1.1.23