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

Contents of /chewbacca/event/PamelaRun.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Wed Dec 30 14:50:01 2009 UTC (14 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.4: +21 -3 lines
Error occurred while calculating annotation data.
Bug in writing and deleting files fixed

1 /** @file
2 * $Author: mocchiut $
3 * $Date: 2009/07/29 15:47:23 $
4 * $Revision: 1.4 $
5 *
6 * Implementation of the PamelaRun class.
7 */
8 #include <iostream>
9 #include <iomanip>
10 #include <list>
11 #include <exception>
12
13 #include <TFile.h> //Substituted by Maurizio 05 Feb 2004
14 #include <TTree.h> //Substituted by Maurizio 05 Feb 2004
15 #include <TChain.h> //Substituted by Maurizio 05 Feb 2004
16 #include <TKey.h> //Substituted by Maurizio 05 Feb 2004
17 #include <TList.h> //Substituted by Maurizio 05 Feb 2004
18
19
20 #include "PamelaRun.h"
21 #include "EventHeader.h"
22 #include "Algorithm.h"
23 #include "AlgorithmInfo.h"
24 #include "Exception.h"
25 #include <sys/stat.h>
26
27 extern "C" {
28 #include <dirent.h>
29 #include "DirectoryStructure.h"
30 }
31
32 #include "yodaversion.h"
33 //#define version 60313
34 //extern int GetYODAver();
35
36 using namespace pamela;
37
38 //marco: distructor
39 PamelaRun::~PamelaRun()
40 {
41 delete SingleFile; SingleFile=NULL;
42 }
43
44
45 /**
46 * Create a new Pamela run.
47 * @param run Run number
48 * @param path Base path name to the data
49 */
50 PamelaRun::PamelaRun(std::string fileName, std::string path, bool multiple, short compr):
51 Path(path),
52 Run(fileName),
53 RunNumber(1),//veirificare se รจ possibilie eliminare questa variabile
54 compression(compr),
55 Multiple(multiple),
56 SingleFile(0){
57
58 RunExists(fileName);
59 info = RunInfoYoda(this);
60 }
61
62
63 /**
64 * Get the run name according to a certain run number.
65 * @param run Run number.
66 * @return a string with the run name.
67 */
68 std::string PamelaRun::GetRunName(int run) {
69 std::stringstream temp;
70 temp.str("");
71 temp << std::setw( 4 ) << std::setfill( '0' ) << run;
72 return "Run" + temp.str();
73 }
74
75 /**
76 * Check if the run number is already assigned
77 * @param int run - Number of the run to check
78 * @return int
79 */
80 void PamelaRun::RunExists(std::string input) throw (std::exception){
81 // int res;
82 // DIR *dirp;
83 std::string fileName;
84 //std::string pathDir((char*)getenv("YODA_DATA"));
85 std::string pathDir(GetPath());
86 std::string tempName;
87 std::string::size_type pos;
88
89 pos = input.find_last_of("/");
90 fileName = input.substr(pos+1);
91 pos = fileName.find_last_of(".");
92 fileName = fileName.substr(0,pos);
93 pathDir = pathDir + "/";
94 tempName = pathDir + fileName;
95 oss.str("");
96 oss << Path << "/" << fileName;
97 UnpackPath = oss.str();
98 oss.str("");
99 oss << fileName;
100 Run = oss.str();
101 }
102
103
104 /**
105 * Get the directory name that contains the files of a certain event
106 * type for this run.
107 * @param type the packet type.
108 * @return the complete path for this event type.
109 */
110 std::string PamelaRun::GetDirName(PacketType const * type) const {
111 //std::stringstream oss;
112 //std::string name = type->GetName();
113 //oss.str("");
114 //oss << Path << "/" << Run << "/" << "pippo";
115 //return oss.str();
116 //return "pippo";
117 //std::string EventType = type->GetName();
118 return Path + "/" + Run + "/" + type->GetName();
119 }
120
121 /**
122 * Get the file name for a certain event type.
123 * @param type subpacket type.
124 * @param name subpacket name.
125 * @return the complete path and file name.
126 */
127 std::string PamelaRun::GetFileName(const SubPacket* type, std::string name) {
128 if (type->IsDetectorSpecific()) {
129 return UnpackPath + "/" + type->GetPacketType()->GetName() + "/"
130 + Run + "." + type->GetPacketType()->GetName() + "."
131 + type->GetSubDetector()->GetName() + "."
132 + name + ".root";
133 } else {
134 return UnpackPath + "/" + type->GetPacketType()->GetName() + "/"
135 + Run + "." + type->GetPacketType()->GetName() + "."
136 + name + ".root";
137 /*
138 return Path + "/" + type->GetPacketType()->GetName() + "/"
139 + Run + "." + type->GetPacketType()->GetName() + "."
140 + name + ".root"; */
141 }
142 }
143
144 /**
145 * Get the file name for a certain event type.
146 * @param type subpacket type.
147 * @return the complete path and file name.
148 */
149 std::string PamelaRun::GetFileName(const SubPacket* type) {
150 //return GetFileName(type, type->GetSubPacketName());
151 return GetFileName(type, "pippo");
152 }
153
154 /**
155 * Get the branch name that corresponds to a certain
156 * subpacket. Usually, this is the name of the subpacket.
157 * @param type subpacket type.
158 * @return the corresponding branch name.
159 */
160 static std::string GetDefaultBranchName(const SubPacket* type) {
161 return type->GetSubPacketName();
162 }
163
164 /**
165 * Get the tree name for a certain subpacket. This is the name of the
166 * subdetector for detector specific subpackets, and the packet name
167 * ("Physics" etc.) for common packets.
168 * @param type the packet type.
169 * @return the corresponding tree name.
170 */
171 static std::string GetTreeName(const SubPacket* type) {
172 if (type->IsDetectorSpecific()) {
173 return type->GetSubDetector()->GetName();
174 } else {
175 return type->GetPacketType()->GetName();
176 }
177 }
178
179 /**
180 * Get a list of all root files from a certain path.
181 * @param path Path name to start the search.
182 * @return A list of all file names.
183 */
184 static std::list<std::string> GetRootFiles(std::string path) throw (std::exception) {
185 std::list<std::string> files;
186 DIR *dir = opendir(path.c_str());
187 if (dir == 0) {
188 //marco
189 // // logger->debug("Could not open " + path);
190 //throw Exception("Could not open " + path);
191 }
192
193 for (struct dirent *d = readdir(dir); d != NULL; d = readdir(dir)) {
194 if ((strcmp(".",d->d_name) == 0) || (strcmp("..",d->d_name) == 0))
195 continue;
196 std::string filename = path + "/" + d->d_name;
197 struct stat buf;
198 stat(filename.c_str(), &buf);
199 if S_ISDIR(buf.st_mode) {
200 std::list<std::string>toAdd = GetRootFiles(filename);
201 files.insert(files.end(), toAdd.begin(), toAdd.end());
202 } else if ((filename.substr(filename.size()-5, filename.size())
203 == ".root") // correct suffix
204 && (!isdigit(filename[filename.size()-6]))) { // base file
205 std::string nextfilename = filename;
206 nextfilename.insert(filename.size()-5, "_1");
207 if (stat(nextfilename.c_str(), &buf) == 0) {
208 filename.insert(filename.size()-5, "*");
209 }
210 // // logger->debug("Using " + filename);
211 files.push_back(filename);
212 }
213 }
214 return files;
215 }
216
217 /**
218 * Helper function to open the ROOT TTree of the header within the run
219 * framework.
220 * @param type The packet type.
221 * @return the ROOT TTree.
222 */
223 TChain* PamelaRun::ReadHeaderTree(const PacketType *type)
224 throw (std::exception) {
225 EventHeader header(type);
226 std::string FileName = GetFileName(&header);
227 std::string TreeName = GetTreeName(&header);
228 TChain *tree = new TChain(TreeName.c_str());
229 tree->Add(FileName.c_str());
230 return tree;
231 }
232
233 /**
234 * All add trees of a file as friend to a given tree. The tree name of
235 * each tree found in the file is used as the name of the friend alias.
236 * @param tree The base tree to add all other as friends.
237 * @param FileName The name of the file with other trees.
238 */
239 static void AddAllAsFriend(TChain* tree, std::string FileName) {
240 std::string BaseFileName = FileName;
241 bool HaveChain = false;
242 if (BaseFileName[BaseFileName.size()-6] == '*') {
243 BaseFileName.erase(BaseFileName.size()-6, 1);
244 HaveChain = true;
245 }
246 TFile* File = new TFile(BaseFileName.c_str(), "read");
247 if (!File->IsOpen()) {
248 // // logger->error("Could not open file " + BaseFileName + " for reading.");
249 return;
250 }
251 TList* list = File->GetListOfKeys();
252 if (HaveChain) {
253 for (TIter i(list); TKey* k = (TKey*)i();) {
254 if (std::string(TTree::Class()->GetName()) == k->GetClassName()) {
255 std::string TreeName = k->GetName();
256 TChain* FriendChain = new TChain(TreeName.c_str());
257 FriendChain->Add(FileName.c_str());
258 tree->AddFriend(FriendChain, TreeName.c_str());
259 //logger->warn("Adding chain " + TreeName + " with " + FriendChain->GetEntries() + " entries as Friend");
260 }
261 }
262 File->Close();
263 } else {
264 for (TIter i(list); TKey* k = (TKey*)i();) {
265 if (std::string(TTree::Class()->GetName()) == k->GetClassName()) {
266 std::string TreeName = k->GetName();
267 TTree* FriendTree = (TTree *)File->Get(TreeName.c_str());
268 tree->AddFriend(FriendTree, TreeName.c_str());
269 //logger->debug("Adding tree " + TreeName + " with " + FriendTree->GetEntries() + " entries as Friend");
270 }
271 }
272 }
273 }
274
275 /**
276 * Read all Root TTrees which belong to a certain event type and mount them
277 * together as "friends".
278 * @param type The packet type.
279 * @return The root trees with the friends.
280 */
281 TTree* PamelaRun::ReadTTree(const PacketType* type) {
282 oss.str("");
283 oss << "Getting root files of " << type->GetName();
284 //logger->debug(oss.str().c_str());
285 RootTreeMap::iterator t = TTreeMap.find(type);
286
287 if (t != TTreeMap.end()) {
288 return t->second;
289 } else {
290 oss.str("");
291 oss << "Reading root files of " << type->GetName();
292 //// logger->debug(oss.str().c_str());
293 EventHeader header(type);
294 std::string HeaderFileName = GetFileName(&header);
295 TChain* HeaderTree = ReadHeaderTree(type);
296 std::list<std::string> rootfiles = GetRootFiles(GetDirName(type));
297 for (std::list<std::string>::iterator i = rootfiles.begin();
298 i != rootfiles.end(); i++){
299 if (*i == HeaderFileName)
300 continue; // dont add the header tree itself.
301 AddAllAsFriend(HeaderTree, *i);
302
303 }
304 TTreeMap.insert(RootTreeMap::value_type(type, HeaderTree));
305 return HeaderTree;
306 }
307 }
308
309 /**
310 * Register a certain SubPacket, identified by its name, to be read
311 * from the repository. This function is made for interactive work.
312 * @param subpacket A pointer to the pointer of the packet.
313 * @param name The name of the subpacket
314 */
315 void PamelaRun::ReadSubPacket(void* subpacket, std::string name) {
316 SubPacket *packet = *(SubPacket**)subpacket;
317
318 // look into the map of subpackets if we already read it.
319 // 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);
322 if (i != SubPacketAddresses.end()) { // it is in the map
323 *(SubPacket**)subpacket = i->second;
324 return;
325 } else { // not found in the map of used subpackets
326 TTree* tree = ReadTTree(packet->GetPacketType());
327 TBranch* branch = tree->GetBranch(name.c_str());
328 if (branch != 0) {
329 branch->SetAddress(subpacket);
330 SubPacketAddresses.insert(SubPacketMap::value_type(FullName, packet));
331 } else {
332 oss.str("");
333 oss << "Could not find data for " << packet->GetPacketType()->GetName() << "/" << name ;
334 //// logger->error(oss.str().c_str());
335 }
336 }
337 }
338
339 /**
340 * Register a certain SubPacket, identified by its default name, to be
341 * read from the repository. This function is made for
342 * interactive work.
343 * @param subpacket A pointer to the pointer of the packet.
344 */
345 void PamelaRun::ReadSubPacket(void* subpacket) {
346 SubPacket *packet = *(SubPacket**)subpacket;
347 ReadSubPacket(subpacket, GetDefaultBranchName(packet));
348 }
349
350 /**
351 * Register a certain SubPacket with its default name, to be read from
352 * the repository. This functions is for use from the algorithm.
353 * @param algo Algorithm that needs this SubPacket.
354 * @param subpacket A pointer to the pointer of the packet.
355 */
356 void PamelaRun::ReadSubPacket(const Algorithm* algo, void* subpacket) {
357 //:TODO: store the request of the algorithm here.
358 ReadSubPacket(subpacket);
359 }
360
361 /**
362 * Register a certain SubPacket, with a custom name, to
363 * be read from the repository. This functions is for use from
364 * the algorithm.
365 * @param algo Algorithm that needs this SubPacket.
366 * @param subpacket A pointer to the pointer of the packet.
367 * @param name The name of the subpacket
368 */
369 void PamelaRun::ReadSubPacket(const Algorithm* algo, void* subpacket,
370 std::string name) {
371 //:TODO: store the request of the algorithm here.
372 ReadSubPacket(subpacket, name);
373 }
374
375 /**
376 * Helper function to create a ROOT TTree within the run framework.
377 * @param algo Algorithm that creates this SubPacket.
378 * @param packet subpacket type
379 * @param name the name of the subpacket
380 * @return the ROOT TTree.
381 */
382 TTree* PamelaRun::CreateTTree(Algorithm* algo, const SubPacket* packet,
383 std::string name)
384 throw (std::exception) {
385 std::string FileName = "";
386 std::string EventType = packet->GetPacketType()->GetName();
387 TFile* File = 0;
388 std::string TreeName = GetTreeName(packet);
389 TTree *tree = 0;
390 FileName = GetFileName(packet, name);
391 CreateDirectoryStructure(FileName.c_str());
392 File = new TFile(FileName.c_str(), "create");
393 // 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);
396
397 File->SetCompressionLevel(compression);
398 if (!File->IsOpen()) {
399 // // logger->error("Could not open file " + FileName);
400 //throw Exception("Could not open file " + FileName);
401 }
402 //logger->debug("Creating file " + FileName + " with Tree " + TreeName);
403 return tree;
404 }
405
406
407 /**
408 * Register a certain SubPacket to be written to the repository. A
409 * usual call sequence for this function ist
410 * MyEvent *event = new MyEvent();
411 * run->WriteSubPacket(this, &event, event->Class()
412 * @param algo Algorithm that produces this SubPacket.
413 * @param subpacket A pointer to the pointer of the subpacket.
414 * @param c The class the subpacket belongs to.
415 * @param name The name of the packet.
416 */
417 void PamelaRun::WriteSubPacket(Algorithm *algo, void* subpacket,
418 const TClass *c, std::string name) {
419 SubPacket *packet = *(SubPacket **)subpacket;
420 oss.str("");
421 oss << "Register: " << name << " for " << algo->GetAlgorithmName() << " (writing)";
422 //logger->debug(oss.str().c_str());
423 TTree* HeaderTree = ReadTTree(packet->GetPacketType());
424 // std::string FullName = packet->GetPacketType()->GetName() + "." + name;
425 std::string FullName = (const std::string)packet->GetPacketType()->GetName() + "." + name;
426 if (Multiple) {
427 TTree* tree = CreateTTree(algo, packet, name);
428 oss.str("");
429 oss << "Branch: " << name << " Class: " << c->GetName();
430 //logger->debug(oss.str().c_str());
431 tree->Branch(name.c_str(), c->GetName(), subpacket);
432 HeaderTree->AddFriend(tree, tree->GetName());
433 SubPacketAddresses.insert(SubPacketMap::value_type(FullName, packet));
434 } else {
435 std::string nameBranch(name);
436 HeaderTree->Branch(nameBranch.c_str(), c->GetName(), subpacket);
437 SubPacketAddresses.insert(SubPacketMap::value_type(FullName, packet));
438 }
439 }
440
441 /**
442 * Register a certain SubPacket with its default name to be written to
443 * the repository. A usual call sequence for this function ist
444 * MyEvent *event = new MyEvent();
445 * run->WriteSubPacket(this, &event, event->Class()
446 * @param algo Algorithm that produces this SubPacket.
447 * @param subpacket A pointer to the pointer of the subpacket.
448 * @param c The class the subpacket belongs to.
449 */
450 void PamelaRun::WriteSubPacket(Algorithm *algo, void* subpacket,
451 const TClass *c) {
452 SubPacket *packet = *(SubPacket **)subpacket;
453 WriteSubPacket(algo, subpacket, c, GetDefaultBranchName(packet));
454 }
455
456 /**
457 * Write the header packet to all ROOT files in the tree. Intended to
458 * be used for raw data readers that create the initial event structure.
459 * @param algo Algorithm that produces this SubPacket.
460 * @param subpacket A pointer to the pointer of the header packet.
461 */
462 void PamelaRun::WriteHeaders(Algorithm* algo, EventHeader** subpacket) {
463 WriteHeader(algo, subpacket, PacketType::PhysEndRun);
464 WriteHeader(algo, subpacket, PacketType::CalibCalPulse1);
465 WriteHeader(algo, subpacket, PacketType::CalibCalPulse2);
466 WriteHeader(algo, subpacket, PacketType::Physics);
467 WriteHeader(algo, subpacket, PacketType::CalibTrkBoth);
468 WriteHeader(algo, subpacket, PacketType::CalibTrk1);
469 WriteHeader(algo, subpacket, PacketType::CalibTrk2);
470 WriteHeader(algo, subpacket, PacketType::CalibTof);
471 WriteHeader(algo, subpacket, PacketType::CalibS4);
472 WriteHeader(algo, subpacket, PacketType::CalibCalPed);
473 WriteHeader(algo, subpacket, PacketType::Calib1_Ac1);
474 WriteHeader(algo, subpacket, PacketType::Calib1_Ac2);
475 WriteHeader(algo, subpacket, PacketType::Calib2_Ac1);
476 WriteHeader(algo, subpacket, PacketType::Calib2_Ac2);
477 //marco: aggiunto
478 WriteHeader(algo, subpacket, PacketType::CalibCal);
479 WriteHeader(algo, subpacket, PacketType::RunHeader);
480 WriteHeader(algo, subpacket, PacketType::RunTrailer);
481 WriteHeader(algo, subpacket, PacketType::CalibHeader);
482 WriteHeader(algo, subpacket, PacketType::CalibTrailer);
483 WriteHeader(algo, subpacket, PacketType::InitHeader);
484 WriteHeader(algo, subpacket, PacketType::InitTrailer);
485 WriteHeader(algo, subpacket, PacketType::EventTrk);
486 WriteHeader(algo, subpacket, PacketType::Log);
487 WriteHeader(algo, subpacket, PacketType::VarDump);
488 WriteHeader(algo, subpacket, PacketType::ArrDump);
489 WriteHeader(algo, subpacket, PacketType::TabDump);
490 WriteHeader(algo, subpacket, PacketType::Tmtc);
491 WriteHeader(algo, subpacket, PacketType::Mcmd);
492 WriteHeader(algo, subpacket, PacketType::ForcedFECmd);
493 WriteHeader(algo, subpacket, PacketType::Ac1Init);
494 WriteHeader(algo, subpacket, PacketType::CalInit);
495 WriteHeader(algo, subpacket, PacketType::TrkInit);
496 WriteHeader(algo, subpacket, PacketType::TofInit);
497 WriteHeader(algo, subpacket, PacketType::TrgInit);
498 WriteHeader(algo, subpacket, PacketType::NdInit);
499 WriteHeader(algo, subpacket, PacketType::S4Init);
500 WriteHeader(algo, subpacket, PacketType::Ac2Init);
501 WriteHeader(algo, subpacket, PacketType::CalAlarm);
502 WriteHeader(algo, subpacket, PacketType::Ac1Alarm);
503 WriteHeader(algo, subpacket, PacketType::TrkAlarm);
504 WriteHeader(algo, subpacket, PacketType::TrgAlarm);
505 WriteHeader(algo, subpacket, PacketType::TofAlarm);
506 WriteHeader(algo, subpacket, PacketType::S4Alarm);
507 WriteHeader(algo, subpacket, PacketType::Ac2Alarm);
508 WriteHeader(algo, subpacket, PacketType::TsbT);
509 WriteHeader(algo, subpacket, PacketType::TsbB);
510
511 }
512
513 /**
514 * Write the ROOT files to disk.
515 */
516 void PamelaRun::WriteFiles(void) {
517 WriteFilesEasy();
518 return;
519 // Workaround: unlink all friend trees first top avoid to store
520 // the links in the header tree file.
521 for (RootTreeMap::iterator i = TTreeMap.begin(); i != TTreeMap.end(); i++) {
522 if (i->second->GetListOfFriends() != 0) {
523 i->second->GetListOfFriends()->Delete();
524 }
525 }
526
527
528 TTree *softinfo = 0;
529 Int_t version=GetYODAver();
530 //Int_t version= 60312;
531 //printf("version = %f \n",version);
532 softinfo = new TTree("SoftInfo","YODA software info");
533 softinfo->Branch("SoftInfo",&version,"version/I");
534 softinfo->Fill();
535
536 for (TTreeListMap::iterator i = WritingRootTrees.begin();
537 i != WritingRootTrees.end(); i++) {
538 for (TTreeList::iterator j = i->second.begin();
539 j != i->second.end(); j++) {
540 (*j)->GetCurrentFile()->Write(0,TObject::kOverwrite);
541 }
542 }
543
544 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.
565 * @param type the package type of the trees to fill.
566 */
567 void PamelaRun::FillTrees(const PacketType* type) {
568 try{
569 for (TTreeList::iterator j = WritingRootTrees[type].begin();
570 j != WritingRootTrees[type].end(); j++) {
571 (*j)->Fill();
572 }
573 } catch(Exception exc){
574 // // logger->fatal("ORRORE!!!");
575 }
576 }
577
578
579 /**
580 * Write the header packet of a specified packet type. This is mainly used
581 * for the raw reader to create the base for the event structure.
582 * @param algo Algorithm that produces this SubPacket.
583 * @param subpacket A pointer to the pointer of the packet.
584 * @param type The packet type.
585 */
586 void PamelaRun::WriteHeader(Algorithm* algo, EventHeader** subpacket,
587 const PacketType* type) {
588
589 EventHeader header(type);
590 std::string EventType = (&header)->GetPacketType()->GetName();
591 // std::cout<<EventType<<std::endl;
592
593 std::string FileName = "";
594 TFile* File = 0;
595 Long64_t maxsize = 5000000000LL;
596 TTree::SetMaxTreeSize(maxsize);
597 TTree *tree = 0;
598 if ( Multiple ){
599 FileName = GetFileName(&header, GetDefaultBranchName(&header));
600 CreateDirectoryStructure(FileName.c_str());
601 File = new TFile(FileName.c_str(), "create");
602 File->SetCompressionLevel(compression);
603 // tree = new TTree("Pscu", algo->GetAlgorithmName().c_str());
604 tree = new TTree("Pscu", algo->GetAlgorithmName());
605 WritingRootTrees[(&header)->GetPacketType()].push_back(tree);
606 tree->GetCurrentFile()->cd();
607 tree->Branch(GetDefaultBranchName(&header).c_str(),
608 (*subpacket)->Class()->GetName(), subpacket);
609 TTreeMap.insert(RootTreeMap::value_type(type, tree));
610
611 } else {
612 if (!Multiple && (SingleFile == NULL)){
613 //std::string pathDir((char*)getenv("YODA_DATA"));
614 SingleFile = new TFile((GetPath() + "/" + Run + ".root").c_str(), "update");
615 SingleFile->SetCompressionLevel(compression);
616 }
617
618 // 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);
621 tree->GetCurrentFile()->cd();
622 tree->Branch(GetDefaultBranchName(&header).c_str(),
623 (*subpacket)->Class()->GetName(), subpacket);
624
625 TTreeMap.insert(RootTreeMap::value_type(type, tree));
626 }
627
628 //marco:
629 if(File){delete File; File = 0;}
630 // if(tree){delete tree; tree = 0;}
631
632 }

  ViewVC Help
Powered by ViewVC 1.1.23