Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:55

0001 void test_PedestalMapGain12(){
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","Pedestal RMS (ADC Counts)", 85, 0.1, 85.1,20,0.1, 20.1 );
0015  temp_chan->SetMaximum(2.);
0016  temp_chan->SetMinimum(0.5);
0017  temp_chan->GetXaxis()->SetTitle("Channel j");
0018  temp_chan->GetYaxis()->SetTitle("Channel i");
0019  // temp_chan->GetYaxis()->SetNDivisions(405);
0020  // temp_chan->GetXaxis()->SetNDivisions(405);
0021 
0022 
0023  //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 "  ;
0024 
0025 char * sql="SELECT count( channelview.logic_id) from channelview,MON_PEDESTALS_DAT , mon_run_iov, run_iov WHERE  run_iov.run_num=18085 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 "  ;
0026 
0027  TSQLResult *res=db->Query(sql);   
0028  
0029 
0030  int nlines=0;
0031  int j=0; 
0032  do {
0033    j++;
0034    TSQLRow *row1=res->Next();
0035    TOracleRow * row2=(TOracleRow *)row1;  
0036    
0037    for (int i=0; i<res->GetFieldCount();i++) {
0038      //  printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0039      if(i==0) nlines=atoi( row2->GetField(i));
0040    }
0041    // cout <<  endl;
0042    delete row2;
0043    
0044  } while (j<1);
0045   cout <<  "Number of records in the DB: " << nlines << endl; 
0046   cout <<"first loop done "<< endl; 
0047 
0048 
0049 /*print rows one by one */
0050 
0051 //char * sql="SELECT channelview.id2, CAST( MON_PEDESTALS_DAT.PED_RMS_G12 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 "  ;
0052 
0053 char * sql="SELECT channelview.id2, CAST( MON_PEDESTALS_DAT.PED_RMS_G12 AS NUMBER), run_iov.run_num  from channelview,MON_PEDESTALS_DAT , mon_run_iov, run_iov WHERE run_iov.run_num=18085 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 "  ;
0054 
0055 
0056  TSQLResult *res=db->Query(sql);   
0057  
0058  float temp=0;
0059  int chan=0;
0060  int j=0; 
0061  int run_num=0;
0062  do {
0063    j++;
0064    TSQLRow *row1=res->Next();
0065    TOracleRow * row2=(TOracleRow *)row1;  
0066    
0067    for (int i=0; i<res->GetFieldCount();i++) {
0068      //   printf(" %*.*s ",row2->GetFieldLength(i),row2->GetFieldLength(i),row2->GetField(i)); 
0069      if(i==0) chan=atoi( row2->GetField(i));
0070      if(i==1) temp=atof( row2->GetField(i));
0071      if(i==2) run_num=atoi( row2->GetField(i));
0072    }
0073    //   cout <<  endl;
0074    
0075    Float_t tpippo= (Float_t)temp;
0076    Float_t tchanx= (Float_t) ((chan-1)/20)+1 ;
0077    Float_t tchany= (Float_t) ((chan-1)%20)+1 ;
0078    temp_chan->Fill(tchanx, tchany, tpippo);
0079    
0080      
0081    delete row2;
0082    
0083  } while (j<nlines);
0084   cout <<  "run number: " << run_num << endl; 
0085   cout <<"loop done "<< endl; 
0086 
0087  
0088  // c1->cd(1);
0089  //hv_vmon->Draw();
0090  //c1->Update();
0091 
0092  //  c1->cd(1);
0093  temp_chan->Draw("colz");
0094  c1->Update(); 
0095  
0096 
0097  
0098  printf("end \n");
0099  delete res;
0100  delete db;
0101  
0102 }