/[PAMELA software]/yoda/event/PamelaRun.cpp
ViewVC logotype

Diff of /yoda/event/PamelaRun.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6.1 by kusanagi, Wed Feb 15 15:47:14 2006 UTC revision 6.10 by mocchiut, Mon Oct 16 16:02:20 2006 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: kusanagi $   * $Author: pam-rm2 $
3   * $Date: 2006/02/07 17:11:07 $   * $Date: 2006/08/23 14:39:44 $
4   * $Revision: 6.0 $   * $Revision: 6.8 $
5   *   *
6   * Implementation of the PamelaRun class.   * Implementation of the PamelaRun class.
7   */   */
# Line 29  extern "C" { Line 29  extern "C" {
29  #include <dirent.h>  #include <dirent.h>
30  #include "DirectoryStructure.h"  #include "DirectoryStructure.h"
31  }  }
32    
33    #include "yodaversion.h"
34    //#define version 60313
35    //extern int GetYODAver();
36    
37  using namespace pamela;  using namespace pamela;
38    
# Line 55  std::string PamelaRun::GetRunName(int ru Line 59  std::string PamelaRun::GetRunName(int ru
59   int res;   int res;
60   DIR *dirp;   DIR *dirp;
61   std::string fileName;   std::string fileName;
62   std::string pathDir((char*)getenv("YODA_DATA"));   //std::string pathDir((char*)getenv("YODA_DATA"));
63     std::string pathDir(GetPath());
64   std::string tempName;   std::string tempName;
65   std::string::size_type pos;   std::string::size_type pos;
66    
67   pos = input.find_last_of("/");   pos = input.find_last_of("/");
  //if ((pos == std::string::npos) && !input.empty()) ;//throw Exception("Directories not allowed....");  
68   fileName = input.substr(pos+1);   fileName = input.substr(pos+1);
69   pos = fileName.find_last_of(".");   pos = fileName.find_last_of(".");
70   fileName = fileName.substr(0,pos);   fileName = fileName.substr(0,pos);
71   pathDir = pathDir + "/";   pathDir = pathDir + "/";
72   tempName = pathDir + fileName + "00";   tempName = pathDir + fileName;
73   //oss << pathDir << fileName << std::setw( 2 ) << std::setfill( '0' );   oss.str("");
74   oss.str(tempName.c_str());   oss << Path << "/" << fileName;
75   int i = 0;   UnpackPath = oss.str();
  while (res){  
     //if ((dirp = opendir(tempName.c_str())) == NULL) {  
     if ((dirp = opendir(oss.str().c_str())) == NULL) {  
         res = 0;  
     } else {  
         closedir(dirp);  
         oss.str("");  
         oss << pathDir << fileName << std::setw( 2 ) << std::setfill( '0' ) << ++i;  
         res = 1;  
     }  
  }  
  oss.str("");  
  oss << Path << "/" << fileName << std::setw( 2 ) << std::setfill( '0' ) << i;  
  Path = oss.str();  
76   oss.str("");   oss.str("");
77   oss << fileName << std::setw( 2 ) << std::setfill( '0' ) << i;   oss << fileName;
78   Run = oss.str();   Run = oss.str();
 //return (oss.str());  
