void mySelector::SlaveTerminate()
{
   // The SlaveTerminate() function is called after all entries or objects
   // have been processed. When running with PROOF SlaveTerminate() is called
   // on each slave server.
  cout<<"-------------End of Slave Job----------------"<<endl;
  tNow.Set();tNow.Print();
  cout<<"Number of Event: "<<fNumberOfEvents<<", elapsed time: "<<tNow.Convert()-tBegin.Convert()<<"seconds,rate: "<<float(fNumberOfEvents)/(tNow.Convert()-tBegin.Convert())<<endl;
}
void xrootdTestVanderbilt(const int iOption=0) {

  TDatime *dateTime = new TDatime;
  int iDate = dateTime->GetDate();
  int iTime = dateTime->GetTime();
  cout << "  Begin Vanderbilt access testing " << iDate << " at " << iTime << endl;

  if(iOption == 0 || iOption == 1) {
    TFile *f = TFile::Open("root://cmsxrootd.fnal.gov//store/test/xrootd/T2_US_Vanderbilt//store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root");
    if(f) {
      cout << "\n cmsxrootd.fnal.gov successful access to Vanderbilt" << endl;
      f->ls();
      f->Close();
    }
    else {
      cout << "\n cmsxrootd.fnal.gov unsuccessful access to Vanderbilt" << endl;
    }
    dateTime->Set();     // set to system date/time
    iDate = dateTime->GetDate();
    iTime = dateTime->GetTime();
    cout << "  Completed Vanderbilt access test from FNAL on " << iDate << " at " << iTime << endl;
  } // check on iOption = 0 or iOption = 1
  if(iOption == 0 || iOption == 2) {
    TFile *g = TFile::Open("root://cms-xrd-global.cern.ch//store/test/xrootd/T2_US_Vanderbilt//store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root");
    if(g) {
      cout << "\n cms-xrd-global.cern.ch successful access to Vanderbilt" << endl;
      g->ls();
      g->Close();
    }
    else {
      cout << "\n cms-xrd-global.cern.ch unsuccessful access to Vanderbilt" << endl;
    }
    dateTime->Set();     // set to system date/time
    iDate = dateTime->GetDate();
    iTime = dateTime->GetTime();
    cout << "  Completed Vanderbilt access test from CERN on " << iDate << " at " << iTime << endl;
  } // check on iOption = 0 or iOption = 2
  dateTime->Set();     // set to system date/time
  cout << "\n  Completed Vanderbilt access testing " << iDate << " at " << iTime << endl;
return;
}
void mySelector::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();
   tBegin.Set();
   fNumberOfEvents = 0;
   cout<<"-------Begin of job-------"<<endl;
   tBegin.Print();
}
Exemple #4
0
void MySelector::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();

   // some time measurement
   tBegin.Set(); printf("*==* ---------- Begin of Job ----------");
   tBegin.Print();
}
void mySelector::Terminate()
{
   // The Terminate() function is the last function to be called during
   // a query. It always runs on the client, it can be used to present
   // the results graphically or save the results to file.
  TString option = GetOption();
  TString output = "gr_";
  output += option;
  output += ".root";
  TFile *hfile = new TFile(output,"RECREATE","FONLL CCbar cross section");
  
  hfile->cd();
  const Int_t npoint = eventnumber;
  Float_t x[npoint];
  Float_t y[npoint];
  Float_t ylow[npoint];
  Float_t yup[npoint];
  for(int i=0;i<npoint;i++)
    {
      x[i] = Pt[i];
      y[i] = Central[i];
      ylow[i] = Down[i];
      yup[i] = Up[i];
    }
  //TGraph *grFONLLD0 = new TGraph(npoint,Pt,Central);
  TDirectoryFile *ratioErr = new TDirectoryFile(option,"ratio error of scale pp500 to pp200 ");
  ratioErr->SetName(option);
  ratioErr->Add(hRatio);
  TGraph *grFONLLRatio = new TGraph(npoint,x,y);
  grFONLLRatio->SetName("grFONLLRatio");
  TGraph *grFONLLRatio_u = new TGraph(npoint,x,yup);
  grFONLLRatio_u->SetName("grFONLLRatio_u");
  TGraph *grFONLLRatio_d = new TGraph(npoint,x,ylow);
  grFONLLRatio_d->SetName("grFONLLRatio_d");
  grFONLLRatio->Print();
  ///grFONLLRatio->Write();
  ratioErr->Add(grFONLLRatio);
  grFONLLRatio_u->Print();
  //grFONLLRatio_u->Write();
  ratioErr->Add(grFONLLRatio_u);
  grFONLLRatio_d->Print();
  //grFONLLRatio_d->Write();
  ratioErr->Add(grFONLLRatio_d);
  ratioErr->Write();
  hfile->Print();
  hfile->Close();
  tNow.Set();
  cout<<"----------End of job----------"<<endl;
  tNow.Print();
}
Exemple #6
0
void MySelector::SlaveTerminate()
{
   // The SlaveTerminate() function is called after all entries or
   // objects have been processed. When running with PROOF
   // SlaveTerminate() is called on each slave server.

  // some statistics at end of job
  printf("\n *==* ---------- End of Slave Job ----------   ");
  tNow.Set(); tNow.Print();
  printf(
  "Number of Events: %i, elapsed time: %i sec, rate: %g evts/sec\n"
  ,fNumberOfEvents,
  tNow.Convert()-tBegin.Convert(),
   float(fNumberOfEvents)/(tNow.Convert()-tBegin.Convert()) );
}
Exemple #7
0
//_____________________________________________________________________________
void THaRunBase::SetDate( UInt_t tloc )
{
  // Set timestamp of this run to 'tloc' which is in Unix time
  // format (number of seconds since 01 Jan 1970).

#if ROOT_VERSION_CODE >= ROOT_VERSION(3,1,6)
  TDatime date( tloc );
#else
  time_t t = tloc;
  struct tm* tp = localtime(&t);
  TDatime date;
  date.Set( tp->tm_year, tp->tm_mon+1, tp->tm_mday,
	    tp->tm_hour, tp->tm_min, tp->tm_sec );
#endif
  SetDate( date );
}
Exemple #8
0
void MySelector::Terminate()
{
   // The Terminate() function is the last function to be called
   // during a query. It always runs on the client, it can be used
   // to present the results graphically or save the results to
   // file.

   // finally, store all output
   TFile hfile("MySelector_Result.root","RECREATE","MuonResults");
   fOutput->Write();

   //Example to retrieve output from output list
   h_resistance=
      dynamic_cast<TH1F *>(fOutput->FindObject("resistance"));
   TCanvas c_result("cresult","Resistance",100,100,300,300);
   h_resistance->Draw();
   c_result.SaveAs("ResistanceDistribution.png");

   tNow.Set(); printf("*==* ---------- End of Job ---------- ");
   tNow.Print();
}
Exemple #9
0
// main method
void LEDRef_evtdis(const int runno = 615,
		   const int gainv = 0,  /*0=low, 1=high*/
		   const int evtnum= -10,
		   int ymax=1023, // set the scale of plots
		   const int delay = 1)  // -1=no delay, wait for input, X>=0 => sleep aprox. X sec. after making plot
{
  // set ranges to plot
  const int strip_f = 0; // first
  const int strip_l = NSTRIPS - 1;
  
  const int nsamples = 65; // number of ADC time samples per channel and event
  
  const int saveplot = 0;
  const int numbering      = 1; // 0: no numbering, 1: nubering on each plot
  const int dofit = 0; // 0: no fit, 1: try to fit the spectra 
  const int debug    = 0;
  const float gammaN = 2;
  // end of setup    
  
  // Assume we are just interested in the 1st segment, _0.root below for fname*
  Char_t fname[256];
  sprintf(fname, "/local/data/Run_%09d.Seq_1A.Stream_0.root",runno);
  cout << "TOTCHAN " << TOTCHAN << endl;

  // set up a raw reader of the data
  AliRawReader *rawReader = NULL;
  rawReader = new AliRawReaderRoot(fname);
  AliCaloRawStream *in = NULL; 
  in = new AliCaloRawStream(rawReader,"EMCAL");

  // set up histograms
  TH1F *hfit[TOTCHAN];
  TF1 *f1[TOTCHAN];
  char ch_label[TOTCHAN][100];
  char buff1[100];
  char name[80];
  for(int i=0; i<TOTCHAN; i++) {
    sprintf(buff1,"hfit_%d",i);
    hfit[i] = new TH1F(buff1,"hfit", nsamples , -0.5, nsamples - 0.5);
    hfit[i]->SetDirectory(0);
    sprintf(name,"f1_%d",i);
    f1[i] = new TF1(name,fitfun,0,70,5);
    f1[i]->SetLineWidth(2);
    f1[i]->SetLineColor(2);

    //	int idx = istrip + NSTRIPS * gain; // encoding used later
    int gain = i / (NSTRIPS);
    int istrip = i % NSTRIPS;
    sprintf(ch_label[i], "Strip%02d", istrip);
  }
  
  TCanvas *cc1 = new TCanvas("cc1","3 columns of 8 strips each",600,800);
  int numcol = NSETS;
  int numrow = NSTRIPS_IN_SET;
  cc1->Divide(numcol, numrow);
  
  TText *t = new TText;
  t->SetTextSize(0.17);
  int clr[2] = {4,2}; // colors
  
  // figure out which events we should look at
  int firstevent = evtnum;
  int lastevent = evtnum;
  if (evtnum < 0) { // get a bunch of events
    firstevent = 0;
    lastevent = - evtnum;
  }
  if (evtnum == 0) { // get all events
    firstevent = 0;
    lastevent = 1000000;
  }
  
  Int_t iev =0;
  AliRawEventHeaderBase *aliHeader=NULL;    
  while ( rawReader->NextEvent() && iev < firstevent) {
    aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader();
    iev++;
  }
  
  // loop over selected events
  while ( rawReader->NextEvent() && iev <= lastevent) {
    aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader();
    int runNumber = aliHeader->Get("RunNb"); 
    
    cout << "Found run number " << runNumber << endl;
    
    // reset histograms
    for(int i=0; i<TOTCHAN; i++) {
      hfit[i]->Reset();
    }
    
    // get events (the "1" ensures that we actually select all events for now)
    if ( 1 || aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent ) {
      const UInt_t * evtId = aliHeader->GetP("Id");
      int evno_raw = (int) evtId[0];
      int timestamp = aliHeader->Get("Timestamp");
      
      cout << " evno " << evno_raw
	   << " size " << aliHeader->GetEventSize()
	   << " type " << aliHeader->Get("Type")
	   << " type name " << aliHeader->GetTypeName()
	   << " timestamp " << timestamp
	   << endl;
      
      /// process_event stream
      while ( in->Next() ) {
	
	int strip = in->GetColumn();
	int gain = in->GetRow();
	
	if (in->IsLEDMonData()) {
	  
	  int idx = strip + NSTRIPS*gain;
	  //cout << "hist idx " << idx << endl;
	  
	  if (idx < 0 || idx > TOTCHAN) { 
	    cout << "Hist idx out of range: " << idx << endl;
	  }
	  else { // reasonable range of idx
	    hfit[idx]->SetBinContent(in->GetTime(), in->GetSignal());
	  }

	} // LED Ref data only

      } // Raw data read
    
      // Next: let's actually plot the data..
      for (Int_t strip = strip_f; strip <= strip_l; strip++) {
	
	int idx = strip + NSTRIPS*gainv;
	
	// which set/column does the strip belong in
	int iset = strip / NSTRIPS_IN_SET; 	  
	int within_set = strip % NSTRIPS_IN_SET; 	  
	// on which pad should we plot it?
	int pad_id = (NSTRIPS_IN_SET-1-within_set)*NSETS + iset + 1;
	
	cout << "strip " << strip 
	     << ". set="<< iset << ", within_set=" << within_set
	     << ", pad=" << pad_id << endl;
	cc1->cd(pad_id);
	hfit[idx]->SetTitle("");
	hfit[idx]->SetFillColor(5);
	hfit[idx]->SetMaximum(ymax);
	hfit[idx]->SetMinimum(0);
	// we may or may not decide to fit the data
	if (dofit) {
	  f1[i]->SetParameter(0, 0); // initial guess; zero amplitude :=)
	  hfit[idx]->Fit(f1[i]);
	}
	hfit[idx]->Draw();
	if( numbering ) {
	  t->SetTextColor(clr[gainv]);
	  t->DrawTextNDC(0.65,0.65,ch_label[idx]);
	}
      }

      // add some extra text on the canvas
      // print a box showing run #, evt #, and timestamp
      cc1->cd();
      // first draw transparent pad
      TPad *trans = new TPad("trans","",0,0,1,1);
      trans->SetFillStyle(4000);
      trans->Draw();
      trans->cd();
      // then draw text
      TPaveText *label = new TPaveText(.2,.11,.8,.14,"NDC"); 
      //  label->Clear();
      label->SetBorderSize(1);
      label->SetFillColor(0);
      label->SetLineColor(clr[gainv]);
      label->SetTextColor(clr[gainv]);
      //label->SetFillStyle(0);
      TDatime d;
      d.Set(timestamp);
      sprintf(name,"Run %d, Event %d, Hist Max %d, %s",runno,iev,ymax,d.AsString());
      label->AddText(name);
      label->Draw();
      cc1->Update();
      cout << "Done" << endl;
      
      // some shenanigans to hold the plotting, if requested
      if (firstevent != lastevent) {
	if (delay == -1) {
	  // wait for character input before proceeding
	  cout << " enter y to proceed " << endl;
	  char dummy[2];
	  cin >> dummy;
	  cout << " read " << dummy << endl;
	  if (strcmp(dummy, "y")==0) {
	    cout << " ok, continuing with event " << iev+1 << endl;
	  }
	  else {
	    cout << " ok, exiting " << endl;
	    //exit(1);
	  }
	}
	else {
	  cout << "Sleeping for " << delay * 500 << endl;
	  gSystem->Sleep(delay * 500);
	}
      }

      // save plot, if setup/requested to do so
      char plotname[100];
      if (saveplot==1) {
	sprintf(plotname,"Run_%d_LEDRef_Ev%d_Gain%d_MaxHist%d.gif",
		runno,iev,gainv,ymax);  
	cout <<"SAVING plot:"<< plotname << endl;
	cc1->SaveAs(plotname);
      }

    } // event selection