// $Id$ // // File: DEventProcessor_fcal_hists.cc // Created: Mon Apr 3 11:38:03 EDT 2006 // Creator: davidl (on Darwin swire-b241.jlab.org 8.4.0 powerpc) // #include using namespace std; #include "DEventProcessor_fcal_hists.h" #include #include #include #include #include //static TH1F *ccal_amp[17]; //static TH1F *ccal_charge[17]; // Routine used to create our DEventProcessor extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->AddProcessor(new DEventProcessor_fcal_hists()); } } // "C" //------------------ // init //------------------ jerror_t DEventProcessor_fcal_hists::init(void){ app1 = new TApplication("app1",NULL,0); // my_canvas = new TCanvas("FCAL insert ", "FCAL insert ",1000, 700, 850, 800); // my_canvas->Divide(3,4,0.001); TDirectory *dir = new TDirectory("CCAL","CCAL"); dir->cd(); // Go back up to the parent directory dir->cd("../"); tree1 = new TTree("tree1","Reconst ntuple"); tree1->Branch("tilel",&tilel,"tilel/I"); tree1->Branch("tiler",&tiler,"tiler/I"); tree1->Branch("amp_1",&_1,"amp_1/F"); tree1->Branch("amp_2",&_2,"amp_2/F"); tree1->Branch("amp_3",&_3,"amp_3/F"); tree1->Branch("amp_4",&_4,"amp_4/F"); tree1->Branch("amp_5",&_5,"amp_5/F"); tree1->Branch("amp_6",&_6,"amp_6/F"); tree1->Branch("amp_7",&_7,"amp_7/F"); tree1->Branch("amp_8",&_8,"amp_8/F"); tree1->Branch("amp_9",&_9,"amp_9/F"); tree1->Branch("amp_10",&_10,"amp_10/F"); tree1->Branch("amp_11",&_11,"amp_11/F"); tree1->Branch("amp_12",&_12,"amp_12/F"); tree1->Branch("ch_1",&ch_1,"ch_1/F"); tree1->Branch("ch_2",&ch_2,"ch_2/F"); tree1->Branch("ch_3",&ch_3,"ch_3/F"); tree1->Branch("ch_4",&ch_4,"ch_4/F"); tree1->Branch("ch_5",&ch_5,"ch_5/F"); tree1->Branch("ch_6",&ch_6,"ch_6/F"); tree1->Branch("ch_7",&ch_7,"ch_7/F"); tree1->Branch("ch_8",&ch_8,"ch_8/F"); tree1->Branch("ch_9",&ch_9,"ch_9/F"); tree1->Branch("ch_10",&ch_10,"ch_10/F"); tree1->Branch("ch_11",&ch_11,"ch_11/F"); tree1->Branch("ch_12",&ch_12,"ch_12/F"); tree1->Branch("t_1",&t_1,"t_1/F"); tree1->Branch("t_2",&t_2,"t_2/F"); tree1->Branch("t_3",&t_3,"t_3/F"); tree1->Branch("t_4",&t_4,"t_4/F"); tree1->Branch("t_5",&t_5,"t_5/F"); tree1->Branch("t_6",&t_6,"t_6/F"); tree1->Branch("t_7",&t_7,"t_7/F"); tree1->Branch("t_8",&t_8,"t_8/F"); tree1->Branch("t_9",&t_9,"t_9/F"); tree1->Branch("t_10",&t_10,"t_10/F"); tree1->Branch("t_11",&t_11,"t_11/F"); tree1->Branch("t_12",&t_12,"t_12/F"); ps_tile1 = new TH1F("ps_tile1","ps_tile1", 146, -0.5, 145.5); ps_tile2 = new TH1F("ps_tile2","ps_tile2", 146, -0.5, 145.5); prot_int = new TH1F("integral","integral", 100, 0.,1000.); tile_amp = new TH2F("tile_amp","tile_amp", 146,-0.5,145.5,100,0.,1000.); // tree1->Branch("ch1",&ch[1],"ch[17]/F"); // tree1->Branch("charge1",&charge[1],"charge[17]/F"); // tree1->Branch("test_ch1",&ch[1],"ch/F"); // tree1->Branch("test_charge1",&charge[1],"charge/F"); return NOERROR; } //------------------ // brun //------------------ jerror_t DEventProcessor_fcal_hists::brun(JEventLoop *eventLoop, int32_t runnumber){ return NOERROR; } //------------------ // evnt //------------------ jerror_t DEventProcessor_fcal_hists::evnt(JEventLoop *loop, uint64_t eventnumber) { int debug = 1; unsigned int trig_bit[33], trig_bit_fp[33]; vector pulse_data; vector ps_pairs; vector l1trig; memset(amp,0,sizeof(amp)); loop->Get(ps_pairs); loop->Get(pulse_data); loop->Get(l1trig); // cout << " Event number = " << eventnumber << " " << pulse_data.size() << endl; japp->RootWriteLock(); tilel = -1; tiler = -1; amp_1 = 0; amp_2 = 0; amp_3 = 0; amp_4 = 0; amp_5 = 0; amp_6 = 0; amp_7 = 0; amp_8 = 0; amp_9 = 0; amp_10 = 0; amp_11 = 0; amp_12 = 0; ch_1 = 0; ch_2 = 0; ch_3 = 0; ch_4 = 0; ch_5 = 0; ch_6 = 0; ch_7 = 0; ch_8 = 0; ch_9 = 0, ch_10 = 0; ch_11 = 0; ch_12 = 0; t_1 = 0; t_2 = 0; t_3 = 0; t_4 = 0; t_5 = 0; t_6 = 0; t_7 = 0; t_8 = 0; t_9 = 0; t_10 = 0; t_11 = 0; t_12 = 0; memset(trig_bit,0,sizeof(trig_bit)); if( l1trig.size() > 0){ for(unsigned int bit = 0; bit < 32; bit++){ trig_bit[bit + 1] = (l1trig[0]->trig_mask & (1 << bit)) ? 1 : 0; } for(unsigned int bit = 0; bit < 32; bit++){ trig_bit_fp[bit + 1] = (l1trig[0]->fp_trig_mask & (1 << bit)) ? 1 : 0; } } if(trig_bit[4] != 1){ japp->RootUnLock(); return NOERROR; } // PS int tile1 = -100; int tile2 = -100; if(ps_pairs.size() > 0){ tile1 = ps_pairs[0]->ee.first->column; tile2 = ps_pairs[0]->ee.second->column; tilel = tile1; tiler = tile2; } int nhit_ch[12]; memset(nhit_ch,0,sizeof(nhit_ch)); // cout << "Pulse Data Size = " << pulse_data.size() << endl; for(unsigned int kk = 0; kk < pulse_data.size(); kk++){ int crate = pulse_data[kk]->rocid; int slot = pulse_data[kk]->slot; int channel = pulse_data[kk]->channel; if(channel == 15) channel = 2; // uint32_t time = (pulse_data[kk]->time & 0x7FC0) >> 6; float time = float(pulse_data[kk]->course_time); // cout << time << endl; if(nhit_ch[channel] == 1) continue; if( (crate == 94) && (slot == 9) && (channel >= 0) && (channel < 12) ){ // if( (crate == 94) && (slot == 9) && (channel == 5) ){ if(nhit_ch[channel] == 1) continue; ps_tile1->Fill(tile1); ps_tile2->Fill(tile2); int pulse_int = pulse_data[kk]->integral; int pulse_peak = pulse_data[kk]->pulse_peak; int nsamples_integral = pulse_data[kk]->nsamples_integral; int pedestal = pulse_data[kk]->pedestal; float ped_sub_int = pulse_int - (pedestal/4.)*nsamples_integral; float ped_sub_peak = pulse_peak - (pedestal/4.); #if 0 cout << "Crate = " << crate << " Slot = " << slot << " Channel = " << channel << " Integral = " << pulse_int << " Peak = " << pulse_peak << " NS integral = " << nsamples_integral << " Pedestal = " << pedestal/4. << " PS tile1 = " << tile1 << " PS tile 2 = " << tile2 << endl; #endif float my_int = pulse_int - (pedestal/4.)*nsamples_integral; switch(channel){ case 0: amp_1 = ped_sub_peak; ch_1 = ped_sub_int; t_1 = time; nhit_ch[0] = 1; break; case 1: amp_2 = ped_sub_peak; ch_2 = ped_sub_int; t_2 = time; nhit_ch[1] = 1; break; case 2: amp_3 = ped_sub_peak; ch_3 = ped_sub_int; t_3 = time; nhit_ch[2] = 1; break; case 3: amp_4 = ped_sub_peak; ch_4 = ped_sub_int; t_4 = time; nhit_ch[3] = 1; break; case 4: amp_5 = ped_sub_peak; ch_5 = ped_sub_int; t_5 = time; nhit_ch[4] = 1; break; case 5: amp_6 = ped_sub_peak; ch_6 = ped_sub_int; t_6 = time; nhit_ch[5] = 1; break; case 6: amp_7 = ped_sub_peak; ch_7 = ped_sub_int; t_7 = time; nhit_ch[6] = 1; break; case 7: amp_8 = ped_sub_peak; ch_8 = ped_sub_int; t_8 = time; nhit_ch[7] = 1; break; case 8: amp_9 = ped_sub_peak; ch_9 = ped_sub_int; t_9 = time; nhit_ch[8] = 1; break; case 9: amp_10 = ped_sub_peak; ch_10 = ped_sub_int; t_10 = time; nhit_ch[9] = 1; break; case 10: amp_11 = ped_sub_peak; ch_11 = ped_sub_int; t_11 = time; nhit_ch[10] = 1; break; case 11: amp_12 = ped_sub_peak; ch_12 = ped_sub_int; t_12 = time; nhit_ch[11] = 1; break; default: break; } prot_int->Fill(ped_sub_int); tile_amp->Fill(tile1,ped_sub_int); } } if(tilel > 0 && tiler > 0){ tree1->Fill(); } japp->RootUnLock(); return NOERROR; } //------------------ // erun //------------------ jerror_t DEventProcessor_fcal_hists::erun(void) { // Any final calculations on histograms (like dividing them) // should be done here. This may get called more than once. return NOERROR; } //------------------ // fini //------------------ jerror_t DEventProcessor_fcal_hists::fini(void) { return NOERROR; }