79  }  }
80    
81  /**  /**
# Line 132  std::string PamelaRun::GetDirName(Packet Line 121  std::string PamelaRun::GetDirName(Packet
121   */   */
122  std::string PamelaRun::GetFileName(const SubPacket* type, std::string name) {  std::string PamelaRun::GetFileName(const SubPacket* type, std::string name) {
123    if (type->IsDetectorSpecific()) {    if (type->IsDetectorSpecific()) {
124      return Path + "/" + type->GetPacketType()->GetName() + "/"      return UnpackPath + "/" + type->GetPacketType()->GetName() + "/"
125        + Run + "." + type->GetPacketType()->GetName() + "."        + Run + "." + type->GetPacketType()->GetName() + "."
126        + type->GetSubDetector()->GetName() + "."        + type->GetSubDetector()->GetName() + "."
127        + name + ".root";        + name + ".root";
128    } else {    } else {
129      return Path + "/" + type->GetPacketType()->GetName() + "/"      return UnpackPath + "/" + type->GetPacketType()->GetName() + "/"
130        + Run + "." + type->GetPacketType()->GetName() + "."        + Run + "." + type->GetPacketType()->GetName() + "."
131        + name + ".root";        + name + ".root";
132     /*     /*
# Line 464  void PamelaRun::WriteHeaders(Algorithm* Line 453  void PamelaRun::WriteHeaders(Algorithm*
453      WriteHeader(algo, subpacket, PacketType::CalibCalPulse1);      WriteHeader(algo, subpacket, PacketType::CalibCalPulse1);
454      WriteHeader(algo, subpacket, PacketType::CalibCalPulse2);      WriteHeader(algo, subpacket, PacketType::CalibCalPulse2);
455      WriteHeader(algo, subpacket, PacketType::Physics);      WriteHeader(algo, subpacket, PacketType::Physics);
456        WriteHeader(algo, subpacket, PacketType::CalibTrkBoth);
457      WriteHeader(algo, subpacket, PacketType::CalibTrk1);      WriteHeader(algo, subpacket, PacketType::CalibTrk1);
458      WriteHeader(algo, subpacket, PacketType::CalibTrk2);      WriteHeader(algo, subpacket, PacketType::CalibTrk2);
459      WriteHeader(algo, subpacket, PacketType::CalibTof);      WriteHeader(algo, subpacket, PacketType::CalibTof);
# Line 496  void PamelaRun::WriteHeaders(Algorithm* Line 486  void PamelaRun::WriteHeaders(Algorithm*
486      WriteHeader(algo, subpacket, PacketType::S4Init);          WriteHeader(algo, subpacket, PacketType::S4Init);    
487      WriteHeader(algo, subpacket, PacketType::Ac2Init);      WriteHeader(algo, subpacket, PacketType::Ac2Init);
488      WriteHeader(algo, subpacket, PacketType::CalAlarm);          WriteHeader(algo, subpacket, PacketType::CalAlarm);    
489      WriteHeader(algo, subpacket, PacketType::AcAlarm);          WriteHeader(algo, subpacket, PacketType::Ac1Alarm);    
490      WriteHeader(algo, subpacket, PacketType::TrkAlarm);          WriteHeader(algo, subpacket, PacketType::TrkAlarm);    
491      WriteHeader(algo, subpacket, PacketType::TrgAlarm);          WriteHeader(algo, subpacket, PacketType::TrgAlarm);    
492      WriteHeader(algo, subpacket, PacketType::TofAlarm);      WriteHeader(algo, subpacket, PacketType::TofAlarm);
493      WriteHeader(algo, subpacket, PacketType::S4Alarm);      WriteHeader(algo, subpacket, PacketType::S4Alarm);
494        WriteHeader(algo, subpacket, PacketType::Ac2Alarm);    
495      WriteHeader(algo, subpacket, PacketType::TsbT);      WriteHeader(algo, subpacket, PacketType::TsbT);
496      WriteHeader(algo, subpacket, PacketType::TsbB);      WriteHeader(algo, subpacket, PacketType::TsbB);
497  }  }
# Line 517  void PamelaRun::WriteFiles(void) { Line 508  void PamelaRun::WriteFiles(void) {
508      }      }
509    }    }
510    
511      TTree *softinfo = 0;
512      Int_t version=GetYODAver();
513      //Int_t version= 60312;
514      //printf("version = %f \n",version);
515      softinfo = new TTree("SoftInfo","YODA software info");
516      softinfo->Branch("SoftInfo",&version,"version/I");
517      softinfo->Fill();
518    
519    for (TTreeListMap::iterator i = WritingRootTrees.begin();    for (TTreeListMap::iterator i = WritingRootTrees.begin();
520         i != WritingRootTrees.end(); i++) {         i != WritingRootTrees.end(); i++) {
521      for (TTreeList::iterator j = i->second.begin();      for (TTreeList::iterator j = i->second.begin();
# Line 524  void PamelaRun::WriteFiles(void) { Line 523  void PamelaRun::WriteFiles(void) {
523        (*j)->GetCurrentFile()->Write(0,TObject::kOverwrite);        (*j)->GetCurrentFile()->Write(0,TObject::kOverwrite);
524      }      }
525    }    }
526      
527      softinfo->Delete();
528  }  }
529    
530  /**  /**
# Line 556  void PamelaRun::WriteHeader(Algorithm* a Line 557  void PamelaRun::WriteHeader(Algorithm* a
557    
558    std::string FileName = "";    std::string FileName = "";
559    TFile* File = 0;    TFile* File = 0;
560      Long64_t maxsize = 5000000000LL;
561      TTree::SetMaxTreeSize(maxsize);
562    TTree *tree = 0;    TTree *tree = 0;
563    if ( Multiple ){    if ( Multiple ){
564          FileName = GetFileName(&header, GetDefaultBranchName(&header));          FileName = GetFileName(&header, GetDefaultBranchName(&header));
# Line 570  void PamelaRun::WriteHeader(Algorithm* a Line 573  void PamelaRun::WriteHeader(Algorithm* a
573          TTreeMap.insert(RootTreeMap::value_type(type, tree));          TTreeMap.insert(RootTreeMap::value_type(type, tree));
574    } else {    } else {
575          if (!Multiple && (SingleFile == NULL)){          if (!Multiple && (SingleFile == NULL)){
576                  std::string pathDir((char*)getenv("YODA_DATA"));                  //std::string pathDir((char*)getenv("YODA_DATA"));
577                  SingleFile = new TFile((pathDir + "/" + Run + ".root").c_str(), "update");                  SingleFile = new TFile((GetPath() + "/" + Run + ".root").c_str(), "update");
578                  SingleFile->SetCompressionLevel(compression);                  SingleFile->SetCompressionLevel(compression);
579          }          }
580          tree = new TTree(EventType.c_str(), algo->GetAlgorithmName().c_str());          tree = new TTree(EventType.c_str(), algo->GetAlgorithmName().c_str());

Legend:
Removed from v.6.1  
changed lines
  Added in v.6.10

  ViewVC Help
Powered by ViewVC 1.1.23