Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 void test_PedestalMapGain1(){
0002 
0003 /*connect with oracle server */
0004 TSQLServer *db=TSQLServer::Connect("oracle://pccmsecdb:1521/ecalh4db","read01","XXXpasswordXXX");
0005 
0006  gStyle->SetOptStat(0);
0007  gStyle->SetOptFit();
0008  gStyle->SetPalette(1,0);
0009  c1 = new TCanvas("c1","The Map",200,10,600,400);
0010  c1->SetGrid();
0011  // c1->Divide(2,3);
0012 
0013  
0014 temp_chan  = new TH2F("temp_chan","SM map", 85, -0.5, 84.5,20,-0.5, 19.5 );
0015  temp_chan->SetMaximum(1.);
0016  temp_chan->SetMinimum(0.);
0017 
0018 
0019 char * sql="SELECT count( channelview.logic_id) from channelview,MON_PEDESTALS_DAT , mon_run_iov, run_iov WHERE  mon_run_iov.iov_id=(select mon_run_iov.iov_id from mon_run_iov where subrun_start=(select max(SUBRUN_START) from MON_RUN_IOV, RUN_IOV, RUN_TAG, run_type_def where RUN_iov.tag_id=RUN_tag.tag_id and RUN_tag.LOCATION_ID=1 and run_IOV.iov_id=mon_run_iov.run_iov_id and run_type_def.config_ver=1 and run_type_def.def_id=run_tag.RUN_TYPE_ID and run_type_def.run_type='PEDESTAL')) and run_iov.iov_id=mon_run_iov.run_iov_id and mon_run_iov.iov_id=MON_PEDESTALS_DAT.iov_id and channelview.logic_id=MON_PEDESTALS_DAT.logic_id and channelview.name=channelview.maps_to order by id1, id2 "  ;
0020 
0021  TSQLResult *res=db->Query(sql);   
0022  
0023 
0024  int nlines=0;
0025  int j=0; 
0026  do {
0027    j++;
0028    TSQLRow *row1=res->Next();
0029    TOracleRow * row2=(TOracleRow *)row1;  
0030    
0031    for (int i=0; i<res->GetFieldCount();i++) {
0032      //  printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0033      if(i==0) nlines=atoi( row2->GetField(i));
0034    }
0035    // cout <<  endl;
0036    delete row2;
0037    
0038  } while (j<1);
0039   cout <<  "Number of records in the DB: " << nlines << endl; 
0040   cout <<"first loop done "<< endl; 
0041 
0042 
0043 /*print rows one by one */
0044 
0045 char * sql="SELECT channelview.id2, CAST( MON_PEDESTALS_DAT.PED_RMS_G1 AS NUMBER), run_iov.run_num  from channelview,MON_PEDESTALS_DAT , mon_run_iov, run_iov WHERE  mon_run_iov.iov_id=(select mon_run_iov.iov_id from mon_run_iov where subrun_start=(select max(SUBRUN_START) from MON_RUN_IOV, RUN_IOV, RUN_TAG, run_type_def where RUN_iov.tag_id=RUN_tag.tag_id and RUN_tag.LOCATION_ID=1 and run_IOV.iov_id=mon_run_iov.run_iov_id and run_type_def.config_ver=1 and run_type_def.def_id=run_tag.RUN_TYPE_ID and run_type_def.run_type='PEDESTAL')) and run_iov.iov_id=mon_run_iov.run_iov_id and mon_run_iov.iov_id=MON_PEDESTALS_DAT.iov_id and channelview.logic_id=MON_PEDESTALS_DAT.logic_id and channelview.name=channelview.maps_to order by id1, id2 "  ;
0046 
0047  TSQLResult *res=db->Query(sql);   
0048  
0049  float temp=0;
0050  int chan=0;
0051  int j=0; 
0052  int run_num=0;
0053  do {
0054    j++;
0055    TSQLRow *row1=res->Next();
0056    TOracleRow * row2=(TOracleRow *)row1;  
0057    
0058    for (int i=0; i<res->GetFieldCount();i++) {
0059      //   printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0060      if(i==0) chan=atoi( row2->GetField(i));
0061      if(i==1) temp=atof( row2->GetField(i));
0062      if(i==2) run_num=atoi( row2->GetField(i));
0063    }
0064    //   cout <<  endl;
0065    
0066    Float_t tpippo= (Float_t)temp;
0067    Float_t tchanx= (Float_t) ((chan-1)/20) ;
0068    Float_t tchany= (Float_t) ((chan-1)%20) ;
0069    temp_chan->Fill(tchanx, tchany, tpippo);
0070    
0071      
0072    delete row2;
0073    
0074  } while (j<nlines);
0075   cout <<  "run number: " << run_num << endl; 
0076   cout <<"loop done "<< endl; 
0077 
0078  
0079  // c1->cd(1);
0080  //hv_vmon->Draw();
0081  //c1->Update();
0082 
0083  //  c1->cd(1);
0084  temp_chan->Draw("colz");
0085  c1->Update(); 
0086  
0087 
0088  
0089  printf("end \n");
0090  delete res;
0091  delete db;
0092  
0093 }