/[PAMELA software]/quicklook/QLflightTmtc_Header/TmtcTemperature.cpp
ViewVC logotype

Annotation of /quicklook/QLflightTmtc_Header/TmtcTemperature.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Thu Jul 6 17:01:08 2006 UTC (18 years, 4 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v1r08
Changes since 1.4: +16 -8 lines
Tmtc: stato ipm aggiornato

1 pam-fi 1.3
2    
3 pam-rm2 1.1 /**
4     * TmtcTemperature
5     * author Marcelli
6     * version 1.1 - 10 December 2005
7     *
8     * Version 1.2 - 28 December 2004
9     * If TFile does not exist the function exit to prompt
10     * If nevents = 0 the function exit to promt
11     * Initialize to 0 alla array dedicated to graphs
12     *
13     * version 1.3 - 22 February 2005 - Nagni
14     * For compatibility with batch mode excution:
15     * 1) Added "include <iostream>" and "using namespace std"
16     * 2) Removed gROOT->Reset()
17     *
18     * version 1.4 - 25 February 2005 - Marcelli
19     * Canvas of thermistors divided in 12 pads
20     *
21     * Version 1.5
22     * Date 08 March 2005 - Nagni
23     * Added "format" parameter for saving the produced image in various formats
24     * (for a complete list of types refer to TPad::SaveAs method)
25     *
26     * version 1.6
27     * Date 24 May 2005 - Marcelli
28     * Added four thermistor (files after DW_050516_007 has 16 thermistors instead of 12)
29     *
30     * version 1.7
31     * Date 02 February 2006 - Marcelli
32     * Modified to work with new version of YODA
33     *
34     * version 1.8
35     * Date March 2006 - Marcelli
36     * For compilation:
37     * Added function "int main(int argc, char* argv[])"
38     *
39     * Description : To monitor information from TMTC Packet (voltage, CC,....)
40     *
41     * Parameters:
42     * TString base - the path to the root directory for the specific Pamela unpack session
43     * TString outDir - the path where to save the output image (Default = base)
44     * TString format - the format which will be used fo rsave the produced images (Default = "jpg")
45     *
46     */
47    
48    
49    
50    
51     #include <iostream>
52     #include <sstream>
53     #include "TStyle.h"
54     #include "TFile.h"
55 pam-fi 1.3 #include "TAxis.h"
56     #include "TLegend.h"
57     #include "TF1.h"
58 pam-rm2 1.1 #include "TList.h"
59     #include "TTree.h"
60     #include "TObjString.h"
61     #include "TCanvas.h"
62     #include "TGraph.h"
63 pam-fi 1.3 #include "TMultiGraph.h"
64 pam-rm2 1.1 #include "TH1F.h"
65     #include "TGaxis.h"
66     #include "TString.h"
67     #include "TPaveText.h"
68     #include "tmtc/TmtcEvent.h"
69     #include "tmtc/TmtcRecord.h"
70    
71    
72     using namespace std;
73    
74     ///////////////////////////////////////////////////////////////////////////////////////////////
75     /////////////////////////////////////FUNZIONI DI CONVERSIONE///////////////////////////////////
76     ///////////////////////////////////////////////////////////////////////////////////////////////
77    
78    
79     //reference: Laben Document, TL 18348, pag. 79
80     float convert_th(int TH) {
81    
82     float a,q,deltax,deltay;
83     float gradi[111],grado=-1;
84     int adc[111]={4095, 3868, 3654, 3454, 3265, 3088, 2922, 2765, 2618, 2479, 2348, 2225, 2110, 2000, 1897, 1800, 1709, 1622, 1541, 1464, 1391, 1322, 1257, 1196, 1138, 1083, 1031, 981, 935, 890, 849, 809, 771, 736, 702, 670, 639, 610, 583, 557, 532, 508, 486, 464, 444, 425, 406, 389, 372, 356, 341, 327, 313, 300, 288, 276, 264, 254, 243, 233, 224, 215, 206, 198, 190, 183, 175, 169, 162, 156, 150, 144, 138, 133, 128, 123, 118, 114, 110, 106, 102, 98, 94, 91, 87, 84, 81, 78, 75, 73, 70, 67, 65, 63, 60, 58, 56, 54, 52, 50, 49, 47, 45, 44, 42, 41, 39, 38, 37, 35, 34};
85     int maxpos=-1,minpos=-1,i;
86    
87     for (i=0;i<111;i++)
88     {
89     gradi[i]=-35+i;
90     }
91    
92     if (TH > 4095)
93     {
94     grado=100.;
95     return grado;
96     }
97    
98     if (TH <= 34)
99     {
100     grado=100.;
101     return grado;
102     }
103    
104    
105     if (TH==4095)
106     {
107     grado=-35.;
108     return grado;
109     }
110     else
111     {
112    
113     for (i=1;i<111;i++)
114     {
115     if (TH>=adc[i])
116     {
117     minpos=i;
118     maxpos=i-1;
119     break;
120     }
121     }
122     deltax=adc[maxpos]-adc[minpos];
123     deltay=gradi[maxpos]-gradi[minpos];
124     a=deltay/deltax;
125     q=gradi[maxpos]-a*adc[maxpos];
126     grado=a*TH+q;
127     }
128     return (grado);
129     }
130    
131    
132    
133     //reference: Laben Document, TL 18348, pag. 76
134     float convert_volt(int in) {
135    
136     float a,q,deltax,deltay;
137     float inputvoltage[52],voltage=-1;
138     float adc[52];
139     int maxpos=-1,minpos=-1,i;
140    
141     for (i=0;i<52;i++)
142     {
143     inputvoltage[i] = (i*0.10);
144     }
145     for (i=0;i<52;i++)
146     {
147     adc[i] = (i*5);
148     }
149    
150     if (in==0)
151     {
152     voltage= 0.00;
153     }
154     else
155     {
156    
157     for (i=0;i<52;i++)
158     {
159     if (in<=adc[i])
160     {
161     minpos=i;
162     maxpos=i-1;
163     break;
164     }
165     }
166     deltax=adc[maxpos]-adc[minpos];
167     deltay=inputvoltage[maxpos]-inputvoltage[minpos];
168     a=deltay/deltax;
169     q=inputvoltage[maxpos]-a*adc[maxpos];
170     voltage=a*in+q;
171     }
172     return (voltage);
173    
174     }
175    
176    
177     ////////////////////////////////////////////////////////////////////////////////
178     ////////////////////////// TMTC TEMPERATURE //////////////////////////////////
179     //////////////////////////////////////////////////////////////////////////////////
180    
181     void TmtcTemperature(TString base, TString outDir, TString format){
182    
183     //------- load root file --------------
184     TFile *file = new TFile(base.Data());
185    
186     if ( outDir == "" ) outDir = ".";
187    
188     if (!file){
189     printf("No such file in the directory has been found");
190     return;
191     }
192    
193     //--- Takes the tree of Tmtc -----------
194     TPaveText *pt=0;
195     TPaveText *pt1=0;
196    
197     TTree *tr = (TTree*)file->Get("Tmtc");
198     TBranch *tmtcBr = tr->GetBranch("Tmtc");
199    
200     pamela::TmtcEvent *tme=0;
201     pamela::TmtcRecord *tmr=0;
202    
203     tr->SetBranchAddress("Tmtc", &tme);
204    
205     //////--------to analize data-----------------//////
206     Long64_t nevents = tmtcBr->GetEntries();
207     if (nevents<=0) {
208     file->Close();
209     printf("nevents = %i", nevents);
210     return;
211     }
212    
213    
214 pam-rm2 1.5 string titolocc[] ={"IPM1 input","IPM2 input","IPM3 input","IPM4 input","IPM5 input","IPM6 input","KHB_HOT","KHB_COLD","IDAQ_HOT","IDAQ_COLD","VCB_STANDBY","VRL_HOT","VRL_COLD","PSB","TOFHV_HOT","TOFHV_COLD"};
215 pam-fi 1.3
216 pam-rm2 1.4 string titoloth[] ={"IPM_TH","S1_TH","S4_TH","S4_ND_PLATE_TH","TRK_TH1","TRK_TH2","FLUID_IN_TH","FLUID_OUT_TH","VME_TH1","DCDC_TH","CPU_TH1","CPU_TH2", "IPM_CPU_TH", "VRL_TH1", "VRL_TH2", "VME_TH2"};
217 pam-fi 1.3
218    
219     const Int_t size = nevents;
220 pam-rm2 1.1 std::stringstream oss;
221     Int_t recordstot=0;
222 pam-fi 1.3 Int_t recordstotmax=0;
223     Int_t records[size];
224     Int_t ev[size];
225     Double_t OBT[size];
226     Int_t tot=0;
227 pam-rm2 1.1 Int_t m=0;
228     Int_t l=0;
229    
230 pam-fi 1.3
231     for (Int_t i = 0; i < size; i++){ ///ciclo per decidere le pagine
232 pam-rm2 1.1 tmtcBr->GetEntry(i);
233 pam-fi 1.3 Long64_t tmpSize = tme->Records->GetEntries();
234 pam-rm2 1.1 recordstot=recordstot+tmpSize;
235 pam-fi 1.3 if (tmpSize>0){
236     tmr = (pamela::TmtcRecord*)tme->Records->At(0);
237     if(i==0){
238     ev[0]=0;
239     records[0]=0;
240     OBT[0]=tmr->TM_RECORD_OBT;
241 pam-rm2 1.4 }else if (fmod(i, 35)==0 || ((tmr->TM_RECORD_OBT)<OBT[i-1]) || (i==(size-1)) ){
242 pam-fi 1.3 //}else if ((fmod(i, 20)==0) || (i==(size-1)) ){
243     tot=tot+1;
244     if (recordstotmax<recordstot) recordstotmax=recordstot;
245     records[tot]=recordstot;
246     OBT[tot]=tmr->TM_RECORD_OBT;
247     ev[tot]=i;
248     recordstot=0;
249 pam-rm2 1.1 }
250 pam-fi 1.3 }
251     }
252    
253 pam-rm2 1.1
254    
255 pam-fi 1.3 const Int_t lungmax=16*recordstotmax;
256     const Int_t lungmin=6*recordstotmax;
257    
258    
259 pam-rm2 1.4 Double_t xrecordobtcc[lungmax], yccdiagacq[lungmax], ythana[lungmax], xrecordobtth[lungmax], xrecordobtdea[lungmin], ydea[lungmin], xrecordobtcc_1[lungmax], xrecordobtcc_1d[lungmax], xrecordobtcc_1u[lungmax], yccdiagacq_1[lungmax], yccdiagacq_1d[lungmax], yccdiagacq_1u[lungmax], ythana_1[lungmax], xrecordobtth_1[lungmax], xrecordobtdea_1[lungmin], ydea_1[lungmin];
260 pam-fi 1.3
261     Double_t yccdiagacq_11u[lungmax], yccdiagacq_11d[lungmax], yccipm12u[lungmax], yccipm12d[lungmax], yccipmkk1u[lungmax], yccipmkk1d[lungmax], yccipmerror[lungmax], yccipmerror2[lungmax];
262    
263 pam-fi 1.2
264 pam-rm2 1.1
265 pam-fi 1.3 /////ciclo sulle pagine////////////////////
266     for (Int_t interval=0; interval<tot; interval++){
267    
268     ///-------to create canvas--------------------//
269     TCanvas *Canvascc = new TCanvas("Tmtc_1", base, 2500, 2000);
270     Canvascc->Divide(1,15);
271     Canvascc->SetFillColor(10);
272    
273     TCanvas *Canvasthdea = new TCanvas("Tmtc_4", base, 1280, 1024);
274     Canvasthdea->SetFillColor(10);
275     Canvasthdea->Divide(4,4);
276 pam-rm2 1.1
277 pam-fi 1.3
278     TCanvas *Canvasvoltdea = new TCanvas("Tmtc_5", base, 1280, 1024);
279     Canvasvoltdea->SetFillColor(10);
280     Canvasvoltdea->Divide(2,3);
281    
282    
283     recordstot=0;
284    
285     for (Int_t i = ev[interval]; i < ev[interval+1]; i++){ //ciclo su un sottogruppo
286     // cout<<"ciclo da "<<ev[interval]<<" a "<< ev[interval+1]<<"\n";
287     tmtcBr->GetEntry(i);
288     l=0;
289     m=0;
290     Long64_t tmpSize = tme->Records->GetEntries();
291     Int_t size_b = tmpSize;
292     for (Int_t j = 0; j < size_b; j++){
293     tmr = (pamela::TmtcRecord*)tme->Records->At(j);
294    
295     for (Int_t k =0; k <16; k++){
296     yccdiagacq[16*recordstot+16*j+k] = (((tmr->TM_DIAG_AND_BILEVEL_ACQ)>>(15-k))&0x0001);
297     xrecordobtcc[16*recordstot+16*j+k] = tmr->TM_RECORD_OBT;
298     }
299    
300     for (Int_t k =0; k <16; k++){
301     ythana[16*recordstot+16*j+k] = convert_th(tmr->TM_TH_ANA[k]);
302     xrecordobtth[16*recordstot+16*j+k] = tmr->TM_RECORD_OBT;
303     }
304    
305     for (Int_t k =0; k <6; k++){
306     ydea[6*recordstot+6*j+k] = convert_volt(tmr->TM_DEA_ANA[k]);
307     xrecordobtdea[6*recordstot+6*j+k] = tmr->TM_RECORD_OBT;
308     }
309     }
310     recordstot=recordstot+tmpSize;
311     }
312    
313     TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString();
314     filename = ((TObjString*)filename.Tokenize('.')->First())->GetString();
315    
316     TLegend *leg1 = new TLegend(0.87,0.80,0.98,0.94, "");
317     leg1->SetFillColor(10);
318     leg1->SetBorderSize(0);
319    
320     Canvascc->cd();
321     pt = new TPaveText (.87,.95,.98,.98);
322     oss.str("");
323     oss<<filename.Data();
324     pt->AddText(oss.str().c_str());
325     pt->SetTextColor(1);
326     //pt->SetTextSize(1);
327     pt->SetFillColor(10);
328     pt->SetBorderSize(0);
329     pt->Draw();
330    
331     /*
332     TLine *line = new TLine;
333     line->SetLineColor(4);
334     line->SetLineWidth(2);
335     line->DrawLine(0, 0.60, 1, 0.60);
336     line->Draw();
337     line->DrawLine(0, 0.33, 1, 0.33);
338     line->Draw();
339     line->DrawLine(0, 0.20, 1, 0.20);
340     line->Draw();
341     line->DrawLine(0, 0.13, 1, 0.13);
342     line->Draw();
343     */
344    
345    
346    
347     //CC Graph
348     for (Int_t k =0; k<16; k++){
349     for (Int_t i = 0; i < recordstot; i++){
350     if (k>0) {
351     yccdiagacq_11u[i]=yccdiagacq_1u[i];
352     yccdiagacq_11d[i]=yccdiagacq_1d[i];
353     }
354     yccdiagacq_1d[i]=0;
355     yccdiagacq_1u[i]=0;
356     if (yccdiagacq[16*i+k]==0) {
357     yccdiagacq_1d[i]=-1;
358     xrecordobtcc_1[i]= xrecordobtcc[16*i+k];
359     }
360     else if (yccdiagacq[16*i+k]==1){
361     yccdiagacq_1u[i]=1;
362     xrecordobtcc_1[i]= xrecordobtcc[16*i+k];
363     }
364     if (k==1) {
365     if (yccdiagacq_11u[i]==1 && yccdiagacq_1u[i]==1) yccipm12u[i]=1;
366     else yccipm12u[i]=0;
367     if (yccdiagacq_11d[i]==-1 && yccdiagacq_1d[i]==-1) yccipm12d[i]=-1;
368     else yccipm12d[i]=0;
369     }
370     if (k==1 || k==3 || k==5 || k==7 || k==9) {
371     if (yccdiagacq_11u[i]==1 && yccdiagacq_1u[i]==1) yccipmkk1u[i]=1;
372     else yccipmkk1u[i]=0;
373     if (yccdiagacq_11d[i]==-1 && yccdiagacq_1d[i]==-1) yccipmkk1d[i]=-1;
374     else yccipmkk1d[i]=0;
375     if (k==7 || k==9) {
376 pam-rm2 1.5 /* if (yccipmkk1u[i]==1 && yccipm12d[i]==0 && yccipm12u[i]==0) yccipmerror[i]=1;
377 pam-fi 1.3 else if (yccipmkk1d[i]==-1 && yccipm12d[i]==0 && yccipm12u[i]==0 || (yccipmkk1d[i]==-1 && yccipm12u[i]==1)) yccipmerror[i]=-1;
378 pam-rm2 1.5 else yccipmerror[i]=0;*/
379     if ((yccipmkk1u[i]==1 && ydea[6*i]<0.65 && ydea[6*i+1]>3.15 && ydea[6*i+1]<4.25) || (yccipmkk1u[i]==1 && ydea[6*i+1]<0.65 && ydea[6*i]>3.15 && ydea[6*i]<4.25)) yccipmerror[i]=1;
380     else if ((yccipmkk1d[i]==-1 && ydea[6*i]<0.65 && ydea[6*i+1]>3.15 && ydea[6*i+1]<4.25) || (yccipmkk1d[i]==-1 && ydea[6*i+1]<0.65 && ydea[6*i]>3.15 && ydea[6*i]<4.25) || (yccipmkk1d[i]==-1 && ydea[6*i]<0.65 && ydea[6*i+1]<0.65)) yccipmerror[i]=-1;
381 pam-fi 1.3 else yccipmerror[i]=0;
382     }
383     }
384     if (k==6 || k==7 || k==8 || k==9) {
385 pam-rm2 1.5 /*if (yccdiagacq_1d[i]==-1 && yccipm12u[i]==1) yccipmerror2[i]=-1;
386     else yccipmerror2[i]=0;*/
387     if (yccdiagacq_1d[i]==-1 && ydea[6*i]<0.65 && ydea[6*i+1]<0.65) yccipmerror2[i]=-1;
388 pam-fi 1.3 else yccipmerror2[i]=0;
389     }
390     if (k==13) {
391 pam-rm2 1.5 if ((yccdiagacq_1d[i]==-1 && ydea[6*i]<0.65 && ydea[6*i+1]>3.15 && ydea[6*i+1]<4.25) || (yccdiagacq_1d[i]==-1 && ydea[6*i+1]<0.65 && ydea[6*i]>3.15 && ydea[6*i]<4.25)) yccdiagacq_1d[i]==-1; //psb on
392     if (yccdiagacq_1u[i]==1 && ydea[6*i]<0.65 && ydea[6*i+1]<0.65) yccdiagacq_1u[i]==1; //psb off
393     /*if (yccdiagacq_1d[i]==-1 && yccipm12d[i]==-1) yccipmerror[i]=-1;
394 pam-fi 1.3 else if (yccdiagacq_1u[i]==1 && yccipm12d[i]==0 && yccipm12u[i]==0) yccipmerror[i]=1;
395 pam-rm2 1.5 else yccipmerror[i]=0;*/
396     if (yccdiagacq_1d[i]==-1 && ydea[6*i]<0.65 && ydea[6*i+1]<0.65) yccipmerror[i]=-1;
397     else if ((yccdiagacq_1u[i]==1 && ydea[6*i]<0.65 && ydea[6*i+1]>3.15 && ydea[6*i+1]<4.25) || (yccdiagacq_1u[i]==1 && ydea[6*i+1]<0.65 && ydea[6*i]>3.15 && ydea[6*i]<4.25)) yccipmerror[i]=1;
398     else yccipmerror[i]=0; //psb alarm
399 pam-fi 1.3 }
400     if (k==15) {
401     yccdiagacq_11u[i]=0;
402     yccdiagacq_11d[i]=0;
403     }
404     }
405    
406     //CC IPM
407     if (k==0 || k==1 ||k==2 || k==3 || k==4 || k==5 ){
408     Canvascc->cd(m+1);
409     Canvascc->cd(m+1)->SetGridx();
410     gPad->SetFillColor(10);
411     gPad->SetFrameBorderSize(0);
412     gPad->SetLineColor(1);
413     gPad->SetFrameBorderMode(0);
414    
415    
416     pt = new TPaveText (.01,.30,.10,.70);
417     oss.str("");
418     oss<<titolocc[k];
419     pt->AddText(oss.str().c_str());
420     pt->SetFillColor(10);
421     pt->SetBorderSize(0);
422     pt->Draw();
423    
424    
425     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
426     ccrecordd->SetTitle("");
427     ccrecordd->SetFillColor(8);
428     ccrecordd->GetXaxis()->SetLabelSize(0);
429     ccrecordd->GetXaxis()->SetTickLength(0);
430     ccrecordd->GetYaxis()->SetLabelSize(0);
431     ccrecordd->GetYaxis()->SetTickLength(0);
432     ccrecordd->SetMaximum(1.3);
433     ccrecordd->SetMinimum(-1.3);
434     ccrecordd->GetXaxis()->SetAxisColor(0);
435     ccrecordd->Draw("AB");
436     if (k==0) leg1->AddEntry(ccrecordd,"ON","f");
437    
438     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
439     ccrecordu->SetTitle("");
440     ccrecordu->SetFillColor(17);
441     ccrecordu->GetXaxis()->SetLabelSize(0);
442     ccrecordu->GetXaxis()->SetTickLength(0);
443     ccrecordu->GetYaxis()->SetLabelSize(0);
444     ccrecordu->GetYaxis()->SetTickLength(0);
445     ccrecordu->GetXaxis()->SetAxisColor(0);
446     ccrecordu->SetMaximum(1.3);
447     ccrecordu->SetMinimum(-1.3);
448     ccrecordu->Draw("Bsame");
449     if (k==0) leg1->AddEntry(ccrecordu,"OFF","f");
450    
451    
452     if (k==1 || k==3 || k==5){
453     Canvascc->cd(m);
454     TGraph *ccrecorderrord = new TGraph(recordstot, xrecordobtcc_1, yccipmkk1d);
455     ccrecorderrord->SetTitle("");
456     ccrecorderrord->SetFillColor(2);
457     ccrecorderrord->GetXaxis()->SetLabelSize(0);
458     ccrecorderrord->GetXaxis()->SetTickLength(0);
459     ccrecorderrord->GetYaxis()->SetLabelSize(0);
460     ccrecorderrord->GetYaxis()->SetTickLength(0);
461     ccrecorderrord->SetMaximum(1.3);
462     ccrecorderrord->SetMinimum(-1.3);
463     ccrecorderrord->GetXaxis()->SetAxisColor(0);
464     ccrecorderrord->Draw("Bsame");
465    
466     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmkk1u);
467     ccrecorderroru->SetTitle("");
468     ccrecorderroru->SetFillColor(2);
469     ccrecorderroru->GetXaxis()->SetLabelSize(0);
470     ccrecorderroru->GetXaxis()->SetTickLength(0);
471     ccrecorderroru->GetYaxis()->SetLabelSize(0);
472     ccrecorderroru->GetYaxis()->SetTickLength(0);
473     ccrecorderroru->SetMaximum(1.3);
474     ccrecorderroru->SetMinimum(-1.3);
475     ccrecorderroru->GetXaxis()->SetAxisColor(0);
476     ccrecorderroru->Draw("Bsame");
477    
478     Canvascc->cd(m+1);
479     ccrecorderrord->Draw("Bsame");
480     ccrecorderroru->Draw("Bsame");
481     }
482    
483    
484     Double_t xmin;
485     Double_t xmax;
486     xmin=ccrecordu->GetXaxis()->GetXmin();
487     xmax=ccrecordu->GetXaxis()->GetXmax();
488     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 0);
489     axis->Draw("same");
490     /*TF1 *func1 = new TF1("func1", "0");
491     func1->SetRange(xmin,xrecordobtcc_1[recordstot-1]);
492     func1->SetLineColor(1);
493     func1->SetLineStyle(1);
494     func1->SetLineWidth(2);
495     func1->Draw("same");*/
496    
497     m=m+1;
498     }
499    
500     //CC idaq-khb-tof
501     if (k==6 || k==7 || k==8 || k==9 || k==14 || k==15){
502     Canvascc->cd(l+7);
503     gPad->SetFillColor(10);
504     gPad->SetFrameBorderSize(0);
505    
506     pt = new TPaveText (.00,.30,.09,.70);
507     oss.str("");
508     oss<<titolocc[k];
509     pt->AddText(oss.str().c_str());
510     pt->SetFillColor(10);
511     pt->SetBorderSize(0);
512     pt->Draw();
513    
514    
515     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
516     ccrecordd->SetTitle("");
517     if (k==14 || k==15) ccrecordd->SetFillColor(2);
518     else ccrecordd->SetFillColor(8);
519     ccrecordd->GetXaxis()->SetLabelSize(0);
520     ccrecordd->GetXaxis()->SetTickLength(0);
521     ccrecordd->GetYaxis()->SetLabelSize(0);
522     ccrecordd->GetYaxis()->SetTickLength(0);
523     ccrecordd->SetMaximum(1.3);
524     ccrecordd->SetMinimum(-1.3);
525     ccrecordd->GetXaxis()->SetAxisColor(0);
526     ccrecordd->Draw("AB");
527    
528     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
529     ccrecordu->SetTitle("");
530     if (k==14 || k==15) {
531     ccrecordu->SetFillColor(7);
532     if (k==14) leg1->AddEntry(ccrecordu,"ON-OFF-LATCHUP","f");
533     }
534     else ccrecordu->SetFillColor(17);
535     ccrecordu->GetXaxis()->SetAxisColor(0);
536     ccrecordu->GetXaxis()->SetLabelSize(0);
537     ccrecordu->GetXaxis()->SetTickLength(0);
538     ccrecordu->GetYaxis()->SetLabelSize(0);
539     ccrecordu->GetYaxis()->SetTickLength(0);
540     ccrecordu->SetMaximum(1.3);
541     ccrecordu->SetMinimum(-1.3);
542     ccrecordu->Draw("Bsame");
543    
544     if (k==6 || k==7 || k==8 || k==9){
545     Canvascc->cd(l+7);
546     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmerror2);
547     ccrecorderroru->SetTitle("");
548     ccrecorderroru->SetFillColor(2);
549     ccrecorderroru->GetXaxis()->SetLabelSize(0);
550     ccrecorderroru->GetXaxis()->SetTickLength(0);
551     ccrecorderroru->GetYaxis()->SetLabelSize(0);
552     ccrecorderroru->GetYaxis()->SetTickLength(0);
553     ccrecorderroru->SetMaximum(1.3);
554     ccrecorderroru->SetMinimum(-1.3);
555     ccrecorderroru->GetXaxis()->SetAxisColor(0);
556     ccrecorderroru->Draw("Bsame");
557     }
558    
559    
560     if (k==7 || k==9){
561     Canvascc->cd(l+7-1);
562     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmerror);
563     ccrecorderroru->SetTitle("");
564     ccrecorderroru->SetFillColor(2);
565     ccrecorderroru->GetXaxis()->SetLabelSize(0);
566     ccrecorderroru->GetXaxis()->SetTickLength(0);
567     ccrecorderroru->GetYaxis()->SetLabelSize(0);
568     ccrecorderroru->GetYaxis()->SetTickLength(0);
569     ccrecorderroru->SetMaximum(1.3);
570     ccrecorderroru->SetMinimum(-1.3);
571     ccrecorderroru->GetXaxis()->SetAxisColor(0);
572     if (k==7) leg1->AddEntry(ccrecorderroru,"ALARM","f");
573     ccrecorderroru->Draw("Bsame");
574    
575     Canvascc->cd(l+7);
576     ccrecorderroru->Draw("Bsame");
577     }
578    
579    
580     Double_t xmin;
581     Double_t xmax;
582     xmin=ccrecordu->GetXaxis()->GetXmin();
583     xmax=ccrecordu->GetXaxis()->GetXmax();
584     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 1.5);
585     axis->Draw("same");
586     /*TF1 *func1 = new TF1("func1", "0");
587     func1->SetRange(xmin,xrecordobtcc_1[recordstot-1]);
588     func1->SetLineColor(1);
589     func1->SetLineStyle(1);
590     func1->SetLineWidth(2);
591     func1->Draw("same");*/
592     l=l+1;
593    
594     }
595    
596     //CC vrl
597     if (k==11 || k==12 || k==13 ){
598     if (k==13) Canvascc->cd(13);
599     if (k==11) Canvascc->cd(14);
600     if (k==12) Canvascc->cd(15);
601     gPad->SetFillColor(10);
602     gPad->SetFrameBorderSize(0);
603    
604     pt = new TPaveText (.01,.30,.09,.70);
605     oss.str("");
606     oss<<titolocc[k];
607     pt->AddText(oss.str().c_str());
608     pt->SetFillColor(10);
609     pt->SetBorderSize(0);
610     pt->Draw();
611    
612     if (k==11 || k==12){
613     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
614     ccrecordd->SetTitle("");
615     ccrecordd->SetFillColor(8);
616     ccrecordd->GetXaxis()->SetAxisColor(0);
617     ccrecordd->GetXaxis()->SetLabelSize(0);
618     ccrecordd->GetXaxis()->SetTickLength(0);
619     ccrecordd->GetYaxis()->SetLabelSize(0);
620     ccrecordd->GetYaxis()->SetTickLength(0);
621     ccrecordd->SetMaximum(1.3);
622     ccrecordd->SetMinimum(-1.3);
623     ccrecordd->Draw("AB");
624    
625    
626     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
627     ccrecordu->SetTitle("");
628     ccrecordu->SetFillColor(17);
629     ccrecordu->GetXaxis()->SetAxisColor(0);
630     ccrecordu->GetXaxis()->SetLabelSize(0);
631     ccrecordu->GetXaxis()->SetTickLength(0);
632     ccrecordu->GetYaxis()->SetLabelSize(0);
633     ccrecordu->GetYaxis()->SetTickLength(0);
634     ccrecordu->SetMaximum(1.3);
635     ccrecordu->SetMinimum(-1.3);
636     ccrecordu->Draw("Bsame");
637    
638     Double_t xmin;
639     Double_t xmax;
640     xmin=ccrecordu->GetXaxis()->GetXmin();
641     xmax=ccrecordu->GetXaxis()->GetXmax();
642     if (k==12){
643     TGaxis *axis = new TGaxis (xmin, -1, xmax, -1, xmin, xmax, 510, "", 0);
644     axis->SetLabelSize(0.24);
645     axis->SetLabelColor(1);
646     axis->SetTitle("OBT (ms)");
647     //axis->CenterTitle();
648     axis->SetTitleOffset(0.4);
649     axis->SetTitleSize(0.21);
650     axis->Draw();
651     TF1 *func1 = new TF1("func1", "0");
652     func1->SetRange(xmin,xmax);
653     func1->SetLineColor(1);
654     func1->SetLineStyle(1);
655     func1->SetLineWidth(1);
656     func1->Draw("same");
657     }
658     if (k==11){
659     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 0);
660     axis->SetLineWidth(1);
661     axis->SetTickSize(2);
662     axis->Draw("same");
663     }
664     }
665    
666     if (k==13){
667     Canvascc->cd(13);
668    
669     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
670     ccrecordd->SetTitle("");
671     ccrecordd->SetFillColor(8);
672     ccrecordd->GetXaxis()->SetAxisColor(0);
673     ccrecordd->GetXaxis()->SetLabelSize(0);
674     ccrecordd->GetXaxis()->SetTickLength(0);
675     ccrecordd->GetYaxis()->SetLabelSize(0);
676     ccrecordd->GetYaxis()->SetTickLength(0);
677     ccrecordd->SetMaximum(1.3);
678     ccrecordd->SetMinimum(-1.3);
679     ccrecordd->Draw("AB");
680    
681     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
682     ccrecordu->SetTitle("");
683     ccrecordu->SetFillColor(17);
684     ccrecordu->GetXaxis()->SetAxisColor(0);
685     ccrecordu->GetXaxis()->SetLabelSize(0);
686     ccrecordu->GetXaxis()->SetTickLength(0);
687     ccrecordu->GetYaxis()->SetLabelSize(0);
688     ccrecordu->GetYaxis()->SetTickLength(0);
689     ccrecordu->SetMaximum(1.3);
690     ccrecordu->SetMinimum(-1.3);
691     ccrecordu->Draw("Bsame");
692    
693     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmerror);
694     ccrecorderroru->SetTitle("");
695     ccrecorderroru->SetFillColor(2);
696     ccrecorderroru->GetXaxis()->SetLabelSize(0);
697     ccrecorderroru->GetXaxis()->SetTickLength(0);
698     ccrecorderroru->GetYaxis()->SetLabelSize(0);
699     ccrecorderroru->GetYaxis()->SetTickLength(0);
700     ccrecorderroru->SetMaximum(1.3);
701     ccrecorderroru->SetMinimum(-1.3);
702     ccrecorderroru->GetXaxis()->SetAxisColor(0);
703     ccrecorderroru->Draw("Bsame");
704    
705    
706     Double_t xmin=ccrecordu->GetXaxis()->GetXmin();
707     Double_t xmax=ccrecordu->GetXaxis()->GetXmax();
708     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 0);
709     axis->SetLineWidth(1);
710     axis->SetTickSize(2);
711     axis->Draw("same");
712     }
713    
714     }
715    
716     }
717    
718     Canvascc->cd();
719     leg1->Draw();
720     Canvascc->Update();
721    
722     // TH Graph
723     Canvasthdea->cd();
724     //thermistors number=16
725     if (tr->GetBranch("Records.TM_TH_ANA[16]")){
726     for (Int_t k =0; k<16; k++){
727     for (Int_t i = 0; i < recordstot; i++){
728     ythana_1[i]= ythana[16*i+k];
729     xrecordobtth_1[i]= xrecordobtth[16*i+k];
730     }
731     Canvasthdea->cd(k+1);
732    
733     TGraph *threcord = new TGraph(recordstot, xrecordobtth_1, ythana_1);
734     threcord->SetLineColor(kBlue);
735     threcord->SetMarkerColor(kBlue);
736     threcord->SetMarkerStyle(21);
737 pam-rm2 1.4 threcord->SetMinimum(-10);
738     threcord->SetMaximum(60);
739     threcord->GetXaxis()->SetTitle("OBT");
740     threcord->GetXaxis()->CenterTitle();
741     threcord->GetYaxis()->SetTitle("Temperature value (°C)");
742     threcord->GetYaxis()->CenterTitle();
743     oss.str("");
744     oss << filename.Data() <<": " <<titoloth[k] ;
745     threcord->SetTitle(oss.str().c_str());
746    
747     Double_t xmin=threcord->GetXaxis()->GetXmin();
748     Double_t xmax=threcord->GetXaxis()->GetXmax();
749     if (k==10 || k==11 ) {
750     TPaveText *pt = new TPaveText (.45,.75,.55,.82);
751     pt->AddText("OFF");
752     pt->SetBorderSize(1);
753     pt->Draw();
754     threcord->Draw("ACsame");
755     TF1 *func1 = new TF1("func1", "50");
756     func1->SetRange(xmin,xmax);
757     func1->SetLineColor(2);
758     func1->SetLineStyle(1);
759     func1->SetLineWidth(2);
760     func1->Draw("same");
761     pt->Draw();
762     }else {
763     TPaveText *pt = new TPaveText (.45,.7,.55,.77);
764     pt->AddText("OFF");
765     pt->SetBorderSize(1);
766     pt->Draw();
767     threcord->Draw("ACsame");
768     TF1 *func1 = new TF1("func1", "45");
769     func1->SetRange(xmin,xmax);
770     func1->SetLineColor(2);
771     func1->SetLineStyle(1);
772     func1->SetLineWidth(2);
773     func1->Draw("same");
774     pt->Draw();
775     }
776    
777    
778    
779 pam-fi 1.3 }
780     }
781    
782     // DEA Graph
783     Canvasvoltdea->cd();
784     for (Int_t k =0; k<6; k++){
785     for (Int_t i = 0; i < recordstot; i++){
786     ydea_1[i]= ydea[6*i + k];
787     xrecordobtdea_1[i]= xrecordobtdea[6*i+k];
788     }
789     Canvasvoltdea->cd(k+1);
790 pam-rm2 1.4
791 pam-fi 1.3 TPaveText *pt = new TPaveText (.84,.13,.92,.19);
792     pt->AddText("OFF");
793     pt->SetBorderSize(1);
794     pt->Draw();
795     TPaveText *pt1 = new TPaveText (.84,.67,.92,.73);
796     pt1->AddText("ON");
797     pt1->SetBorderSize(1);
798     pt1->Draw();
799    
800     TGraph *dearecord = new TGraph(recordstot, xrecordobtdea_1, ydea_1);
801     dearecord->SetLineColor(kBlue);
802     dearecord->SetLineWidth(1);
803     dearecord->SetMarkerStyle(21);
804     dearecord->SetMarkerSize(0.5);
805     dearecord->SetMarkerColor(kBlue);
806 pam-rm2 1.4 dearecord->SetMinimum(0.0);
807     dearecord->SetMaximum(5.0);
808     dearecord->GetXaxis()->SetTitle("OBT");
809     dearecord->GetXaxis()->CenterTitle();
810     dearecord->GetYaxis()->SetTitle("Voltage value (V)");
811     dearecord->GetYaxis()->CenterTitle();
812     oss.str("");
813 pam-rm2 1.5 oss << filename.Data()<<": IPM "<<k+1<<" output";
814 pam-rm2 1.4 dearecord->SetTitle(oss.str().c_str());
815     dearecord->Draw("ACPLsame");
816    
817     Double_t xmin=dearecord->GetXaxis()->GetXmin();
818     Double_t xmax=dearecord->GetXaxis()->GetXmax();
819     TF1 *func1 = new TF1("func1", "0.65");
820     func1->SetRange(xmin, xmax);
821     func1->SetLineColor(2);
822     func1->SetLineStyle(1);
823     func1->SetLineWidth(2);
824     func1->Draw("Csame");
825    
826     TF1 *func2 = new TF1("func2", "3.15");
827     func2->SetRange(xmin, xmax);
828     func2->SetLineColor(2);
829     func2->SetLineStyle(1);
830     func2->SetLineWidth(2);
831     func2->Draw("Csame");
832    
833     TF1 *func3 = new TF1("func3", "4.25");
834     func3->SetRange(xmin, xmax);
835     func3->SetLineColor(2);
836     func3->SetLineStyle(1);
837     func3->SetLineWidth(2);
838     func3->Draw("Csame");
839    
840    
841     pt1->Draw();
842     pt->Draw();
843 pam-fi 1.3 }
844    
845    
846     stringstream oss1, oss2, oss3, oss4;
847     oss.str("");
848     oss1.str("");
849     oss2.str("");
850     oss << outDir.Data() << filename.Data() << "_Tmtc_cc_"<<interval+1<<"." << format;
851     oss1 << outDir.Data() << filename.Data() << "_Tmtc_th_dea_"<<interval+1<<"." << format;
852     oss2 << outDir.Data() << filename.Data() << "_Tmtc_volt_dea_"<<interval+1<<"." << format;
853     Canvascc->SaveAs(oss.str().c_str());
854     Canvasthdea->SaveAs(oss1.str().c_str());
855     Canvasvoltdea->SaveAs(oss2.str().c_str()); //// fine del lavoro sul sottogruppo
856    
857     Canvascc->Clear();
858     Canvasthdea->Clear();
859     Canvasvoltdea->Clear();
860     //gROOT->GetListOfCanvases()->Delete();
861     //gROOT->Reset();
862    
863     }
864 pam-rm2 1.1
865    
866 pam-fi 1.3 file->Close();
867 pam-rm2 1.1 }
868    
869    
870     //////////////////////////////////////////////////////////////////////////////////
871     ///////////////////////// MAIN ///////////////////////////////////////////////
872     //////////////////////////////////////////////////////////////////////////////////
873    
874    
875     int main(int argc, char* argv[]){
876     TString path;
877     TString outDir = "./";
878     TString format = "jpg";
879    
880     if (argc < 2){
881     printf("You have to insert at least the file to analyze \n");
882     printf("Try '--help' for more information. \n");
883     exit(1);
884     }
885    
886     if (!strcmp(argv[1], "--help")){
887     printf( "Usage: TmtcTemperature FILE [OPTION] \n");
888     printf( "\t --help Print this help and exit \n");
889     printf( "\t -outDir[path] Path where to put the output [default ./] \n");
890     printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n");
891     exit(1);
892     }
893    
894     path=argv[1];
895    
896     for (int i = 2; i < argc; i++){
897    
898    
899     if (!strcmp(argv[i], "-outDir")){
900     if (++i >= argc){
901     printf( "-outDir needs arguments. \n");
902     printf( "Try '--help' for more information. \n");
903     exit(1);
904     }
905     else{
906     outDir = argv[i];
907     continue;
908     }
909     }
910    
911     if (!strcmp(argv[i], "-format")){
912     if (++i >= argc){
913     printf( "-format needs arguments. \n");
914     printf( "Try '--help' for more information. \n");
915     exit(1);
916     }
917     else{
918     format = argv[i];
919     continue;
920     }
921     }
922    
923    
924     }
925    
926     TmtcTemperature(argv[1], outDir, format);
927    
928     }

  ViewVC Help
Powered by ViewVC 1.1.23