Просмотр исходного кода

first implementation of converter is ready

ParfenovPeter лет назад: 2
Родитель
Сommit
331a4760eb

+ 4 - 5
bin/main.cpp

@@ -100,7 +100,7 @@ int main(int argc, char **argv)
         std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl;
         return 1;
       }
-      if (std::string(argv[i]) == "-debug" && i != argc - 1)
+      if (std::string(argv[i]) == "-debug")
       {
         mciUtility::GetInstance()->debug = 1;
         continue;
@@ -180,8 +180,7 @@ int main(int argc, char **argv)
 
   for (Long64_t ievent=0; ievent<Nentries; ievent++)
   {
-    if (ievent % 1000 == 0)
-      std::cout << "Event [" << ievent << "/" << Nentries << "]" << std::endl;
+    std::cout << "Event [" << ievent << "/" << Nentries << "]" << std::endl;
     
     event = (mciEvent *)readerManager->ReadEvent(ievent);
     if (!event) continue;
@@ -191,7 +190,7 @@ int main(int argc, char **argv)
     Nparticles = event->GetNparticles();
     for (int iparticle = 0; iparticle < Nparticles; iparticle++)
     {
-      particle = readerManager->ReadParticle(iparticle);
+      particle = (mciParticle*) readerManager->ReadParticle(iparticle);
       if (!particle) continue;
 
       writerManager->SetParticle(particle, iparticle);
@@ -208,4 +207,4 @@ int main(int argc, char **argv)
 
   return 0;
 
-}
+}

+ 4 - 1
format/mciEvent.cxx

@@ -2,7 +2,10 @@
 
 ClassImp(mciEvent);
 
-mciEvent::mciEvent(/* args */)
+mciEvent::mciEvent(/* args */) :  fB(0.),
+                                  fPhiRP(0.),
+                                  fNparticles(0),
+                                  fNparticipants(0)
 {
 }
 

+ 3 - 0
format/mciEvent.h

@@ -12,6 +12,7 @@ private:
   Float_t fB;
   Float_t fPhiRP;
   Int_t fNparticles;
+  Int_t fNparticipants;
 
 public:
   mciEvent(/* args */);
@@ -21,11 +22,13 @@ public:
   virtual void SetB(Float_t _a) { fB = _a; }
   virtual void SetPhiRP(Float_t _a) { fPhiRP = _a; }
   virtual void SetNparticles(Float_t _a) { fNparticles = _a; }
+  virtual void SetNparticipants(Float_t _a) { fNparticipants = _a; }
 
   // Getters
   virtual Float_t GetB() const { return fB; }
   virtual Float_t GetPhiRP() const { return fPhiRP; }
   virtual Int_t GetNparticles() const { return fNparticles; }
+  virtual Int_t GetNparticipants() const { return fNparticipants; }
 
   ClassDef(mciEvent, 0);
 };

+ 6 - 1
format/mciParticle.cxx

@@ -2,7 +2,12 @@
 
 ClassImp(mciParticle);
 
-mciParticle::mciParticle(/* args */)
+mciParticle::mciParticle(/* args */) :  fMom(mciUtility::GetInstance()->error_code, mciUtility::GetInstance()->error_code, mciUtility::GetInstance()->error_code),
+                                        fR(mciUtility::GetInstance()->error_code, mciUtility::GetInstance()->error_code, mciUtility::GetInstance()->error_code),
+                                        fEn(mciUtility::GetInstance()->error_code),
+                                        fT(mciUtility::GetInstance()->error_code),
+                                        fPdg(mciUtility::GetInstance()->error_code),
+                                        fCharge(mciUtility::GetInstance()->error_code)
 {
 }
 

+ 2 - 0
format/mciParticle.h

@@ -6,6 +6,8 @@
 #include <Rtypes.h>
 #include <TVector3.h>
 
