00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TXXXAnlProc.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TH1.h"
00021 #include "TH2.h"
00022 #include "TGraph.h"
00023 #include "TMultiGraph.h"
00024
00025 #include "TGo4WinCond.h"
00026
00027 #include "TXXXAnlEvent.h"
00028 #include "TXXXUnpackEvent.h"
00029 #include "TXXXParameter.h"
00030 #include "TXXXCalibPar.h"
00031
00032
00033 TXXXAnlProc::TXXXAnlProc()
00034 : TGo4EventProcessor(),fSum1(0),fSum2(0),fSum3(0),
00035 fInput(0),fParam1(0),fParam2(0),fWinCon(0)
00036 {
00037 }
00038
00039
00040 TXXXAnlProc::TXXXAnlProc(const char* name) :
00041 TGo4EventProcessor(name)
00042 {
00043 cout << "**** TXXXAnlProc: Create" << endl;
00045 fParam1 = (TXXXParameter*) GetParameter("XXXPar1");
00046 fParam2 = (TXXXParameter*) GetParameter("XXXPar2");
00047 fWinCon = (TGo4WinCond *) GetAnalysisCondition("wincon1");
00048
00049
00050 if(GetHistogram("Sum1")==0)
00051 {
00052 fSum1 = new TH1I ("Sum1", "Sum over 8 channels",5000,1,5001);
00053 fSum2 = new TH1I ("Sum2", "Sum over 8 channels shift 1",5000,1,5001);
00054 fSum3 = new TH1I ("Sum3", "Sum over 8 channels shift 2",5000,1,5001);
00055 fCaliSum1= new TH1I ("Sum1Calib", "Sum over 8 channels(keV)",5000,1,20);
00056 AddHistogram(fSum1);
00057 AddHistogram(fSum2);
00058 AddHistogram(fSum3);
00059 AddHistogram(fCaliSum1);
00060 fCaligraph=new TGraph;
00061 fCaligraph->SetName("Calibration");
00062 fCaligraph->SetMarkerStyle(3);
00063 AddObject(fCaligraph);
00064
00065 fxGraph1=new TGraph;
00066 fxGraph1->SetName("Testgraph1");
00067 fxGraph1->SetMarkerStyle(5);
00068
00069 for(Int_t i=0;i<50;++i)
00070 {
00071 fxGraph1->SetPoint(i,i,30*sin((Double_t)(i)/10));
00072 }
00073 fxGraph2=new TGraph;
00074 fxGraph2->SetName("Testgraph2");
00075 fxGraph2->SetMarkerStyle(4);
00076
00077 for(Int_t i=0;i<50;++i)
00078 {
00079 fxGraph2->SetPoint(i,i,30*cos((Double_t)(i)/10));
00080 }
00081 fxMultiGraph=new TMultiGraph("MultiTest","This is a test multigraph");
00082 fxMultiGraph->Add(fxGraph1);
00083 fxMultiGraph->Add(fxGraph2);
00084 AddObject(fxMultiGraph);
00085 }
00086 else
00087 {
00088 fSum1 =(TH1I*)GetHistogram("Sum1");
00089 fSum2 =(TH1I*)GetHistogram("Sum2");
00090 fSum3 =(TH1I*)GetHistogram("Sum3");
00091 fCaliSum1=(TH1I*)GetHistogram("Sum1Calib");
00092 fCaligraph= (TGraph*)GetObject("Calibration");
00093 cout << "AnlProc: Restored histograms from autosave" << endl;
00094 }
00095 if(GetParameter("CaliPar")==0)
00096 {
00097
00098 fCalipar=new TXXXCalibPar("CaliPar",GetHistogram("Cr1Ch01"),fCaligraph);
00099 AddParameter(fCalipar);
00100 }
00101 else
00102 {
00103
00104 fCalipar= (TXXXCalibPar*) GetParameter("CaliPar");
00105 }
00106 }
00107
00108 TXXXAnlProc::~TXXXAnlProc()
00109 {
00110 }
00111
00112
00113
00114 void TXXXAnlProc::XXXEventAnalysis(TXXXAnlEvent* poutevt)
00115 {
00116 Int_t ii,i;
00117 fInput = (TXXXUnpackEvent*) GetInputEvent();
00118
00119 poutevt->SetValid(kTRUE);
00120 i=0;
00121 for(ii=0;ii<4;ii++)
00122 {
00123 poutevt->frData[i]=(Float_t)fInput->fiCrate1[ii];
00124 if(fInput->fiCrate1[ii]) fCaliSum1->Fill(fCalipar->Energy(fInput->fiCrate1[ii]));
00125 i++;
00126 }
00127 for(ii=0;ii<4;ii++)
00128 {
00129 poutevt->frData[i]=(Float_t)fInput->fiCrate2[ii];
00130 if(fInput->fiCrate2[ii]) fCaliSum1->Fill(fCalipar->Energy(fInput->fiCrate2[ii]));
00131 i++;
00132 }
00133 for(ii=0;ii<8;ii++)
00134 {
00135 if(poutevt->frData[ii])
00136 {
00137 if(fWinCon->Test(poutevt->frData[ii])) fSum1->Fill(poutevt->frData[ii]);
00138 fSum2->Fill(poutevt->frData[ii]+fParam1->frP1);
00139 fSum3->Fill(poutevt->frData[ii]+fParam2->frP1);
00140 }
00141 }
00142
00143 }
00144
00145