00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TXXXProc.h"
00015
00016 #include "TH1.h"
00017 #include "TH2.h"
00018 #include "TROOT.h"
00019 #include "TCutG.h"
00020
00021 #include "TGo4Log.h"
00022 #include "TGo4WinCond.h"
00023 #include "TGo4PolyCond.h"
00024 #include "TGo4CondArray.h"
00025 #include "TGo4Picture.h"
00026 #include "TGo4MbsEvent.h"
00027
00028 #include "TXXXControl.h"
00029 #include "TXXXEvent.h"
00030
00031
00032 TXXXProc::TXXXProc() : TGo4EventProcessor()
00033 {
00034 TGo4Log::Info("TXXXProc: Create instance");
00035 }
00036
00037 TXXXProc::~TXXXProc()
00038 {
00039 TGo4Log::Info("TXXXProc: Delete instance");
00040 }
00041
00042
00043 TXXXProc::TXXXProc(const char* name) : TGo4EventProcessor(name)
00044 {
00045 TGo4Log::Info("TXXXProc: Create instance %s", name);
00046
00048
00049
00050 fControl = (TXXXControl *) GetParameter("Control");
00051
00052
00053
00054
00055 ExecuteScript("histofill.C");
00056 fControl->PrintParameter(0,0);
00057
00058 TGo4Log::Info("TXXXProc: Produce histograms");
00059
00060 for(int i=0;i<8;i++) {
00061 fCr1Ch[i] = MakeTH1('I', Form("Crate1/Cr1Ch%02d",i+1), Form("Crate 1 channel %2d",i+1), 5000, 1., 5001.);
00062 fCr2Ch[i] = MakeTH1('I', Form("Crate2/Cr2Ch%02d",i+1), Form("Crate 2 channel %2d",i+1), 5000, 1., 5001.);
00063 }
00064
00065 fCr1Ch1x2 = MakeTH2('I', "Cr1Ch1x2","Crate 1 channel 1x2", 200, 1., 5001., 200, 1., 5001.);
00066 fHis1 = MakeTH1('I', "His1","Condition histogram", 5000, 1., 5001.);
00067 fHis2 = MakeTH1('I', "His2","Condition histogram", 5000, 1., 5001.);
00068 fHis1gate = MakeTH1('I', "His1g","Gated histogram", 5000, 1., 5001.);
00069 fHis2gate = MakeTH1('I', "His2g","Gated histogram", 5000, 1., 5001.);
00070
00071 TGo4Log::Info("TXXXProc: Produce conditions");
00072 fconHis1 = MakeWinCond("cHis1", 100, 2000, "His1");
00073 fconHis2 = MakeWinCond("cHis2", 100, 2000, "His2");
00074
00075 Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
00076 fPolyCon = MakePolyCond("polycon", 3, cutpnts);
00077
00078 fConArr = (TGo4CondArray*)GetAnalysisCondition("polyconar");
00079 if(fConArr==0) {
00080
00081 TGo4Log::Info("TXXXProc: Create condition array");
00082 Double_t xvalues[4] = { 1000, 2000, 1500, 1000 };
00083 Double_t yvalues[4] = { 1000, 1000, 3000, 1000 };
00084 TCutG* mycut = new TCutG("cut2", 4, xvalues, yvalues);
00085 fConArr = new TGo4CondArray("polyconar",4,"TGo4PolyCond");
00086 fConArr->SetValues(mycut);
00087 fConArr->Disable(true);
00088 delete mycut;
00089 AddAnalysisCondition(fConArr);
00090 } else {
00091 TGo4Log::Info("TXXXProc: Restore condition array from autosave");
00092 fConArr->ResetCounts();
00093 }
00094
00095 ((*fConArr)[0])->Enable();
00096 ((*fConArr)[1])->Enable();
00097
00098 TGo4Log::Info("TXXXProc: Produce pictures");
00099 fcondSet = GetPicture("condSet");
00100 if (fcondSet==0) {
00101
00102
00103 fcondSet = new TGo4Picture("condSet","Set conditions");
00104 fcondSet->SetDivision(2,2);
00105 fcondSet->Pic(0,0)->AddObject(fHis1);
00106 fcondSet->Pic(0,1)->AddObject(fHis2);
00107 fcondSet->Pic(0,0)->AddCondition(fconHis1);
00108 fcondSet->Pic(0,1)->AddCondition(fconHis2);
00109 fcondSet->Pic(1,0)->AddObject(fHis1gate);
00110 fcondSet->Pic(1,1)->AddObject(fHis2gate);
00111 fcondSet->Pic(1,0)->SetFillAtt(4, 1001);
00112 fcondSet->Pic(1,0)->SetLineAtt(4,1,1);
00113 fcondSet->Pic(1,1)->SetFillAtt(9, 1001);
00114 fcondSet->Pic(1,1)->SetLineAtt(9,1,1);
00115 AddPicture(fcondSet);
00116 }
00117
00118 fPicture = GetPicture("Picture");
00119 if (fPicture == 0) {
00120 fPicture = new TGo4Picture("Picture","Picture example");
00121 fPicture->SetLinesDivision(3, 2,3,1);
00122 fPicture->LPic(0,0)->AddObject(fCr1Ch[0]);
00123 fPicture->LPic(0,0)->SetFillAtt(5, 3001);
00124 fPicture->LPic(0,0)->SetLineAtt(5,1,1);
00125 fPicture->LPic(0,1)->AddObject(fCr1Ch[1]);
00126 fPicture->LPic(0,1)->SetFillAtt(4, 3001);
00127 fPicture->LPic(0,1)->SetLineAtt(4,1,1);
00128 fPicture->LPic(1,0)->AddObject(fCr1Ch[2]);
00129 fPicture->LPic(1,0)->SetFillAtt(6, 1001);
00130 fPicture->LPic(1,0)->SetLineAtt(6,1,1);
00131 fPicture->LPic(1,1)->AddObject(fCr1Ch[3]);
00132 fPicture->LPic(1,1)->SetFillAtt(7, 1001);
00133 fPicture->LPic(1,1)->SetLineAtt(7,1,1);
00134 fPicture->LPic(1,2)->AddObject(fCr1Ch[4]);
00135 fPicture->LPic(3,0)->AddObject(fCr1Ch1x2);
00136 fPicture->LPic(3,0)->SetDrawOption("CONT");
00137 AddPicture(fPicture);
00138 }
00139 }
00140
00141
00142 Bool_t TXXXProc::BuildEvent(TGo4EventElement* target)
00143 {
00144
00145
00146 TXXXEvent* XXXEvent = (TXXXEvent*) target;
00147
00148 TGo4MbsEvent* source = (TGo4MbsEvent*) GetInputEvent();
00149 if(source == 0) {
00150 TGo4Log::Error("TXXXProc: no input event!");
00151 return kFALSE;
00152 }
00153 if(source->GetTrigger() > 11) {
00154 TGo4Log::Info("TXXXProc: Skip trigger event");
00155 XXXEvent->SetValid(kFALSE);
00156 return kFALSE;
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166 source->ResetIterator();
00167 TGo4MbsSubEvent* psubevt(0);
00168 while((psubevt = source->NextSubEvent()) != 0) {
00169 Int_t *pdata = psubevt->GetDataField();
00170 Int_t lwords = psubevt->GetIntLen();
00171 if(lwords > 8) lwords=8;
00172
00173 if(psubevt->GetSubcrate() == 1) {
00174 for(Int_t i = 0; i<lwords; i++) {
00175
00176
00177 Float_t value = (Float_t)*pdata++;
00178 Int_t index = i;
00179 XXXEvent->fCrate1[index] = value;
00180 }
00181 }
00182 if(psubevt->GetSubcrate() == 2)
00183 for(Int_t i = 0; i<lwords; i++)
00184 XXXEvent->fCrate2[i] = (Float_t)*pdata++;
00185 }
00186
00187
00188 if(fControl->fill) {
00189 for(Int_t i = 0; i<8; i++) {
00190 fCr1Ch[i]->Fill(XXXEvent->fCrate1[i]);
00191 fCr2Ch[i]->Fill(XXXEvent->fCrate2[i]);
00192 }
00193 Float_t value1 = XXXEvent->fCrate1[0];
00194 Float_t value2 = XXXEvent->fCrate1[1];
00195 fHis1->Fill(value1);
00196 fHis2->Fill(value2);
00197 if (fconHis1->Test(value1)) fHis1gate->Fill(value1);
00198 if (fconHis2->Test(value2)) fHis2gate->Fill(value2);
00199
00200 if (fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00201 if(((*fConArr)[0])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00202 if(((*fConArr)[1])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00203 }
00204 XXXEvent->SetValid(kTRUE);
00205 return kTRUE;
00206 }