+#include <Utility.h>
+
 class mciParticle
 {
 private:

+ 8 - 8
readers/mciReader_hsd_root.cxx

@@ -68,19 +68,21 @@ mciEvent *mciReader_hsd_root::ReadEvent(Long64_t iev)
 
 mciParticle *mciReader_hsd_root::ReadParticle(Int_t ipart)
 {
+  mciParticle *particle = new mciParticle();
+
   if (!ChainCheck())
   {
-    return nullptr;
+    return particle;
   }
 
   if (ipart >= fEvent->GetNpart() + fEventFrag->GetNfragMST())
   {
-    return nullptr;
+    return particle;
   }
 
   if (ipart < 0)
   {
-    return nullptr;
+    return particle;
   }
 
   bool is_particle = false;
@@ -97,22 +99,20 @@ mciParticle *mciReader_hsd_root::ReadParticle(Int_t ipart)
 
   if (!is_particle && !is_fragment)
   {
-    return nullptr;
+    return particle;
   }
 
   if (is_particle && is_fragment)
   {
-    return nullptr;
+    return particle;
   }
 
-  mciParticle *particle = new mciParticle();
-
   if (is_particle)
   {
     fParticle = fEvent->GetParticle(ipart);
     if (fParticle->IsInMST()) // Check whether the particle from PHSD was used to create MST fragment
     {
-      return nullptr;
+      return particle;
     }
     particle->SetEnergy(fParticle->E());
     particle->SetPdg(fParticle->GetPdg());

+ 3 - 3
readers/mciReader_hsd_root.h

@@ -5,8 +5,8 @@
 #include <TChain.h>
 #include <TLorentzVector.h>
 
-#include <qaEvent.h>
-#include <qaParticle.h>
+#include <mciEvent.h>
+#include <mciParticle.h>
 #include <Utility.h>
 
 #include <mciReader_manager.h>
@@ -45,4 +45,4 @@ public:
   ClassDef(mciReader_hsd_root, 0);
 };
 
-#endif
+#endif

+ 1 - 0
readers/mciReader_mcpico.cxx

@@ -66,6 +66,7 @@ mciEvent *mciReader_mcpico::ReadEvent(Long64_t iev)
   event->SetB(bimp);
   event->SetPhiRP(phi2);
   event->SetNparticles(nh);
+  event->SetNparticipants(npart);
 
   return event;
 }

+ 0 - 2
readers/mciReader_mcpico.h

@@ -10,8 +10,6 @@
 
 #include <mciReader_manager.h>
 
-#define MAX_TRACKS 15000
-
 class mciReader_mcpico : virtual public mciReader_manager
 {
 private:

+ 15 - 9
readers/mciReader_phqmd.cxx

@@ -2,7 +2,7 @@
 
 ClassImp(mciReader_phqmd);
 
-mciReader_phqmd::mciReader_phqmd(/* args */) : is_init(false), fCurrentEvent(-1), fEvent(nullptr), fParticle(nullptr)
+mciReader_phqmd::mciReader_phqmd(/* args */) : is_init(false), fCurrentEvent(-1), fEvent(nullptr), fParticle(nullptr), fNpart(0)
 {
 }
 
@@ -68,19 +68,24 @@ mciEvent *mciReader_phqmd::ReadEvent(Long64_t iev)
 
 mciParticle *mciReader_phqmd::ReadParticle(Int_t ipart)
 {
+  mciParticle *particle = new mciParticle();
+
   if (!ChainCheck())
   {
-    return nullptr;
+    if (mciUtility::GetInstance()->debug) std::cerr << "mciReader_phqmd::ReadParticle: Failed chain check!" << std::endl;
+    return particle;
   }
 
   if (ipart >= fEvent->GetNpart() + fEventFrag->GetNfragMST())
   {
-    return nullptr;
+    if (mciUtility::GetInstance()->debug) std::cerr << "mciReader_phqmd::ReadParticle: ipart >= Nparticlpants + Nfragments (" << ipart << " >= " << fEvent->GetNpart() << " + " << fEventFrag->GetNfragMST() << ")!" << std::endl;
+    return particle;
   }
 
   if (ipart < 0)
   {
-    return nullptr;
+    if (mciUtility::GetInstance()->debug) std::cerr << "mciReader_phqmd::ReadParticle: ipart < 0!" << std::endl;
+    return particle;
   }
 
   bool is_particle = false;
@@ -97,22 +102,23 @@ mciParticle *mciReader_phqmd::ReadParticle(Int_t ipart)
 
   if (!is_particle && !is_fragment)
   {
-    return nullptr;
+    if (mciUtility::GetInstance()->debug) std::cerr << "mciReader_phqmd::ReadParticle: particle is neither participant nor spectator!" << std::endl;
+    return particle;
   }
 
   if (is_particle && is_fragment)
   {
-    return nullptr;
+    if (mciUtility::GetInstance()->debug) std::cerr << "mciReader_phqmd::ReadParticle: particle is both participant and spectator!" << std::endl;
+    return particle;
   }
 
-  mciParticle *particle = new mciParticle();
-
   if (is_particle)
   {
     fParticle = fEvent->GetParticle(ipart);
     if (fParticle->IsInMST()) // Check whether the particle from PHSD was used to create MST fragment
     {
-      return nullptr;
+      if (mciUtility::GetInstance()->debug) std::cerr << "mciReader_phqmd::ReadParticle: particle was used to create MST fragment!" << std::endl;
+      return particle;
     }
     particle->SetEnergy(fParticle->E());
     particle->SetPdg(fParticle->GetPdg());

+ 1 - 0
readers/mciReader_phqmd.h

@@ -30,6 +30,7 @@ private:
   Baryon *fBaryonMST;
   Fragment *fFragmentMST;
   TLorentzVector fMomentum;
+  Int_t fNpart;
 
   Bool_t ChainCheck();
 

+ 14 - 3
utility/Utility.cxx

@@ -47,9 +47,20 @@ TChain *mciUtility::initChain(const TString &inputFileName, const char *chainNam
   TChain *chain = new TChain(chainName);
   std::ifstream file(inputFileName.Data());
   std::string line;
-  while (std::getline(file, line))
+  std::string basename = inputFileName.Data();
+  if (basename.find(".root") != std::string::npos)
   {
-    chain->Add(line.c_str());
+    chain->Add(inputFileName.Data());
+  }
+  if (file.is_open())
+  {
+    while (std::getline(file, line))
+    {
+      if (line.find(".root") != std::string::npos)
+      {
+        chain->Add(line.c_str());
+      }
+    }
   }
 
   return chain;
@@ -74,4 +85,4 @@ Double_t mciUtility::GetCharge(Int_t pdg)
   if (!particle)
     return error_code;
   return particle->Charge() / 3.;
-}
+}

+ 2 - 2
utility/Utility.h

@@ -13,10 +13,10 @@
 #include <Rtypes.h>
 #include <TString.h>
 #include <TChain.h>
+#include <TFile.h>
 #include <TEnv.h>
 
-#include <mciEvent.h>
-#include <mciParticle.h>
+#define MAX_TRACKS 15000
 
 class mciUtility
 {

+ 1 - 1
writers/mciWriter_mcpico.cxx

@@ -39,7 +39,7 @@ void mciWriter_mcpico::SetEvent(mciEvent *const& _ievent)
   phi3  = 0.;
   ecc2  = 0.;
   ecc3  = 0.;
-  npart = 0;
+  npart = _ievent->GetNparticipants();
   nh    = _ievent->GetNparticles();
 }
 

+ 0 - 2
writers/mciWriter_mcpico.h

@@ -11,8 +11,6 @@
 
 #include <mciWriter_manager.h>
 
-#define MAX_TRACKS 15000
-
 class mciWriter_mcpico : virtual public mciWriter_manager
 {
 private: