Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:03

0001 //
0002 // File: ConditionBrowser_1279914969655.C
0003 //
0004 // run this script
0005 // root -b -q ConditionBrowser_1279914969655.C
0006 //
0007 
0008 char NAME[200];
0009 Int_t NROW;
0010 Double_t WEIGHT[20000];
0011 Int_t TIME[20000];
0012 Double_t VALUE[20000];
0013 
0014 void getFillandRun()
0015 {
0016   TFile f("ConditionBrowser_1279914969655.root");
0017   TTree *t = (TTree*)f.Get("tree");
0018   t->SetBranchAddress("NAME", &NAME);
0019   t->SetBranchAddress("NROW", &NROW);
0020   t->SetBranchAddress("WEIGHT", WEIGHT);
0021   t->SetBranchAddress("TIME", TIME);
0022   t->SetBranchAddress("VALUE", VALUE);
0023   Int_t nentries = (Int_t)t->GetEntries();
0024 
0025   std::map< int, int> fillmap;
0026   std::map< int, int> runmap;
0027 
0028  
0029   for (Int_t i=0; i<nentries; i++)
0030   {
0031     t->GetEntry(i);
0032     cout << NAME << endl;
0033     cout << NROW << endl;
0034     //cout << "ROW \tWEIGHT \tTIME \tVALUE" << endl;
0035     for (Int_t j=0; j<NROW; j++)
0036     {
0037       //cout << (j+1) << " \t"
0038       //     << WEIGHT[j] << " \t"
0039       //     << SecUTC(TIME[j]) << " \t"
0040       //     << VALUE[j] << endl;
0041       if (i==0) {
0042     fillmap[VALUE[j]] = TIME[j];
0043       } else {
0044     runmap[VALUE[j]] = TIME[j];
0045       }
0046     }
0047   }
0048   
0049   for (std::map<int,int>::const_iterator it=fillmap.begin(); it != fillmap.end(); ++it ) {
0050     
0051     int t0 = it->second;
0052     int afill = it->first;
0053     ++it;
0054     //if ( it == fillmap.end() ) break;
0055     int t1 = it->second;
0056     --it;
0057 
0058     int run0 = 0;
0059     int run1 = 0;
0060 
0061     for (std::map<int,int>::const_iterator itt=runmap.begin(); itt != runmap.end(); ++itt) {
0062       
0063       int t0run = itt->second;
0064       int run = itt->first;
0065 
0066       if ( t0run>= t0 && t0run< t1 ) {
0067     if ( run0==0 ) run0 = run;
0068     run1 = run;
0069       }
0070     
0071     }
0072     cout << "fill: "<< afill << " run: " << run0 << " - " << run1 << endl; 
0073   }
0074   f.Close();
0075 }
0076 
0077 TString SecUTC(Int_t sec)
0078 {
0079   TTimeStamp ts(sec, 0);
0080   TString s = ts.AsString("c");
0081   return s(0, 4) + "." +
0082          s(5, 2) + "." +
0083          s(8, 2) + " " +
0084          s(11, 2) + ":" +
0085          s(14, 2) + ":" +
0086          s(17, 2);
0087 }