• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

beamtime/cern-oct11/go4/BUCHAREST/TTRDBucharestProc.cxx (r4864/r2480)

Go to the documentation of this file.
00001 #include "TTRDBucharestProc.h"
00002 
00003 #include "TMbsCrateParam.h"
00004 
00005 TTRDBucharestProc::TTRDBucharestProc(const char* name) : TCBMBeamtimeProc(name),fCrateInputEvent(0), fOutputEvent(0),fBeamEvent(0)
00006 {
00007    cout << "**** TTRDBucharestProc: Create instance" << name << endl;
00008 
00009    fPar = (TTRDBucharestParam*) MakeParameter("TRDBucharestPar", "TTRDBucharestParam");
00010 
00011    TMbsCrateParam* mbspar = dynamic_cast<TMbsCrateParam*> (GetParameter("MbsCratePar"));
00012 
00013    TString obname, obtitle;   
00014 
00015    if (mbspar && !mbspar->fBucharestSetup)
00016 
00017    /*********** MADCs *************/
00018    for (int mad = 0; mad < 2; mad++) {
00019 
00020 
00021       for (int ch = 0; ch < N_MADC_CHA; ch++) {
00022 
00023          obname.Form("BUCHAREST/MADC%d/MADC%d_ch%d_pion", mad,mad,ch);
00024          obtitle.Form("MADC %d Channel %d pion", mad, ch);
00025          fMadc_pion[mad][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 0x3FF, 0, 0x3FF);
00026 
00027          obname.Form("BUCHAREST/MADC%d/MADC%d_ch%d_electron",mad,mad,ch);
00028          obtitle.Form("MADC %d Channel %d electron", mad, ch);
00029          fMadc_electron[mad][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 0x3FF, 0, 0x3FF);
00030 
00031       }
00032 
00033 
00034       obname.Form("MADC%d_pion_Buch", mad);
00035       if (GetPicture(obname.Data()) == 0) {
00036          obtitle.Form("Pion channels overview MADC %2d", mad);
00037          TGo4Picture* pic = new TGo4Picture(obname.Data(), obtitle.Data());
00038          pic->SetDivision(8, 4);
00039          for(int y=0; y<8;++y)
00040             for(int x=0;x<4;++x) {
00041                pic->Pic(y, x)->AddObject(fMadc_pion[mad][4*y+x]);
00042                pic->Pic(y, x)->SetFillAtt(5, 3001);
00043                pic->Pic(y, x)->SetRangeX(0, 200);
00044                pic->Pic(y, x)->SetLogScale(1, 1);
00045             }
00046          AddPicture(pic);
00047       }
00048 
00049 
00050       obname.Form("MADC%d_electron_Buch", mad);
00051       if (GetPicture(obname.Data()) == 0) {
00052          obtitle.Form("Electron channels overview MADC %2d", mad);
00053          TGo4Picture* pic = new TGo4Picture(obname.Data(), obtitle.Data());
00054          pic->SetDivision(8, 4);
00055          for(int y=0; y<8;++y)
00056             for(int x=0;x<4;++x) {
00057                pic->Pic(y, x)->AddObject(fMadc_electron[mad][4*y+x]);
00058                pic->Pic(y, x)->SetFillAtt(5, 3001);
00059                pic->Pic(y, x)->SetRangeX(0, 200);
00060                pic->Pic(y, x)->SetLogScale(1, 1);
00061             }
00062          AddPicture(pic);
00063       }
00064    }
00065    printf("TTRDBucharestProc Histograms created \n");
00066    fflush ( stdout);
00067 }
00068 
00069 
00070 TTRDBucharestProc::~TTRDBucharestProc()
00071 {
00072 }
00073 
00074 void TTRDBucharestProc::InitEvent(TGo4EventElement* outevnt)
00075 {
00076    // first assign input event:
00077    // since input event object is never discarded within processor lifetime,
00078    // we just search for subevent by name once to speed up processing
00079    if(fCrateInputEvent==0)
00080    {
00081       TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00082       if(btevent)
00083       {
00084          fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(btevent->GetSubEvent("MBSCRATE"));
00085       }
00086       else
00087       {
00088          fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(GetInputEvent());
00089 
00090       }
00091       if(fCrateInputEvent==0) {
00092          GO4_STOP_ANALYSIS_MESSAGE("**** TTRDBucharestProc: Fatal error: input event is not a TMbsCrateEvent!!! STOP GO4");
00093       }
00094    }
00095    // then assign output event
00096    // since output event object is never discarded within processor lifetime,
00097    // we just search for subevent by name once to speed up processing
00098    if(fOutputEvent==0)
00099    {
00100       TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00101       if(btevent)
00102       {
00103          fOutputEvent=dynamic_cast<TTRDBucharestEvent*>(btevent->GetSubEvent("TRDBUCHAREST"));
00104          // since output event object is never discarded within processor lifetime,
00105          // we just search for subevent by name once to speed up processing
00106          if(fBeamEvent==0)
00107             fBeamEvent=dynamic_cast<TBeamMonitorEvent*>(btevent->GetSubEvent("BEAM"));
00108       }
00109       else
00110       {
00111 
00112          fOutputEvent= dynamic_cast<TTRDBucharestEvent*>(outevnt);
00113       }
00114       if(fOutputEvent==0) {
00115          GO4_STOP_ANALYSIS_MESSAGE("**** TTRDBucharestProc: Fatal error: output event is not a TTRDBucharestEvent!!! STOP GO4");
00116       }
00117    }
00118 }
00119 
00120 void TTRDBucharestProc::FinalizeEvent()
00121 {
00122    // correlate with beam only if we are in combined mode
00123    if (fBeamEvent && fCrateInputEvent->IsValid())
00124    {
00125 
00126       for (int mad = 0; mad < 2; mad++) {
00127          for (int ch = 0; ch < N_MADC_CHA; ch++) {
00128             UShort_t adc=fCrateInputEvent->fMadc[mad][ch];
00129             if(adc==0) continue; // skip not filled channels
00130 
00131             if (fBeamEvent->IsPulser()) {
00132                // to be done ...
00133             }
00134 
00135 
00136             if (fBeamEvent->fIsPion)
00137             {
00138                fMadc_pion[mad][ch]->Fill(adc);
00139                fOutputEvent->fMadc_Pion[mad][ch] = adc;
00140             }
00141             if (fBeamEvent->fIsElectron)
00142             {
00143                fMadc_electron[mad][ch]->Fill(adc);
00144                fOutputEvent->fMadc_Electron[mad][ch] = adc;
00145             }
00146          } // for ch
00147       }// for mad
00148    } // if BeamEvent
00149 }
00150 
00151 
00152 

Generated on Tue Dec 10 2013 04:52:16 for ROCsoft by  doxygen 1.7.1