/[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.3 - (hide annotations) (download)
Tue Jun 20 11:10:38 2006 UTC (18 years, 5 months ago) by pam-fi
Branch: MAIN
CVS Tags: v1r03
Changes since 1.2: +656 -364 lines
new tmtc display

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-fi 1.3 string titolocc[] ={"IPM1","IPM2","IPM3","IPM4","IPM5","IPM6","KHB_HOT","KHB_COLD","IDAQ_HOT","IDAQ_COLD","VCB_STANDBY","VRL_HOT","VRL_COLD","PSB","TOFHV_HOT","TOFHV_COLD"};
215    
216     string titoloth[] ={"IPM_TH","S1_TH","S4_TH","S4_ND_PLATE_TH","TRK_TH1","TRK_TH2","FLUID_IN_TH","FLUID_OUT_TH","VME_TH","DCDC_TH","CPU_TH1","CPU_TH2", "IPM_CPU_TH", "VRL_TH1", "VRL_TH2", "VME_COOL_TH"};
217    
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     }else if (fmod(i, 50)==0 || ((tmr->TM_RECORD_OBT)<OBT[i-1]) || (i==(size-1)) ){
242     //}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     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], limth[lungmax], limvolt1[lungmin], limvolt2[lungmin], limvolt3[lungmin];
260    
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     if (yccipmkk1u[i]==1 && yccipm12d[i]==0 && yccipm12u[i]==0) yccipmerror[i]=1;
377     else if (yccipmkk1d[i]==-1 && yccipm12d[i]==0 && yccipm12u[i]==0 || (yccipmkk1d[i]==-1 && yccipm12u[i]==1)) yccipmerror[i]=-1;
378     else yccipmerror[i]=0;
379     }
380     }
381     if (k==6 || k==7 || k==8 || k==9) {
382     if (yccdiagacq_1d[i]==-1 && yccipm12u[i]==1) yccipmerror2[i]=-1;
383     else yccipmerror2[i]=0;
384     }
385     if (k==13) {
386     if (yccdiagacq_1d[i]==-1 && yccipm12d[i]==0 && yccipm12u[i]==0) yccdiagacq_1d[i]==-1; //psb on
387     if (yccdiagacq_1u[i]==1 && yccipm12u[i]==1) yccdiagacq_1u[i]==1; //psb off
388     if (yccdiagacq_1d[i]==-1 && yccipm12d[i]==-1) yccipmerror[i]=-1;
389     else if (yccdiagacq_1u[i]==1 && yccipm12d[i]==0 && yccipm12u[i]==0) yccipmerror[i]=1;
390     else yccipmerror[i]=0; //psb alarm
391     }
392     if (k==15) {
393     yccdiagacq_11u[i]=0;
394     yccdiagacq_11d[i]=0;
395     }
396     }
397    
398     //CC IPM
399     if (k==0 || k==1 ||k==2 || k==3 || k==4 || k==5 ){
400     Canvascc->cd(m+1);
401     Canvascc->cd(m+1)->SetGridx();
402     gPad->SetFillColor(10);
403     gPad->SetFrameBorderSize(0);
404     gPad->SetLineColor(1);
405     gPad->SetFrameBorderMode(0);
406    
407    
408     pt = new TPaveText (.01,.30,.10,.70);
409     oss.str("");
410     oss<<titolocc[k];
411     pt->AddText(oss.str().c_str());
412     pt->SetFillColor(10);
413     pt->SetBorderSize(0);
414     pt->Draw();
415    
416    
417     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
418     ccrecordd->SetTitle("");
419     ccrecordd->SetFillColor(8);
420     ccrecordd->GetXaxis()->SetLabelSize(0);
421     ccrecordd->GetXaxis()->SetTickLength(0);
422     ccrecordd->GetYaxis()->SetLabelSize(0);
423     ccrecordd->GetYaxis()->SetTickLength(0);
424     ccrecordd->SetMaximum(1.3);
425     ccrecordd->SetMinimum(-1.3);
426     ccrecordd->GetXaxis()->SetAxisColor(0);
427     ccrecordd->Draw("AB");
428     if (k==0) leg1->AddEntry(ccrecordd,"ON","f");
429    
430     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
431     ccrecordu->SetTitle("");
432     ccrecordu->SetFillColor(17);
433     ccrecordu->GetXaxis()->SetLabelSize(0);
434     ccrecordu->GetXaxis()->SetTickLength(0);
435     ccrecordu->GetYaxis()->SetLabelSize(0);
436     ccrecordu->GetYaxis()->SetTickLength(0);
437     ccrecordu->GetXaxis()->SetAxisColor(0);
438     ccrecordu->SetMaximum(1.3);
439     ccrecordu->SetMinimum(-1.3);
440     ccrecordu->Draw("Bsame");
441     if (k==0) leg1->AddEntry(ccrecordu,"OFF","f");
442    
443    
444     if (k==1 || k==3 || k==5){
445     Canvascc->cd(m);
446     TGraph *ccrecorderrord = new TGraph(recordstot, xrecordobtcc_1, yccipmkk1d);
447     ccrecorderrord->SetTitle("");
448     ccrecorderrord->SetFillColor(2);
449     ccrecorderrord->GetXaxis()->SetLabelSize(0);
450     ccrecorderrord->GetXaxis()->SetTickLength(0);
451     ccrecorderrord->GetYaxis()->SetLabelSize(0);
452     ccrecorderrord->GetYaxis()->SetTickLength(0);
453     ccrecorderrord->SetMaximum(1.3);
454     ccrecorderrord->SetMinimum(-1.3);
455     ccrecorderrord->GetXaxis()->SetAxisColor(0);
456     ccrecorderrord->Draw("Bsame");
457    
458     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmkk1u);
459     ccrecorderroru->SetTitle("");
460     ccrecorderroru->SetFillColor(2);
461     ccrecorderroru->GetXaxis()->SetLabelSize(0);
462     ccrecorderroru->GetXaxis()->SetTickLength(0);
463     ccrecorderroru->GetYaxis()->SetLabelSize(0);
464     ccrecorderroru->GetYaxis()->SetTickLength(0);
465     ccrecorderroru->SetMaximum(1.3);
466     ccrecorderroru->SetMinimum(-1.3);
467     ccrecorderroru->GetXaxis()->SetAxisColor(0);
468     ccrecorderroru->Draw("Bsame");
469    
470     Canvascc->cd(m+1);
471     ccrecorderrord->Draw("Bsame");
472     ccrecorderroru->Draw("Bsame");
473     }
474    
475    
476     Double_t xmin;
477     Double_t xmax;
478     xmin=ccrecordu->GetXaxis()->GetXmin();
479     xmax=ccrecordu->GetXaxis()->GetXmax();
480     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 0);
481     axis->Draw("same");
482     /*TF1 *func1 = new TF1("func1", "0");
483     func1->SetRange(xmin,xrecordobtcc_1[recordstot-1]);
484     func1->SetLineColor(1);
485     func1->SetLineStyle(1);
486     func1->SetLineWidth(2);
487     func1->Draw("same");*/
488    
489     m=m+1;
490     }
491    
492     //CC idaq-khb-tof
493     if (k==6 || k==7 || k==8 || k==9 || k==14 || k==15){
494     Canvascc->cd(l+7);
495     gPad->SetFillColor(10);
496     gPad->SetFrameBorderSize(0);
497    
498     pt = new TPaveText (.00,.30,.09,.70);
499     oss.str("");
500     oss<<titolocc[k];
501     pt->AddText(oss.str().c_str());
502     pt->SetFillColor(10);
503     pt->SetBorderSize(0);
504     pt->Draw();
505    
506    
507     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
508     ccrecordd->SetTitle("");
509     if (k==14 || k==15) ccrecordd->SetFillColor(2);
510     else ccrecordd->SetFillColor(8);
511     ccrecordd->GetXaxis()->SetLabelSize(0);
512     ccrecordd->GetXaxis()->SetTickLength(0);
513     ccrecordd->GetYaxis()->SetLabelSize(0);
514     ccrecordd->GetYaxis()->SetTickLength(0);
515     ccrecordd->SetMaximum(1.3);
516     ccrecordd->SetMinimum(-1.3);
517     ccrecordd->GetXaxis()->SetAxisColor(0);
518     ccrecordd->Draw("AB");
519    
520     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
521     ccrecordu->SetTitle("");
522     if (k==14 || k==15) {
523     ccrecordu->SetFillColor(7);
524     if (k==14) leg1->AddEntry(ccrecordu,"ON-OFF-LATCHUP","f");
525     }
526     else ccrecordu->SetFillColor(17);
527     ccrecordu->GetXaxis()->SetAxisColor(0);
528     ccrecordu->GetXaxis()->SetLabelSize(0);
529     ccrecordu->GetXaxis()->SetTickLength(0);
530     ccrecordu->GetYaxis()->SetLabelSize(0);
531     ccrecordu->GetYaxis()->SetTickLength(0);
532     ccrecordu->SetMaximum(1.3);
533     ccrecordu->SetMinimum(-1.3);
534     ccrecordu->Draw("Bsame");
535    
536     if (k==6 || k==7 || k==8 || k==9){
537     Canvascc->cd(l+7);
538     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmerror2);
539     ccrecorderroru->SetTitle("");
540     ccrecorderroru->SetFillColor(2);
541     ccrecorderroru->GetXaxis()->SetLabelSize(0);
542     ccrecorderroru->GetXaxis()->SetTickLength(0);
543     ccrecorderroru->GetYaxis()->SetLabelSize(0);
544     ccrecorderroru->GetYaxis()->SetTickLength(0);
545     ccrecorderroru->SetMaximum(1.3);
546     ccrecorderroru->SetMinimum(-1.3);
547     ccrecorderroru->GetXaxis()->SetAxisColor(0);
548     ccrecorderroru->Draw("Bsame");
549     }
550    
551    
552     if (k==7 || k==9){
553     Canvascc->cd(l+7-1);
554     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmerror);
555     ccrecorderroru->SetTitle("");
556     ccrecorderroru->SetFillColor(2);
557     ccrecorderroru->GetXaxis()->SetLabelSize(0);
558     ccrecorderroru->GetXaxis()->SetTickLength(0);
559     ccrecorderroru->GetYaxis()->SetLabelSize(0);
560     ccrecorderroru->GetYaxis()->SetTickLength(0);
561     ccrecorderroru->SetMaximum(1.3);
562     ccrecorderroru->SetMinimum(-1.3);
563     ccrecorderroru->GetXaxis()->SetAxisColor(0);
564     if (k==7) leg1->AddEntry(ccrecorderroru,"ALARM","f");
565     ccrecorderroru->Draw("Bsame");
566    
567     Canvascc->cd(l+7);
568     ccrecorderroru->Draw("Bsame");
569     }
570    
571    
572     Double_t xmin;
573     Double_t xmax;
574     xmin=ccrecordu->GetXaxis()->GetXmin();
575     xmax=ccrecordu->GetXaxis()->GetXmax();
576     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 1.5);
577     axis->Draw("same");
578     /*TF1 *func1 = new TF1("func1", "0");
579     func1->SetRange(xmin,xrecordobtcc_1[recordstot-1]);
580     func1->SetLineColor(1);
581     func1->SetLineStyle(1);
582     func1->SetLineWidth(2);
583     func1->Draw("same");*/
584     l=l+1;
585    
586     }
587    
588     //CC vrl
589     if (k==11 || k==12 || k==13 ){
590     if (k==13) Canvascc->cd(13);
591     if (k==11) Canvascc->cd(14);
592     if (k==12) Canvascc->cd(15);
593     gPad->SetFillColor(10);
594     gPad->SetFrameBorderSize(0);
595    
596     pt = new TPaveText (.01,.30,.09,.70);
597     oss.str("");
598     oss<<titolocc[k];
599     pt->AddText(oss.str().c_str());
600     pt->SetFillColor(10);
601     pt->SetBorderSize(0);
602     pt->Draw();
603    
604     if (k==11 || k==12){
605     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
606     ccrecordd->SetTitle("");
607     ccrecordd->SetFillColor(8);
608     ccrecordd->GetXaxis()->SetAxisColor(0);
609     ccrecordd->GetXaxis()->SetLabelSize(0);
610     ccrecordd->GetXaxis()->SetTickLength(0);
611     ccrecordd->GetYaxis()->SetLabelSize(0);
612     ccrecordd->GetYaxis()->SetTickLength(0);
613     ccrecordd->SetMaximum(1.3);
614     ccrecordd->SetMinimum(-1.3);
615     ccrecordd->Draw("AB");
616    
617    
618     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
619     ccrecordu->SetTitle("");
620     ccrecordu->SetFillColor(17);
621     ccrecordu->GetXaxis()->SetAxisColor(0);
622     ccrecordu->GetXaxis()->SetLabelSize(0);
623     ccrecordu->GetXaxis()->SetTickLength(0);
624     ccrecordu->GetYaxis()->SetLabelSize(0);
625     ccrecordu->GetYaxis()->SetTickLength(0);
626     ccrecordu->SetMaximum(1.3);
627     ccrecordu->SetMinimum(-1.3);
628     ccrecordu->Draw("Bsame");
629    
630     Double_t xmin;
631     Double_t xmax;
632     xmin=ccrecordu->GetXaxis()->GetXmin();
633     xmax=ccrecordu->GetXaxis()->GetXmax();
634     if (k==12){
635     TGaxis *axis = new TGaxis (xmin, -1, xmax, -1, xmin, xmax, 510, "", 0);
636     axis->SetLabelSize(0.24);
637     axis->SetLabelColor(1);
638     axis->SetTitle("OBT (ms)");
639     //axis->CenterTitle();
640     axis->SetTitleOffset(0.4);
641     axis->SetTitleSize(0.21);
642     axis->Draw();
643     TF1 *func1 = new TF1("func1", "0");
644     func1->SetRange(xmin,xmax);
645     func1->SetLineColor(1);
646     func1->SetLineStyle(1);
647     func1->SetLineWidth(1);
648     func1->Draw("same");
649     }
650     if (k==11){
651     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 0);
652     axis->SetLineWidth(1);
653     axis->SetTickSize(2);
654     axis->Draw("same");
655     }
656     }
657    
658     if (k==13){
659     Canvascc->cd(13);
660    
661     TGraph *ccrecordd = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1d);
662     ccrecordd->SetTitle("");
663     ccrecordd->SetFillColor(8);
664     ccrecordd->GetXaxis()->SetAxisColor(0);
665     ccrecordd->GetXaxis()->SetLabelSize(0);
666     ccrecordd->GetXaxis()->SetTickLength(0);
667     ccrecordd->GetYaxis()->SetLabelSize(0);
668     ccrecordd->GetYaxis()->SetTickLength(0);
669     ccrecordd->SetMaximum(1.3);
670     ccrecordd->SetMinimum(-1.3);
671     ccrecordd->Draw("AB");
672    
673     TGraph *ccrecordu = new TGraph(recordstot, xrecordobtcc_1, yccdiagacq_1u);
674     ccrecordu->SetTitle("");
675     ccrecordu->SetFillColor(17);
676     ccrecordu->GetXaxis()->SetAxisColor(0);
677     ccrecordu->GetXaxis()->SetLabelSize(0);
678     ccrecordu->GetXaxis()->SetTickLength(0);
679     ccrecordu->GetYaxis()->SetLabelSize(0);
680     ccrecordu->GetYaxis()->SetTickLength(0);
681     ccrecordu->SetMaximum(1.3);
682     ccrecordu->SetMinimum(-1.3);
683     ccrecordu->Draw("Bsame");
684    
685     TGraph *ccrecorderroru = new TGraph(recordstot, xrecordobtcc_1, yccipmerror);
686     ccrecorderroru->SetTitle("");
687     ccrecorderroru->SetFillColor(2);
688     ccrecorderroru->GetXaxis()->SetLabelSize(0);
689     ccrecorderroru->GetXaxis()->SetTickLength(0);
690     ccrecorderroru->GetYaxis()->SetLabelSize(0);
691     ccrecorderroru->GetYaxis()->SetTickLength(0);
692     ccrecorderroru->SetMaximum(1.3);
693     ccrecorderroru->SetMinimum(-1.3);
694     ccrecorderroru->GetXaxis()->SetAxisColor(0);
695     ccrecorderroru->Draw("Bsame");
696    
697    
698     Double_t xmin=ccrecordu->GetXaxis()->GetXmin();
699     Double_t xmax=ccrecordu->GetXaxis()->GetXmax();
700     TGaxis *axis = new TGaxis (xmin, 0, xmax, 0, xmin, xmax, 510, "+-", 0);
701     axis->SetLineWidth(1);
702     axis->SetTickSize(2);
703     axis->Draw("same");
704     }
705    
706     }
707    
708     }
709    
710     Canvascc->cd();
711     leg1->Draw();
712     Canvascc->Update();
713    
714     // TH Graph
715     Canvasthdea->cd();
716     //thermistors number 12
717     if (tr->GetBranch("Records.TM_TH_ANA[12]")){
718     for (Int_t k =0; k<12; k++){
719     for (Int_t i = 0; i < recordstot; i++){
720     ythana_1[i]= ythana[12*i+k];
721     xrecordobtth_1[i]= xrecordobtth[12*i+k];
722     limth[i] = 45;
723     }
724     Canvasthdea->cd(k+1);
725     TGraph *graph = new TGraph(recordstot, xrecordobtth_1, limth);
726     graph->SetMarkerColor(50);
727     graph->SetLineColor(50);
728     graph->SetMarkerStyle(21);
729     graph->SetMarkerSize(0.3);
730     graph->SetMinimum(-10);
731     graph->SetMaximum(60);
732     graph->GetXaxis()->SetTitle("OBT");
733     graph->GetXaxis()->CenterTitle();
734     graph->GetYaxis()->SetTitle("Temperature value (C)");
735     graph->GetYaxis()->CenterTitle();
736     oss.str("");
737     oss << filename.Data() <<": " <<titoloth[k] ;
738     graph->SetTitle(oss.str().c_str());
739    
740     TPaveText *pt = new TPaveText (.45,.7,.55,.77);
741     pt->AddText("OFF");
742     pt->SetBorderSize(1);
743     pt->Draw();
744     graph->Draw("ACP");
745     pt->Draw();
746    
747     TGraph *threcord = new TGraph(recordstot, xrecordobtth_1, ythana_1);
748     threcord->SetLineColor(kBlue);
749     threcord->SetMarkerColor(kBlue);
750     threcord->SetMarkerStyle(21);
751     threcord->Draw("C");
752     }
753     }
754     //thermistors number=16
755     if (tr->GetBranch("Records.TM_TH_ANA[16]")){
756     for (Int_t k =0; k<16; k++){
757     for (Int_t i = 0; i < recordstot; i++){
758     ythana_1[i]= ythana[16*i+k];
759     xrecordobtth_1[i]= xrecordobtth[16*i+k];
760     limth[i] = 45;
761     }
762     Canvasthdea->cd(k+1);
763     TGraph *graph = new TGraph(recordstot, xrecordobtth_1, limth);
764     graph->SetMarkerColor(50);
765     graph->SetLineColor(50);
766     graph->SetMarkerStyle(21);
767     graph->SetMarkerSize(0.3);
768     graph->SetMinimum(-10);
769     graph->SetMaximum(60);
770     graph->GetXaxis()->SetTitle("OBT");
771     graph->GetXaxis()->CenterTitle();
772     graph->GetYaxis()->SetTitle("Temperature value (C)");
773     graph->GetYaxis()->CenterTitle();
774     oss.str("");
775     oss << filename.Data() <<": " <<titoloth[k] ;
776     graph->SetTitle(oss.str().c_str());
777    
778     TPaveText *pt = new TPaveText (.45,.7,.55,.77);
779     pt->AddText("OFF");
780     pt->SetBorderSize(1);
781     pt->Draw();
782     graph->Draw("ACP");
783     pt->Draw();
784    
785     TGraph *threcord = new TGraph(recordstot, xrecordobtth_1, ythana_1);
786     threcord->SetLineColor(kBlue);
787     threcord->SetMarkerColor(kBlue);
788     threcord->SetMarkerStyle(21);
789     threcord->Draw("C");
790     }
791     }
792    
793     // DEA Graph
794     Canvasvoltdea->cd();
795     for (Int_t k =0; k<6; k++){
796     for (Int_t i = 0; i < recordstot; i++){
797     ydea_1[i]= ydea[6*i + k];
798     xrecordobtdea_1[i]= xrecordobtdea[6*i+k];
799     limvolt1[i]= 0.65;
800     limvolt2[i]= 3.15;
801     limvolt3[i]= 4.25;
802     }
803     Canvasvoltdea->cd(k+1);
804     TGraph *graph1 = new TGraph(recordstot, xrecordobtth_1, limvolt1);
805     TPaveText *pt = new TPaveText (.84,.13,.92,.19);
806     pt->AddText("OFF");
807     pt->SetBorderSize(1);
808     pt->Draw();
809     TPaveText *pt1 = new TPaveText (.84,.67,.92,.73);
810     pt1->AddText("ON");
811     pt1->SetBorderSize(1);
812     pt1->Draw();
813     graph1->SetMarkerColor(50);
814     graph1->SetLineColor(50);
815     graph1->SetMarkerStyle(21);
816     graph1->SetMarkerSize(0.3);
817     graph1->SetMinimum(0.0);
818     graph1->SetMaximum(5.0);
819     graph1->GetXaxis()->SetTitle("OBT");
820     graph1->GetXaxis()->CenterTitle();
821     graph1->GetYaxis()->SetTitle("Voltage value (V)");
822     graph1->GetYaxis()->CenterTitle();
823     oss.str("");
824     oss << filename.Data()<<": IPM "<<k+1<<" Voltage";
825     graph1->SetTitle(oss.str().c_str());
826     graph1->Draw("ACP");
827     pt1->Draw();
828     pt->Draw();
829    
830     TGraph *graph2 = new TGraph(recordstot, xrecordobtth_1, limvolt2);
831     graph2->SetMarkerColor(50);
832     graph2->SetLineColor(50);
833     graph2->SetMarkerStyle(21);
834     graph2->SetMarkerSize(0.2);
835     graph2->SetMinimum(0.0);
836     graph2->SetMaximum(5.0);
837     graph2->Draw("CP");
838    
839     TGraph *graph3 = new TGraph(recordstot, xrecordobtth_1, limvolt3);
840     graph3->SetMarkerColor(50);
841     graph3->SetLineColor(50);
842     graph3->SetMarkerStyle(21);
843     graph3->SetMarkerSize(0.2);
844     graph3->SetMinimum(0.0);
845     graph3->SetMaximum(5.0);
846     graph3->Draw("CP");
847    
848     TGraph *dearecord = new TGraph(recordstot, xrecordobtdea_1, ydea_1);
849     dearecord->SetLineColor(kBlue);
850     dearecord->SetLineWidth(1);
851     dearecord->SetMarkerStyle(21);
852     dearecord->SetMarkerSize(0.5);
853     dearecord->SetMarkerColor(kBlue);
854     dearecord->Draw("CPL");
855     }
856    
857    
858     stringstream oss1, oss2, oss3, oss4;
859     oss.str("");
860     oss1.str("");
861     oss2.str("");
862     oss << outDir.Data() << filename.Data() << "_Tmtc_cc_"<<interval+1<<"." << format;
863     oss1 << outDir.Data() << filename.Data() << "_Tmtc_th_dea_"<<interval+1<<"." << format;
864     oss2 << outDir.Data() << filename.Data() << "_Tmtc_volt_dea_"<<interval+1<<"." << format;
865     Canvascc->SaveAs(oss.str().c_str());
866     Canvasthdea->SaveAs(oss1.str().c_str());
867     Canvasvoltdea->SaveAs(oss2.str().c_str()); //// fine del lavoro sul sottogruppo
868    
869     Canvascc->Clear();
870     Canvasthdea->Clear();
871     Canvasvoltdea->Clear();
872     //gROOT->GetListOfCanvases()->Delete();
873     //gROOT->Reset();
874    
875     }
876 pam-rm2 1.1
877    
878 pam-fi 1.3 file->Close();
879 pam-rm2 1.1 }
880    
881    
882     //////////////////////////////////////////////////////////////////////////////////
883     ///////////////////////// MAIN ///////////////////////////////////////////////
884     //////////////////////////////////////////////////////////////////////////////////
885    
886    
887     int main(int argc, char* argv[]){
888     TString path;
889     TString outDir = "./";
890     TString format = "jpg";
891    
892     if (argc < 2){
893     printf("You have to insert at least the file to analyze \n");
894     printf("Try '--help' for more information. \n");
895     exit(1);
896     }
897    
898     if (!strcmp(argv[1], "--help")){
899     printf( "Usage: TmtcTemperature FILE [OPTION] \n");
900     printf( "\t --help Print this help and exit \n");
901     printf( "\t -outDir[path] Path where to put the output [default ./] \n");
902     printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n");
903     exit(1);
904     }
905    
906     path=argv[1];
907    
908     for (int i = 2; i < argc; i++){
909    
910    
911     if (!strcmp(argv[i], "-outDir")){
912     if (++i >= argc){
913     printf( "-outDir needs arguments. \n");
914     printf( "Try '--help' for more information. \n");
915     exit(1);
916     }
917     else{
918     outDir = argv[i];
919     continue;
920     }
921     }
922    
923     if (!strcmp(argv[i], "-format")){
924     if (++i >= argc){
925     printf( "-format needs arguments. \n");
926     printf( "Try '--help' for more information. \n");
927     exit(1);
928     }
929     else{
930     format = argv[i];
931     continue;
932     }
933     }
934    
935    
936     }
937    
938     TmtcTemperature(argv[1], outDir, format);
939    
940     }

  ViewVC Help
Powered by ViewVC 1.1.23