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 |
*/ |
*/ |
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 |
|
|
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 |
/** |
/** |
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 |
/* |
/* |
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); |
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 |
} |
} |
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(); |
523 |
(*j)->GetCurrentFile()->Write(0,TObject::kOverwrite); |
(*j)->GetCurrentFile()->Write(0,TObject::kOverwrite); |
524 |
} |
} |
525 |
} |
} |
526 |
|
|
527 |
|
softinfo->Delete(); |
528 |
} |
} |
529 |
|
|
530 |
/** |
/** |
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)); |
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()); |