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