/[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.1 - (hide annotations) (download)
Sat Jun 17 11:02:09 2006 UTC (18 years, 5 months ago) by pam-rm2
Branch: MAIN
Branch point for: QLflightTmtc_Header
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23