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

beamtime/cern-oct12/go4/BUCHAREST/TTRDBucharestProc.cxx (r4864/r3721)

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

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