#include "TF1.h" #include "TCanvas.h" #include "TPad.h" #include "TText.h" #include "Stntuple/obj/TStnHeaderBlock.hh" #include "Stntuple/obj/TStnTrackBlock.hh" #include "TMetAnaModule.hh" //_____________________________________________________________________________ TMetAnaModule::TMetAnaModule(const char* name, const char* title): TStnModule(name,title) { fMyronFlag = -1; fMinMet = 20.; } //_____________________________________________________________________________ TMetAnaModule::~TMetAnaModule() { } //_____________________________________________________________________________ void TMetAnaModule::BookHistograms() { // book histograms Delete("hist"); for (int i=0; i<2; i++) { fHist.fMet[i] = new TH1F(Form("met_%i",i), Form("Met(%i)",i),200 ,0,200); AddHistogram(fHist.fMet[i]); fHist.fMetPhi[i] = new TH1F(Form("metphi_%i",i), Form("MetPhi(%i)",i),128 ,0,6.3); AddHistogram(fHist.fMetPhi[i]); } fHist.fMet0VsMet1 = new TH2F("met0_vs_met1","Met(0) vs Met(1)", 100,0,200,100,0,200); AddHistogram(fHist.fMet0VsMet1); fHist.fSumEt = new TH1F("sumet", "SUM(Et)",100,0,200); AddHistogram(fHist.fSumEt); } //_____________________________________________________________________________ int TMetAnaModule::BeginJob() { // register the data block RegisterDataBlock("MetBlock","TStnMetBlock",&fMetBlock); // book histograms BookHistograms(); if (! fMetBlock) { printf(" >>> branch *** %s *** doesn't exist \n","MetBlock"); fEnabled = 0; } return 0; } //_____________________________________________________________________________ int TMetAnaModule::BeginRun() { return 0; } //_____________________________________________________________________________ int TMetAnaModule::Event(int ientry) { fMetBlock->GetEntry(ientry); // do whatever you want if (PrintLevel()) { fMetBlock->Print(); } for (int i=0; i<2; i++) { fHist.fMet [i]->Fill(fMetBlock->fMet [i]); fHist.fMetPhi[i]->Fill(fMetBlock->fMetphi[i]); } fHist.fMet0VsMet1->Fill(fMetBlock->Met(1),fMetBlock->Met(0),1); fHist.fSumEt->Fill(fMetBlock->fSumet); //----------------------------------------------------------------------------- // filtering part //----------------------------------------------------------------------------- int passed = fMetBlock->fMet[0] > fMinMet; SetPassed(passed); return 0; } //_____________________________________________________________________________ int TMetAnaModule::EndJob() { printf("----- end job: ---- %s\n",GetName()); return 0; } //_____________________________________________________________________________ void TMetAnaModule::PlotHistograms(int run_number, int slide) { // plot slides char name[120], canvas_name[120], title[120], pad_name[120]; sprintf(name,"run_%i_%i",run_number,slide); sprintf(title,"run %i slide %i ",run_number, slide); sprintf(canvas_name,"%s_%s",GetName(),name); sprintf(pad_name,"%s_p1",canvas_name); if (slide == 1) { //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- // TPostScript ps("l1ana.ps",-111); TCanvas* c = NewSlide(name,title,2,3); TPad* p1 = (TPad*) c->GetPrimitive(pad_name); p1->cd(1); fHist.fMet[0]->Draw(); fHist.fMet[1]->Draw("same"); p1->cd(2); fHist.fMetPhi[0]->Draw(); fHist.fMetPhi[1]->Draw("same"); p1->cd(3); fHist.fSumEt->Draw(); gPad->Update(); } }