//_____________________________________________________________________________ // Plug strip d-bank analysis module: below are the examples of what // one can do in the interactive session //_____________________________________________________________________________ /* ****** to run: (note naming convention: class_name = "T"+module_name+"Module"), the source code of the class is stored in TStnAna x("results/ar0192ea.0001cmu0.stn_new"); TStnAna x("results/dataval_muon.root"); .L TPesAnaModule.cc+ x.AddModule(new TPesAnaModule); x.Run(); ****** to display a histogram TPesAnaModule::Hist_t* c; TPesAnaModule* m = (TPesAnaModule*) x.GetModule("PesAna"); c = m->GetHist(); c->fAdcCounts->Draw(); ****** to process one event (#11 in the ntuple) and to print the data x.ProcessEvent(11) TPesAnaModule* m = (TPesAnaModule*) x.GetModule("PesAna"); TPesDataBlock* pes = m->GetPesDataBlock(); TStnHeaderBlock* hdr = m->GetHeaderBlock (); pes->Print(); hdr->Print(); */ #include "TF1.h" #include "TCanvas.h" #include "Stntuple/obj/TStnHeaderBlock.hh" #include "Stntuple/obj/TStnTrackBlock.hh" #include "TPesAnaModule.hh" // ClassImp(TPesAnaModule) //_____________________________________________________________________________ TPesAnaModule::TPesAnaModule(const char* name, const char* title): TStnModule(name,title) { } //_____________________________________________________________________________ TPesAnaModule::~TPesAnaModule() { } //_____________________________________________________________________________ void TPesAnaModule::BookHistograms() { char name [200]; char title[200]; Delete("hist"); // book histograms HBook1F(fHist.fNHitStrips, "n_hit_strips", "PES: N_hit_strips ",500,0,10000); HBook1F(fHist.fAdcCounts, "adc_counts", "PES: ADC spectrum " ,500,0,500); for (int side=0; side<2; side++) { for (int iw=0; iw<8; iw++) { for (int il=0; il<2; il++) { sprintf(name, "%s_layer_ped_%1i_%1i_%1i",GetName(),side,iw,il); sprintf(title,"%s: PES: ADC spectrum side=%i wedge=%i layer=%i", GetName(),side,iw,il); fHist.fLayerPed[side][iw][il]= new TH1F(name, title,500 ,0,500); AddHistogram(fHist.fLayerPed[side][iw][il]); } } } int k =0; for (int iw=5; iw<7; iw++) { for (int il=0; il<2; il++) { sprintf(name, "%s_strip_profile_%1i_%1i",GetName(),iw,il); sprintf(title,"%s: PES: strip profile wedge=%i layer=%i", GetName(),iw,il); fHist.fStripProfile[k] = new TH1F(name, title,200 ,0,200); AddHistogram(fHist.fStripProfile[k]); fHist.fStripProfile[k]->SetMaximum(300); k++; } } } //_____________________________________________________________________________ int TPesAnaModule::BeginJob() { // register the data blocks and book the histograms RegisterDataBlock("PesDataBlock","TPesDataBlock",&fPesDataBlock); BookHistograms(); return 0; } //_____________________________________________________________________________ int TPesAnaModule::BeginRun() { return 0; } //_____________________________________________________________________________ int TPesAnaModule::Event(int ientry) { fPesDataBlock->GetEntry(ientry); // do whatever you want if (PrintLevel()) { GetHeaderBlock()->Print(); fPesDataBlock->Print(); } int ntot = 0; for (int is=0; is<2; is++) { for (int iw=0; iw<8; iw++) { for (int il=0; il<2; il++) { int nstrips = fPesDataBlock->GetNHitStrips(is,iw,il); ntot += nstrips; if ( nstrips > 0) { // there is something in this data block for (int ich=0; ich<200; ich++) { int adc_counts = fPesDataBlock->GetAdcCounts(is,iw,il,ich+1); fHist.fAdcCounts->Fill(adc_counts); fHist.fLayerPed[is][iw][il]->Fill(adc_counts); } } if (is == 0) { if ( (iw == 5) || (iw == 6)) { int k = (iw-5)*2+il; fHist.fStripProfile[k]->Reset(); for (int ich=0; ich<200; ich++) { int adc_counts = fPesDataBlock->GetAdcCounts(is,iw,il,ich+1); fHist.fStripProfile[k]->SetBinContent(ich+1,adc_counts); } } } } } } fHist.fNHitStrips->Fill(ntot); return 0; } //_____________________________________________________________________________ void TPesAnaModule::DisplayEvent() { // TCanvas* c = (TCanvas*) gROOT->FindObject("TPesAnaModule_DisplayEvent_canvas"); // if (! c) { TCanvas* c = new TCanvas("TPesAnaModule_DisplayEvent_canvas", "West plug PES events", 0,0,800,600); c->Divide(2,2); // } // c->Divide(1,4); for (int j=0; j<4; j++) { c->cd(j+1); fHist.fStripProfile[j]->Draw(); } c->Modified(); c->Update(); } //_____________________________________________________________________________ int TPesAnaModule::EndJob() { printf("----- end job: ---- %s\n",GetName()); return 0; }