00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TXXXProc.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TH1.h"
00021 #include "TH2.h"
00022 #include "TROOT.h"
00023 #include "TCutG.h"
00024 #include "TGo4WinCond.h"
00025 #include "TGo4PolyCond.h"
00026 #include "TGo4CondArray.h"
00027 #include "TGo4Picture.h"
00028 #include "TGo4MbsEvent.h"
00029 #include "snprintf.h"
00030
00031 #include "TXXXParam.h"
00032 #include "TXXXControl.h"
00033 #include "TXXXEvent.h"
00034
00035
00036 TXXXProc::TXXXProc() : TGo4EventProcessor()
00037 {
00038 cout << "**** TXXXProc: Create instance " << endl;
00039 }
00040
00041 TXXXProc::~TXXXProc()
00042 {
00043 cout << "**** TXXXProc: Delete instance " << endl;
00044 }
00045
00046
00047 TXXXProc::TXXXProc(const char* name) : TGo4EventProcessor(name)
00048 {
00049 cout << "**** TXXXProc: Create instance " << name << endl;
00050
00051 Text_t chis[16];
00052 Text_t chead[64];
00053 Int_t i;
00054
00056
00057 fParam = (TXXXParam *) GetParameter("Par1");
00058 fControl = (TXXXControl *) GetParameter("Control");
00059
00060
00061
00062
00063
00064 gROOT->ProcessLine(".x histofill.C");
00065 fControl->PrintParameter(0,0);
00066
00067
00068 if(GetHistogram("Crate1/Cr1Ch01")==0)
00069 {
00070 for(i =0;i<8;i++)
00071 {
00072 snprintf(chis,15,"Cr1Ch%02d",i+1); snprintf(chead, 63, "Crate 1 channel %2d",i+1);
00073 fCr1Ch[i] = new TH1I (chis,chead,5000,1,5000);
00074 AddHistogram(fCr1Ch[i],"Crate1");
00075 snprintf(chis,15,"Cr2Ch%02d",i+1); snprintf(chead, 63, "Crate 2 channel %2d",i+1);
00076 fCr2Ch[i] = new TH1I (chis,chead,5000,1,5000);
00077 AddHistogram(fCr2Ch[i],"Crate2");
00078 }
00079 fCr1Ch1x2 = new TH2I("Cr1Ch1x2","Crate 1 channel 1x2",200,1,5000,200,1,5000);
00080 AddHistogram(fCr1Ch1x2);
00081 fHis1 = new TH1I ("His1","Condition histogram",5000,1,5000);
00082 AddHistogram(fHis1);
00083 fHis2 = new TH1I ("His2","Condition histogram",5000,1,5000);
00084 AddHistogram(fHis2);
00085 fHis1gate = new TH1I ("His1g","Gated histogram",5000,1,5000);
00086 AddHistogram(fHis1gate);
00087 fHis2gate = new TH1I ("His2g","Gated histogram",5000,1,5000);
00088 AddHistogram(fHis2gate);
00089 cout << "**** TXXXProc: Created histograms" << endl;
00090 }
00091 else
00092 {
00093 for(i =0;i<8;i++)
00094 {
00095 snprintf(chis,15,"Crate1/Cr1Ch%02d",i+1); fCr1Ch[i] = (TH1I*)GetHistogram(chis);
00096 snprintf(chis,15,"Crate2/Cr2Ch%02d",i+1); fCr2Ch[i] = (TH1I*)GetHistogram(chis);
00097 }
00098 fCr1Ch1x2 = (TH2I*)GetHistogram("Cr1Ch1x2");
00099 fHis1 = (TH1I*)GetHistogram("His1");
00100 fHis2 = (TH1I*)GetHistogram("His2");
00101 fHis1gate = (TH1I*)GetHistogram("His1g");
00102 fHis2gate = (TH1I*)GetHistogram("His2g");
00103 cout << "**** TXXXProc: Restored histograms from autosave" << endl;
00104 }
00105
00106 if(GetAnalysisCondition("cHis1")==0)
00107 {
00108 fconHis1= new TGo4WinCond("cHis1");
00109 fconHis2= new TGo4WinCond("cHis2");
00110 fconHis1->SetValues(100,2000);
00111 fconHis2->SetValues(100,2000);
00112 AddAnalysisCondition(fconHis1);
00113 AddAnalysisCondition(fconHis2);
00114
00115 Double_t xvalues[4]={400,700,600,400};
00116 Double_t yvalues[4]={800,900,1100,800};
00117 TCutG* mycut= new TCutG("cut1",4,xvalues,yvalues);
00118 fPolyCon= new TGo4PolyCond("polycon");
00119 fPolyCon->SetValues(mycut);
00120 fPolyCon->Disable(true);
00121 delete mycut;
00122 AddAnalysisCondition(fPolyCon);
00123
00124 xvalues[0]=1000;xvalues[1]=2000;xvalues[2]=1500;xvalues[3]=1000;
00125 yvalues[0]=1000;yvalues[1]=1000;yvalues[2]=3000;yvalues[3]=1000;
00126 mycut= new TCutG("cut2",4,xvalues,yvalues);
00127 fConArr = new TGo4CondArray("polyconar",4,"TGo4PolyCond");
00128 fConArr->SetValues(mycut);
00129 fConArr->Disable(true);
00130 delete mycut;
00131 AddAnalysisCondition(fConArr);
00132 cout << "**** TXXXProc: Created conditions" << endl;
00133 }
00134 else
00135 {
00136 fPolyCon = (TGo4PolyCond*) GetAnalysisCondition("polycon");
00137 fConArr = (TGo4CondArray*)GetAnalysisCondition("polyconar");
00138 fconHis1 = (TGo4WinCond*) GetAnalysisCondition("cHis1");
00139 fconHis2 = (TGo4WinCond*) GetAnalysisCondition("cHis2");
00140 fconHis1->ResetCounts();
00141 fconHis2->ResetCounts();
00142 fPolyCon->ResetCounts();
00143 fConArr->ResetCounts();
00144 cout << "**** TXXXProc: Restored conditions from autosave" << endl;
00145 }
00146
00147 fconHis1->SetHistogram("His1");
00148 fconHis2->SetHistogram("His2");
00149 fconHis1->Enable();
00150 fconHis2->Enable();
00151 fPolyCon->Enable();
00152 ((*fConArr)[0])->Enable();
00153 ((*fConArr)[1])->Enable();
00154
00155 if (GetPicture("Picture")==0)
00156 {
00157
00158
00159 fcondSet = new TGo4Picture("condSet","Set conditions");
00160 fcondSet->SetLinesDivision(2,2,2);
00161 fcondSet->LPic(0,0)->AddObject(fHis1);
00162 fcondSet->LPic(0,1)->AddObject(fHis2);
00163 fcondSet->LPic(0,0)->AddCondition(fconHis1);
00164 fcondSet->LPic(0,1)->AddCondition(fconHis2);
00165 fcondSet->LPic(1,0)->AddObject(fHis1gate);
00166 fcondSet->LPic(1,1)->AddObject(fHis2gate);
00167 fcondSet->LPic(1,0)->SetFillAtt(4, 1001);
00168 fcondSet->LPic(1,0)->SetLineAtt(4,1,1);
00169 fcondSet->LPic(1,1)->SetFillAtt(9, 1001);
00170 fcondSet->LPic(1,1)->SetLineAtt(9,1,1);
00171 AddPicture(fcondSet);
00172
00173 fPicture = new TGo4Picture("Picture","Picture example");
00174 fPicture->SetLinesDivision(3, 2,3,1);
00175 fPicture->LPic(0,0)->AddObject(fCr1Ch[0]);
00176 fPicture->LPic(0,0)->SetFillAtt(5, 3001);
00177 fPicture->LPic(0,0)->SetLineAtt(5,1,1);
00178 fPicture->LPic(0,1)->AddObject(fCr1Ch[1]);
00179 fPicture->LPic(0,1)->SetFillAtt(4, 3001);
00180 fPicture->LPic(0,1)->SetLineAtt(4,1,1);
00181 fPicture->LPic(1,0)->AddObject(fCr1Ch[2]);
00182 fPicture->LPic(1,0)->SetFillAtt(6, 1001);
00183 fPicture->LPic(1,0)->SetLineAtt(6,1,1);
00184 fPicture->LPic(1,1)->AddObject(fCr1Ch[3]);
00185 fPicture->LPic(1,1)->SetFillAtt(7, 1001);
00186 fPicture->LPic(1,1)->SetLineAtt(7,1,1);
00187 fPicture->LPic(1,2)->AddObject(fCr1Ch[4]);
00188 fPicture->LPic(3,0)->AddObject(fCr1Ch1x2);
00189 fPicture->LPic(3,0)->SetDrawOption("CONT");
00190 AddPicture(fPicture);
00191 cout << "**** TXXXProc: Created pictures" << endl;
00192 }
00193 else
00194 {
00195 fPicture = GetPicture("Picture");
00196 fcondSet = GetPicture("condSet");
00197 cout << "**** TXXXProc: Restored pictures from autosave" << endl;
00198 }
00199 }
00200
00201
00202 Bool_t TXXXProc::BuildEvent(TGo4EventElement* target)
00203 {
00204
00205
00206 TXXXEvent* XXXEvent = (TXXXEvent*) target;
00207 TGo4MbsSubEvent* psubevt;
00208 Int_t index=0;
00209 Float_t value1=0;
00210 Float_t value2=0;
00211 Float_t value=0;
00212 Int_t lwords,i;
00213 Int_t *pdata;
00214
00215 fInput = (TGo4MbsEvent* ) GetInputEvent();
00216 if(fInput == 0)
00217 {
00218 cout << "AnlProc: no input event !"<< endl;
00219 return kFALSE;
00220 }
00221 if(fInput->GetTrigger() > 11)
00222 {
00223 cout << "**** TXXXProc: Skip trigger event"<<endl;
00224 XXXEvent->SetValid(kFALSE);
00225 return kFALSE;
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235 fInput->ResetIterator();
00236 while((psubevt = fInput->NextSubEvent()) != 0)
00237 {
00238 pdata=psubevt->GetDataField();
00239 lwords= psubevt->GetIntLen();
00240 if(lwords > 8) lwords=8;
00241
00242 if(psubevt->GetSubcrate() == 1)
00243 {
00244 for(i = 0; i<lwords; i++)
00245 {
00246
00247
00248 value=(Float_t)*pdata++;
00249 index=i;
00250 XXXEvent->fCrate1[index] = value;
00251 }
00252 }
00253 if(psubevt->GetSubcrate() == 2)
00254 {
00255 for(i = 0; i<lwords; i++) XXXEvent->fCrate2[i] = (Float_t)*pdata++;
00256 }
00257 }
00258
00259
00260 if(fControl->fill)
00261 {
00262 for(i = 0; i<8; i++)
00263 {
00264 fCr1Ch[i]->Fill(XXXEvent->fCrate1[i]);
00265 fCr2Ch[i]->Fill(XXXEvent->fCrate2[i]);
00266 }
00267 value1=XXXEvent->fCrate1[0];
00268 value2=XXXEvent->fCrate1[1];
00269 fHis1->Fill(value1);
00270 fHis2->Fill(value2);
00271 if(fconHis1->Test(value1))fHis1gate->Fill(value1);
00272 if(fconHis2->Test(value2))fHis2gate->Fill(value2);
00273
00274 if(fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00275 if(((*fConArr)[0])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00276 if(((*fConArr)[1])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00277 }
00278 XXXEvent->SetValid(kTRUE);
00279 return kTRUE;
00280 }
00281
00282