Beispiel #1
0
//______________________________________________________________________
IlcRunLoader* AccessFile(TString FileName){
  // Function used to open the input file and fetch the IlcRun object

  IlcRunLoader* rl = IlcRunLoader::Open(FileName.Data());
  if (rl == 0x0){
    cerr<<"AccessFile : Can not open session RL=NULL"<< endl;
    return rl;
  }
 
  Int_t retval = rl->LoadgIlc();
  if (retval){
    cerr<<"AccessFile : LoadgIlc returned error"<<endl;
    return rl;
  }
  return rl;
}
Beispiel #2
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();


}
Beispiel #3
0
void display2(const char *filename="gilc.root", Int_t nevent=0,
              Int_t *tracks=0, Int_t ntracks=0)
{
   // Dynamically link some shared libs
   if (gClassTable->GetID("IlcRun") < 0) {
      gROOT->LoadMacro("loadlibs.C");
      loadlibs();
   } else {
//       delete gIlc->GetRunLoader();
      delete gIlc;
      gIlc = 0;
   }
   //gSystem->Load("libIlcL3Src");
   gSystem->Load("libDISPLAY");

   // Connect the ROOT Gilc file containing Geometry, Kine and Hits
   IlcRunLoader *rl = 0;
   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
   if(file) {
      Info("display2.C", "gilc.root is already open");
   }
   rl = IlcRunLoader::Open(filename, "DISPLAYED EVENT");

   if (rl == 0) {
      Error("display2.C", "can not get Run Loader, exiting...");
      return;
   }

   // Get IlcRun object from file or create it if not on file
   rl->LoadgIlc();

   gIlc = rl->GetIlcRun();
   if (!gIlc) {
      Error("display2.C", "IlcRun object not found on file, exiting...");
      return;
  }

   // Create Event Display object
   IlcDisplay2 *edisplay = new IlcDisplay2(gClient->GetRoot(), 900, 700);
   // if (ntracks > 0) edisplay->SetTracksToDisplay(tracks, ntracks);

   // Display the requested event
   rl->GetEvent(nevent);
   rl->LoadKinematics();
   rl->LoadHeader();
   rl->LoadHits();

   //edisplay->FindModules();
   edisplay->ShowNextEvent(0);
}
Beispiel #4
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;
         }
      }
   }
}
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 #6
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;
}
Beispiel #7
0
void fastGen(Int_t nev = 1, char* filename = "gilc.root")
{
  IlcPDG::AddParticlesToPdgDataBase();
  TDatabasePDG::Instance();
 


  // Run loader
  IlcRunLoader* rl = IlcRunLoader::Open("gilc.root","FASTRUN","recreate");
  
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(nev);
  rl->LoadKinematics("RECREATE");
  rl->MakeTree("E");
  gIlc->SetRunLoader(rl);
  
  //  Create stack
  rl->MakeStack();
  IlcStack* stack = rl->Stack();
  
  //  Header
  IlcHeader* header = rl->GetHeader();
  
  //  Create and Initialize Generator
 
  // Example of charm generation taken from Config_PythiaHeavyFlavours.C
  IlcGenPythia *gener = new IlcGenPythia(-1);
  gener->SetEnergyCMS(14000.);
  gener->SetMomentumRange(0,999999);
  gener->SetPhiRange(0., 360.);
  gener->SetThetaRange(0.,180.);
  //  gener->SetProcess(kPyCharmppMNR); // Correct Pt distribution, wrong mult
  gener->SetProcess(kPyMb); // Correct multiplicity, wrong Pt
  gener->SetStrucFunc(kCTEQ4L);
  gener->SetPtHard(2.1,-1.0);
  gener->SetFeedDownHigherFamily(kFALSE);
  gener->SetStack(stack);
  gener->Init();

  // Go to gilc.root
  rl->CdGAFile();

  // Forbid some decays. Do it after gener->Init(0, because
  // the initialization of the generator includes reading of the decay table.

  IlcPythia * py= IlcPythia::Instance();
  py->SetMDME(737,1,0); //forbid D*+->D+ + pi0
  py->SetMDME(738,1,0);//forbid D*+->D+ + gamma

  // Forbid all D0 decays except D0->K- pi+
  for(Int_t d=747; d<=762; d++){ 
    py->SetMDME(d,1,0);
  }
  // decay 763 is D0->K- pi+
  for(Int_t d=764; d<=807; d++){ 
    py->SetMDME(d,1,0);
  }

  //
  //                        Event Loop
  //
  
  TStopwatch timer;
  timer.Start();
  for (Int_t iev = 0; iev < nev; iev++) {
    
    cout <<"Event number "<< iev << endl;
    
    //  Initialize event
    header->Reset(0,iev);
    rl->SetEventNumber(iev);
    stack->Reset();
    rl->MakeTree("K");
    
    //  Generate event
    Int_t nprim = 0;
    Int_t ntrial = 0;
    Int_t ndstar = 0;
   
   

    //-------------------------------------------------------------------------------------

    while(!ndstar) {
      // Selection of events with D*
      stack->Reset();
      stack->ConnectTree(rl->TreeK());
      gener->Generate();
      ntrial++;
      nprim = stack->GetNprimary();
      
      for(Int_t ipart =0; ipart < nprim; ipart++){
        TParticle * part = stack->Particle(ipart);
        if(part)    {
          
          if (TMath::Abs(part->GetPdgCode())== 413) {

	    TArrayI daughtersId;

	    GetFinalDecayProducts(ipart,*stack,daughtersId);

	    Bool_t kineOK = kTRUE;

	    Double_t thetaMin = TMath::Pi()/4;
	    Double_t thetaMax = 3*TMath::Pi()/4;

	    for (Int_t id=1; id<=daughtersId[0]; id++) {
	      TParticle * daughter = stack->Particle(daughtersId[id]);
	      if (!daughter) {
		kineOK = kFALSE;
		break;
	      }

	      Double_t theta = daughter->Theta();
	      if (theta<thetaMin || theta>thetaMax) {
		kineOK = kFALSE;
		break;
	      }
	    }

	    if (!kineOK) continue;

            part->Print();
            ndstar++;     
	    
          }
        }
      }   
    }   
      
    cout << "Number of particles " << nprim << endl;
    cout << "Number of trials " << ntrial << endl;
    
    //  Finish event
    header->SetNprimary(stack->GetNprimary());
    header->SetNtrack(stack->GetNtrack());  
    
    //      I/O
    stack->FinishEvent();
    header->SetStack(stack);
    rl->TreeE()->Fill();
    rl->WriteKinematics("OVERWRITE");
    
  } // event loop
  timer.Stop();
  timer.Print();
  
  //                         Termination
  //  Generator
  gener->FinishRun();
  //  Write file
  rl->WriteHeader("OVERWRITE");
  gener->Write();
  rl->Write();
}
Beispiel #8
0
TEveTrackList*
kine_tracks(Double_t min_pt,  Double_t min_p,
	    Bool_t   pdg_col, Bool_t   recurse,
	    Bool_t   use_track_refs)
{
  IlcRunLoader* rl =  IlcEveEventManager::AssertRunLoader();
  rl->LoadKinematics();
  IlcStack* stack = rl->Stack();
  if (!stack)
  {
    Error("kine_tracks", "can not get kinematics.");
    return 0;
  }

  gEve->DisableRedraw();

  TEveTrackList* cont = new TEveTrackList("Kine Tracks");
  cont->SetMainColor(3);
  TEveTrackPropagator* trkProp = cont->GetPropagator();

  kine_track_propagator_setup(trkProp);

  gEve->AddElement(cont);
  Int_t count = 0;
  Int_t Np = stack->GetNprimary();
  for (Int_t i = 0; i < Np; ++i)
  {
    TParticle* p = stack->Particle(i);
    if (p->GetStatusCode() <= 1)
    {
      if (p->Pt() < min_pt && p->P() < min_p) continue;

      ++count;
      IlcEveTrack* track = new IlcEveTrack(p, i, trkProp);

      //PH The line below is replaced waiting for a fix in Root
      //PH which permits to use variable siza arguments in CINT
      //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
      //PH    track->SetName(Form("%s [%d]", p->GetName(), i));
      char form[1000];
      sprintf(form,"%s [%d]", p->GetName(), i);
      track->SetName(form);
      track->SetStdTitle();
      Int_t ml = p->GetMother(0);
      if (ml != -1)
      {
        track->SetTitle(Form("%s\nMother label=%d\nMother Pdg=%d",
                             track->GetElementTitle(),
                             ml, stack->Particle(ml)->GetPdgCode()));
      }
      set_track_color(track, pdg_col);

      gEve->AddElement(track, cont);

      if (recurse)
	kine_daughters(track, stack, min_pt, min_p, pdg_col, recurse);
    }
  }

  // set path marks
  IlcEveKineTools kt;
  kt.SetDaughterPathMarks(cont, stack, recurse);
  if (use_track_refs && rl->LoadTrackRefs() == 0)
  {
    kt.SetTrackReferences(cont, rl->TreeTR(), recurse);
    trkProp->SetEditPathMarks(kTRUE);
  }
  kt.SortPathMarks(cont, recurse);

  //PH  const Text_t* tooltip = Form("min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
  char tooltip[1000];
  sprintf(tooltip,"min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
  cont->SetTitle(tooltip); // Not broadcasted automatically ...

  cont->MakeTracks(recurse);
  gEve->EnableRedraw();
  gEve->Redraw3D();

  return cont;
}
Beispiel #9
0
void clusters()
{
  IlcEveEventManager::AssertGeometry();

  IlcRunLoader *rl        = IlcEveEventManager::AssertRunLoader();
  IlcESDEvent  *esd       = IlcEveEventManager::AssertESD();
  IlcEveEventManager::AssertESDfriend();
  IlcEveEventManager::AssertMagField();

  const char* detNames[] = { "ITS", "TPC", /*"TRD",*/ "TOF", "HMPID" };
  const Int_t detIds[]   = {   0,     1,   /*  2,  */   3,     5   };
  const Int_t detN       = sizeof(detNames)/sizeof(char*);

  // Hack - IlcReconstruction does wonders with gGeoManager.
  TGeoManager* xxx = gGeoManager; gGeoManager = 0;
  IlcReconstruction* reco = new IlcReconstruction;
  gGeoManager = xxx;

  // Hack for ITS - it requires RecoParams outside event-loop!
  reco->SetRecoParam("ITS", IlcITSRecoParam::GetLowFluxParam());

  reco->ImportRunLoader(rl);
  {
    TString alldets;
    for (Int_t i = 0; i < detN; ++i) {
      alldets += detNames[i];
      alldets += " ";
    }
    reco->CreateTrackers(alldets);
  }

  TObjArray* clarr = new TObjArray();

  // Load clusters, fill them into clarr.

  for (Int_t i = 0; i < detN; ++i)
  {
    Int_t det = detIds[i];
    rl->LoadRecPoints(detNames[i]);

    TTree *cTree = rl->GetTreeR(detNames[i], false);
    if (cTree == 0)
      continue;

    IlcTracker* tracker = reco->GetTracker(det);
    if (tracker == 0) continue;
    tracker->LoadClusters(cTree);
    tracker->FillClusterArray(clarr);
  }

  // Loop over tracks and friends, tag used clusters.

  for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
  {
    IlcESDtrack* at = esd->GetTrack(n);

    Int_t idx[200];
    for (Int_t i = 0; i < detN; ++i)
    {
      Int_t det = detIds[i];
      IlcTracker* tracker = reco->GetTracker(det);
      if (tracker == 0) continue;
      Int_t nclusters = at->GetClusters(det, idx);
      Int_t p=0;
      for (Int_t c = 0; c < nclusters; )
      {
        Int_t index = idx[p++];
        if (index < 0) continue;
        c++;
        IlcCluster* cluster = tracker->GetCluster(index);
        if (cluster) cluster->IncreaseClusterUsage();
        //else printf("Zero cluster pointer for detector: %s\n",detNames[i]);
      }
    }
  }

  for (Int_t i = 0; i < detN; ++i)
    rl->UnloadRecPoints(detNames[i]);

  // Fill visualization structs

  TEveElementList* list = new TEveElementList("Clusters");
  gEve->AddElement(list);

  TEvePointSet* shared = new TEvePointSet("Shared Clusters");
  shared->SetMainColor(2);
  shared->SetMarkerSize(0.4);
  shared->SetMarkerStyle(2);
  list->AddElement(shared);

  TEvePointSet* used = new TEvePointSet("Single-used Clusters");
  used->SetMainColor(3);
  used->SetMarkerSize(0.4);
  used->SetMarkerStyle(2);
  list->AddElement(used);

  TEvePointSet* nonused = new TEvePointSet("Not-used Clusters");
  nonused->SetMainColor(4);
  nonused->SetMarkerSize(0.4);
  nonused->SetMarkerStyle(2);
  list->AddElement(nonused);

  // Loop over all clusters, fill appropriate container based
  // on shared/used information.

  Int_t ncl = clarr->GetEntriesFast();
  for (Int_t i = 0; i < ncl; ++i)
  {
    IlcCluster   *cluster = (IlcCluster*) clarr->UncheckedAt(i);
    TEvePointSet *dest    = 0;
    if (cluster->IsClusterShared())
      dest = shared;
    else if (cluster->IsClusterUsed())
      dest = used;
    else
      dest = nonused;

    Float_t g[3]; //global coordinates
    cluster->GetGlobalXYZ(g);
    dest->SetNextPoint(g[0], g[1], g[2]);
    dest->SetPointId(cluster);
  }

  delete clarr;

  // ??? What to do with trackers ???
  // I'd propose: have global reconstruction that owns them.
  // IlcEveEventManager::AssertIlcReconstruction();
  // do we have bit-field for detectors, like
  // enum IlcDetectors_e {
  //    kITS = BIT(0),
  //    kTPC = BIT(1),
  //    ...
  //    kCentralTracking = kITS | kTPC | kTRD | kTOF,
  //    ...
  //  };

  gEve->Redraw3D();
}
Beispiel #10
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();


}
Beispiel #11
0
void fastGenPA(Int_t nev = 1, char* filename = "gilc.root")
{
//  Runloader
    IlcRunLoader* rl = IlcRunLoader::Open("gilc.root", "FASTRUN", "recreate");

    rl->SetCompressionLevel(2);
    rl->SetNumberOfEventsPerFile(10000);
    rl->LoadKinematics("RECREATE");
    rl->MakeTree("E");
    gIlc->SetRunLoader(rl);


//  Create stack
    rl->MakeStack();
    IlcStack* stack      = rl->Stack();
 
//  Header
    IlcHeader* header = rl->GetHeader();


//  Create and Initialize Generator
    IlcGenerator *gener = CreateGenerator();
    gener->Init();
    gener->SetStack(stack);
    
//
//                        Event Loop
//
    Int_t iev;
     
    for (iev = 0; iev < nev; iev++) {

	printf("\n \n Event number %d \n \n", iev);

	//  Initialize event

	header->Reset(0,iev);
	rl->SetEventNumber(iev);
	stack->Reset();
	rl->MakeTree("K");

//  Generate event

	gener->Generate();

//  Analysis
	Int_t npart = stack->GetNprimary();
	printf("Analyse %d Particles\n", npart);
	for (Int_t part=0; part<npart; part++) {
	    TParticle *MPart = stack->Particle(part);
	    Int_t mpart  = MPart->GetPdgCode();
	}
	
//  Finish event
	header->SetNprimary(stack->GetNprimary());
	header->SetNtrack(stack->GetNtrack());  
//      I/O
//	
	stack->FinishEvent();
	header->SetStack(stack);
	rl->TreeE()->Fill();
	rl->WriteKinematics("OVERWRITE");
    } // event loop
//
//                         Termination
//  Generator
    gener->FinishRun();

    //  Write file
    rl->WriteHeader("OVERWRITE");
    gener->Write();
    rl->Write();
}
Beispiel #12
0
void gen(Int_t nev = 1, char* filename = "gilc.root")
{
  // Load libraries
  // gSystem->SetIncludePath("-I$ROOTSYS/include -I$ILC_ROOT/include -I$ILC_ROOT");
  gSystem->Load("liblhapdf.so");      // Parton density functions
  gSystem->Load("libEGPythia6.so");   // TGenerator interface
  gSystem->Load("libpythia6.so");     // Pythia
  gSystem->Load("libIlcPythia6.so");  // ILC specific implementations

  IlcPDG::AddParticlesToPdgDataBase();
  TDatabasePDG::Instance();

  // Run loader
  IlcRunLoader* rl = IlcRunLoader::Open("gilc.root","FASTRUN","recreate");
  
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(nev);
  rl->LoadKinematics("RECREATE");
  rl->MakeTree("E");
  gIlc->SetRunLoader(rl);
  
  //  Create stack
  rl->MakeStack();
  IlcStack* stack = rl->Stack();
  
  //  Header
  IlcHeader* header = rl->GetHeader();
  
  //  Create and Initialize Generator
  gROOT->LoadMacro("$ILC_ROOT/test/vmctest/ppbench/genPPbenchConfig.C");
  IlcGenerator* gener = genPPbenchConfig();

  // Go to gilc.root
  rl->CdGAFile();

  // Forbid some decays. Do it after gener->Init(0, because
  // the initialization of the generator includes reading of the decay table.
  // ...

  //
  // Event Loop
  //
  
  TStopwatch timer;
  timer.Start();
  for (Int_t iev = 0; iev < nev; iev++) {
    
    cout <<"Event number "<< iev << endl;
    
    // Initialize event
    header->Reset(0,iev);
    rl->SetEventNumber(iev);
    stack->Reset();
    rl->MakeTree("K");
    
    // Generate event
    stack->Reset();
    stack->ConnectTree(rl->TreeK());
    gener->Generate();
    cout << "Number of particles " << stack->GetNprimary() << endl;
    
    // Finish event
    header->SetNprimary(stack->GetNprimary());
    header->SetNtrack(stack->GetNtrack());  
    
    // I/O
    stack->FinishEvent();
    header->SetStack(stack);
    rl->TreeE()->Fill();
    rl->WriteKinematics("OVERWRITE");
    
  } // event loop
  timer.Stop();
  timer.Print();
  
  //                         Termination
  //  Generator
  gener->FinishRun();
  //  Write file
  rl->WriteHeader("OVERWRITE");
  gener->Write();
  rl->Write();
}
Beispiel #13
0
void fastGen(Int_t nev = 1, char* filename = "gilc.root")
{
  // Run loader
  IlcRunLoader* rl = IlcRunLoader::Open("gilc.root","FASTRUN","recreate");
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(nev);
  rl->LoadKinematics("RECREATE");
  rl->MakeTree("E");
  gIlc->SetRunLoader(rl);
  
  //  Create stack
  rl->MakeStack();
  IlcStack* stack      = rl->Stack();
  
  //  Header
  IlcHeader* header = rl->GetHeader();
  
  //  Generator
  IlcGenPythia *gener = new IlcGenPythia(-1);
  gener->SetMomentumRange(0,999999);
  gener->SetProcess(kPyMb);
  gener->SetEnergyCMS(14000.);
  gener->SetThetaRange(45, 135);
  gener->SetPtRange(0., 1000.);
  gener->SetStack(stack);
  gener->Init();
  rl->CdGAFile();
  //
  //                        Event Loop
  //
  for (Int_t iev = 0; iev < nev; iev++) {
    
    //  Initialize event
    header->Reset(0,iev);
    rl->SetEventNumber(iev);
    stack->Reset();
    rl->MakeTree("K");
    
    //  Generate event
    Int_t nprim = 0;
    Int_t ntrial = 0;
    Int_t minmult = 1000;

    while(nprim<minmult) {
      // Selection of events with multiplicity
      // bigger than "minmult"
      stack->Reset();
      gener->Generate();
      ntrial++;
      nprim = stack->GetNprimary();
      
    }
    cout << "Number of particles " << nprim << endl;
    cout << "Number of trials " << ntrial << endl;
    
    //  Finish event
    header->SetNprimary(stack->GetNprimary());
    header->SetNtrack(stack->GetNtrack());  
    
    //      I/O
    stack->FinishEvent();
    header->SetStack(stack);
    rl->TreeE()->Fill();
    rl->WriteKinematics("OVERWRITE");
    
  } // event loop
  
  //                         Termination
  //  Generator
  gener->FinishRun();
  //  Stack
  stack->FinishRun();
  //  Write file
  rl->WriteHeader("OVERWRITE");
  gener->Write();
  rl->Write();
}
Beispiel #14
0
void commonConfig(ConfigVersion_t configVersion = kConfigV0)
{
  cout << "Running commonConfig.C ... " << endl;

    // Set Random Number seed
  gRandom->SetSeed(123456); // Set 0 to use the currecnt time
  IlcLog::Message(IlcLog::kInfo, Form("Seed for random number generation = %d",gRandom->GetSeed()), "Config.C", "Config.C", "Config()","Config.C", __LINE__);


  //=======================================================================
  // Load Pythia libraries
  //=======================================================================

  LoadPythia();

  //=======================================================================
  // ILC steering object (IlcRunLoader)
  //=======================================================================

  IlcRunLoader* rl 
    = IlcRunLoader::Open("gilc.root",
			  IlcConfig::GetDefaultEventFolderName(),
			  "recreate");
  if ( ! rl ) {
    gIlc->Fatal("Config.C","Can not instatiate the Run Loader");
    return;
  }
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(3);
  gIlc->SetRunLoader(rl);
  
  //======================================================================
  // Trigger configuration
  //=======================================================================

  IlcSimulation::Instance()->SetTriggerConfig(pprTrigConfName[strig]);
  cout << "Trigger configuration is set to  " << pprTrigConfName[strig] << endl;

  // ============================= 
  // Magnetic field
  // ============================= 

  // Field (L3 0.5 T)
  IlcMagF* field = new IlcMagF("Maps","Maps", -1., -1., IlcMagF::k5kG);
  TGeoGlobalMagField::Instance()->SetField(field);

  printf("\n \n Comment: %s \n \n", comment.Data());

  // ============================= 
  // Modules
  // ============================= 

  rl->CdGAFile();

  Int_t   iABSO  =  1;
  Int_t   iDIPO  =  1;
  Int_t   iFMD   =  1;
  Int_t   iFRAME =  1;
  Int_t   iHALL  =  1;
  Int_t   iITS   =  1;
  Int_t   iMAG   =  1;
  Int_t   iMUON  =  1;
  Int_t   iPHOS  =  1;
  Int_t   iPIPE  =  1;
  Int_t   iPMD   =  1;
  Int_t   iHMPID =  1;
  Int_t   iSHIL  =  1;
  Int_t   iT0    =  1;
  Int_t   iTOF   =  1;
  Int_t   iTPC   =  1;
  Int_t   iTRD   =  1;
  Int_t   iZDC   =  1;
  Int_t   iEMCAL =  1;
  Int_t   iACORDE = 1;
  Int_t   iVZERO =  1;

  rl->CdGAFile();
  //=================== Ilc BODY parameters =============================
  IlcBODY *BODY = new IlcBODY("BODY", "Ilc envelop");

  if (iMAG)
  {
      //=================== MAG parameters ============================
      // --- Start with Magnet since detector layouts may be depending ---
      // --- on the selected Magnet dimensions ---
      IlcMAG *MAG = new IlcMAG("MAG", "Magnet");
  }


  if (iABSO)
  {
      //=================== ABSO parameters ============================
      IlcABSO *ABSO = new IlcABSOv3("ABSO", "Muon Absorber");
  }

  if (iDIPO)
  {
      //=================== DIPO parameters ============================

      IlcDIPO *DIPO = new IlcDIPOv3("DIPO", "Dipole version 3");
  }

  if (iHALL)
  {
      //=================== HALL parameters ============================

      IlcHALL *HALL = new IlcHALLv3("HALL", "Ilc Hall");
  }


  if (iFRAME)
  {
      //=================== FRAME parameters ============================

      IlcFRAMEv2 *FRAME = new IlcFRAMEv2("FRAME", "Space Frame");
      FRAME->SetHoles(1);
  }

  if (iSHIL)
  {
      //=================== SHIL parameters ============================

      IlcSHIL *SHIL = new IlcSHILv3("SHIL", "Shielding Version 3");
  }


  if (iPIPE)
  {
      //=================== PIPE parameters ============================

      IlcPIPE *PIPE = new IlcPIPEv3("PIPE", "Beam Pipe");
  }
 
  if (iITS)
  {
      //=================== ITS parameters ============================

      IlcITS *ITS  = new IlcITSv11("ITS","ITS v11");
  }

  if (iTPC)
  {
      //============================ TPC parameters ===================
      IlcTPC *TPC = new IlcTPCv2("TPC", "Default");
  }


  if (iTOF) {
      //=================== TOF parameters ============================
      IlcTOF *TOF = new IlcTOFv6T0("TOF", "normal TOF");
  }


  if (iHMPID)
  {
      //=================== HMPID parameters ===========================
      IlcHMPID *HMPID = new IlcHMPIDv3("HMPID", "normal HMPID");

  }


  if (iZDC)
  {
      //=================== ZDC parameters ============================

      IlcZDC *ZDC = new IlcZDCv3("ZDC", "normal ZDC");
  }

  if (iTRD)
  {
      //=================== TRD parameters ============================

      IlcTRD *TRD = new IlcTRDv1("TRD", "TRD slow simulator");
      if ( configVersion == kConfigV1 ) {
        IlcTRDgeometry *geoTRD = TRD->GetGeometry();
        // Partial geometry: modules at 0,1,7,8,9,16,17
        // starting at 3h in positive direction
        geoTRD->SetSMstatus(2,0);
        geoTRD->SetSMstatus(3,0);
        geoTRD->SetSMstatus(4,0);
        geoTRD->SetSMstatus(5,0);
        geoTRD->SetSMstatus(6,0);
        geoTRD->SetSMstatus(11,0);
        geoTRD->SetSMstatus(12,0);
        geoTRD->SetSMstatus(13,0);
        geoTRD->SetSMstatus(14,0);
        geoTRD->SetSMstatus(15,0);
        geoTRD->SetSMstatus(16,0);
      }
  }

  if (iFMD)
  {
      //=================== FMD parameters ============================
      IlcFMD *FMD = new IlcFMDv1("FMD", "normal FMD");
  }

  if (iMUON)
  {
      //=================== MUON parameters ===========================
      // New MUONv1 version (geometry defined via builders)
      IlcMUON *MUON = new IlcMUONv1("MUON", "default");
  }
  //=================== PHOS parameters ===========================

  if (iPHOS)
  {
     if ( configVersion == kConfigV0 ) 
       IlcPHOS *PHOS = new IlcPHOSv1("PHOS", "IHEP");
     else if ( configVersion == kConfigV1 )  
       IlcPHOS *PHOS = new IlcPHOSv1("PHOS", "noCPV_Modules123"); 
  }


  if (iPMD)
  {
      //=================== PMD parameters ============================
      IlcPMD *PMD = new IlcPMDv1("PMD", "normal PMD");
  }

  if (iT0)
  {
      //=================== T0 parameters ============================
      IlcT0 *T0 = new IlcT0v1("T0", "T0 Detector");
  }

  if (iEMCAL)
  {
      //=================== EMCAL parameters ============================
    if ( configVersion == kConfigV0 ) 
      IlcEMCAL *EMCAL = new IlcEMCALv2("EMCAL", "EMCAL_COMPLETEV1");
    else if ( configVersion == kConfigV1 )  
      IlcEMCAL *EMCAL = new IlcEMCALv2("EMCAL", "EMCAL_FIRSTYEARV1");
  }

   if (iACORDE)
  {
      //=================== ACORDE parameters ============================
      IlcACORDE *ACORDE = new IlcACORDEv1("ACORDE", "normal ACORDE");
  }

   if (iVZERO)
  {
      //=================== VZERO parameters ============================
      IlcVZERO *VZERO = new IlcVZEROv7("VZERO", "normal VZERO");
  }

  IlcLog::Message(IlcLog::kInfo, "End of Config", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);

  cout << "Running commonConfig.C finished ... " << endl;
}
Beispiel #15
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;
}
Beispiel #16
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 #17
0
TEveElement*
kine_track(Int_t  label,
	   Bool_t import_mother, Bool_t import_daughters,
	   Bool_t pdg_col,       Bool_t recurse,
           TEveElement* cont)
{
  // Create mother and daughters tracks with given label.
  // mother     -> particle with label
  // daughters  -> daughters of label

  if (label < 0) {
    Warning("kine_track", "label not set.");
    return 0;
  }

  IlcRunLoader* rl =  IlcEveEventManager::AssertRunLoader();
  rl->LoadKinematics();
  IlcStack* stack = rl->Stack();
  if (!stack)
  {
     Warning("kine_track", "can not get kinematics.");
    return 0;
  }
  if (label >= stack->GetNtrack())
  {
    Warning("kine_track", "label out of range.");
    return 0;
  }

  TParticle* p = stack->Particle(label);

  if (import_mother || (import_daughters && p->GetNDaughters()))
  {
    TEveTrackPropagator* rs = 0;

    if (cont == 0)
    {
      TEveTrackList* tlist = new TEveTrackList
	(Form("Kinematics of %d %d", label, p->GetNDaughters()));
      cont = tlist;

      TEveTrackPropagator* trkProp = tlist->GetPropagator();

      kine_track_propagator_setup(trkProp);

      char tooltip[1000];
      sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters());
      tlist->SetTitle(tooltip);
      trkProp->SetMaxOrbs(2);
      trkProp->SetEditPathMarks(kTRUE);

      gEve->AddElement(cont);
      rs = tlist->GetPropagator();
    }
    else
    {
      // check if container is TEveTrackList or IlcEveTrack (has rnr-style)
      IlcEveTrack* t = dynamic_cast<IlcEveTrack*>(cont);
      if (t) {
	rs = t->GetPropagator();
      } else {
        TEveTrackList* l = dynamic_cast<TEveTrackList*>(cont);
        if (l)
	  rs = l->GetPropagator();
        else
	  Error("kine_tracks.C", "TrackRenderStyle not set.");
      }
    }

    if (import_mother)
    {
      IlcEveTrack* track = new IlcEveTrack(p, label, rs);
      char form[1000];
      sprintf(form,"%s [%d]", p->GetName(), label);
      track->SetName(form);
      track->SetStdTitle();
      set_track_color(track, pdg_col);

      track->MakeTrack();
      gEve->AddElement(track, cont);
      cont = track;
    }

    if (import_daughters && p->GetNDaughters())
    {
      for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
      {
	TParticle* dp = stack->Particle(d);
	IlcEveTrack* track = new IlcEveTrack(dp, d, rs);
	char form[1000];
	sprintf(form,"%s [%d]", dp->GetName(), d);
	track->SetName(form);
	track->SetStdTitle();
	set_track_color(track, pdg_col);

        track->MakeTrack();
	gEve->AddElement(track, cont);

	if (recurse)
	  kine_daughters(track, stack, 0, 0, pdg_col, recurse);
      }
    }
  }

  gEve->Redraw3D();
  return cont;
}