Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TXXXProc.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE 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 "Riostream.h"
00019 
00020 #include "TH1.h"
00021 #include "TH2.h"
00022 #include "TCutG.h"
00023 #include "snprintf.h"
00024 
00025 #include "TGo4MbsEvent.h"
00026 #include "TGo4WinCond.h"
00027 #include "TGo4PolyCond.h"
00028 #include "TGo4CondArray.h"
00029 #include "TGo4Picture.h"
00030 
00031 #include "TXXXParam.h"
00032 
00033 //***********************************************************
00034 TXXXProc::TXXXProc() : TGo4EventProcessor("Proc")
00035 {
00036   cout << "**** TXXXProc: Create instance " << endl;
00037 }
00038 //***********************************************************
00039 TXXXProc::~TXXXProc()
00040 {
00041   cout << "**** TXXXProc: Delete instance " << endl;
00042 }
00043 //***********************************************************
00044 // this one is used in standard factory
00045 TXXXProc::TXXXProc(const char* name) : TGo4EventProcessor(name)
00046 {
00047   cout << "**** TXXXProc: Create instance " << name << endl;
00048 
00049   Text_t chis[16];
00050   Text_t chead[64];
00051   Int_t i;
00052 
00054 
00055   // Creation of parameters (check if restored from auto save file):
00056   if(GetParameter("Par1")==0)
00057     {// no auto save, create new
00058       fParam = new TXXXParam("Par1");
00059       AddParameter(fParam);
00060       cout << "**** TXXXProc: Created parameter" << endl;
00061     }
00062   else // got them from autosave file, restore pointers
00063     {
00064       fParam=(TXXXParam *)GetParameter("Par1");
00065       cout << "**** TXXXProc: Restored parameter from autosave" << endl;
00066     }
00067 
00068   // Creation of histograms (check if restored from auto save file):
00069   if(GetHistogram("Crate1/Cr1Ch01")==0)
00070     {// no auto save, create new
00071       for(i =0;i<8;i++)
00072    {
00073      snprintf(chis,15,"Cr1Ch%02d",i+1);  snprintf(chead,63,"Crate 1 channel %2d",i+1);
00074           fCr1Ch[i] = new TH1I (chis,chead,5000,1,5000);
00075           AddHistogram(fCr1Ch[i],"Crate1");
00076      snprintf(chis,15,"Cr2Ch%02d",i+1);  snprintf(chead,63, "Crate 2 channel %2d",i+1);
00077           fCr2Ch[i] = new TH1I (chis,chead,5000,1,5000);
00078           AddHistogram(fCr2Ch[i],"Crate2");
00079    }
00080       fCr1Ch1x2 = new TH2I("Cr1Ch1x2","Crate 1 channel 1x2",200,1,5000,200,1,5000);
00081       AddHistogram(fCr1Ch1x2);
00082       fHis1     = new TH1I ("His1","Condition histogram",5000,1,5000);
00083       AddHistogram(fHis1);
00084       fHis2     = new TH1I ("His2","Condition histogram",5000,1,5000);
00085       AddHistogram(fHis2);
00086       fHis1gate = new TH1I ("His1g","Gated histogram",5000,1,5000);
00087       AddHistogram(fHis1gate);
00088       fHis2gate = new TH1I ("His2g","Gated histogram",5000,1,5000);
00089       AddHistogram(fHis2gate);
00090       cout << "**** TXXXProc: Created histograms" << endl;
00091     }
00092   else // got them from autosave file, restore pointers
00093     {
00094       for(i =0;i<8;i++)
00095    {
00096      snprintf(chis,15,"Crate1/Cr1Ch%02d",i+1); fCr1Ch[i] = (TH1I*)GetHistogram(chis);
00097      snprintf(chis,15,"Crate2/Cr2Ch%02d",i+1); fCr2Ch[i] = (TH1I*)GetHistogram(chis);
00098    }
00099       fCr1Ch1x2 = (TH2I*)GetHistogram("Cr1Ch1x2");
00100       fHis1     = (TH1I*)GetHistogram("His1");
00101       fHis2     = (TH1I*)GetHistogram("His2");
00102       fHis1gate = (TH1I*)GetHistogram("His1g");
00103       fHis2gate = (TH1I*)GetHistogram("His2g");
00104       cout << "**** TXXXProc: Restored histograms from autosave" << endl;
00105     }
00106   // Creation of conditions (check if restored from auto save file):
00107   if(GetAnalysisCondition("cHis1")==0)
00108     {// no auto save, create new
00109       fconHis1= new TGo4WinCond("cHis1");
00110       fconHis2= new TGo4WinCond("cHis2");
00111       fconHis1->SetValues(100,2000);
00112       fconHis2->SetValues(100,2000);
00113       AddAnalysisCondition(fconHis1);
00114       AddAnalysisCondition(fconHis2);
00115 
00116       Double_t xvalues[4]={400,700,600,400};
00117       Double_t yvalues[4]={800,900,1100,800};
00118       TCutG* mycut= new TCutG("cut1",4,xvalues,yvalues);
00119       fPolyCon= new TGo4PolyCond("polycon");
00120       fPolyCon->SetValues(mycut); // copies mycat into fPolyCon
00121       fPolyCon->Disable(true);   // means: condition check always returns true
00122       delete mycut; // mycat has been copied into the conditions
00123       AddAnalysisCondition(fPolyCon);
00124 
00125       xvalues[0]=1000;xvalues[1]=2000;xvalues[2]=1500;xvalues[3]=1000;
00126       yvalues[0]=1000;yvalues[1]=1000;yvalues[2]=3000;yvalues[3]=1000;
00127       mycut= new TCutG("cut2",4,xvalues,yvalues);
00128       fConArr = new TGo4CondArray("polyconar",4,"TGo4PolyCond");
00129       fConArr->SetValues(mycut);
00130       fConArr->Disable(true);   // means: condition check always returns true
00131       delete mycut; // mycat has been copied into the conditions
00132       AddAnalysisCondition(fConArr);
00133       cout << "**** TXXXProc: Created conditions" << endl;
00134     }
00135   else // got them from autosave file, restore pointers
00136     {
00137       fPolyCon  = (TGo4PolyCond*) GetAnalysisCondition("polycon");
00138       fConArr   = (TGo4CondArray*)GetAnalysisCondition("polyconar");
00139       fconHis1  = (TGo4WinCond*)  GetAnalysisCondition("cHis1");
00140       fconHis2  = (TGo4WinCond*)  GetAnalysisCondition("cHis2");
00141       fconHis1->ResetCounts();
00142       fconHis2->ResetCounts();
00143       fPolyCon->ResetCounts();
00144       fConArr->ResetCounts();
00145       cout << "**** TXXXProc: Restored conditions from autosave" << endl;
00146     }
00147   // connect histograms to conditions. will be drawn when condition is edited.
00148   fconHis1->SetHistogram("His1");
00149   fconHis2->SetHistogram("His2");
00150   fconHis1->Enable();
00151   fconHis2->Enable();
00152   fPolyCon->Enable();
00153   ((*fConArr)[0])->Enable();
00154   ((*fConArr)[1])->Enable(); // 2 and 3 remain disabled
00155 
00156   if (GetPicture("Picture")==0)
00157     {// no auto save, create new
00158       // in the upper two pads, the condition limits can be set,
00159       // in the lower two pads, the resulting histograms are shown
00160       fcondSet = new TGo4Picture("condSet","Set conditions");
00161       fcondSet->SetLinesDivision(2,2,2);
00162       fcondSet->LPic(0,0)->AddObject(fHis1);
00163       fcondSet->LPic(0,1)->AddObject(fHis2);
00164       fcondSet->LPic(0,0)->AddCondition(fconHis1);
00165       fcondSet->LPic(0,1)->AddCondition(fconHis2);
00166       fcondSet->LPic(1,0)->AddObject(fHis1gate);
00167       fcondSet->LPic(1,1)->AddObject(fHis2gate);
00168       fcondSet->LPic(1,0)->SetFillAtt(4, 1001); // solid
00169       fcondSet->LPic(1,0)->SetLineAtt(4,1,1);
00170       fcondSet->LPic(1,1)->SetFillAtt(9, 1001); // solid
00171       fcondSet->LPic(1,1)->SetLineAtt(9,1,1);
00172       AddPicture(fcondSet);
00173 
00174       fPicture = new TGo4Picture("Picture","Picture example");
00175       fPicture->SetLinesDivision(3, 2,3,1);
00176       fPicture->LPic(0,0)->AddObject(fCr1Ch[0]);
00177       fPicture->LPic(0,0)->SetFillAtt(5, 3001); // pattern
00178       fPicture->LPic(0,0)->SetLineAtt(5,1,1);
00179       fPicture->LPic(0,1)->AddObject(fCr1Ch[1]);
00180       fPicture->LPic(0,1)->SetFillAtt(4, 3001); // pattern
00181       fPicture->LPic(0,1)->SetLineAtt(4,1,1);
00182       fPicture->LPic(1,0)->AddObject(fCr1Ch[2]);
00183       fPicture->LPic(1,0)->SetFillAtt(6, 1001); // solid
00184       fPicture->LPic(1,0)->SetLineAtt(6,1,1);
00185       fPicture->LPic(1,1)->AddObject(fCr1Ch[3]);
00186       fPicture->LPic(1,1)->SetFillAtt(7, 1001); // solid
00187       fPicture->LPic(1,1)->SetLineAtt(7,1,1);
00188       fPicture->LPic(1,2)->AddObject(fCr1Ch[4]);
00189       fPicture->LPic(3,0)->AddObject(fCr1Ch1x2);
00190       fPicture->LPic(3,0)->SetDrawOption("CONT");
00191       AddPicture(fPicture);
00192       cout << "**** TXXXProc: Created pictures" << endl;
00193     }
00194   else  // got them from autosave file, restore pointers
00195     {
00196       fPicture = GetPicture("Picture");
00197       fcondSet = GetPicture("condSet");
00198       cout << "**** TXXXProc: Restored pictures from autosave" << endl;
00199     }
00200 }
00201 //-----------------------------------------------------------
00202 // event function
00203 Bool_t TXXXProc::BuildEvent(TGo4EventElement* target)
00204 {  // called by framework. We dont fill any output event here at all
00205 
00206   TGo4MbsSubEvent* psubevt;
00207   Int_t index=0;
00208   Float_t value1=0;
00209   Float_t value2=0;
00210   Float_t value=0;
00211   Int_t lwords,i;
00212   Int_t *pdata;
00213 
00214   fInput = (TGo4MbsEvent* ) GetInputEvent();
00215   if(fInput == 0)
00216     {
00217     cout << "AnlProc: no input event !"<< endl;
00218     return kFALSE;
00219     }
00220   if(fInput->GetTrigger() > 11)
00221     {
00222       cout << "**** TXXXProc: Skip trigger event"<<endl;
00223       return kFALSE;
00224     }
00225   // first we fill the arrays fCrate1,2 with data from MBS source
00226   // we have up to two subevents, crate 1 and 2
00227   // Note that one has to loop over all subevents and select them by
00228   // crate number:   psubevt->GetSubcrate(),
00229   // procid:         psubevt->GetProcid(),
00230   // and/or control: psubevt->GetControl()
00231   // here we use only crate number
00232 
00233   fInput->ResetIterator();
00234   while((psubevt = fInput->NextSubEvent()) != 0) // loop over subevents
00235     {
00236       pdata=psubevt->GetDataField();
00237       lwords= psubevt->GetIntLen();
00238       if(lwords > 8) lwords=8; // take only first 8 lwords
00239 
00240       if(psubevt->GetSubcrate() == 1)
00241    {
00242      for(i = 0; i<lwords; i++)
00243        {
00244          //index =  *pdata&0xfff;      // in case low word is index
00245          //value = (*pdata>>16)&0xfff; // and high word is data
00246          value=(Float_t)*pdata++;      // otherwise longword data
00247          index=i;                      // and index in order
00248          fCrate1[index] = value; // copy to output event
00249        }
00250    }
00251       if(psubevt->GetSubcrate() == 2)
00252    {
00253      for(i = 0; i<lwords; i++) fCrate2[i] = (Float_t)*pdata++;
00254    }
00255     }
00256 
00257   // now we fill histograms from the arrays
00258   for(i = 0; i<8; i++)
00259     {
00260       fCr1Ch[i]->Fill(fCrate1[i]);
00261       fCr2Ch[i]->Fill(fCrate2[i]);
00262     }
00263   value1=fCrate1[0];
00264   value2=fCrate1[1];
00265   fHis1->Fill(value1); //fill histograms without gate
00266   fHis2->Fill(value2);
00267   if(fconHis1->Test(value1))fHis1gate->Fill(value1); //fill histograms with gate
00268   if(fconHis2->Test(value2))fHis2gate->Fill(value2);
00269   // fill Cr1Ch1x2 for three polygons:
00270   if(fPolyCon->Test(value1,value2))        fCr1Ch1x2->Fill(value1,value2);
00271   if(((*fConArr)[0])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00272   if(((*fConArr)[1])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
00273   return kTRUE;
00274 }
00275 
00276 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:10 2008 for Go4-v3.04-1 by  doxygen 1.4.2