コード例 #1
0
ファイル: mergeByComponent.C プロジェクト: ktf/AliPhysics
//___________________________________________________________________
void MakeFileList(const char *searchdir, const char *pattern, const char* outputFileName="calib.list", Int_t timeOut=10)
{
  gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut));
  gEnv->SetValue("XNet.RequestTimeout", timeOut);
  gEnv->SetValue("XNet.ConnectTimeout", timeOut);
  gEnv->SetValue("XNet.TransactionTimeout", timeOut);
  TFile::SetOpenTimeout(timeOut);

  TGrid::Connect("alien");

  TString command;
  command = Form("find %s %s", searchdir, pattern);
  cerr<<"command: "<<command<<endl;
  TGridResult *res = gGrid->Command(command);
  if (!res) return;
  TIter nextmap(res);
  TMap *map = 0;

  ofstream outputFile;
  outputFile.open(Form(outputFileName));

  //first identify the largest file and put it at the beginning
  Int_t largestFileSize=0;
  TString largestFile;
  TObject* largestObject;
  while((map=(TMap*)nextmap()))
  {
    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
    TObjString *objsSize = dynamic_cast<TObjString*>(map->GetValue("size"));
    if (!objs || !objs->GetString().Length()) continue;
    if (!objsSize || !objsSize->GetString().Length()) continue;

    Int_t currentFileSize=objsSize->GetString().Atoi();
    if (currentFileSize>largestFileSize) 
    {
      largestFileSize=currentFileSize;
      largestFile=objs->GetString();
      largestObject=map;
    }
  }
  outputFile << largestFile.Data()<< endl;
  res->Remove(largestObject);
  
  //then write the rest of the entries to the file
  nextmap.Reset();
  while((map=(TMap*)nextmap()))
  {
    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
    if (!objs || !objs->GetString().Length())
    {
      delete res;
      break;
    }

    TString src=Form("%s",objs->GetString().Data());
    outputFile << src.Data()<< endl;
  }
  outputFile.close();
  return;
}
コード例 #2
0
ファイル: mergeFiles.C プロジェクト: ekfriis/farmout
void WriteMergeObjects( TFile *target ) {
  cout << "Writing the merged data." << endl;

  TIterator *nextobj = MergeObjects.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TObject *obj = MergeObjects.GetValue(pathname_obj);
    target->cd(path);

    obj->Write( name );

    delete obj;
  }
  MergeObjects.Clear();

  target->Write();

  // Temporarily let multiple root files remain if > 2GB
  // Prevent Target_1.root Target_2.root, ... from happening.
  //  long long max_tree_size = 200000000000LL; // 200 GB
  //  if(TTree::GetMaxTreeSize() < max_tree_size ) {
  //    TTree::SetMaxTreeSize(max_tree_size);
  //  }

  nextobj = MergeChains.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TChain *ch = (TChain *)MergeChains.GetValue(pathname_obj);
    target->cd(path);
    ch->Merge(target,0,"KEEP");

    delete ch;

	// in case of multiple objects with same pathname, must remove
	// this one from the list so we don't get the same (deleted)
	// one next time we look up the same name
	MergeChains.Remove(pathname_obj);
  }
  MergeChains.Clear();

  InitializedMergeObjects = false;
}
コード例 #3
0
void MergeFlowd() 
{
	TGrid *alien = TGrid::Connect("alien");
	if (alien->IsZombie())
	{
		delete alien;
		cout << "Fatal: Alien is a zombie!" << endl;
		return;
	}

  Int_t runlist[] = {                                                               // Counter
    /*170309, 170308, 170306, 170270, 170269, 170268, 170230, 170228,*/ 170204, 170203, // 10
    170193, 170163, 170159, 170155, 170081, 170027, 169859, 169858, 169855, 169846, // 20
    169838, 169837, 169835, 169417, 169415, 169411, 169238, 169167, 169160, 169156, // 30
    169148, 169145, 169144, 169138, 169094, 169091, 169035, 168992, 168988, 168826, // 40
    168777, 168514, 168512, 168511, 168467, 168464, 168460, 168458, 168362, 168361, // 50
    168342, 168341, 168325, 168322, 168311, 168310, 167988, 167987                  // 58
  };	

  TFileMerger merger;
  TString dataBaseDir = "/alice/cern.ch/user/m/mpuccio/Flowd_PbPb2011/output/000";
  merger.OutputFile("FileMerger.root");
  for (int iRun = 0; iRun < 1; ++iRun)
  {
  	TString runDir = Form("%s%i",dataBaseDir.Data(),runlist[iRun]);
  	TGridResult *res = alien->Command(Form("find %s */mpuccio_Flowd.root",runDir.Data()));
  	TIter iter(res);
  	TMap *map;
  	while ((map = (TMap*)iter())) 
  	{
  		TObjString *obj = dynamic_cast<TObjString*>(map->GetValue("turl"));
  		if (!obj || !obj->String().Length())
  		{
  			delete res;
  			break;
  		}

  		TFile *f = TFile::Open(obj->String().Data());
  		if (!f->IsOpen())
  		{
  			cout << "File " << obj->String().Data() << " has some problems..." << endl;
  			continue;
  		}
  		merger.AddFile(f);
  		merger.PartialMerge();
  		f->Close();
  	}
  }
  merger.Merge();
  merger.Write();
}
コード例 #4
0
ファイル: runGridpPb.C プロジェクト: ktf/AliPhysics
bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){
        //
        // Find Data sample in the list of samples
        //
        TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data()));
        if(!entry){
                printf("Sample %s not found in the list of samples", g_sample.Data());
                return false;
        }
        // Copy to output container
        sampleinfis.SetOwner(kFALSE);
        for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival);
        return true;
}
コード例 #5
0
ファイル: mergeFiles.C プロジェクト: ekfriis/farmout
void MergeRootfile( TDirectory *target, TString source_name ) {

  TFile *source = NULL;
  if( !InitializedMergeObjects ) {
    InitializedMergeObjects = true;
    source = TFile::Open(source_name);
    cout << "Initializing merge objects from " << source_name << endl;
    InitMergeObjects( target, source );
    delete source;
    return;
  }

  // loop over all objects to be merged
  TIterator *nextobj = MergeObjects.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TObject *obj = MergeObjects.GetValue(pathname_obj);

    if ( obj->IsA()->InheritsFrom( "TH1" ) ) {
      // descendant of TH1 -> merge it

      TH1 *h1 = (TH1*)obj;

      if( !source ) {
        source = TFile::Open(source_name);
      }
      // make sure we are at the correct directory level by cd'ing to path
      source->cd( path );
      TH1 *h2 = (TH1*)gDirectory->Get( h1->GetName() );
      if ( h2 ) {
        h1->Add( h2 );
        delete h2;
      }
    }
  }

  delete nextobj;
  nextobj = NULL;

  // loop over all chains to be merged
  nextobj = MergeChains.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TChain *ch = (TChain *)MergeChains.GetValue(pathname_obj);

    ch->Add(source_name);
  }

  delete nextobj;
  nextobj = NULL;

  if( source ) {
    delete source;
  }
}
コード例 #6
0
ファイル: r3ball.C プロジェクト: malabi/R3BRoot
void r3ball(Int_t nEvents = 1,
	    TMap& fDetList,
            TString Target = "LeadTarget",
            Bool_t fVis = kFALSE,
            TString fMC = "TGeant3",
            TString fGenerator = "box",
            Bool_t fUserPList = kFALSE,
            Bool_t fR3BMagnet = kTRUE,
            Bool_t fCalifaHitFinder = kFALSE,
            Bool_t fStarTrackHitFinder = kFALSE,
            Double_t fMeasCurrent = 2000.,
            TString OutFile = "r3bsim.root",
            TString ParFile = "r3bpar.root",
            TString InFile = "evt_gen.dat",
            double energy1, double energy2)
{


  TString dir = getenv("VMCWORKDIR");
  TString r3bdir = dir + "/macros";
  
  TString r3b_geomdir = dir + "/geometry";
  gSystem->Setenv("GEOMPATH",r3b_geomdir.Data());
  
  TString r3b_confdir = dir + "gconfig";
  gSystem->Setenv("CONFIG_DIR",r3b_confdir.Data());
  
  // In general, the following parts need not be touched
  // ========================================================================
  
  // ----    Debug option   -------------------------------------------------
  gDebug = 0;
  // ------------------------------------------------------------------------
  
  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  // ------------------------------------------------------------------------
  
  
  // -----   Create simulation run   ----------------------------------------
  FairRunSim* run = new FairRunSim();
  run->SetName(fMC.Data());              // Transport engine
  run->SetOutputFile(OutFile.Data());          // Output file
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
  
  FairLogger::GetLogger()->SetLogScreenLevel("DEBUG");
  
  //  R3B Special Physics List in G4 case
  if ( (fUserPList  == kTRUE ) &&
       (fMC.CompareTo("TGeant4")   == 0)
      ){
    run->SetUserConfig("g4R3bConfig.C");
    run->SetUserCuts("SetCuts.C");
  }
  
  
  // -----   Create media   -------------------------------------------------
  run->SetMaterials("media_r3b.geo");       // Materials
  
  
  // Magnetic field map type
  Int_t fFieldMap = 0;
  
  
  // Global Transformations
  //- Two ways for a Volume Rotation are supported
  //-- 1) Global Rotation (Euler Angles definition)
  //-- This represent the composition of : first a rotation about Z axis with
  //-- angle phi, then a rotation with theta about the rotated X axis, and
  //-- finally a rotation with psi about the new Z axis.
  Double_t phi,theta,psi;
  
  //-- 2) Rotation in Ref. Frame of the Volume
  //-- Rotation is Using Local Ref. Frame axis angles
  Double_t thetaX,thetaY,thetaZ;
  

  //- Global Translation  Lab. frame.
  Double_t tx,ty,tz;
  
  
  // -----   Create R3B geometry --------------------------------------------
  //R3B Cave definition
  FairModule* cave= new R3BCave("CAVE");
  cave->SetGeometryFileName("r3b_cave.geo");
  run->AddModule(cave);
  

  //R3B Target definition
  if (fDetList.FindObject("TARGET") ) {
    R3BModule* target= new R3BTarget(Target.Data());
    target->SetGeometryFileName(((TObjString*)fDetList.GetValue("TARGET"))->GetString().Data());
    run->AddModule(target);
  }
  
  //R3B SiTracker Cooling definition
  if (fDetList.FindObject("VACVESSELCOOL") ) {
    R3BModule* vesselcool= new R3BVacVesselCool(Target.Data());
    vesselcool->SetGeometryFileName(((TObjString*)fDetList.GetValue("VACVESSELCOOL"))->GetString().Data());
    run->AddModule(vesselcool);
  }
  //R3B Magnet definition
  if (fDetList.FindObject("ALADIN") ) {
    fFieldMap = 0;
    R3BModule* mag = new R3BMagnet("AladinMagnet");
    mag->SetGeometryFileName(((TObjString*)fDetList.GetValue("ALADIN"))->GetString().Data());
    run->AddModule(mag);
  }
  
  //R3B Magnet definition
  if (fDetList.FindObject("GLAD") ) {
    fFieldMap = 1;
    R3BModule* mag = new R3BGladMagnet("GladMagnet", ((TObjString*)fDetList->GetValue("GLAD"))->GetString(), "GLAD Magnet");
    run->AddModule(mag);
  }
  
  if (fDetList.FindObject("CRYSTALBALL") ) {
    //R3B Crystal Calorimeter
    R3BDetector* xball = new R3BXBall("XBall", kTRUE);
    xball->SetGeometryFileName(((TObjString*)fDetList.GetValue("CRYSTALBALL"))->GetString().Data());
    run->AddModule(xball);
  }
  
  if (fDetList.FindObject("CALIFA") ) {
    // CALIFA Calorimeter
    R3BDetector* califa = new R3BCalifa("Califa", kTRUE);
//    ((R3BCalifa *)califa)->SelectGeometryVersion(0x438b);
    ((R3BCalifa *)califa)->SelectGeometryVersion(17);
    //Selecting the Non-uniformity of the crystals (1 means +-1% max deviation)
    ((R3BCalifa *)califa)->SetNonUniformity(.0);
    califa->SetGeometryFileName(((TObjString*)fDetList.GetValue("CALIFA"))->GetString().Data());
    run->AddModule(califa);
  }

  // Tracker
  if (fDetList.FindObject("TRACKER")  ) {
    R3BDetector* tra = new R3BTra("Tracker", kTRUE);
    tra->SetGeometryFileName(((TObjString*)fDetList.GetValue("TRACKER"))->GetString().Data());
    run->AddModule(tra);
  }
  
  // STaRTrack
  if (fDetList.FindObject("STaRTrack")  ) {
    R3BDetector* tra = new R3BSTaRTra("STaRTrack", kTRUE);
    tra->SetGeometryFileName(((TObjString*)fDetList.GetValue("STaRTrack"))->GetString().Data());
    run->AddModule(tra);
  }
  
  // DCH drift chambers
  if (fDetList.FindObject("DCH") ) {
    R3BDetector* dch = new R3BDch("Dch", kTRUE);
    dch->SetGeometryFileName(((TObjString*)fDetList.GetValue("DCH"))->GetString().Data());
    run->AddModule(dch);
  }
  
  // Tof
  if (fDetList.FindObject("TOF") ) {
    R3BDetector* tof = new R3BTof("Tof", kTRUE);
    tof->SetGeometryFileName(((TObjString*)fDetList.GetValue("TOF"))->GetString().Data());
    run->AddModule(tof);
  }
  
  // mTof
  if (fDetList.FindObject("MTOF") ) {
    R3BDetector* mTof = new R3BmTof("mTof", kTRUE);
    mTof->SetGeometryFileName(((TObjString*)fDetList.GetValue("MTOF"))->GetString().Data());
    run->AddModule(mTof);
  }

  // GFI detector
  if (fDetList.FindObject("GFI") ) {
    R3BDetector* gfi = new R3BGfi("Gfi", kTRUE);
    gfi->SetGeometryFileName(((TObjString*)fDetList.GetValue("GFI"))->GetString().Data());
    run->AddModule(gfi);
  }
  
  // Land Detector
  if (fDetList.FindObject("LAND") ) {
    R3BDetector* land = new R3BLand("Land", kTRUE);
    land->SetVerboseLevel(1);
    land->SetGeometryFileName(((TObjString*)fDetList.GetValue("LAND"))->GetString().Data());
    run->AddModule(land);
  }
  
  // NeuLand Scintillator Detector
  if(fDetList.FindObject("SCINTNEULAND")) {
    R3BDetector* land = new R3BLand("Land", kTRUE);
    land->SetVerboseLevel(1);
    land->SetGeometryFileName(((TObjString*)fDetList.GetValue("SCINTNEULAND"))->GetString().Data());
    run->AddModule(land);
  }
  
  // MFI Detector
  if(fDetList.FindObject("MFI")) {
    R3BDetector* mfi = new R3BMfi("Mfi", kTRUE);
    mfi->SetGeometryFileName(((TObjString*)fDetList.GetValue("MFI"))->GetString().Data());
    run->AddModule(mfi);
  }

  // PSP Detector
  if(fDetList.FindObject("PSP")) {
    R3BDetector* psp = new R3BPsp("Psp", kTRUE);
    psp->SetGeometryFileName(((TObjString*)fDetList.GetValue("PSP"))->GetString().Data());
    run->AddModule(psp);
  }
  
  // Luminosity detector
  if (fDetList.FindObject("LUMON") ) {
    R3BDetector* lumon = new ELILuMon("LuMon", kTRUE);
    lumon->SetGeometryFileName(((TObjString*)fDetList.GetValue("LUMON"))->GetString().Data());
    run->AddModule(lumon);
  }
  
  // -----   Create R3B  magnetic field ----------------------------------------
  Int_t typeOfMagneticField = 0;
  Int_t fieldScale = 1;
  Bool_t fVerbose = kFALSE;
  
  //NB: <D.B>
  // If the Global Position of the Magnet is changed
  // the Field Map has to be transformed accordingly
  if (fFieldMap == 0) {
    R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps");
    magField->SetCurrent(fMeasCurrent);
    magField->SetScale(fieldScale);
    
    if ( fR3BMagnet == kTRUE ) {
      run->SetField(magField);
    } else {
      run->SetField(NULL);
    }
  } else if(fFieldMap == 1){
    R3BGladFieldMap* magField = new R3BGladFieldMap("R3BGladMap");
    magField->SetScale(fieldScale);
    
    if ( fR3BMagnet == kTRUE ) {
      run->SetField(magField);
    } else {
      run->SetField(NULL);
    }
  }  //! end of field map section
  
  // -----   Create PrimaryGenerator   --------------------------------------

  // 1 - Create the Main API class for the Generator
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  
  if (fGenerator.CompareTo("ion") == 0  ) {
          // R3B Ion Generator
          Int_t z = 30;  // Atomic number
          Int_t a = 65; // Mass number
          Int_t q = 0;   // Charge State 
          Int_t m = 1;   // Multiplicity
          Double_t px = 40./a;  // X-Momentum / per nucleon!!!!!!
          Double_t py = 600./a;  // Y-Momentum / per nucleon!!!!!!
          Double_t pz = 0.01/a;  // Z-Momentum / per nucleon!!!!!!
          R3BIonGenerator* ionGen = new R3BIonGenerator(z,a,q,m,px,py,pz);
          ionGen->SetSpotRadius(1,1,0);
          // add the ion generator
          primGen->AddGenerator(ionGen);
  }

  if (fGenerator.CompareTo("ascii") == 0  ) {
    R3BAsciiGenerator* gen = new R3BAsciiGenerator((dir+"/input/"+InFile).Data());
    primGen->AddGenerator(gen);
  }
  

  if (fGenerator.CompareTo("box") == 0  ) {
	  // 2- Define the BOX generator
	  Double_t pdgId=2212; // proton beam
	  Double_t theta1= 25.;  // polar angle distribution
	  //Double_t theta2= 7.;
	  Double_t theta2= 66.;
//	  Double_t momentum=1.09008; // 500 MeV/c
//	  Double_t momentum=0.4445834; // 100 MeV/c
          Double_t momentum1=TMath::Sqrt(energy1*energy1 + 2*energy1*0.938272046);
          Double_t momentum2=TMath::Sqrt(energy2*energy2 + 2*energy2*0.938272046);
	  FairBoxGenerator* boxGen = new FairBoxGenerator(pdgId, 1);
	  boxGen->SetThetaRange (   theta1,   theta2);
	  boxGen->SetPRange     (momentum1,momentum2);
	  boxGen->SetPhiRange   (0,360.);
	  //boxGen->SetXYZ(0.0,0.0,-1.5);
	  boxGen->SetXYZ(0.0,0.0,0.0);
          boxGen->SetDebug(kFALSE);
	  // add the box generator
	  primGen->AddGenerator(boxGen);

          //primGen->SetTarget(0.25, 0.5);
          //primGen->SmearVertexZ(kTRUE);
  } 
	
  if (fGenerator.CompareTo("gammas") == 0  ) {
        // 2- Define the CALIFA Test gamma generator
        //Double_t pdgId=22; // gamma emission
        Double_t pdgId=2212; // proton emission
        Double_t theta1= 10.;  // polar angle distribution
        Double_t theta2= 40.;
        //Double_t theta2= 90.; 
        //Double_t momentum=0.002; // 0.010 GeV/c = 10 MeV/c 
        Double_t momentumI=0.002; // 0.010 GeV/c = 10 MeV/c 
        Double_t momentumF=0.002; // 0.010 GeV/c = 10 MeV/c 
        //Double_t momentumF=0.808065; // 0.808065 GeV/c (300MeV Kin Energy for protons) 
        //Double_t momentumI=0.31016124; // 0.31016124 GeV/c (50MeV Kin Energy for protons)
        //Double_t momentum=0.4442972; // 0.4442972 GeV/c (100MeV Kin Energy for protons)
        //Double_t momentum=0.5509999; // 0.5509999 GeV/c (150MeV Kin Energy for protons)
        //Double_t momentumI=0.64405; // 0.64405 GeV/c (200MeV Kin Energy for protons) 
        Int_t multiplicity = 1;
        R3BCALIFATestGenerator* gammasGen = new R3BCALIFATestGenerator(pdgId, multiplicity);
        gammasGen->SetThetaRange (theta1,   theta2);
        gammasGen->SetCosTheta();
        gammasGen->SetPRange(momentumI,momentumF);
        gammasGen->SetPhiRange(-180.,180.);
        //gammasGen->SetXYZ(0.0,0.0,-1.5);
        //gammasGen->SetXYZ(0.0,0.0,0);
        gammasGen->SetBoxXYZ(-0.1,0.1,-0.1,0.1,-0.1,0.1);
        //gammasGen->SetLorentzBoost(0.8197505718204776); //beta=0.81975 for 700 A MeV
        // add the gamma generator
        primGen->AddGenerator(gammasGen);
  }


  if (fGenerator.CompareTo("r3b") == 0  ) {
    R3BSpecificGenerator *pR3bGen = new R3BSpecificGenerator();
    
    // R3bGen properties
    pR3bGen->SetBeamInteractionFlag("off");
    pR3bGen->SetRndmFlag("off");
    pR3bGen->SetRndmEneFlag("off");
    pR3bGen->SetBoostFlag("off");
    pR3bGen->SetReactionFlag("on");
    pR3bGen->SetGammasFlag("off");
    pR3bGen->SetDecaySchemeFlag("off");
    pR3bGen->SetDissociationFlag("off");
    pR3bGen->SetBackTrackingFlag("off");
    pR3bGen->SetSimEmittanceFlag("off");
    
    // R3bGen Parameters
    pR3bGen->SetBeamEnergy(1.); // Beam Energy in GeV
    pR3bGen->SetSigmaBeamEnergy(1.e-03); // Sigma(Ebeam) GeV
    pR3bGen->SetParticleDefinition(2212); // Use Particle Pdg Code
    pR3bGen->SetEnergyPrim(0.3); // Particle Energy in MeV
    Int_t fMultiplicity = 50;
    pR3bGen->SetNumberOfParticles(fMultiplicity); // Mult.
    
    // Reaction type
    //        1: "Elas"
    //        2: "iso"
    //        3: "Trans"
    pR3bGen->SetReactionType("Elas");
    
    // Target  type
    //        1: "LeadTarget"
    //        2: "Parafin0Deg"
    //        3: "Parafin45Deg"
    //        4: "LiH"
    
    pR3bGen->SetTargetType(Target.Data());
    Double_t thickness = (0.11/2.)/10.;  // cm
    pR3bGen->SetTargetHalfThicknessPara(thickness); // cm
    pR3bGen->SetTargetThicknessLiH(3.5); // cm
    pR3bGen->SetTargetRadius(1.); // cm
    
    pR3bGen->SetSigmaXInEmittance(1.); //cm
    pR3bGen->SetSigmaXPrimeInEmittance(0.0001); //cm
    
    // Dump the User settings
    pR3bGen->PrintParameters();
    primGen->AddGenerator(pR3bGen);
  }
  
  if (fGenerator.CompareTo("p2p") == 0  ) {
    R3Bp2pGenerator* gen = new R3Bp2pGenerator(("/lustre/nyx/fairgsi/mwinkel/r3broot/input/p2p/build/" + InFile).Data());
    primGen->AddGenerator(gen);

#if 0
    // Coincident gammas
    R3BGammaGenerator *gammaGen = new R3BGammaGenerator();
    
    gammaGen->SetEnergyLevel(0, 0.);
    gammaGen->SetEnergyLevel(1, 3E-3);
    gammaGen->SetEnergyLevel(2, 4E-3);

    gammaGen->SetBranchingRatio(2, 1, 0.5);
    gammaGen->SetBranchingRatio(2, 0, 0.5);
    gammaGen->SetBranchingRatio(1, 0, 1.);

    gammaGen->SetInitialLevel(2);

    gammaGen->SetLorentzBoost(TVector3(0, 0, 0.777792));

    primGen->AddGenerator(gammaGen);
#endif
  }

  run->SetGenerator(primGen);
  
  
  //-------Set visualisation flag to true------------------------------------
  run->SetStoreTraj(fVis);
  

  FairLogger::GetLogger()->SetLogVerbosityLevel("LOW");

 
  // ----- Initialize CalifaHitFinder task (CrystalCal to Hit) ------------------------------------
  if(fCalifaHitFinder) {
    R3BCalifaCrystalCal2Hit* califaHF = new R3BCalifaCrystalCal2Hit();
    califaHF->SetClusteringAlgorithm(1,0);
    califaHF->SetDetectionThreshold(0.000050);//50 KeV
    califaHF->SetExperimentalResolution(6.);  //percent @ 1 MeV
    //califaHF->SetComponentResolution(.25);    //sigma = 0.5 MeV
    califaHF->SetPhoswichResolution(3.,5.);   //percent @ 1 MeV for LaBr and LaCl 
    califaHF->SelectGeometryVersion(17);
    califaHF->SetAngularWindow(0.25,0.25);      //[0.25 around 14.3 degrees, 3.2 for the complete calorimeter]
    run->AddTask(califaHF);
  }

  // ----- Initialize StarTrackHitfinder task ------------------------------------
  if(fStarTrackHitFinder) {
    R3BSTaRTraHitFinder* trackHF = new R3BSTaRTraHitFinder();
    //trackHF->SetClusteringAlgorithm(1,0);
    trackHF->SetDetectionThreshold(0.000050); //50 KeV
    trackHF->SetExperimentalResolution(0.);
    //trackHF->SetAngularWindow(0.15,0.15);      //[0.25 around 14.3 degrees, 3.2 for the complete calorimeter]
    run->AddTask(trackHF);
  }
  
	
  // -----   Initialize simulation run   ------------------------------------
  run->Init();

  // ------  Increase nb of step for CALO
  Int_t nSteps = 150000;
  TVirtualMC::GetMC()->SetMaxNStep(nSteps);
  
  
  // -----   Runtime database   ---------------------------------------------
  R3BFieldPar* fieldPar = (R3BFieldPar*) rtdb->getContainer("R3BFieldPar");
      fieldPar->SetParameters(magField);
      fieldPar->setChanged();
  Bool_t kParameterMerged = kTRUE;
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
  parOut->open(ParFile.Data());
  rtdb->setOutput(parOut);
  rtdb->saveOutput();
  rtdb->print();
  
  
  // -----   Start run   ----------------------------------------------------
  if(nEvents > 0) {
    run->Run(nEvents);
  }
  
  
  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished succesfully." << endl;
  cout << "Output file is "    << OutFile << endl;
  cout << "Parameter file is " << ParFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime
  << "s" << endl << endl;
  // ------------------------------------------------------------------------

  cout << " Test passed" << endl;
  cout << " All ok " << endl;

}
コード例 #7
0
ファイル: raw2treeGrid_collection.C プロジェクト: ktf/AliRoot
void raw2treeGrid_collection()
{

  // reading RAW data from test LCS
  // filling histograms
  // fillinf tree
  //  gROOT->LoadMacro("loadlibs.C");
  //  loadlibs();
  Int_t allData[220][5];
  TGrid::Connect("alien://");
  TTree *fT0OutTree=new TTree("t0tree","None here");
 TAlienCollection *collnum = TAlienCollection::Open("wn.xml");
  Int_t numrun;
  collnum->Reset();
  collnum->Next();
  TString buf_runnum;
  TString buf_path = collnum->GetTURL() ;
  for(int i=0; i<buf_path.Length();i++)	{
    if(buf_path(i,4)=="/raw")	{
      buf_runnum = buf_path(i-6,6);
      numrun = buf_runnum.Atoi();
      break;
    }
  }
  
  TString names[220];
  Int_t chvalue[220], meanchvalue[220];
  AliT0LookUpKey* lookkey= new AliT0LookUpKey();
  AliT0LookUpValue*  lookvalue= new AliT0LookUpValue();
  AliCDBManager * man = AliCDBManager::Instance();
  man->SetDefaultStorage("raw://");
  man->SetRun(numrun);
  AliT0Parameters *fParam = AliT0Parameters::Instance();
  fParam->Init(); 
  TMap *lookup = fParam->GetMapLookup();
  TMapIter *iter = new TMapIter(lookup);
  for( Int_t iline=0; iline<212; iline++)
    {
      lookvalue = ( AliT0LookUpValue*) iter->Next();
      lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);      
      if(lookkey){
	Int_t key=lookkey->GetKey();
	names[key]=lookkey->GetChannelName();
	fT0OutTree->Branch(Form("%s",names[key].Data()), &chvalue[key]);
      }
      else
	{printf(" no such value %i \n", iline);}
    } 
  Float_t meanCFD[24], meanQT1[24];
 
  for (int ich=0; ich<24; ich++) {
    meanCFD[ich] = fParam->GetCFD(ich);
    meanQT1[ich] = fParam->GetQT1(ich);
  }
  Float_t meanOrA = fParam->GetMeanOrA();
  Float_t meanOrC = fParam->GetMeanOrC();
  Float_t meanTVDC = fParam->GetMeanVertex();
  //new QTC

  Float_t qt01mean[28] = {18712.5, 18487.5, 18487.5, 18537.5, 
  			  18562.5, 18462.5, 18537.5, 18537.5, 
			  18537.5, 18587.5, 18587.5, 18512.5,
			   18512.5, 18512.5, 18487.5, 18562.5,
			    18537.5, 18512.5, 18537.5, 18537.5,
			     18512.5, 18587.5, 18562.5, 18512.5,
		      18358, 18350, 18374, 18362};
  Float_t qt11mean[28] = {18705, 18495, 18465, 18555, 
  			18555, 18435, 18525, 18525, 
			18525, 18585, 18585, 18495, 
			18495, 18525, 18465, 18555, 
			18525, 18495, 18555, 18495, 
			18495, 18585, 18585, 18495,
		      18358, 18350, 18374, 18362};
  Int_t ind[26];
  for (int iii=0; iii<12; iii++) ind[iii]=25;
  for (int iii=12; iii<24; iii++) ind[iii]=57;

  UInt_t event;
   fT0OutTree->Branch("event", &event);
   ULong64_t triggerMask;
   fT0OutTree->Branch("triggers", &triggerMask);
    TAlienCollection *coll = TAlienCollection::Open("wn.xml");
      coll->Reset();
    
   AliRawReader *reader;
