00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TXXXProc.h"
00015
00016
00017
00018 #include "TH1.h"
00019 #include "TH2.h"
00020
00021 #include "TGo4Log.h"
00022 #include "TGo4MbsEvent.h"
00023 #include "TGo4WinCond.h"
00024 #include "TGo4PolyCond.h"
00025 #include "TGo4Picture.h"
00026
00027 #include "TXXXParam.h"
00028
00029
00030 TXXXProc::TXXXProc() : TGo4EventProcessor()
00031 {
00032 }
00033
00034
00035 TXXXProc::~TXXXProc()
00036 {
00037 TGo4Log::Info("TXXXProc: Delete instance");
00038 }
00039
00040
00041
00042 TXXXProc::TXXXProc(const char* name) : TGo4EventProcessor(name)
00043 {
00044 TGo4Log::Info("TXXXProc: Create instance");
00045
00046 fParam = (TXXXParam*) MakeParameter("Par1", "TXXXParam");
00047
00048 for(int i=0;i<8;i++) {
00049 fCr1Ch[i] = MakeTH1('I', Form("Crate1/Cr1Ch%02d",i+1), Form("Crate 1 channel %2d",i+1), 5000, 1., 5001.);
00050 fCr2Ch[i] = MakeTH1('I', Form("Crate2/Cr2Ch%02d",i+1), Form("Crate 2 channel %2d",i+1), 5000, 1., 5001.);
00051 }
00052
00053 fCr1Ch1x2 = MakeTH2('I', "Cr1Ch1x2","Crate 1 channel 1x2", 200, 1., 5001., 200, 1., 5001.);
00054 fHis1 = MakeTH1('I', "His1","Condition histogram", 5000, 1., 5001.);
00055 fHis2 = MakeTH1('I', "His2","Condition histogram", 5000, 1., 5001.);
00056 fHis1gate = MakeTH1('I', "His1g","Gated histogram", 5000, 1., 5001.);
00057 fHis2gate = MakeTH1('I', "His2g","Gated histogram", 5000, 1., 5001.);
00058 fHis3 = MakeTH1('I', "His3","Singular histogram", 20000, 0.999, 1.001);
00059
00060 fconHis1 = MakeWinCond("cHis1", 100,2000, "His1");
00061 fconHis2 = MakeWinCond("cHis2", 100,2000, "His2");
00062
00063 Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
00064 fPolyCon = MakePolyCond("polycon", 3, cutpnts);
00065
00066 fcondSet = GetPicture("condSet");
00067 if (fcondSet==0) {
00068
00069
00070 fcondSet = new TGo4Picture("condSet","Set conditions");
00071 fcondSet->SetDivision(2,2);
00072 fcondSet->Pic(0,0)->AddObject(fHis1);
00073 fcondSet->Pic(0,1)->AddObject(fHis2);
00074 fcondSet->Pic(0,0)->AddCondition(fconHis1);
00075 fcondSet->Pic(0,1)->AddCondition(fconHis2);
00076 fcondSet->Pic(1,0)->AddObject(fHis1gate);
00077 fcondSet->Pic(1,1)->AddObject(fHis2gate);
00078
00079 fcondSet->Pic(1,0)->SetFillAtt(4, 1001);
00080 fcondSet->Pic(1,0)->SetLineAtt(4,1,1);
00081 fcondSet->Pic(1,1)->SetFillAtt(9, 1001);
00082 fcondSet->Pic(1,1)->SetLineAtt(9,1,1);
00083 AddPicture(fcondSet);
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 }
00099
00100
00101
00102 Bool_t TXXXProc::BuildEvent(TGo4EventElement*)
00103 {
00104
00105 if ((GetInputEvent()==0) || (GetInputEvent()->IsA() != TGo4MbsEvent::Class())) {
00106 std::cout << "TXXXProc: no input MBS event found!" << std::endl;
00107 return kFALSE;
00108 }
00109
00110 TGo4MbsEvent* evnt = (TGo4MbsEvent*) GetInputEvent();
00111
00112 if(evnt->GetTrigger() > 11) {
00113 std::cout << "**** TXXXProc: Skip trigger event" << std::endl;
00114 return kFALSE;
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124 Float_t Crate1[8];
00125 Float_t Crate2[8];
00126 for(Int_t i = 0; i<8; i++) {
00127 Crate1[i] = 0.;
00128 Crate2[i] = 0.;
00129 }
00130
00131
00132
00133
00134
00135
00136 evnt->ResetIterator();
00137 TGo4MbsSubEvent *psubevt(0);
00138 while((psubevt = evnt->NextSubEvent()) != 0) {
00139 Int_t * pdata = psubevt->GetDataField();
00140 Int_t lwords = psubevt->GetIntLen();
00141 if(lwords > 8) lwords = 8;
00142
00143 if(psubevt->GetSubcrate() == 1)
00144 for(Int_t i = 0; i<lwords; i++)
00145 Crate1[i] = (Float_t)*pdata++;
00146
00147 if(psubevt->GetSubcrate() == 2)
00148 for(Int_t i = 0; i<lwords; i++)
00149 Crate2[i] = (Float_t)*pdata++;
00150 }
00151
00152
00153 if (fParam->fillRaw)
00154 for(Int_t i = 0; i<8; i++) {
00155 fCr1Ch[i]->Fill(Crate1[i]);
00156 fCr2Ch[i]->Fill(Crate2[i]);
00157 }
00158 Float_t value1 = Crate1[0];
00159 Float_t value2 = Crate1[1];
00160 fHis1->Fill(value1);
00161 fHis2->Fill(value2);
00162 if(fconHis1->Test(value1))fHis1gate->Fill(value1);
00163 if(fconHis2->Test(value2))fHis2gate->Fill(value2);
00164 if(fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00165 fHis3->Fill(1.);
00166 return kTRUE;
00167 }