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

Diff of /chewbacca/event/PamelaRun.cpp

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

revision 1.1.1.1 by mocchiut, Tue Sep 23 07:19:55 2008 UTC revision 1.5 by mocchiut, Wed Dec 30 14:50:01 2009 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: messineo $   * $Author: mocchiut $
3   * $Date: 2008-03-11 14:26:19 $   * $Date: 2009/07/29 15:47:23 $
4   * $Revision: 1.4 $   * $Revision: 1.4 $
5   *   *
6   * Implementation of the PamelaRun class.   * Implementation of the PamelaRun class.
# Line 51  PamelaRun::PamelaRun(std::string fileNam Line 51  PamelaRun::PamelaRun(std::string fileNam
51    Path(path),    Path(path),
52    Run(fileName),    Run(fileName),
53    RunNumber(1),//veirificare se è possibilie eliminare questa variabile    RunNumber(1),//veirificare se è possibilie eliminare questa variabile
54      compression(compr),
55    Multiple(multiple),    Multiple(multiple),
56    SingleFile(0),    SingleFile(0){
   compression(compr){  
57    
58    RunExists(fileName);    RunExists(fileName);
59    info = RunInfoYoda(this);    info = RunInfoYoda(this);
# Line 78  std::string PamelaRun::GetRunName(int ru Line 78  std::string PamelaRun::GetRunName(int ru
78   * @return int   * @return int
79   */   */
80   void PamelaRun::RunExists(std::string input) throw (std::exception){   void PamelaRun::RunExists(std::string input) throw (std::exception){
81   int res;     // int res;
82   DIR *dirp;     // DIR *dirp;
83   std::string fileName;   std::string fileName;
84   //std::string pathDir((char*)getenv("YODA_DATA"));   //std::string pathDir((char*)getenv("YODA_DATA"));
85   std::string pathDir(GetPath());   std::string pathDir(GetPath());
# Line 316  void PamelaRun::ReadSubPacket(void* subp Line 316  void PamelaRun::ReadSubPacket(void* subp
316    SubPacket *packet = *(SubPacket**)subpacket;    SubPacket *packet = *(SubPacket**)subpacket;
317    
318    // look into the map of subpackets if we already read it.    // look into the map of subpackets if we already read it.
319    std::string FullName = packet->GetPacketType()->GetName() + "." + name;    //  std::string FullName = packet->GetPacketType()->GetName() + "." + name;
320      std::string FullName = (const std::string)packet->GetPacketType()->GetName() + "." + name;
321    SubPacketMap::iterator i = SubPacketAddresses.find(FullName);    SubPacketMap::iterator i = SubPacketAddresses.find(FullName);
322    if (i != SubPacketAddresses.end()) { // it is in the map    if (i != SubPacketAddresses.end()) { // it is in the map
323      *(SubPacket**)subpacket = i->second;      *(SubPacket**)subpacket = i->second;
# Line 389  TTree* PamelaRun::CreateTTree(Algorithm* Line 390  TTree* PamelaRun::CreateTTree(Algorithm*
390    FileName = GetFileName(packet, name);    FileName = GetFileName(packet, name);
391    CreateDirectoryStructure(FileName.c_str());    CreateDirectoryStructure(FileName.c_str());
392    File = new TFile(FileName.c_str(), "create");    File = new TFile(FileName.c_str(), "create");
393    tree = new TTree(TreeName.c_str(), algo->GetAlgorithmName().c_str());    //  tree = new TTree(TreeName.c_str(), algo->GetAlgorithmName().c_str());    
394      tree = new TTree(TreeName.c_str(), algo->GetAlgorithmName());
395    WritingRootTrees[packet->GetPacketType()].push_back(tree);    WritingRootTrees[packet->GetPacketType()].push_back(tree);
396        
397    File->SetCompressionLevel(compression);    File->SetCompressionLevel(compression);
# Line 419  void PamelaRun::WriteSubPacket(Algorithm Line 421  void PamelaRun::WriteSubPacket(Algorithm
421    oss <<  "Register: " << name << " for " << algo->GetAlgorithmName() << " (writing)";    oss <<  "Register: " << name << " for " << algo->GetAlgorithmName() << " (writing)";
422    //logger->debug(oss.str().c_str());    //logger->debug(oss.str().c_str());
423    TTree* HeaderTree = ReadTTree(packet->GetPacketType());    TTree* HeaderTree = ReadTTree(packet->GetPacketType());
424    std::string FullName = packet->GetPacketType()->GetName() + "." + name;    //  std::string FullName = packet->GetPacketType()->GetName() + "." + name;
425      std::string FullName = (const std::string)packet->GetPacketType()->GetName() + "." + name;
426    if (Multiple) {    if (Multiple) {
427          TTree* tree = CreateTTree(algo, packet, name);          TTree* tree = CreateTTree(algo, packet, name);
428          oss.str("");          oss.str("");
# Line 511  void PamelaRun::WriteHeaders(Algorithm* Line 514  void PamelaRun::WriteHeaders(Algorithm*
514   * Write the ROOT files to disk.   * Write the ROOT files to disk.
515   */   */
516  void PamelaRun::WriteFiles(void) {  void PamelaRun::WriteFiles(void) {
517      WriteFilesEasy();
518      return;
519    // Workaround: unlink all friend trees first top avoid to store    // Workaround: unlink all friend trees first top avoid to store
520    // the links in the header tree file.    // the links in the header tree file.
521    for (RootTreeMap::iterator i = TTreeMap.begin(); i != TTreeMap.end(); i++) {    for (RootTreeMap::iterator i = TTreeMap.begin(); i != TTreeMap.end(); i++) {
# Line 538  void PamelaRun::WriteFiles(void) { Line 543  void PamelaRun::WriteFiles(void) {
543        
544    softinfo->Delete();    softinfo->Delete();
545  }  }
546    /**
547     * Write the ROOT files to disk.
548     */
549    void PamelaRun::WriteFilesEasy() {
550      SingleFile->cd();
551      TTree *softinfo = 0;
552      Int_t version=GetYODAver();
553      //Int_t version= 60312;
554      //printf("version = %f \n",version);
555      softinfo = new TTree("SoftInfo","YODA software info");
556      softinfo->Branch("SoftInfo",&version,"version/I");
557      softinfo->Fill();
558      
559      SingleFile->Write("",TObject::kOverwrite);
560      
561      softinfo->Delete();
562    }
563  /**  /**
564   * Fill all ROOT trees of a certain type that were opened for writing.   * Fill all ROOT trees of a certain type that were opened for writing.
565   * @param type the package type of the trees to fill.   * @param type the package type of the trees to fill.
# Line 567  void PamelaRun::WriteHeader(Algorithm* a Line 588  void PamelaRun::WriteHeader(Algorithm* a
588    
589    EventHeader header(type);    EventHeader header(type);
590    std::string EventType = (&header)->GetPacketType()->GetName();    std::string EventType = (&header)->GetPacketType()->GetName();
591   // std::cout<<EventType<<std::endl;    //  std::cout<<EventType<<std::endl;
592    
593    std::string FileName = "";    std::string FileName = "";
594    TFile* File = 0;    TFile* File = 0;
# Line 579  void PamelaRun::WriteHeader(Algorithm* a Line 600  void PamelaRun::WriteHeader(Algorithm* a
600          CreateDirectoryStructure(FileName.c_str());          CreateDirectoryStructure(FileName.c_str());
601          File = new TFile(FileName.c_str(), "create");            File = new TFile(FileName.c_str(), "create");  
602          File->SetCompressionLevel(compression);          File->SetCompressionLevel(compression);
603          tree = new TTree("Pscu", algo->GetAlgorithmName().c_str());          //      tree = new TTree("Pscu", algo->GetAlgorithmName().c_str());
604            tree = new TTree("Pscu", algo->GetAlgorithmName());
605          WritingRootTrees[(&header)->GetPacketType()].push_back(tree);          WritingRootTrees[(&header)->GetPacketType()].push_back(tree);
606          tree->GetCurrentFile()->cd();          tree->GetCurrentFile()->cd();
607          tree->Branch(GetDefaultBranchName(&header).c_str(),          tree->Branch(GetDefaultBranchName(&header).c_str(),
# Line 589  void PamelaRun::WriteHeader(Algorithm* a Line 611  void PamelaRun::WriteHeader(Algorithm* a
611    } else {    } else {
612          if (!Multiple && (SingleFile == NULL)){          if (!Multiple && (SingleFile == NULL)){
613                  //std::string pathDir((char*)getenv("YODA_DATA"));                  //std::string pathDir((char*)getenv("YODA_DATA"));
614                  SingleFile = new TFile((GetPath() + "/" + Run + ".root").c_str(), "update");            SingleFile = new TFile((GetPath() + "/" + Run + ".root").c_str(), "update");
615                  SingleFile->SetCompressionLevel(compression);                  SingleFile->SetCompressionLevel(compression);
616          }          }
617    
618          tree = new TTree(EventType.c_str(), algo->GetAlgorithmName().c_str());          //      tree = new TTree(EventType.c_str(), algo->GetAlgorithmName().c_str());
619            tree = new TTree(EventType.c_str(), algo->GetAlgorithmName());
620          WritingRootTrees[type].push_back(tree);          WritingRootTrees[type].push_back(tree);
621          tree->GetCurrentFile()->cd();          tree->GetCurrentFile()->cd();
622          tree->Branch(GetDefaultBranchName(&header).c_str(),          tree->Branch(GetDefaultBranchName(&header).c_str(),
623                 (*subpacket)->Class()->GetName(), subpacket);                 (*subpacket)->Class()->GetName(), subpacket);
624    
625          TTreeMap.insert(RootTreeMap::value_type(type, tree));              TTreeMap.insert(RootTreeMap::value_type(type, tree));    
626    }    }
627    

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23