NewNearlinePlots.C
Go to the documentation of this file.
1 #include <TSQLServer.h>
2 #include <TSQLResult.h>
3 #include <iostream.h>
4 #include <fstream>
5 #include <iomanip.h>
6 #include <sstream>
7 #include <string>
8 #include <cstring>
9 
10 
12 
13  gROOT->Reset();
14  gStyle->SetOptStat(0);
15  gStyle->SetOptFit(1);
16  gStyle->SetOptTitle(1);
17  gStyle->SetPalette(1);
18  gStyle->SetFillColor(0);
19  gStyle->SetPadColor(0);
20  gStyle->SetCanvasColor(0);
21  gStyle->SetStatColor(0);
22  gStyle->SetTitleColor(1);
23  gStyle->SetTitleSize(0.06);
24  gStyle->SetPadBorderMode(0);
25  gStyle->SetPadBottomMargin(0.15);
26  gStyle->SetPadLeftMargin(0.12);
27  gStyle->SetPadRightMargin(0.09);
28  gStyle->SetFrameBorderMode(0);
29  gStyle->SetCanvasBorderMode(0);
30 
31  TDatime da(2003,01,02,1,00,00);
32  gStyle->SetTimeOffset(da.Convert());
33 
34  TDatime *TNow = new TDatime;//.TDatime();
35  int XNow=TNow->Convert();
36  int XDayAgo =XNow - 60*60*24;
37  int XWeekAgo =XNow - 60*60*24*7;
38  int X2WeeksAgo =XNow - 60*60*24*7*2;
39  int XMonthAgo =XNow - 60*60*24*30;
40  int X2MonthsAgo=XNow - 60*60*24*30*2;
41 
42  TNow->Print();
43  cout<<XNow<<"\t"<<XDayAgo<<"\t"<<60*60*24<<"\t"<<XDayAgo-XNow<<endl;
44 //cin.get();
45 
46  int XPeriod[5];
47  XPeriod[0]=XDayAgo;
48  XPeriod[1]=XWeekAgo;
49  XPeriod[3]=X2WeeksAgo;
50  XPeriod[2]=XMonthAgo;
51  XPeriod[4]=X2MonthsAgo;
52 
53 for(int i=0;i<5;i++){
54 cout<<XPeriod[i]<<"\t"<<XNow - XPeriod[i]<<endl;
55 }
56 //cin.get();
57  int NHist=35;
58  int NPeriods=3;
59  TString hname[50][5];
60  TString htitle[50][5];
61 
62  TString hRunname[5];
63  TString hRuntitle[5];
64 
65  TH2F *hNearline[50][5];
66  TGraph *gNearline[50][5];
67 
68  TH2F *hRun[5];
69  TGraph *gRun[5];
70 
71  TF1 *fNearline[50];
72 
73 
74  TString Period[5][2];
75  Period[0][0]= "24 hr";
76  Period[0][1]= "DAY";
77  Period[1][0]= "week";
78  Period[1][1]= "WEEK";
79  Period[2][0]= "month";
80  Period[2][1]= "MONTH";
81  Period[3][0]= "two weeks";
82  Period[3][1]= "TWOWEEKS";
83  Period[4][0]= "two months";
84  Period[4][1]= "TWOMONTHS";
85 
86 
87  Double_t MinBin[50];
88  Double_t MaxBin[50];
89  Int_t LastRun=0;
90  Int_t LastSubrun=0;
91 
92  for(int i=0; i<NPeriods;i++){
93  hname[0][i] = "NEvents" + Period[i][1];
94  htitle[0][i]= "Number of events noise events for last "+Period[i][0]+";End subrun time; Number of events per subrun";
95 
96  hname[1][i] ="CosmicRate"+Period[i][1];
97  htitle[1][i]="Cosmic trigger rate for last "+Period[i][0]+";End subrun time; Cosmic trigger rate per subrun (Hz)";
98 
99  hname[2][i] ="RunNumber"+Period[i][1];
100  htitle[2][i]="Run Number for last "+Period[i][0]+";End subrun time; Run Number";
101 
102  hname[3][i] ="SubrunNumber"+Period[i][1];
103  htitle[3][i]="Subrun Number for last "+Period[i][0]+";End subrun time; Subrun Number";
104 
105  hname[4][i] ="NEmptyEvents"+Period[i][1];
106  htitle[4][i]="Fraction of empty events for last "+Period[i][0]+";End subrun time; Fraction of empty events per subrun (%)";
107 
108  hname[5][i] ="NNoiseEvents"+Period[i][1];
109  htitle[5][i]="Fraction of noise events for last "+Period[i][0]+";End subrun time; noise slice only events percentage (%)";
110 
111  hname[6][i] ="NGoodChannels"+Period[i][1];
112  htitle[6][i]="Number of active channels for last "+Period[i][0]+";End subrun time; # active channels per subrun";
113 
114  hname[7][i] ="NSlices"+Period[i][1];
115  htitle[7][i]="Number of slices per event for last "+Period[i][0]+";End subrun time; # slices per event";
116 
117  hname[8][i] ="NHitsPerSlices"+Period[i][1];
118  htitle[8][i]="Number of hits per slice with noise slice for last "+Period[i][0]+";End subrun time; # hits per slice";
119 
120  hname[9][i] ="NHitsPerSlicesNoNoise"+Period[i][1];
121  htitle[9][i]="Number hits per slice without noise for last "+Period[i][0]+";End subrun time; # hits per slice";
122 
123  hname[10][i]="NHitPerEvent"+Period[i][1];
124  htitle[10][i]="Fraction of active channels per event for last "+Period[i][0]+";End subrun time; # hits /# active channels (%)";
125 
126  hname[11][i]="OccupancyMPV"+Period[i][1];
127  htitle[11][i]="Fit (Landau) MPV for hit occupancy for last "+Period[i][0]+";End subrun time; MPV";
128 
129  hname[12][i]="OccupancySigma"+Period[i][1];
130  htitle[12][i]="Fit (Landau) sigma for hit occupancy for last " +Period[i][0]+";End subrun time; sigma";
131 
132  hname[13][i]="SubrunDuration"+Period[i][1];
133  htitle[13][i]="Duration of the subrun for last " +Period[i][0]+";End subrun time;minutes";
134 
135  hname[14][i]="SliceDuration"+Period[i][1];
136  htitle[14][i]="Duration of slices for last " +Period[i][0]+";End subrun time;ns";
137 
138  hname[15][i]="DCM11"+Period[i][1];
139  htitle[15][i]="Number of active FEBs for DCM-3-1-1 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
140 
141  hname[16][i]="DCM12"+Period[i][1];
142  htitle[16][i]="Number of active FEBs for DCM-3-1-2 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
143 
144  hname[17][i]="DCM13"+Period[i][1];
145  htitle[17][i]="Number of active FEBs for DCM-3-1-3 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
146 
147  hname[18][i]="DCM21"+Period[i][1];
148  htitle[18][i]="Number of active FEBs for DCM-3-2-1 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
149 
150  hname[19][i]="DCM22"+Period[i][1];
151  htitle[19][i]="Number of active FEBs for DCM-3-2-2 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
152 
153  hname[20][i]="DCM23"+Period[i][1];
154  htitle[20][i]="Number of active FEBs for DCM-3-2-3 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
155 
156  hname[21][i]="DCM31"+Period[i][1];
157  htitle[21][i]="Number of active FEBs for DCM-3-3-1 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
158 
159  hname[22][i]="DCM32"+Period[i][1];
160  htitle[22][i]="Number of active FEBs for DCM-3-3-2 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
161 
162  hname[23][i]="DCM33"+Period[i][1];
163  htitle[23][i]="Number of active FEBs for DCM-3-3-3 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
164 
165  hname[24][i]="DCM41"+Period[i][1];
166  htitle[24][i]="Number of active FEBs for DCM-3-4-1 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
167 
168  hname[25][i]="DCM42"+Period[i][1];
169  htitle[25][i]="Number of active FEBs for DCM-3-4-2 for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
170 
171 
172  hname[26][i]="nDCMs"+Period[i][1];
173  htitle[26][i]="Number of active DCMs for last " +Period[i][0]+";End subrun time;# active DCMs per subrun";
174 
175 
176 
177  hname[27][i]="CMNumberTracks"+Period[i][1];
178  htitle[27][i]="Number of cosmic muon tracks for last " +Period[i][0]+";End subrun time;number of tracks per subrun";
179 
180  hname[28][i]="CMLiveTime"+Period[i][1];
181  htitle[28][i]="Cosmic muons effective exposure time for last "+Period[i][0]+";End subrun time;( s)";
182 
183  hname[29][i]="CMRate"+Period[i][1];
184  htitle[29][i]="Normilized Cosmic muon rate for last "+Period[i][0]+";End subrun time;(Hz)/ # active channels";
185 
186  hname[30][i]="CMTrackLength"+Period[i][1];
187  htitle[30][i]="Cosmic muon trak length for last "+Period[i][0]+";End subrun time;(cm)";
188 
189  hname[31][i]="CMTrackRMS"+Period[i][1];
190  htitle[31][i]="Cosmic muon trak RMS for last "+Period[i][0]+";End subrun time;(cm)";
191 
192  hname[32][i] ="NRawChannels"+Period[i][1];
193  htitle[32][i]="Number of active raw channels for last "+Period[i][0]+";End subrun time; # active raw channels per subrun";
194 
195  hname[33][i]="FEB"+Period[i][1];
196  htitle[33][i]="Number of active FEBs for last " +Period[i][0]+";End subrun time;# active FEBs per subrun";
197 
198  hname[34][i] ="NHitsPerNoiseSlices"+Period[i][1];
199  htitle[34][i]="Number of hits per noise slice for last "+Period[i][0]+";End subrun time; # hits per slice";
200 
201  hRunname[i] ="RunBoundry"+Period[i][1];
202  hRuntitle[i] ="Time of the new run for last "+Period[i][0]+";Start subrun time; # hits per slice";
203 
204  }
205 
206  for(int i=0; i<NPeriods;i++){
207  for(int j=0; j<NHist;j++){
208 
209  hNearline[j][i] = new TH2F(hname[j][i],htitle[j][i],1000,XPeriod[i], XNow, 100,0,0.1);
210  hNearline[j][i]->GetXaxis()->SetTimeDisplay(1);
211  hNearline[j][i]->GetXaxis()->SetLabelSize(0.03);
212  hNearline[j][i]->SetMarkerStyle(2);
213  hNearline[j][i]->SetMarkerSize(2);
214  hNearline[j][i]->SetMarkerColor(2);
215 
216 
217  if(i==0) hNearline[j][i]->GetXaxis()->SetTimeFormat("%H:%M");
218  else hNearline[j][i]->GetXaxis()->SetTimeFormat("%m\/%d");
219 
220  hNearline[j][i]->SetBit(TH1::kCanRebin);
221  // gNearline[j][i] = new TGraph(hNearline[j][i]);
222 
223  }
224 
225  hRun[i] = new TH2F(hRunname[i],hRuntitle[i],1000,XPeriod[i], XNow, 1,0,100000);
226  hRun[i]->GetXaxis()->SetTimeDisplay(1);
227  hRun[i]->GetXaxis()->SetLabelSize(0.03);
228  hRun[i]->SetMarkerStyle(2);
229  hRun[i]->SetMarkerSize(2);
230  hRun[i]->SetMarkerColor(1);
231 
232 
233  if(i==0) hRun[i]->GetXaxis()->SetTimeFormat("%H:%M");
234  else hRun[i]->GetXaxis()->SetTimeFormat("%m\/%d");
235 
236  hRun[i]->SetBit(TH1::kCanRebin);
237  ;
238 
239  }
240 
241 
242  //CANA plots
243 
244 
245  TChain *numichain0 = new TChain("cana");
246  TChain *numichain1 = new TChain("cana");
247  TChain *numichain2 = new TChain("cana");
248  TChain *numichain3 = new TChain("cana");
249  TChain *numichain4 = new TChain("cana");
250 
251  TChain *bnbchain0 = new TChain("cana");
252  TChain *bnbchain1 = new TChain("cana");
253  TChain *bnbchain2 = new TChain("cana");
254  TChain *bnbchain3 = new TChain("cana");
255  TChain *bnbchain4 = new TChain("cana");
256 
257 
258  Int_t binSize=5;
259  Int_t firstBin = -100;
260  Int_t lastBin = 600;
261  Int_t nBins = (lastBin - firstBin) / binSize;
262 
263 
264 
265  const char* software_release="S12.02.14";
266  Int_t trig_type = 2; //0 will return numi files; 1 will return booster files; 2 will return cosmic files
267  std::string filename = "goodrunfiles.txt";
268 
269  //**************END OF TYPICAL USER'S NEED TO ALTER THIS SCRIPT*******************************************
270 
271  // std::ofstream runfile;
272  // runfile.open(filename.c_str());
273 
274  std::stringstream dbstream;
275  std::string dbstring;
276 
277  dbstream << "select * from nearline_metrics,subrun_cosmicmetrics where "
278  << " nearline_metrics.softwarerelease='"<<software_release<<"' "
279  << " and nearline_metrics.triggertype="<<trig_type
280  << " and nearline_metrics.run=subrun_cosmicmetrics.run"
281  << " and nearline_metrics.subrun=subrun_cosmicmetrics.subrun"
282  << " and nearline_metrics.triggertype=subrun_cosmicmetrics.triggertype"
283 // << " order by nearline_metrics.run asc";
284  << " order by nearline_metrics.run desc";
285 
286 
287 
288 
289  dbstring = dbstream.str();
290  char * dbcstr;
291  dbcstr = new char [dbstring.size()+1];
292  strcpy(dbcstr, dbstring.c_str());
293 
294 
295  TSQLServer *db = TSQLServer::Connect("pgsql://novadbdev.fnal.gov/nova_dev", "nova_reader", "");
296  TSQLStatement *stmt = db->Statement(dbcstr,1000);
297  if(stmt->Process()){
298  // store result of statement in buffer
299  stmt->StoreResult();
300 
301  //...........................................................................................................................
302 
303 
304 
305  while (stmt->NextResultRow())
306  {
307 
308  // Extract rows one after another
309 
310  UInt_t run = stmt->GetUInt(0);
311  Int_t subrun = stmt->GetInt(1);
312  Int_t triggertype = stmt->GetInt(2);
313  Int_t nevents = stmt->GetInt(3);
314  Int_t nemptyevents = stmt->GetInt(4);
315  Int_t nnoiseevents = stmt->GetInt(5);
316  Int_t nactivechannels = stmt->GetInt(6);
317  Int_t nrawactivechannels = stmt->GetInt(7);
318  const char* firsteventtime = stmt->GetString(8);
319  const char* firstnonemptyeventtime = stmt->GetString(9);
320  const char* lastnonemptyeventtime = stmt->GetString(10);
321  const char* lasteventtime = stmt->GetString(11);
322  Double_t nslices = stmt->GetDouble(12);
323  Double_t sliceduration = stmt->GetDouble(13);
324  Double_t hitsperslice = stmt->GetDouble(14);
325  Double_t hitsperslicenonoise = stmt->GetDouble(15);
326  Double_t hitsperevent = stmt->GetDouble(16);
327  Double_t occupancympv = stmt->GetDouble (17);
328  Double_t occupancysigma = stmt->GetDouble(18);
329  const char* detector = stmt->GetString(19);
330  const char* softwarerelease = stmt->GetString(20);
331  const char* inserttime = stmt->GetString(21);
332  const char* insertuser = stmt->GetString(22);
333  Int_t dcm11 = stmt->GetInt(21); ///< Number of active FEBs on DCM11
334  Int_t dcm12 = stmt->GetInt(22);
335  Int_t dcm13 = stmt->GetInt(23);
336  Int_t dcm21 = stmt->GetInt(24);
337  Int_t dcm22 = stmt->GetInt(25);
338  Int_t dcm23 = stmt->GetInt(26);
339  Int_t dcm31 = stmt->GetInt(27);
340  Int_t dcm32 = stmt->GetInt(28);
341  Int_t dcm33 = stmt->GetInt(29);
342  Int_t dcm41 = stmt->GetInt(30);// if (dcm41>1000) dcm41=0;
343  Int_t dcm42 = stmt->GetInt(31);
344  Int_t ndcms = stmt->GetInt(32); ///< Number of active DCMs
345  Int_t status = stmt->GetInt(33); ///< status of the file. 1 for files which passed datacheck cuts.
346  UInt_t crun = stmt->GetUInt(36);
347  Int_t csubrun = stmt->GetInt(37);
348  Int_t ctriggertype = stmt->GetInt(38);
349  Int_t cnevents = stmt->GetInt(39);
350  Double_t cntracks = stmt->GetDouble(40);
351  Double_t clivetime = stmt->GetDouble(41);
352  Double_t ccosmicrate = stmt->GetDouble(42);
353  Double_t ctracklength = stmt->GetDouble(43);
354  Double_t ctrackrms = stmt->GetDouble(44);
355 
356 // ........................................................................
357  //Extract percentage of empty and noise events; define small run for file name convention
358 
359  Double_t emptypercentage = 0;
360  Double_t noisepercentage = 0;
361 
362  if (nevents !=0)
363  {
364  emptypercentage=((double) nemptyevents*100)/((double) nevents);
365  noisepercentage=((double) nnoiseevents*100)/((double) nevents);
366  }
367 
368  Int_t smallrun=run/100;
369  //...................................................................................
370 
371 
372  //Extract times of first and last nonempty events
373  TDatime *FirstTime = new TDatime(firstnonemptyeventtime);
374 // TDatime *LastTime = new TDatime(lastnonemptyeventtime);
375  TDatime *LastTime = new TDatime(lasteventtime);
376 
377  UInt_t FirstTimeSec = FirstTime->Convert();
378  Int_t FirstYear = FirstTime->GetYear();
379  UInt_t LastTimeSec = LastTime->Convert();
380  Int_t LastYear = LastTime->GetYear();
381  UInt_t Diff = LastTimeSec - FirstTimeSec;
382 
383 
384 
385  for(int i=0;i<NPeriods;i++){
386 
387 cout<<"i="<<i<<endl;
388 cout<<LastTimeSec<<"\t"<<XPeriod[i]<<"\t"<< LastTimeSec - XPeriod[i] <<endl;
389 LastTime->Print();
390 //cin.get();
391  if(LastTimeSec > XPeriod[i]){
392 
393 
394  cout<<"HERE="<<nevents<<endl;
395 
396 
397  hNearline[0][i]->Fill(LastTimeSec,nevents);
398  hNearline[1][i]->Fill(LastTimeSec,(float)nevents/(float)Diff);
399  hNearline[2][i]->Fill(LastTimeSec,run);
400  hNearline[3][i]->Fill(LastTimeSec,subrun);
401  hNearline[4][i]->Fill(LastTimeSec,emptypercentage);
402  hNearline[5][i]->Fill(LastTimeSec,noisepercentage);
403  hNearline[6][i]->Fill(LastTimeSec,nactivechannels);
404  hNearline[7][i]->Fill(LastTimeSec,nslices);
405  hNearline[8][i]->Fill(LastTimeSec,hitsperslice);
406  hNearline[9][i]->Fill(LastTimeSec,hitsperslicenonoise);
407  hNearline[10][i]->Fill(LastTimeSec,hitsperevent*100);
408  hNearline[11][i]->Fill(LastTimeSec,occupancympv);
409  hNearline[12][i]->Fill(LastTimeSec,occupancysigma);
410  hNearline[13][i]->Fill(LastTimeSec,(float)Diff/60.);
411  hNearline[14][i]->Fill(LastTimeSec,sliceduration);
412  hNearline[15][i]->Fill(LastTimeSec,dcm11);
413  hNearline[16][i]->Fill(LastTimeSec,dcm12);
414  hNearline[17][i]->Fill(LastTimeSec,dcm13);
415  hNearline[18][i]->Fill(LastTimeSec,dcm21);
416  hNearline[19][i]->Fill(LastTimeSec,dcm22);
417  hNearline[20][i]->Fill(LastTimeSec,dcm23);
418  hNearline[21][i]->Fill(LastTimeSec,dcm31);
419  hNearline[22][i]->Fill(LastTimeSec,dcm32);
420  hNearline[23][i]->Fill(LastTimeSec,dcm33);
421  hNearline[24][i]->Fill(LastTimeSec,dcm41);
422  hNearline[25][i]->Fill(LastTimeSec,dcm42);
423  hNearline[26][i]->Fill(LastTimeSec,ndcms);
424  hNearline[27][i]->Fill(LastTimeSec,cntracks);
425  hNearline[28][i]->Fill(LastTimeSec,clivetime);
426  hNearline[29][i]->Fill(LastTimeSec,ccosmicrate/double(nactivechannels));
427  hNearline[30][i]->Fill(LastTimeSec,ctracklength);
428  hNearline[31][i]->Fill(LastTimeSec,ctrackrms);
429  hNearline[32][i]->Fill(LastTimeSec,nrawactivechannels);
430  hNearline[33][i]->Fill(LastTimeSec,dcm11+dcm12+dcm13+dcm21+dcm22+dcm23+dcm31+dcm32+dcm33+dcm41+dcm42);
431  hNearline[34][i]->Fill(LastTimeSec,hitsperslice-hitsperslicenonoise);
432  if(subrun==0) hRun[i]->Fill(FirstTimeSec,run);
433 
434  int smallrun=run/100;
435  cout<<"run="<<run<<" subrun="<<subrun<<endl;
436  LastTime->Print();
437 // cin.get();
438  if (run > LastRun /*|| run==LastRun*/ ){
439 
440  LastRun=run;
441 // if (subrun > LastSubrun)
442  LastSubrun=subrun;
443  }
444 
445 
446  if(subrun<10 ) {
447  if(i==0)numichain0->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s0%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
448  if(i==0)bnbchain0->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s0%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
449  if(i==1)numichain1->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s0%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
450  if(i==1)bnbchain1->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s0%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
451  if(i==2)numichain2->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s0%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
452  if(i==2)bnbchain2->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s0%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
453 
454  if(i==3)numichain3->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s0%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
455  if(i==3)bnbchain3->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s0%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
456  if(i==4)numichain4->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s0%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
457  if(i==4)bnbchain4->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s0%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
458  }
459  if(subrun>9 ){
460  if(i==0)numichain0->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
461  if(i==0)bnbchain0->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
462  if(i==1)numichain1->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
463  if(i==1)bnbchain1->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
464  if(i==2)numichain2->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
465  if(i==2)bnbchain2->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
466  if(i==3)numichain3->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
467  if(i==3)bnbchain3->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
468  if(i==4)numichain4->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/numi/cana_r000%d_s%d_t00_numi_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
469  if(i==4)bnbchain4->Add(Form("/scratch/nearline/NDOS/S12.02.14/000%d/%d/bnb/cana_r000%d_s%d_t01_bnb_S12.02.14_hist.root/Cana/cana",smallrun,run,run,subrun )) ;
470  }
471 
472 
473  }
474  }
475 
476 
477 
478 
479  //...........................................................................
480 
481 
482  }//End of stmt process
483 
484 
485 
486  delete stmt;
487 
488 
489  } //End of stmt loop
490 
491 
492 
493  delete db;
494 
495 
496 
497 
498  /// Get Run boundry TGraph
499 
500 
501 
502  const int NPoints[50][5]={0};
503  Float_t LastPoint[50][50]={0};
504 
505 
506  int status =10;
507 
508  for(int i=NPeriods-1; i>=0;i--){
509  for(int j=0; j<NHist;j++){
510 
511 
512  int hMinBin=1000;
513  int hMaxBin=1;
514  for ( int ny=1; ny < hNearline[j][i]->GetYaxis()->GetNbins(); ny++){
515  for ( int nx=1; nx < hNearline[j][i]->GetXaxis()->GetNbins(); nx++){
516 
517 
518 if(i==0) cout<<"content="<<hNearline[j][i]->GetBinContent(nx,ny)<<endl;
519  if (hNearline[j][i]->GetBinContent(nx,ny)) {
520  NPoints[j][i]++;
521 
522  if (ny < hMinBin) hMinBin = ny;
523  if (ny > hMaxBin) hMaxBin = ny;
524  }
525  }
526  }
527 
528 
529  cout<<"NPoints="<<NPoints[j][i]<<endl;
530  const int Ntemp=NPoints[j][i];
531  Double_t Xpoints[Ntemp+200]={0};
532  Double_t Ypoints[Ntemp+200]={0};
533  // cout<<Xpoints.size<<endl;
534  int pindex=0;
535  for ( int nx=1; nx < hNearline[j][i]->GetXaxis()->GetNbins(); nx++){
536  for ( int ny=1; ny < hNearline[j][i]->GetYaxis()->GetNbins(); ny++){
537 
538 
539  if (hNearline[j][i]->GetBinContent(nx,ny)) {
540 
541  Xpoints[pindex]= hNearline[j][i]->GetXaxis()->GetBinCenter(nx);
542  if(j==0 || j==2 || j==3 || (j>14 && j<28) || j==32 || j==33){
543  Ypoints[pindex]= ceil(hNearline[j][i]->GetYaxis()->GetBinCenter(ny));
544 }
545 else Ypoints[pindex]= hNearline[j][i]->GetYaxis()->GetBinCenter(ny);
546 
547 
548  // cout<<i<<"\t"<<j<<"\t"<<Ntemp<<"\t"<<pindex<<"\t"<<Xpoints[pindex]<<"\t"<<Ypoints[pindex]<<endl;
549  pindex++;
550  LastPoint[j][i]=hNearline[j][i]->GetYaxis()->GetBinCenter(ny);
551 // cout<< LastPoint[j][i]<<endl;
552 
553  }
554  }
555  }
556  // cin.get();
557 
558  if (hMinBin >3 ) hMinBin = hMinBin - 2;
559  if (hMaxBin < hNearline[j][i]->GetXaxis()->GetNbins() -3 ) hMaxBin = hMaxBin + 2;
560 
561  hNearline[j][i]->GetYaxis()->SetRange(hMinBin, hMaxBin);
562 
563 
564  cout<<"test1"<<endl;
565  gNearline[j][i] = new TGraph(Ntemp, Xpoints, Ypoints);
566  gNearline[j][i]->SetTitle(htitle[j][i]);
567  gNearline[j][i]->GetXaxis()->SetTimeDisplay(1);
568  gNearline[j][i]->GetXaxis()->SetLabelSize(0.03);
569  gNearline[j][i]->SetMarkerStyle(2);
570  gNearline[j][i]->SetMarkerSize(2);
571  gNearline[j][i]->SetMarkerColor(1);
572 
573 
574  if(i==0) gNearline[j][i]->GetXaxis()->SetTimeFormat("%H:%M");
575  else gNearline[j][i]->GetXaxis()->SetTimeFormat("%m\/%d");
576 
577 
578  c1 = new TCanvas ( "c1","",10,10, 1000,500);
579 
580 
581  if(i==1){
582 
583  gNearline[j][1]->Fit("pol1");
584  fNearline[j] = gNearline[j][1]->GetFunction("pol1");
585 
586  cout<< LastPoint[j][i]<<endl;
587  cout<< fNearline[j]->GetParameter(0)<<"\t"<< fNearline[j]->GetParameter(1)<<endl;
588  cout<< fNearline[j]->GetParameter(0) + fNearline[j]->GetParameter(1) * XNow<<endl;
589 
590  //cin.get();
591 
592  }
593  if(i==0){
594  c1->SetGridy();
595 
596  float temp_value= fNearline[j]->GetParameter(0) + fNearline[j]->GetParameter(1) * XNow;
597 
598 
599  if (status != 2 || status !=5) status=3;
600 
601  if (temp_value/LastPoint[j][i]> 1.1 || temp_value/LastPoint[j][i] < 0.9 ){
602  c1->SetFillColor(kYellow);
603  if(status !=2 ) status=5;
604 
605  }
606  else if (temp_value/LastPoint[j][i]> 1.3 || temp_value/LastPoint[j][i] < 0.7 ){
607  c1->SetFillColor(kRed);
608  status=2;
609  }
610 
611  if (j==4 ||j ==5 ){
612  if(temp_value/LastPoint[j][i] > 1.1) c1->SetFillColor(kWhite);
613 //cout<<j<<"\t"<<temp_value/LastPoint[j][i]<<endl;cin.get();
614  }
615 
616 
617 // TLegend *ll = new TLegend(0.8,0.9,1.0,1.0,Form("Last point = %.2f",LastPoint[j][i]) );
618  TLegend *ll;
619  if(j==0 || j==2 || j==3 || (j>14 && j<28) || j==32 || j==33){
620  ll = new TLegend(0.8,0.9,1.0,1.0,Form("Last point = %.0f", ceil(LastPoint[j][i])) );
621  }
622  else ll = new TLegend(0.8,0.9,1.0,1.0,Form("Last point = %.2f",LastPoint[j][i]) );
623 
624  gNearline[j][i]->Draw("AP");
625 //if(j==0) hRun[i]->RebinY(hRun[i]->GetYaxis()->GetNbins());
626 
627 // hRun[i]->Draw("same,box");
628  ll->Draw();
629 
630 
631  }
632  else{ c1->SetGrid();
633  gNearline[j][i]->Draw("AP");
634  if(i==1) fNearline[j]->Draw("same");
635  }
636  c1->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/"+hname[j][i]+".png");
637 
638  delete c1;
639  }
640  }
641 
642 
643  // int status =10;
644  //kGreen=3, kYellow=5, kRed=2
645 
646  gStyle->SetCanvasPreferGL(kTRUE);
647  TCanvas *c = new TCanvas("glc","TH3 Drawing", 100, 10, 1000, 300);
648  TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98, " NDOS Nearline status ");
649  TPaveLabel *runpad= new TPaveLabel(0.04, 0.66, 0.96, 0.78, Form("Run/Subrun Number:%d/%d",LastRun,LastSubrun));
650  TPaveLabel *timepad = new TPaveLabel(0.04, 0.46, 0.96, 0.58, TNow->AsString());
651 
652  // cout<<"Status color"<<
653  title->SetFillColor(status);
654  runpad ->SetFillColor(status);
655  timepad ->SetFillColor(status);
656 
657  title->Draw();
658  runpad->Draw();
659  timepad->Draw();
660  c->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/StatusBox.png");
661 
662 
663  //CANA
664 
665 
666  gStyle->SetOptStat(1111);
667 
668 TH1F *TimeNuMIPeakDay = new TH1F("TimeNuMIPeakDay", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
669 TH1F *TimeBNBPeakDay = new TH1F("TimeBNBPeakDay", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
670 TH1F *InTimeNuMIPeakDay = new TH1F("InTimeNuMIPeakDay", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
671 TH1F *InTimeBNBPeakDay = new TH1F("InTimeBNBPeakDay", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
672 
673 
674 TH1F *TimeNuMIPeakWeek = new TH1F("TimeNuMIPeakWeek", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
675 TH1F *TimeBNBPeakWeek = new TH1F("TimeBNBPeakWeek", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
676 TH1F *InTimeNuMIPeakWeek = new TH1F("InTimeNuMIPeakWeek", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
677 TH1F *InTimeBNBPeakWeek = new TH1F("InTimeBNBPeakWeek", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
678 
679 TH1F *TimeNuMIPeakMonth = new TH1F("TimeNuMIPeakMonth", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
680 TH1F *TimeBNBPeakMonth = new TH1F("TimeBNBPeakMonth", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
681 TH1F *InTimeNuMIPeakMonth = new TH1F("InTimeNuMIPeakMonth", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
682 TH1F *InTimeBNBPeakMonth = new TH1F("InTimeBNBPeakMonth", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
683 
684 
685 TH1F *TimeNuMIPeak2Weeks = new TH1F("TimeNuMIPeak2Weeks", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
686 TH1F *TimeBNBPeak2Weeks = new TH1F("TimeBNBPeak2Weeks", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
687 TH1F *InTimeNuMIPeak2Weeks = new TH1F("InTimeNuMIPeak2Weeks", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
688 TH1F *InTimeBNBPeak2Weeks = new TH1F("InTimeBNBPeak2Weeks", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
689 
690 TH1F *TimeNuMIPeak2Months = new TH1F("TimeNuMIPeak2Months", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
691 TH1F *TimeBNBPeak2Months = new TH1F("TimeBNBPeak2Months", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
692 TH1F *InTimeNuMIPeak2Months = new TH1F("InTimeNuMIPeak2Months", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
693 TH1F *InTimeBNBPeak2Months = new TH1F("InTimeBNBPeak2Months", ";Time [#musec];Number of Events", nBins, firstBin, lastBin);
694 
695 
696 TCut cuts ="(nhitx+nhity>9) && nhitx>4 && nhity>4 && tave>0.0 && tave<550.0 && y1<150.0 && abs(x1)<110.0 && z1>25 && z1<770 && cosnumi>0.7";
697 TCut intimenumi="(nhitx+nhity>9) && nhitx>4 && nhity>4 && tave>215 && tave<230.0 && y1<150.0 && abs(x1)<110.0 && z1>25 && z1<770 && cosnumi>0.7";
698 
699 TCut cutsbnb ="(nhitx+nhity>6) && nhitx>3 && nhity>3 && tave>0.0 && tave<550.0 && y1<130.0 && abs(x1)<100.0 && z1>270 && z1<570 && cosnumi>0.7";
700 TCut intimebnb="(nhitx+nhity>6) && nhitx>3 && nhity>3 && tave>318 && tave<321.0 && y1<130.0 && abs(x1)<100.0 && z1>270 && z1<570 && cosnumi>0.7 ";
701 
702 numichain0->Project("TimeNuMIPeakDay", "tave",cuts);
703 numichain0->Project("InTimeNuMIPeakDay", "tave",intimenumi);
704 
705 bnbchain0 ->Project("TimeBNBPeakDay" , "tave",cutsbnb);
706 bnbchain0 ->Project("InTimeBNBPeakDay","tave",intimebnb);
707 
708 cout<<TimeNuMIPeakDay->GetEntries()<<endl;
709 cout<<InTimeNuMIPeakDay->GetEntries()<<endl;
710 //cin.get();
711 
712 numichain1->Project("TimeNuMIPeakWeek", "tave",cuts);
713 bnbchain1 ->Project("TimeBNBPeakWeek" , "tave",cutsbnb);
714 numichain1->Project("InTimeNuMIPeakWeek","tave",intimenumi);
715 bnbchain1 ->Project("InTimeBNBPeakWeek","tave",intimebnb);
716 
717 numichain2->Project("TimeNuMIPeakMonth", "tave",cuts);
718 bnbchain2 ->Project("TimeBNBPeakMonth" , "tave",cutsbnb);
719 numichain2->Project("InTimeNuMIPeakMonth","tave",intimenumi);
720 bnbchain2 ->Project("InTimeBNBPeakMonth","tave",intimebnb);
721 
722 
723 numichain3->Project("TimeNuMIPeak2Weeks", "tave",cuts);
724 bnbchain3 ->Project("TimeBNBPeak2Weeks" , "tave",cutsbnb);
725 numichain3->Project("InTimeNuMIPeak2Weeks","tave",intimenumi);
726 bnbchain3 ->Project("InTimeBNBPeak2Weeks","tave",intimebnb);
727 
728 numichain4->Project("TimeNuMIPeak2Month", "tave",cuts);
729 bnbchain4 ->Project("TimeBNBPeak2Month" , "tave",cutsbnb);
730 numichain4->Project("InTimeNuMIPeak2Month","tave",intimenumi);
731 bnbchain4 ->Project("InTimeBNBPeak2Month","tave",intimebnb);
732 
733 
734 TimeNuMIPeakDay->SetTitle(Form("InTime NuMI Events=%.0f in last 24 hrs ", InTimeNuMIPeakDay->GetEntries()));
735 TimeNuMIPeakWeek->SetTitle(Form("InTime NuMI Events=%.0f in last week ", InTimeNuMIPeakWeek->GetEntries()));
736 TimeNuMIPeakMonth->SetTitle(Form("InTime NuMI Events=%.0f in last month ", InTimeNuMIPeakMonth->GetEntries()));
737 TimeNuMIPeak2Weeks->SetTitle(Form("InTime NuMI Events=%.0f in last week ", InTimeNuMIPeak2Weeks->GetEntries()));
738 TimeNuMIPeak2Months->SetTitle(Form("InTime NuMI Events=%.0f in last month ", InTimeNuMIPeak2Months->GetEntries()));
739 
740 
741 TimeBNBPeakDay->SetTitle(Form("InTime BNB Events=%.0f in last 24 hrs", InTimeBNBPeakDay->GetEntries()));
742 TimeBNBPeakWeek->SetTitle(Form("InTime BNB Events=%.0f in last week", InTimeBNBPeakWeek->GetEntries()));
743 TimeBNBPeakMonth->SetTitle(Form("InTime BNB Events=%.0f in last month", InTimeBNBPeakMonth->GetEntries()));
744 TimeBNBPeak2Weeks->SetTitle(Form("InTime BNB Events=%.0f in last week", InTimeBNBPeak2Weeks->GetEntries()));
745 TimeBNBPeak2Months->SetTitle(Form("InTime BNB Events=%.0f in last month", InTimeBNBPeak2Months->GetEntries()));
746 
747 
748 TCanvas *numi0=new TCanvas("numi0","",10,10,1000,500);
749 TimeNuMIPeakDay->Draw();
750 
751 TCanvas *numi1=new TCanvas("numi1","",10,10,1000,500);
752 TimeNuMIPeakWeek->Draw();
753 
754 TCanvas *numi2=new TCanvas("numi2","",10,10,1000,500);
755 TimeNuMIPeakMonth->Draw();
756 
757 TCanvas *numi3=new TCanvas("numi3","",10,10,1000,500);
758 TimeNuMIPeak2Weeks->Draw();
759 
760 TCanvas *numi4=new TCanvas("numi4","",10,10,1000,500);
761 TimeNuMIPeak2Months->Draw();
762 
763 
764 TCanvas *bnb0=new TCanvas("bnb0","",10,10,1000,500);
765 TimeBNBPeakDay->Draw();
766 TCanvas *bnb1=new TCanvas("bnb1","",10,10,1000,500);
767 TimeBNBPeakWeek->Draw();
768 TCanvas *bnb2=new TCanvas("bnb2","",10,10,1000,500);
769 TimeBNBPeakMonth->Draw();
770 TCanvas *bnb3=new TCanvas("bnb3","",10,10,1000,500);
771 TimeBNBPeak2Weeks->Draw();
772 TCanvas *bnb4=new TCanvas("bnb4","",10,10,1000,500);
773 TimeBNBPeak2Months->Draw();
774 
775 
776 numi0->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/NuMITimePeakDAY.png");
777 numi1->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/NuMITimePeakWEEK.png");
778 numi2->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/NuMITimePeakMONTH.png");
779 numi3->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/NuMITimePeak2WEEKS.png");
780 numi4->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/NuMITimePeak2MONTHS.png");
781 
782 bnb0->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/BNBTimePeakDAY.png");
783 bnb1->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/BNBTimePeakWEEK.png");
784 bnb2->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/BNBTimePeakMONTH.png");
785 bnb2->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/BNBTimePeakWEEK.png");
786 bnb3->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/BNBTimePeak2MONTH.png");
787 
788 
789 
790 }
791 
792 
int nBins
Definition: plotROC.py:16
int status
Definition: fabricate.py:1613
correl_xv GetYaxis() -> SetDecimals()
void NewNearlinePlots()
TDatime * TNow
Definition: AnaPlotMaker.h:41
Double_t nactivechannels
Definition: SimpleIterate.C:52
string filename
Definition: shutoffs.py:106
Int_t nevents
Definition: SimpleIterate.C:25
correl_xv GetXaxis() -> SetDecimals()
UInt_t LastRun
Definition: AnaPlotMaker.h:49
Double_t emptypercentage
Definition: SimpleIterate.C:53
const double j
Definition: BetheBloch.cxx:29
Definition: run.py:1
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
c1
Definition: demo5.py:24
fvar< T > ceil(const fvar< T > &x)
Definition: ceil.hpp:11