Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:58

0001 void test_HVP5Histo(){
0002 
0003 /*connect with oracle server */
0004 TSQLServer *db=TSQLServer::Connect("oracle://pccmsecdb:1521/omds","cms_ecal_hv","zonep5mtcc");
0005 
0006 
0007  Int_t sm=13; // from 0 to 36
0008  Int_t chan_num=1; // from 1 to 34
0009  char table_name[20]="PVSS_HV_IMON_DAT";
0010  char field_name[20]="IMON";
0011  
0012  Float_t curmax=5; // max of the histogram
0013 
0014  Int_t sm_num=1041000000+10000*sm+sm;
0015 
0016  gStyle->SetOptStat(0);
0017  gStyle->SetOptFit();
0018  gStyle->SetPalette(1,0);
0019  TDatime da(2005,01,01,00,00,00);
0020  gStyle->SetTimeOffset(da.Convert());
0021 
0022  char titolo[100];
0023  sprintf(titolo,"%s.%s for chan %d of SM %d",table_name,field_name,chan_num, sm );
0024  
0025  
0026  c1 = new TCanvas("c1","History plot from DB",200,10,600,400);
0027  c1->SetGrid();
0028  //  c1->Divide(2,3);
0029 
0030 /* c2 = new TCanvas("c2","The HV evolution in time",200,10,600,400);
0031 c2->SetGrid();
0032 c3 = new TCanvas("c3","The HV versus channel",200,10,600,400);
0033 c3->SetGrid();
0034 c4 = new TCanvas("c4","The Current",200,10,600,400);
0035 c4->SetGrid();
0036 c5 = new TCanvas("c5","The HV Current evolution in time",200,10,600,400);
0037 c5->SetGrid();
0038 c6 = new TCanvas("c6","The HV Current versus channel",200,10,600,400);
0039 c6->SetGrid();
0040 */
0041 
0042 float tStart=520;
0043 float tEnd=620;
0044  float day_to_sec=24.*60.*60.;
0045  tStart=(tStart-2)*day_to_sec;
0046  tEnd=(tEnd+2)*day_to_sec;
0047  int nbins= (tEnd-tStart)/day_to_sec;
0048  hv_time_vs_vmon  = new TH2F("temp_vs_time",titolo,nbins,tStart ,tEnd , 100, 0.,curmax );
0049 
0050  hv_time_vs_vmon->GetXaxis()->SetTitle("Time");
0051  hv_time_vs_vmon->GetYaxis()->SetTitle(field_name);
0052  hv_time_vs_vmon->GetXaxis()->SetTimeDisplay(1);  // The X axis is a time axis 
0053  hv_time_vs_vmon->GetXaxis()->SetTimeFormat("%d-%m-%y");
0054  hv_time_vs_vmon->GetXaxis()->SetLabelSize(0.02);
0055  hv_time_vs_vmon->SetMarkerStyle(20);
0056  hv_time_vs_vmon->SetMarkerSize(0.7);
0057  // 
0058 
0059 // hv_imon  = new TH1F("hv_imon","HV IMON",100,0.,10.);
0060 // hv_time_vs_imon  = new TH2F("hv_time_vs_imon","HV TIME VS IMON",100,1.E+12,10.E+12,100,0.,10.);
0061 hv_vmon  = new TH1F("hv_vmon","HV VMON",100,0.,500.);
0062 // hv_time_vs_vmon  = new TH2F("hv_time_vs_vmon","HV TIME VS VMON",100,1.E+12,10.E+12,100,0.,500.);
0063 // hv_chan_vs_imon  = new TH2F("hv_chan_vs_imon","HV CHAN VS IMON", 17, 0.5, 17.5,2,0.5, 2.5 );
0064 // hv_chan_vs_vmon  = new TH2F("hv_chan_vs_vmon","HV CHAN VS VMON", 17, 0.5, 17.5, 2,0.5, 2.5 );
0065 // hv_chan_vs_v0  = new TH2F("hv_chan_vs_v0","HV CHAN VS V0", 17, 0.5, 17.5, 2,0.5, 2.5 );
0066 //  hv_chan_vs_diff  = new TH2F("hv_chan_vs_v0","HV CHAN VS V0", 17, 0.5, 17.5, 2,0.5, 2.5 );
0067 
0068 /* query  */
0069  char sql[750];
0070  char query_skeleton4[400];
0071  char query_skeleton4a[50]="SELECT CAST( ";
0072  char query_skeleton4b[200]=" AS NUMBER), (SINCE-to_date('01-JAN-2005 00:00:00','DD-MON-YYYY HH24:MI:SS')), (till-to_date('31-DEC-9999 23:59:59','DD-MON-YYYY HH24:MI:SS'))  FROM ";
0073  char query_skeleton1[25]=" , channelview where ";
0074  char query_skeleton2[100]=" .logic_id=channelview.logic_id and channelview.name=channelview.maps_to and channelview.id1= ";
0075  char query_skeleton5[40]=" and channelview.id2= ";
0076  char query_skeleton3[40]=" order by since ";
0077 
0078  sprintf(query_skeleton4,"%s%s.%s%s%s",query_skeleton4a,table_name,field_name,query_skeleton4b,table_name);
0079 
0080   sprintf(sql,"%s%s%s%s%d%s%d%s",query_skeleton4, query_skeleton1,table_name,
0081       query_skeleton2,sm,query_skeleton5,chan_num,query_skeleton3);
0082 
0083   cout << sql << endl ;
0084 
0085   // char * sql="select logic_id,  Since-to_date('01-JAN-2005 00:00:00','DD-MON-YYYY HH24:MI:SS') , till, vmon from pvss_hv_imon_dat where logic_id= order by logic_id, since";
0086 
0087 
0088 TSQLResult *res=db->Query(sql);   
0089 
0090  float vmon;
0091  float tmon;
0092  float ttill;
0093  
0094  do {int j; 
0095  TSQLRow *row1=res->Next();
0096  TOracleRow * row2=(TOracleRow *)row1;  
0097 
0098  for (int i=0; i<res->GetFieldCount();i++) {
0099    printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0100 
0101    if(i==0) vmon=atof( row2->GetField(i));
0102    if(i==1) tmon=atof( row2->GetField(i))*day_to_sec;
0103    if(i==2) ttill=atof( row2->GetField(i))*day_to_sec;
0104  }
0105  cout <<  endl;
0106  Float_t tpippo= (Float_t)vmon;
0107  Float_t tt= (Float_t)tmon;
0108  hv_vmon->Fill(tpippo);
0109  hv_time_vs_vmon->Fill(tt, tpippo,1.);
0110  cout << tpippo<< tmon<< ttill << endl; 
0111  delete row2;
0112  
0113  } while (ttill<0);
0114  
0115  //  c1->cd(1);
0116  //hv_vmon->Draw();
0117  //c1->Update();
0118  
0119  //c1->cd(3);
0120  hv_time_vs_vmon->Draw();
0121  c1->Update();
0122 
0123  /* 
0124  // now actual Idark plot
0125  
0126 char * sql_act_id="select logic_id-1051110000, till,  value00 from COND_HV_IMON where logic_id>1051110000 and till>9E+15 order by logic_id";
0127 TSQLResult *res_act_id=db->Query(sql_act_id);   
0128 
0129  float idark=0.;
0130  int chan=0;
0131 
0132  do{ int j;
0133  TSQLRow *row1=res_act_id->Next();
0134  TOracleRow * row2=(TOracleRow *)row1;  
0135  
0136  for (int i=0; i<res_act_id->GetFieldCount();i++) {
0137    printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0138    if(i==0) chan=atoi( row2->GetField(i));
0139    if(i==2) idark=atof( row2->GetField(i));
0140  }
0141  cout <<  endl;
0142 
0143 
0144  Float_t tpippo= (Float_t) idark;
0145   Float_t tchanx= (Float_t) (2-chan%2) ;
0146  Float_t tchany= (Float_t) ((chan-1)/2+1) ;
0147  hv_chan_vs_imon->Fill(tchany, tchanx, tpippo);
0148  cout << chan << " " << tchanx << " " << tchany << endl; 
0149  // delete row2;
0150  } while (chan!=34);
0151  
0152  c1->cd(5);
0153  hv_chan_vs_imon->SetMaximum(10.0);
0154  hv_chan_vs_imon->Draw("colz");
0155  c1->Update();
0156 
0157 
0158  // now actual HV plot 
0159 char * sql_act_hv="select logic_id-1051110000,  till, value00 from COND_HV_VMON where logic_id>1051110000 and till>9E+15 order by logic_id";
0160 TSQLResult *res_act_hv=db->Query(sql_act_hv);   
0161  Float_t data[35];
0162 
0163  do{ int j;
0164  TSQLRow *row1=res_act_hv->Next();
0165  TOracleRow * row2=(TOracleRow *)row1;  
0166  
0167  for (int i=0; i<res_act_hv->GetFieldCount();i++) {
0168    printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0169    if(i==0) chan=atoi( row2->GetField(i));
0170    if(i==2) idark=atof( row2->GetField(i));
0171  }
0172  cout <<  endl;
0173 
0174  Float_t tpippo= (Float_t) idark;
0175  data[chan]=tpippo;
0176  Float_t tchanx= (Float_t) (2-chan%2) ;
0177  Float_t tchany= (Float_t) ((chan-1)/2+1) ;
0178  hv_chan_vs_vmon->Fill(tchany, tchanx, tpippo);
0179 
0180 
0181  cout << chan << " " << tchanx << " " << tchany << endl; 
0182  delete row2;
0183 
0184  } while (chan!=34);
0185  
0186  // now actual HV V0 plot 
0187 char * sql_act_v0="select logic_id-1051110000,  till, value00 from COND_HV_V0 where logic_id>1051110000 and till>9E+15 order by logic_id";
0188 TSQLResult *res_act_v0=db->Query(sql_act_v0);   
0189  float v0=0.;
0190 
0191 do{ int j;
0192  
0193  TSQLRow *rows=res_act_v0->Next();
0194  TOracleRow * row3=(TOracleRow *)rows;  
0195  
0196  for (int i=0; i<res_act_v0->GetFieldCount();i++) {
0197    printf(" %*.*s ",row3->GetFieldLength(i),row3->GetFieldLength(i),row3->GetField(i)); 
0198    if(i==0) chan=atoi( row3->GetField(i));
0199    if(i==2) v0=atof( row3->GetField(i));   
0200  }
0201  cout <<  endl;
0202 
0203  
0204  Float_t tv0   = (Float_t) v0;
0205  Float_t tchanx= (Float_t) (2-chan%2) ;
0206  Float_t tchany= (Float_t) ((chan-1)/2+1) ;
0207  Float_t diff=data[chan]-tv0;
0208  
0209  hv_chan_vs_diff->Fill(tchany, tchanx, diff);
0210  hv_chan_vs_v0->Fill(tchany, tchanx, tv0);
0211  
0212  cout << chan << " " << tchanx << " " << tchany << endl; 
0213  
0214  delete row3;
0215  } while (chan!=34);
0216  
0217 
0218 
0219  c1->cd(4);
0220  hv_chan_vs_vmon->SetMaximum(450.0);
0221  hv_chan_vs_vmon->SetMinimum(350.0);
0222 hv_chan_vs_vmon->Draw("colz");
0223 
0224  c1->cd(6);
0225  hv_chan_vs_diff->SetMaximum(30.0);
0226  hv_chan_vs_diff->SetMinimum(-30.0);
0227  hv_chan_vs_diff->Draw("colz");
0228  c1->cd(2);
0229  hv_chan_vs_v0->SetMaximum(450.0);
0230  hv_chan_vs_v0->SetMinimum(350.0);
0231  hv_chan_vs_v0->Draw("colz");
0232  c1->Update();
0233 
0234  */ 
0235  printf("end \n");
0236 
0237  delete res;
0238  delete db;
0239  
0240 }