while (coll->Next()) {
    TString	fFileName=coll->GetTURL();
     //READ DATA
 //     TString	fFileName=Form("alien:///alice/data/2015/LHC15i/000%i/raw/15000%i028.%i.root", numrun, numrun, chunk);
      reader = new AliRawReaderRoot(fFileName);
     if(!reader) continue;

     reader = new AliRawReaderRoot(fFileName);     
     if(!reader) continue;
//     reader->LoadEquipmentIdsMap("T0map.txt");
     reader->RequireHeader(kTRUE);
     for (Int_t i0=0; i0<220; i0++) {
       chvalue[i0] = 0;
       for (Int_t j0=0; j0<5; j0++)  allData[i0][j0]=0; 
     }
     
     AliT0RawReader *start = new AliT0RawReader(reader);
     while (reader->NextEvent()) {
       start->Next();
       for (Int_t ii=0; ii<211; ii++) {
	 chvalue[ii] = 0;
	 for (Int_t iHit=0; iHit<5; iHit++) 
	   {
	     allData[ii][iHit]= start->GetData(ii,iHit);
	     //   	if(allData[ii][iHit]>0) cout<<ii<<" "<<allData[ii][iHit]<<endl;
	   }
       } 
       
       const  UInt_t type =reader->GetType();
       if(type != 7) continue;
       triggerMask  = reader->GetClassMask();
       
        for (Int_t iHit=0; iHit<5; iHit++) {
         if( allData[50][iHit]>meanTVDC-800 && allData[50][iHit]<meanTVDC+800) {
	 chvalue[50]=allData[50][iHit];
         break;
         }
       } 
       
        for (Int_t in=0; in<24;  in++)
	 {
	   for (Int_t iHit=0; iHit<5; iHit++)  //old QTC C side
	     {
	       if (allData[2*in+ind[in]+1][iHit] > meanQT1[in]-800 &&  
		   allData[2*in+ind[in]+1][iHit] < meanQT1[in]+800 ) {
		 chvalue[2*in+ind[in]+1] = allData[2*in+ind[in]+1][iHit];
		 break;
	       }
	     }
	   for (Int_t iHit=0; iHit<5; iHit++)  //old QTC A side
	     {
	       if( (allData[2*in+ind[in]][iHit] > chvalue[2*in+ind[in]+1]) &&
		   chvalue[2*in+ind[in]+1]>0)
		 {
		   chvalue[2*in+ind[in]] = allData[2*in+ind[in]][iHit];
		//   printf("index %i  pmt %i QTC old start %i stop %i \n", 
		//   2*in+ind[in], in,
		 //  chvalue[2*in+ind[in]+1], chvalue[2*in+ind[in]]);
		   break;
		 }
	     }
	 }
       for (Int_t in=0; in<12; in++)  
	 {
	   chvalue[in+68+1] = allData[in+68+1][0] ;
	   chvalue[in+12+1] = allData[in+12+1][0] ;
	   for (Int_t iHit=0; iHit<5; iHit++)  //CFD C side
	     {
	       if(allData[in+1][iHit] > meanCFD[in]-800 && 
		  allData[in+1][iHit] < meanCFD[in]+800)
		 {
		   chvalue[in+1] = allData[in+1][iHit] ; 
		   break;
		 }
	     }
	   for (Int_t iHit=0; iHit<5; iHit++)  //CFD A side
	     {
	       if(allData[in+1+56][iHit]>0)
		 if(allData[in+1+56][iHit] > meanCFD[in+12]-800 && 
		    allData[in+1+56][iHit] < meanCFD[in+12]+800)
		   {
		     chvalue[in+1+56] = allData[in+56+1][iHit] ;
		     break;
		   }
	     }
	 }
       // new QTC    
       Int_t pmt;
       for (Int_t ik=0; ik<106; ik+=4) {
	   if (ik<48)          pmt=ik/4;
	   if (ik>47 && ik<52) pmt= 24;   
	   if (ik>51 && ik<56) pmt= 25; 
	   if(ik>55)           pmt=(ik-8)/4;
	   for(Int_t iHt = 0; iHt<5; iHt++) { 
	     if(allData[107+ik+1][iHt] > (qt01mean[pmt]-800) &&
		allData[107+ik+1][iHt] < (qt01mean[pmt]+800) ) {
	       chvalue[107+ik+1] = allData[107+ik+1][iHt];
	    //   printf("start newQTC 00 ik %i iHt %i pmt %i  QT00 %i QT01 %i \n", ik, iHt, pmt, allData[107+ik][iHt],  allData[107+ik+1][iHt]);
	       break;
	     }
	   }
	   for(Int_t iHt = 0; iHt<5; iHt++) { 
	     if(allData[107+ik][iHt]>chvalue[107+ik+1] &&
		chvalue[107+ik+1]>0) {
	       chvalue[107+ik]=allData[107+ik][iHt] ;
	    //   printf("stop newQTC 00 ik %i iHt %i pmt %i  QT00 %i QT01 %i \n", ik, iHt, pmt, allData[107+ik][iHt],  allData[107+ik+1][iHt]);
	       break;
	     }
	   }
	   for(Int_t iHt = 0; iHt<5; iHt++) {
	     if( allData[107+ik+3][iHt] > (qt11mean[pmt]-800) &&
		 allData[107+ik+3][iHt] < (qt11mean[pmt]+800) ) {
	       chvalue[107+ik+3] = allData[107+ik+3][iHt];
	       break;
	     }
	   }
	   for(Int_t iHt = 0; iHt<5; iHt++) {
	     if( allData[107+ik+2][iHt] > chvalue[107+ik+3]&&
		 chvalue[107+ik+3]>0 ) {
	       chvalue[107+ik+2] = allData[107+ik+2][iHt];
	   //    printf(" newQTC 11 ik %i iHt %i pmt %i QT10 %i QT11 %i \n", ik, iHt, pmt, allData[107+ik+2][iHt],  allData[107+ik+3][iHt]);
		 break;
	     }
	   }
	 } //end new QTC
	 // Or
         for(Int_t iHt = 0; iHt<5; iHt++) {
	 if(allData[51][iHt]>meanOrA-800 && allData[51][iHt]<meanOrA+800) {
	   chvalue[51]=allData[51][iHt];
	   break;
	  }
         }
        for(Int_t iHt = 0; iHt<5; iHt++) {
	 if(allData[52][iHt]>meanOrC-800 && allData[52][iHt]<meanOrC+800) {
	   chvalue[52]=allData[52][iHt];
	   break;
	  }
         }
	   	    

       event++;
       if(chvalue[50]>0)      fT0OutTree->Fill(); 
       
     } //event
     start->Delete();
     }
     reader->Delete();
	
   TFile *hist = new TFile("T0RAWtree.root","RECREATE");
   hist->cd();
   fT0OutTree ->Write();  
			   
}