Beispiel #1
0
ReadTrigger( TString inFile = "gilc.root" )
{
   // Dynamically link some shared libs
   if( gClassTable->GetID( "IlcRun" ) < 0 ) {
      gROOT->ProcessLine( ".x $(ILC_ROOT)/macros/loadlibs.C" );
   } else if( gIlc ) {
      delete IlcRunLoader::Instance();
      delete gIlc;
      gIlc=0;
   }

   IlcRunLoader* rl = IlcRunLoader::Open( inFile.Data() );
   if( rl == 0x0 ) {
      cerr << "ReadTrigger.C : Can not open session RunLoader=NULL"
           << endl;
       return 3;
   }

   // Read and Print Trigger

   rl->LoadTrigger();
   IlcCentralTrigger *aCTP = rl->GetTrigger();
   aCTP->Print();

   // Loop over event and print trigger info
   Int_t nevent = rl->GetNumberOfEvents();
   for( Int_t i=0; i<nevent; i++ ) {
      rl->GetEvent( i );
      cout << endl << "Event " << i
           << " Global Trigger Class Mask: 0x" << hex << aCTP->GetClassMask() << endl;

      // Read trigger inputs from detector. Example. ITS
      IlcLoader * loader = rl->GetDetectorLoader( "ITS" );
      if( loader ) {
         IlcDataLoader * dataLoader = loader->GetDigitsDataLoader();
         if( !dataLoader->IsFileOpen() ) 
            dataLoader->OpenFile( "READ" );
         IlcTriggerDetector* trgdet = (IlcTriggerDetector*)dataLoader->GetDirectory()->Get( "Trigger" );
         if( trgdet ) {
            trgdet->Print();
         } else {
            cerr << "There is not trigger object for " << loader->GetName() << endl;
         }
      }
   }
}
Beispiel #2
0
void test(const char * sdir ="signal",
	  const char * bdir ="backgr") {

  TStopwatch timer;
  timer.Start();

  TString name;

  // Signal file, tree, and branch
  name = sdir;
  name += "/IlcESDs.root";
  TFile * fSig = TFile::Open(name.Data());
  TTree * tSig = (TTree*)fSig->Get("esdTree");

  IlcESDEvent * esdSig = new IlcESDEvent();// The signal ESD object is put here
  esdSig->ReadFromTree(tSig);

  // Run loader (signal events)
  name = sdir;
  name += "/gilc.root";
  IlcRunLoader* rlSig = IlcRunLoader::Open(name.Data());

  // Run loader (underlying events)
  name = bdir;
  name += "/gilc.root";
  IlcRunLoader* rlUnd = IlcRunLoader::Open(name.Data(),"Underlying");

  // gIlc
  rlSig->LoadgIlc();
  rlUnd->LoadgIlc();
  gIlc = rlSig->GetIlcRun();

  // Now load kinematics and event header
  rlSig->LoadKinematics();
  rlSig->LoadHeader();
  rlUnd->LoadKinematics();
  rlUnd->LoadHeader();

  // Loop on events: check that MC and data contain the same number of events
  Long64_t nevSig = rlSig->GetNumberOfEvents();
  Long64_t nevUnd = rlUnd->GetNumberOfEvents();
  Long64_t nSigPerUnd = nevSig/nevUnd;

  cout << nevSig << " signal events" << endl;
  cout << nevUnd << " underlying events" << endl;
  cout << nSigPerUnd << " signal events per one underlying" << endl;

  for (Int_t iev=0; iev<nevSig; iev++) {
    cout << "Signal event " << iev << endl;
    Int_t ievUnd = iev/nSigPerUnd;
    cout << "Underlying event " << ievUnd << endl;

    // Get signal ESD
    tSig->GetEntry(iev);
    // Get signal kinematics
    rlSig->GetEvent(iev);
    // Get underlying kinematics
    rlUnd->GetEvent(ievUnd);

    // Particle stack
    IlcStack * stackSig = rlSig->Stack();
    Int_t nPartSig = stackSig->GetNtrack();
    IlcStack * stackUnd = rlUnd->Stack();
    Int_t nPartUnd = stackUnd->GetNtrack();

    Int_t nrec = esdSig->GetNumberOfTracks();
    cout << nrec << " reconstructed tracks" << endl;
    for(Int_t irec=0; irec<nrec; irec++) {
      IlcESDtrack * track = esdSig->GetTrack(irec);
      UInt_t label = TMath::Abs(track->GetTPCLabel());
      if (label>=10000000) {
	// Underlying event. 10000000 is the
	// value of fkMASKSTEP in IlcRunDigitizer
// 	cout << " Track from the underlying event" << endl;
	label %=10000000;
	if (label>=nPartUnd) continue;
	TParticle * part = stackUnd->Particle(label);
 	if(part) part->Print();
      }
      else {
	cout << " Track " << label << " from the signal event" << endl;
	if (label>=nPartSig) {
	  cout <<"Strange, label outside the range "<< endl;
	  continue;
	}
	TParticle * part = stackSig->Particle(label);
	if(part) part->Print();
      }

    }

  }

  fSig->Close();

  timer.Stop();
  timer.Print();
}
Beispiel #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;
}
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;
}
Beispiel #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();


}