コード例 #1
0
void digitsPHOS(Int_t nevents, Int_t nfiles)
{

 TH1F * hadc = new TH1F ("hadc", "hadc", 100, -10, 200);
 TH1F * hadcLog = new TH1F ("hadclog", "hadclog", 100, -2, 4);
 IlcRunLoader* runLoader = IlcRunLoader::Open("gilc.root","Event","READ");
 IlcPHOSLoader * phosLoader = dynamic_cast<IlcPHOSLoader*>(runLoader->GetLoader("PHOSLoader"));
 
 for (Int_t ievent=0; ievent <nevents; ievent++) {
  // for (Int_t ievent = 0; ievent < runLoader->GetNumberOfEvents(); ievent++) {
   runLoader->GetEvent(ievent) ;
   phosLoader->CleanDigits() ; 
   phosLoader->LoadDigits("READ") ;
   TClonesArray * digits    = phosLoader->Digits() ;
   printf("Event %d contains %d digits\n",ievent,digits->GetEntriesFast());
   
   
   for (Int_t j = 0; j < digits->GetEntries(); j++) {
     
     IlcPHOSDigit* dig = dynamic_cast<IlcPHOSDigit*> (digits->At(j));
     //cout << dig->GetEnergy() << endl;
     hadc->Fill(dig->GetEnergy());
     if(dig->GetEnergy()>0)
       hadcLog->Fill(TMath::Log10(dig->GetEnergy()));
     
   }
   
 }
 
 TFile fc("digits.PHOS.root","RECREATE");
 fc.cd();
 hadc->Write();
 hadcLog->Write();
 fc.Close();


}
コード例 #2
0
Int_t IlcDCHFindClustersFast(Int_t n=0) {
   
   IlcRunLoader* rl = IlcRunLoader::Open("gilc.root");
   if (rl == 0x0) {
      cerr<<"Can not open session"<<endl;
      return 1;
   }
   
   IlcLoader *dchl = (IlcLoader*)rl->GetLoader("DCHLoader");
   if (dchl == 0x0) {
      cerr<<"Can not get DCH Loader"<<endl;
      return 1;
   }
   if (dchl->LoadHits()) {
      cerr<<"Error occured while loading hits"<<endl;
      return 1;
   }


   if (dchl->LoadRecPoints("recreate")) {
      cerr<<"Error occured while loading digits"<<endl;
      return 1;
   }
   
   if (rl->LoadgIlc()) {
      cerr<<"Error occured while l"<<endl;
      return 1;
   }
   rl->LoadKinematics();
   rl->LoadTrackRefs();
   rl->LoadHeader();
   gIlc=rl->GetIlcRun();
   if (!gIlc) {
      cerr<<"Can't get gIlc !\n";
      return 1;
   }

   TDirectory *cwd = gDirectory;

   IlcDCH *dch = (IlcDCH*)gIlc->GetDetector("DCH"); 
//   Int_t ver = dch->IsVersion(); 
//   cerr<<"DCH version "<<ver<<" has been found !\n";
   
   /*if (!gGeoManager) {
     TString geom = "geometry.root";
     TGeoManager::Import(geom.Data());
     }*/
   IlcDCHParam *param=dch->GetParam();
   //param->ReadGeoMatrices();
//   param->SetMWPCReadout(false);

   rl->CdGAFile();

   TStopwatch timer;
   
//    IlcDCHwireposition *wireMatr = new IlcDCHwireposition();
//    IlcDCHclusterizer *clus = new IlcDCHclusterizer("clusterer", "DCH clusterizer");
//    IlcDCHFast dchfast(wireMatr,clus);
   IlcDCHFast dchfast;
   //n = 30;
  
  if (n==0) n = rl->GetNumberOfEvents();

   for(Int_t i=0;i<n;i++){
     printf("Processing event %d\n",i);
     rl->GetEvent(i);
     //     tpcfast.Hits2ExactClusters(rl);
    
     dchfast.Hits2Clusters(rl,i);

   } 
   
   timer.Stop(); 
   timer.Print();
   //cleans everything
   delete rl;
   
//    delete wireMatr;
//    delete clus;


   return 0;
}
コード例 #3
0
Int_t IlcTARGETFindClustersV2(Int_t nev=5, Char_t SlowOrFast='s') {

   cerr<<"Looking for clusters...\n";

   if (gIlc) {
      delete gIlc->GetRunLoader();
      delete gIlc; 
      gIlc=0;
   }
 
   IlcRunLoader *rl = IlcRunLoader::Open("gilc.root");
   if (rl == 0x0) {
      cerr<<"IlcTARGETFindClustersV2.C : Can not open session RL=NULL"<< endl;
      return 1;
   }
     
   IlcTARGETLoader *itsl = (IlcTARGETLoader*)rl->GetLoader("TARGETLoader");
   if (itsl == 0x0) {
      cerr<<"IlcTARGETFindClustersV2.C : can not get TARGET loader"<< endl;
      return 2;
   }

   rl->LoadKinematics();

   Int_t retval = rl->LoadgIlc();
   if (retval) {
      cerr<<"IlcTARGETFindClustersV2.C : LoadgIlc returned error"<< endl;
      delete rl;
      return 3;
   }

   gIlc=rl->GetIlcRun();
   IlcTARGET *TARGET  = (IlcTARGET*)gIlc->GetModule("TARGET");
   if (!TARGET) { cerr<<"Can't find the TARGET !\n"; delete rl; return 3; }
   IlcTARGETgeom *geom=TARGET->GetTARGETgeom();

   itsl->LoadRecPoints("recreate");
   if (SlowOrFast=='s') itsl->LoadDigits("read");
   else itsl->LoadHits("read");
   
   if(SlowOrFast=='s'){
     IlcTARGETclustererV2 clusterer(geom);

     TStopwatch timer;
     if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
     for (Int_t i=0; i<nev; i++) {
       cerr<<"Processing event number: "<<i<<endl;
       rl->GetEvent(i);
       
       TTree *out=itsl->TreeR();
       if (!out) {
	 itsl->MakeTree("R");
	 out=itsl->TreeR();
       }
       
       TTree *in=itsl->TreeD();
       if (!in) {
	 cerr<<"Can't get digits tree !\n";
	 return 4;
       }
       clusterer.Digits2Clusters(in,out);       
       itsl->WriteRecPoints("OVERWRITE");
       timer.Stop(); timer.Print();
     }

   } else{
     
     for(Int_t i=0;i<3;i++){
       TARGET->SetSimulationModel(i,new IlcTARGETsimulationFastPoints());
     }

     TStopwatch timer;
     for (Int_t i=0; i<nev; i++) {
       rl->GetEvent(i);
       if(itsl->TreeR()== 0x0) itsl->MakeTree("R");
       TTree* in = (TTree*)itsl->TreeH();
       TTree* out= (TTree*)itsl->TreeR();
       timer.Start();
       TARGET->Hits2Clusters(in,out);
       timer.Stop(); timer.Print();
       itsl->WriteRecPoints("OVERWRITE");
     }
   }

   delete rl;

   return 0;
}
コード例 #4
0
Int_t IlcTARGETGeoPlot (Int_t evesel=0, char *opt="All+ClustersV2", char *filename="gilc.root", Int_t isfastpoints = 0) {
  /*******************************************************************
   *  This macro displays geometrical information related to the
   *  hits, digits and rec points (or V2 clusters) in TARGET.
   *  There are histograms that are not displayed (i.e. energy
   *  deposition) but that are saved onto a file (see below)
   *
   *  INPUT arguments:
   *
   *  Int_t evesel:  the selected event number. It's =0 by default
   *
   *  Options: Any combination of:
   *    1) subdetector name:  "SPD", "SDD", "SSD", "All" (default)
   *    2) Printouts:        "Verbose" Almost everything is printed out: 
   *                          it is wise to redirect the output onto a file
   *                    e.g.: .x IlcTARGETGeoPlot.C("All+Verbose") > out.log 
   *    3) Rec Points option: "Rec"   ---> Uses Rec. Points (default)
   * 
   *    4) ClustersV2 option: "ClustersV2" ---->Uses ClustersV2
   *                           otherwise ---->uses hits and digits only
   *    Examples:
   *       .x IlcTARGETGeoPlot();  (All subdetectors; no-verbose; no-recpoints)
   *       .x IlcTARGETGeoPlot("SPD+SSD+Verbose+Rec"); 
   *   
   *    filename:   It's "gilc.root" by default. 
   *    isfastpoints: integer. It is set to 0 by defaults. This means that
   *                slow reconstruction is assumed. If fast recpoint are in
   *                in use, isfastpoints must be set =1.
   *
   *  OUTPUT: It produces a root file with a list of histograms
   *    
   *  WARNING: spatial information for SSD/DIGTARGET is obtained by pairing
   *          digits on p and n side originating from the same track, when
   *          possible. This (mis)use of DIGTARGET is tolerated for debugging 
   *          purposes only !!!!  The pairing in real life should be done
   *          starting from info really available... 
   * 
   *  COMPILATION: this macro can be compiled. 
   *      1)       You need to set your include path with
   * gSystem->SetIncludePath("-I- -I$ILC_ROOT/include -I$ILC_ROOT/TARGET -g");
   *      3)       If you are using root instead of ilcroot you need to
   *               execute the macro loadlibs.C in advance
   *      4)       To compile this macro from root (or ilcroot):
   *                 ---  .L IlcTARGETGeoPlot.C++
   *                 ---  IlcTARGETGeoPlot();
   *     
   *  M.Masera  14/05/2001 18:30
   *  Last rev. 31/05/2004 14:00 (Clusters V2 added)  E.C.          
   ********************************************************************/

  //Options
  TString choice(opt);
  Bool_t All = choice.Contains("All");
  Bool_t verbose=choice.Contains("Verbose");
  Bool_t userec=choice.Contains("Rec");
  Bool_t useclustersv2=choice.Contains("ClustersV2");
  Int_t retcode=1; //return code
 
  if (gClassTable->GetID("IlcRun") < 0) {
    gInterpreter->ExecuteMacro("loadlibs.C");
  }
  else { 
    if(gIlc){
      delete gIlc->GetRunLoader();
      delete gIlc;
      gIlc=0;
    }
  }
 
  IlcRunLoader* rl = IlcRunLoader::Open(filename);
  if (rl == 0x0){
    cerr<<"IlcTARGETGeoPlot.C : Can not open session RL=NULL"<< endl;
    return -1;
  }
  Int_t retval = rl->LoadgIlc();
  if (retval){
    cerr<<"IlcTARGETGeoPlot.C : LoadgIlc returned error"<<endl;
    return -1;
  }
  gIlc=rl->GetIlcRun();

  retval = rl->LoadHeader();
  if (retval){
    cerr<<"IlcTARGETGeoPlot.C : LoadHeader returned error"<<endl;
    return -1;
  }

  IlcTARGETLoader* TARGETloader =  (IlcTARGETLoader*) rl->GetLoader("TARGETLoader");

  if(!TARGETloader){
    cerr<<"IlcTARGETGeoPlot.C :  TARGET loader not found"<<endl;
    return -1;
  }

  TARGETloader->LoadHits("read");
  TARGETloader->LoadDigits("read");
  if(isfastpoints==1)TARGETloader->SetRecPointsFileName("TARGET.FastRecPoints.root");
  TARGETloader->LoadRecPoints("read");
  rl->GetEvent(evesel);
  Int_t nparticles = rl->GetHeader()->GetNtrack();
  IlcTARGET *TARGET  = (IlcTARGET*)gIlc->GetModule("TARGET");
  TARGET->SetTreeAddress();
  if(verbose) {
    cout<<" "<<endl<<" "<<endl;
    cout<<"******* Event processing started   *******"<<endl;
    cout<<"In the following, hits with 'StatusEntering' flag active"<<endl;
    cout<<"will not be processed"<<endl; 
    cout << "Number of particles=  " << nparticles <<endl;
  }

  // HTARGET
  TTree *TH = TARGETloader->TreeH();
  Stat_t ntracks = TH->GetEntries();
  if(verbose)cout<<"Number of primary tracks= "<<ntracks<<endl;

  // TARGET
  Int_t nmodules;
  TARGET->InitModules(-1,nmodules);
  cout<<"Number of TARGET modules= "<<nmodules<<endl;
  cout<<"Filling modules... It takes a while, now. Please be patient"<<endl;
  TARGET->FillModules(0,0,nmodules," "," ");
  cout<<"TARGET modules .... DONE!"<<endl;
  
  IlcTARGETDetTypeRec* detTypeRec = new IlcTARGETDetTypeRec(TARGETloader);
  detTypeRec->SetDefaults();
  // DIGTARGET
  TTree *TD = TARGETloader->TreeD();

  //RECPOINTS (V2 clusters)
  TTree *TR = TARGETloader->TreeR();
  TClonesArray *TARGETrec  = detTypeRec->RecPoints();
  TBranch *branch = 0;
  if(userec && TR && TARGETrec){
    if(isfastpoints==1){
      branch = TARGETloader->TreeR()->GetBranch("TARGETRecPointsF");
      cout<<"using fast points\n";
    }
    else {
      branch = TARGETloader->TreeR()->GetBranch("TARGETRecPoints");
    }
    if(branch)branch->SetAddress(&TARGETrec);
  }

  if(userec && (!TR || !TARGETrec || !branch)){
    userec = kFALSE;
    cout<<"\n ======================================================= \n";
    cout<<"WARNING: there are no RECPOINTS on this file ! \n";
    cout<<"======================================================= \n \n";
  }
  if(useclustersv2 && TR && TARGETrec){
    branch = TARGETloader->TreeR()->GetBranch("TARGETRecPoints");
    if(branch)branch->SetAddress(&TARGETrec);
  }

  if(useclustersv2 && (!TR || !TARGETrec || !branch)){
    useclustersv2 = kFALSE;
    cout<<"\n ======================================================= \n";
    cout<<"WARNING: there are no CLUSTERSV2 on this file ! \n";
    cout<<"======================================================= \n \n";
  }


  //local variables
  Int_t mod;   //module number
  Int_t nbytes = 0; 
  Double_t pos[3];  // Global position of the current module
  Float_t ragdet; // Radius of detector (x y plane)
  Int_t first; // first module
  Int_t last; // last module
  Int_t nrecp; //number of RecPoints for a given module

  //List of histograms
  TObjArray histos(26,0);  // contains the pointers to the histograms
  // Book histograms SPD
  TH2F *rspd = new TH2F("rspd","Radii of digits - SPD",50,-10.,10.,50,-10.,10.);
  TH2F *rhspd = new TH2F("rhspd","Radii of hits - SPD",50,-10.,10.,50,-10.,10.);
  TH2F *rmspd = new TH2F("rmspd","Radii of SPD modules",50,-10.,10.,50,-10.,10.);
  TH1F *zspd = new TH1F("zspd","Z of digits - SPD",100,-30.,30.);
  TH1F *zhspd = new TH1F("zhspd","Z of hits - SPD",100,-30.,30.);
  TH1F *zmspd = new TH1F("zmspd","Z of SPD modules",100,-30,30.);

  Char_t title1[50]="";
  Char_t title2[50]="";
  if(userec){ 
    sprintf(title1,"Radii of recpoints - %s","SPD");
    sprintf(title2,"Z of recpoints - %s","SPD");
  }
  if(useclustersv2){
    sprintf(title1,"Radii of clustersV2 - %s","SPD");
    sprintf(title2,"Z of clustersV2 - %s","SPD");
  }
  TH2F *rrspd = new TH2F("rrspd",title1,50,-10.,10.,50,-10.,10.);
  TH1F *zrspd = new TH1F("zrspd",title2,100,-30.,30.);
  TH1F *enespd = new TH1F("enespd","Energy deposition SPD (KeV)",100,0.,1000.);
  histos.AddLast(rspd);  // 0
  histos.AddLast(rhspd); // 1
  histos.AddLast(rmspd); // 2
  histos.AddLast(zspd);  // 3
  histos.AddLast(zhspd); // 4
  histos.AddLast(zmspd); // 5
  histos.AddLast(rrspd); // 6
  histos.AddLast(zrspd); // 7
  histos.AddLast(enespd); // 8
  // Book histograms SDD
  TH2F *rsdd = new TH2F("rsdd","Radii of digits - SDD",50,-40.,40.,50,-40.,40.);
  TH2F *rhsdd = new TH2F("rhsdd","Radii of hits - SDD",50,-40.,40.,50,-40.,40.);
  TH2F *rmsdd = new TH2F("rmsdd","Radii of SDD modules",50,-40.,40.,50,-40.,40.);
  TH1F *zsdd = new TH1F("zsdd","Z of digits - SDD",100,-40.,40.);
  TH1F *zhsdd = new TH1F("zhsdd","Z of hits - SDD",100,-40.,40.);
  TH1F *zmsdd = new TH1F("zmsdd","Z of SDD modules",100,-40,40.);
  Char_t title3[50];
  Char_t title4[50];
  if(userec){ 
    sprintf(title3,"Radii of recpoints - %s","SDD");
    sprintf(title4,"Z of recpoints - %s","SDD");
  }
  if(useclustersv2){
    sprintf(title3,"Radii of clustersV2 - %s","SDD");
    sprintf(title4,"Z of clustersV2 - %s","SDD");
  }
  TH2F *rrsdd = new TH2F("rrsdd",title3,50,-40.,40.,50,-40.,40.);   
  TH1F *zrsdd = new TH1F("zrsdd",title4,100,-40.,40.);
  TH1F *enesdd = new TH1F("enesdd","Energy deposition SDD (KeV)",100,0.,1000.);
  histos.AddLast(rsdd);  // 9
  histos.AddLast(rhsdd); // 10
  histos.AddLast(rmsdd); // 11
  histos.AddLast(zsdd);  // 12
  histos.AddLast(zhsdd); // 13
  histos.AddLast(zmsdd); // 14
  histos.AddLast(rrsdd); // 15
  histos.AddLast(zrsdd); // 16
  histos.AddLast(enesdd); // 17
  // Book histogram SSD
  TH2F *rssd = new TH2F("rssd","Radii of digits - SSD",50,-50.,50.,50,-50.,50.);
  TH2F *rhssd = new TH2F("rhssd","Radii of hits - SSD",50,-50.,50.,50,-50.,50.);
  TH2F *rmssd = new TH2F("rmssd","Radii of SSD modules",50,-50.,50.,50,-50.,50.);
  TH1F *zssd = new TH1F("zssd","Z of digits - SSD",100,-70.,70.);
  TH1F *zhssd = new TH1F("zhssd","Z of hits - SSD",100,-70.,70.);
  TH1F *zmssd = new TH1F("zmssd","Z of SSD modules",100,-70,70.);
  Char_t title5[50];
  Char_t title6[50];
  if(userec){ 
    sprintf(title5,"Radii of recpoints - %s","SSD");
    sprintf(title6,"Z of recpoints - %s","SSD");
  }
  if(useclustersv2){
    sprintf(title5,"Radii of clustersV2 - %s","SSD");
    sprintf(title6,"Z of clustersV2 - %s","SSD");
  }

  TH2F *rrssd = new TH2F("rrssd",title5,50,-50.,50.,50,-50.,50.);
  TH1F *zrssd = new TH1F("zrssd",title6,100,-70.,70.);
  TH1F *enessd = new TH1F("enessd","Energy deposition SSD (KeV)",100,0.,1000.);
  histos.AddLast(rssd);  // 18
  histos.AddLast(rhssd); // 19
  histos.AddLast(rmssd); // 20
  histos.AddLast(zssd);  // 21
  histos.AddLast(zhssd); // 22
  histos.AddLast(zmssd); // 23
  histos.AddLast(rrssd); // 24
  histos.AddLast(zrssd); // 25
  histos.AddLast(enessd); // 26
  //
  // Loop on subdetectors
  // 
  IlcTARGETgeom *geom = TARGET->GetTARGETgeom();
  TString detna; // subdetector name
  for(Int_t subd=0;subd<3;subd++){
    if(All || (choice.Contains("SPD") && subd==0) || (choice.Contains("SDD") && subd==1) || (choice.Contains("SSD") && subd==2)){
      // Prepare array for the digits
      TClonesArray *TARGETdigits  = TARGET->DigitsAddress(subd);
      Bool_t usedigits = kTRUE;
      if(!TARGETdigits){
        usedigits = kFALSE;
        cout<<"\n ======================================================= \n";
        cout<<"WARNING: there are no DIGTARGET on this file ! \n";
        cout<<"======================================================= \n \n";
      }
      // Get segmentation model
      if(subd==0)detna="SPD";
      if(subd==1)detna="SDD";
      if(subd==2)detna="SSD";
      IlcTARGETsegmentation *seg=(IlcTARGETsegmentation*)detTypeRec->GetSegmentationModel(subd);
      // Loop on modules
      first = geom->GetStartDet(subd);
      last = geom->GetLastDet(subd);
      if(verbose){
        cout<<"     "<<endl<<"-------------------------------------"<<endl;
        cout<<"Start processing subdetector "<<detna<<endl;
        cout<<detna<<" first module "<<first<<endl;
        cout<<detna<<" last module "<<last<<endl;
        cout<<" "<<endl<<" "<<endl;
      }
      for (mod=first; mod<=last; mod++){
        geom->GetTrans(mod,pos);  // position of the module in the MRS
        ragdet=sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
        // The following 2 histos are a check of the geometry
        TH2F *bidi = (TH2F*)histos.At(2+subd*9);
        TH1F *uni = (TH1F*)histos.At(5+subd*9);
        bidi->Fill(pos[0],pos[1]);
        uni->Fill(pos[2]);
        if(verbose){
          cout<<"=========================================================\n";
          cout<<detna<<" module="<<mod<<endl;
          cout<<"Mod. coordinates: "<<pos[0]<<", "<<pos[1]<<", ";
          cout<<pos[2]<<" Radius "<<ragdet<<endl;
        }

        // Hits
        GetHitsCoor(TARGET,mod,histos,subd,verbose);

        //RecPoints     
        if(userec){
          detTypeRec->ResetRecPoints();
          branch->GetEvent(mod);
          TH2F *bidi=(TH2F*)histos.At(6+subd*9);
          TH1F *uni=(TH1F*)histos.At(7+subd*9);
          nrecp=GetRecCoor(geom,TARGETrec,mod,bidi,uni,verbose);
        }
        if(useclustersv2){
          detTypeRec->ResetRecPoints();
          branch->GetEvent(mod);
          TH2F *bidi=(TH2F*)histos.At(6+subd*9);
          TH1F *uni=(TH1F*)histos.At(7+subd*9);
          nrecp=GetClusCoor(geom,TARGETrec,mod,bidi,uni,verbose);
	  
        }
     
        // Digits
        if(usedigits){
          detTypeRec->ResetDigits();
          nbytes += TD->GetEvent(mod);
          GetDigits(seg,geom,TARGETdigits,subd,mod,verbose,histos);
        }

      } // End of loop on the modules
      TH1F *h1tmp;
      TH2F *h2tmp;
      //  Plot the histograms
      TCanvas *current=0; // current Canvas (1--> SPD, 2---> SDD, 3---> SSD)
      if(subd==0){
        // Prepare canvas 1
        TCanvas *c1 = new TCanvas("c1","SPD",10,10,600,900);
        c1->Divide(2,3);
        current=c1;
      }
      if(subd==1){
        // Prepare canvas 2
        TCanvas *c2 = new TCanvas("c2","SDD",40,40,600,900);
        c2->Divide(2,3);
        current=c2;
      }
      if(subd==2){
        // Prepare canvas 3
        TCanvas *c3 = new TCanvas("c3","SSD",70,70,600,900);
        c3->Divide(2,3);
        current=c3;
      }
      current->cd(1);
      h2tmp = (TH2F*)histos.At(9*subd);
      h2tmp->Draw();
      current->cd(2);
      h1tmp=(TH1F*)histos.At(3+subd*9);
      h1tmp->Draw();
      current->cd(3);
      h2tmp=(TH2F*)histos.At(1+9*subd);
      h2tmp->Draw();
      current->cd(4);
      h1tmp=(TH1F*)histos.At(4+subd*9);
      h1tmp->Draw();
   
      if(userec || useclustersv2){
        current->cd(5);
        h2tmp=(TH2F*)histos.At(6+9*subd);
        h2tmp->Draw();
        current->cd(6);
        h1tmp=(TH1F*)histos.At(7+subd*9);
        h1tmp->Draw();
      }
  
      else {
        current->cd(5);
        h2tmp=(TH2F*)histos.At(2+9*subd);
        h2tmp->Draw();
        current->cd(6);
        h2tmp=(TH2F*)histos.At(5+9*subd);
        h2tmp->Draw();
      }
    } // if(All.....
  } // end of loop on subdetectors
  // Save the histograms
  TFile *fh = new TFile("IlcTARGETGeoPlot.root","recreate");
  // The list is written to file as a single entry
  TList *lihi = new TList();
  // copy the pointers to the histograms to a TList object.
  // The histograms concerning recpoints are not copied if
  // 'userec' is false.
  for(Int_t i=0;i<histos.GetEntriesFast();i++){
    if(choice.Contains("All") || (choice.Contains("SPD") && i<8) || (choice.Contains("SDD") && i>7 && i<16) || (choice.Contains("SSD") && i>15)){
      if(!(!userec && ((i+2)%9==0 || (i+1)%9==0)))lihi->Add(histos.At(i));
    }
  }
  lihi->Write("Histograms TARGET hits+digits+recpoints",TObject::kSingleKey);
  fh->Close();

  return retcode;
}
コード例 #5
0
void testTARGETMultReco(Char_t* dir = ".") {

  Char_t str[256];

  // ########################################################
  // defining pointers
  IlcRunLoader* runLoader;
  TFile* esdFile = 0;
  TTree* esdTree = 0;
  IlcESD* esd = 0;

  // #########################################################
  // setup gilc and runloader

  if (gIlc) {
    delete gIlc->GetRunLoader();
    delete gIlc;
    gIlc=0;
  }

  sprintf(str,"%s/gilc.root",dir);
  runLoader = IlcRunLoader::Open(str);
  if (runLoader == 0x0) {
    cout << "Can not open session"<<endl;
    return;
  }
  runLoader->LoadgIlc();

  gIlc = runLoader->GetIlcRun();
  runLoader->LoadKinematics();
  runLoader->LoadHeader();

  // #########################################################
  // open esd file and get the tree

  // close it first to avoid memory leak
  if (esdFile)
    if (esdFile->IsOpen())
      esdFile->Close();

  sprintf(str,"%s/IlcESDs.root",dir);
  esdFile = TFile::Open(str);
  esdTree = (TTree*)esdFile->Get("esdTree");
  TBranch * esdBranch = esdTree->GetBranch("ESD");
  esdBranch->SetAddress(&esd);


  // #########################################################
  // setup its stuff

  IlcTARGET* its=(IlcTARGET*)runLoader->GetIlcRun()->GetDetector("TARGET");
  if (!its) {
    cout << " Can't get the TARGET!" << endl;
    return ;
  }
  IlcTARGETgeom* itsGeo=its->GetTARGETgeom();
  if (!itsGeo) {
    cout << " Can't get the TARGET geometry!" << endl;
    return ;
  }
  IlcTARGETLoader* itsLoader = (IlcTARGETLoader*)runLoader->GetLoader("TARGETLoader");
  if (!itsLoader) {
    cout << " Can't get the TARGET loader!" << endl;
    return ;
  }
  itsLoader->LoadRecPoints("read");

  // #########################################################
  IlcTARGETMultReconstructor* multReco = new IlcTARGETMultReconstructor();
  multReco->SetGeometry(itsGeo);

  // #########################################################
  // getting number of events

  Int_t nEvents = (Int_t)runLoader->GetNumberOfEvents();
  Int_t nESDEvents = esdBranch->GetEntries();

  if (nEvents!=nESDEvents) {
    cout << " Different number of events from runloader and esdtree!!!" 
	 << nEvents << " / " << nESDEvents << endl;
    return;
  }

  // ########################################################
  // loop over number of events
  cout << nEvents << " event(s) found in the file set" << endl;
  for(Int_t i=0; i<nEvents; i++) {
    
    cout << "-------------------------" << endl << " event# " << i << endl;
    
    runLoader->GetEvent(i);
    esdBranch->GetEntry(i);

    // ########################################################
    // get the EDS vertex
    const IlcESDVertex* vtxESD = esd->GetVertex();
    Double_t vtx[3];
    vtxESD->GetXYZ(vtx);   
    Float_t esdVtx[3];
    esdVtx[0] = vtx[0];
    esdVtx[1] = vtx[1];
    esdVtx[2] = vtx[2];
    
    ///#########################################################
    // get TARGET clusters 
    TTree* itsClusterTree = itsLoader->TreeR();
    if (!itsClusterTree) {
      cerr<< " Can't get the TARGET cluster tree !\n";
      return;
    }
    multReco->SetHistOn(kTRUE);
    multReco->Reconstruct(itsClusterTree, esdVtx, esdVtx);

    
    for (Int_t t=0; t<multReco->GetNTracklets(); t++) {
      
      cout << "  tracklet " << t 
	   << " , theta = " << multReco->GetTracklet(t)[0]
	   << " , phi = " << multReco->GetTracklet(t)[1] << endl; 
    }

  }
 
  TFile* fout = new TFile("out.root","RECREATE");  

  multReco->SaveHists();
  fout->Write();
  fout->Close();


}