Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4Example1Step/TXXXProc.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
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 // this one is used in standard factory
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");    // created in TXXXAnalysis, values from auto save
00048   fControl = (TXXXControl *) GetParameter("Control"); // created in TXXXAnalysis, values from auto save
00049 
00050   // This example analysis allows for en-disabling the histogram filling.
00051   // Macro setfill.C creates macro histofill.C to set histogram fill status in parameter "Control".
00052   // Executed in Analysis terminal input line by .x setfill.C(n) with n=0,1.
00053   // This macro histofill.C, not the auto save file, will set status.
00054   gROOT->ProcessLine(".x histofill.C");
00055   fControl->PrintParameter("",0);
00056 
00057   // Creation of histograms (check if restored from auto save file):
00058   if(GetHistogram("Crate1/Cr1Ch01")==0)
00059     {// no auto save, create new
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 // got them from autosave file, restore pointers
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   // Creation of conditions (check if restored from auto save file):
00096   if(GetAnalysisCondition("cHis1")==0)
00097     {// no auto save, create new
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); // copies mycat into fPolyCon
00110       fPolyCon->Disable(true);   // means: condition check always returns true
00111       delete mycut; // mycat has been copied into the conditions
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);   // means: condition check always returns true
00120       delete mycut; // mycat has been copied into the conditions
00121       AddAnalysisCondition(fConArr);
00122       cout << "**** TXXXProc: Created conditions" << endl;
00123     }
00124   else // got them from autosave file, restore pointers
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   // connect histograms to conditions. will be drawn when condition is edited.
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(); // 2 and 3 remain disabled
00144 
00145   if (GetPicture("Picture")==0)
00146     {// no auto save, create new
00147       // in the upper two pads, the condition limits can be set,
00148       // in the lower two pads, the resulting histograms are shown
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); // solid
00158       fcondSet->LPic(1,0)->SetLineAtt(4,1,1);
00159       fcondSet->LPic(1,1)->SetFillAtt(9, 1001); // solid
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); // pattern
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); // pattern
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); // solid
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); // solid
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  // got them from autosave file, restore pointers
00184     {
00185       fPicture = GetPicture("Picture");
00186       fcondSet = GetPicture("condSet");
00187       cout << "**** TXXXProc: Restored pictures from autosave" << endl;
00188     }
00189 }
00190 //-----------------------------------------------------------
00191 // event function
00192 void TXXXProc::Event(TXXXEvent* XXXEvent)
00193 {  // called by TXXXEvent
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); // not store
00213       return;
00214     }
00215   // first we fill the TXXXEvent with data from MBS source
00216   // we have up to two subevents, crate 1 and 2
00217   // Note that one has to loop over all subevents and select them by
00218   // crate number:   psubevt->GetSubcrate(),
00219   // procid:         psubevt->GetProcid(),
00220   // and/or control: psubevt->GetControl()
00221   // here we use only crate number
00222 
00223   fInput->ResetIterator();
00224   while((psubevt = fInput->NextSubEvent()) != 0) // loop over subevents
00225     {
00226       pdata=psubevt->GetDataField();
00227       lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
00228       if(lwords > 8) lwords=8; // take only first 8 lwords
00229 
00230       if(psubevt->GetSubcrate() == 1)
00231    {
00232      for(i = 0; i<lwords; i++)
00233        {
00234          //index =  *pdata&0xfff;      // in case low word is index
00235          //value = (*pdata>>16)&0xfff; // and high word is data
00236          value=(Float_t)*pdata++;      // otherwise longword data
00237          index=i;                      // and index in order
00238          XXXEvent->fCrate1[index] = value; // copy to output event
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  // now we fill histograms from XXXEvent
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); //fill histograms without gate
00258       fHis2->Fill(value2);
00259       if(fconHis1->Test(value1))fHis1gate->Fill(value1); //fill histograms with gate
00260       if(fconHis2->Test(value2))fHis2gate->Fill(value2);
00261       // fill Cr1Ch1x2 for three polygons:
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); // to store
00267   return;
00268 }
00269 //-----------------------------------------------------------
00270 ClassImp(TXXXProc)
00271 
00272 
00273 
00274 
00275 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:54 2005 for Go4-v2.10-5 by doxygen1.2.15