Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:39

0001 #include "DQM/SiStripCommon/interface/TkHistoMap.h"
0002 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0003 
0004 //#define debug_TkHistoMap
0005 
0006 TkHistoMap::TkHistoMap(const TkDetMap* tkDetMap) : HistoNumber(35) {
0007   LogTrace("TkHistoMap") << "TkHistoMap::constructor without parameters";
0008   load(tkDetMap, "", 0.0f, false, false, false);
0009 }
0010 
0011 TkHistoMap::TkHistoMap(
0012     const TkDetMap* tkDetMap, const std::string& path, const std::string& MapName, float baseline, bool mechanicalView)
0013     : HistoNumber(35), MapName_(MapName) {
0014   LogTrace("TkHistoMap") << "TkHistoMap::constructor with parameters";
0015   load(tkDetMap, path, baseline, mechanicalView, false);
0016   dqmStore_->meBookerGetter([this, &path, &baseline, mechanicalView](DQMStore::IBooker& ibooker, DQMStore::IGetter&) {
0017     this->createTkHistoMap(ibooker, path, MapName_, baseline, mechanicalView);
0018   });
0019 }
0020 
0021 TkHistoMap::TkHistoMap(const TkDetMap* tkDetMap,
0022                        const std::string& path,
0023                        const std::string& MapName,
0024                        float baseline,
0025                        bool mechanicalView,
0026                        bool isTH2F)
0027     : HistoNumber(35), MapName_(MapName) {
0028   LogTrace("TkHistoMap") << "TkHistoMap::constructor with parameters";
0029   load(tkDetMap, path, baseline, mechanicalView, isTH2F);
0030   dqmStore_->meBookerGetter([this, &path, &baseline, mechanicalView](DQMStore::IBooker& ibooker, DQMStore::IGetter&) {
0031     this->createTkHistoMap(ibooker, path, MapName_, baseline, mechanicalView);
0032   });
0033 }
0034 
0035 TkHistoMap::TkHistoMap(const TkDetMap* tkDetMap,
0036                        DQMStore::IBooker& ibooker,
0037                        const std::string& path,
0038                        const std::string& MapName,
0039                        float baseline,
0040                        bool mechanicalView,
0041                        bool isTH2F)
0042     : HistoNumber(35), MapName_(MapName) {
0043   LogTrace("TkHistoMap") << "TkHistoMap::constructor with parameters";
0044   load(tkDetMap, path, baseline, mechanicalView, isTH2F);
0045   createTkHistoMap(ibooker, path, MapName_, baseline, mechanicalView);
0046 }
0047 
0048 void TkHistoMap::load(const TkDetMap* tkDetMap,
0049                       const std::string& path,
0050                       float baseline,
0051                       bool mechanicalView,
0052                       bool isTH2F,
0053                       bool createTkMap) {
0054   // cannot pass nullptr, otherwise methods making use of TrackerTopology will segfault
0055   if (tkDetMap == nullptr) {
0056     throw cms::Exception("LogicError") << " expected pointer to TkDetMap is null!\n";
0057   }
0058 
0059   cached_detid = 0;
0060   cached_layer = 0;
0061   loadServices();
0062   tkdetmap_ = tkDetMap;
0063   isTH2F_ = isTH2F;
0064 }
0065 
0066 void TkHistoMap::loadServices() {
0067   if (!edm::Service<DQMStore>().isAvailable()) {
0068     edm::LogError("TkHistoMap")
0069         << "\n------------------------------------------"
0070            "\nUnAvailable Service DQMStore: please insert in the configuration file an instance like"
0071            "\n\tprocess.load(\"DQMServices.Core.DQMStore_cfg\")"
0072            "\n------------------------------------------";
0073   }
0074   dqmStore_ = edm::Service<DQMStore>().operator->();
0075 }
0076 
0077 void TkHistoMap::save(const std::string& filename) {
0078   // dqmStore_ only for saving
0079   dqmStore_->save(filename);
0080 }
0081 
0082 void TkHistoMap::loadTkHistoMap(const std::string& path, const std::string& MapName, bool mechanicalView) {
0083   MapName_ = MapName;
0084   tkHistoMap_.resize(HistoNumber);
0085   auto loadMap = [this, &path, mechanicalView](DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0086     std::string fullName, folder;
0087     for (int layer = 1; layer < HistoNumber; ++layer) {
0088       folder = folderDefinition(ibooker, path, MapName_, layer, mechanicalView, fullName);
0089 #ifdef debug_TkHistoMap
0090       LogTrace("TkHistoMap") << "[TkHistoMap::loadTkHistoMap] folder " << folder << " histoName " << fullName
0091                              << " find " << folder.find_last_of("/") << "  length " << folder.length();
0092 #endif
0093       if (folder.find_last_of('/') != folder.length() - 1)
0094         folder += "/";
0095       tkHistoMap_[layer] = igetter.get(folder + fullName);
0096 #ifdef debug_TkHistoMap
0097       LogTrace("TkHistoMap") << "[TkHistoMap::loadTkHistoMap] folder " << folder << " histoName " << fullName
0098                              << " layer " << layer << " ptr " << tkHistoMap_[layer] << " find "
0099                              << folder.find_last_of("/") << "  length " << folder.length();
0100 #endif
0101     }
0102   };
0103   dqmStore_->meBookerGetter(loadMap);
0104 }
0105 
0106 void TkHistoMap::createTkHistoMap(DQMStore::IBooker& ibooker,
0107                                   const std::string& path,
0108                                   const std::string& MapName,
0109                                   float baseline,
0110                                   bool mechanicalView) {
0111   int nchX;
0112   int nchY;
0113   double lowX, highX;
0114   double lowY, highY;
0115   std::string fullName, folder;
0116 
0117   tkHistoMap_.resize(HistoNumber);
0118   const bool bookTH2F = isTH2F_;
0119   for (int layer = 1; layer < HistoNumber; ++layer) {
0120     folder = folderDefinition(ibooker, path, MapName, layer, mechanicalView, fullName);
0121     tkdetmap_->getComponents(layer, nchX, lowX, highX, nchY, lowY, highY);
0122     MonitorElement* me;
0123     if (bookTH2F == false) {
0124       me = ibooker.bookProfile2D(fullName.c_str(), fullName.c_str(), nchX, lowX, highX, nchY, lowY, highY, 0.0, 0.0);
0125     } else {
0126       me = ibooker.book2D(fullName.c_str(), fullName.c_str(), nchX, lowX, highX, nchY, lowY, highY);
0127     }
0128     //initialize bin content for the not assigned bins
0129     if (baseline != 0) {
0130       for (size_t ix = 1; ix <= (unsigned int)nchX; ++ix)
0131         for (size_t iy = 1; iy <= (unsigned int)nchY; ++iy)
0132           if (!tkdetmap_->getDetFromBin(layer, ix, iy))
0133             me->Fill(1. * (lowX + ix - .5), 1. * (lowY + iy - .5), baseline);
0134     }
0135 
0136     tkHistoMap_[layer] = me;
0137 #ifdef debug_TkHistoMap
0138     LogTrace("TkHistoMap") << "[TkHistoMap::createTkHistoMap] folder " << folder << " histoName " << fullName
0139                            << " layer " << layer << " ptr " << tkHistoMap_[layer];
0140 #endif
0141   }
0142 }
0143 
0144 std::string TkHistoMap::folderDefinition(DQMStore::IBooker& ibooker,
0145                                          std::string folder,
0146                                          const std::string& MapName,
0147                                          int layer,
0148                                          bool mechanicalView,
0149                                          std::string& fullName) {
0150   std::string name = MapName + std::string("_");
0151   fullName = name + TkDetMap::getLayerName(layer);
0152 
0153   if (mechanicalView) {
0154     std::stringstream ss;
0155 
0156     SiStripFolderOrganizer folderOrg;
0157     folderOrg.setSiStripFolderName(folder);
0158 
0159     SiStripDetId::SubDetector subDet;
0160     uint32_t subdetlayer = 0, side = 0;
0161     TkDetMap::getSubDetLayerSide(layer, subDet, subdetlayer, side);
0162     folderOrg.getSubDetLayerFolderName(ss, subDet, subdetlayer, side);
0163     folder = ss.str();
0164   }
0165   ibooker.setCurrentFolder(folder);
0166   return folder;
0167 }
0168 
0169 #include <iostream>
0170 void TkHistoMap::fillFromAscii(const std::string& filename) {
0171   std::ifstream file;
0172   file.open(filename.c_str());
0173 
0174   if (file.fail()) {
0175     throw cms::Exception("LogicError") << "failed to open input file" << std::endl;
0176   }
0177 
0178   float value;
0179   uint32_t detid;
0180   while (file.good()) {
0181     file >> detid >> value;
0182     fill(detid, value);
0183   }
0184   file.close();
0185 }
0186 
0187 void TkHistoMap::fill(DetId detid, float value) {
0188   int16_t layer = tkdetmap_->findLayer(detid, cached_detid, cached_layer, cached_XYbin);
0189   if (layer == TkLayerMap::INVALID) {
0190     edm::LogError("TkHistoMap") << " could not fill for detid " << detid.rawId() << ", as the layer is invalid";
0191     return;
0192   }
0193 
0194   TkLayerMap::XYbin xybin = tkdetmap_->getXY(detid, cached_detid, cached_layer, cached_XYbin);
0195 #ifdef debug_TkHistoMap
0196   LogTrace("TkHistoMap") << "[TkHistoMap::fill] Fill detid " << detid.rawId() << " Layer " << layer << " value "
0197                          << value << " ix,iy " << xybin.ix << " " << xybin.iy << " " << xybin.x << " " << xybin.y << " "
0198                          << tkHistoMap_[layer]->getTProfile2D()->GetName();
0199 #endif
0200   if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TPROFILE2D)
0201     tkHistoMap_[layer]->getTProfile2D()->Fill(xybin.x, xybin.y, value);
0202   else if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TH2F)
0203     tkHistoMap_[layer]->getTH2F()->Fill(xybin.x, xybin.y, value);
0204 #ifdef debug_TkHistoMap
0205   LogTrace("TkHistoMap") << "[TkHistoMap::fill] "
0206                          << tkHistoMap_[layer]->getTProfile2D()->GetBinContent(xybin.ix, xybin.iy);
0207   for (size_t ii = 0; ii < 4; ii++)
0208     for (size_t jj = 0; jj < 11; jj++) {
0209       if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TPROFILE2D)
0210         LogTrace("TkHistoMap") << "[TkHistoMap::fill] " << ii << " " << jj << " "
0211                                << tkHistoMap_[layer]->getTProfile2D()->GetBinContent(ii, jj);
0212       if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TH2F)
0213         LogTrace("TkHistoMap") << "[TkHistoMap::fill] " << ii << " " << jj << " "
0214                                << tkHistoMap_[layer]->getTH2F()->GetBinContent(ii, jj);
0215     }
0216 #endif
0217 }
0218 
0219 void TkHistoMap::setBinContent(DetId detid, float value) {
0220   int16_t layer = tkdetmap_->findLayer(detid, cached_detid, cached_layer, cached_XYbin);
0221   if (layer == TkLayerMap::INVALID) {
0222     edm::LogError("TkHistoMap") << " could not setBinContent for detid " << detid.rawId()
0223                                 << ", as the layer is invalid";
0224     return;
0225   }
0226   TkLayerMap::XYbin xybin = tkdetmap_->getXY(detid, cached_detid, cached_layer, cached_XYbin);
0227 
0228   if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TPROFILE2D) {
0229     tkHistoMap_[layer]->getTProfile2D()->SetBinEntries(tkHistoMap_[layer]->getTProfile2D()->GetBin(xybin.ix, xybin.iy),
0230                                                        1);
0231     tkHistoMap_[layer]->getTProfile2D()->SetBinContent(tkHistoMap_[layer]->getTProfile2D()->GetBin(xybin.ix, xybin.iy),
0232                                                        value);
0233   } else if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TH2F) {
0234     tkHistoMap_[layer]->setBinContent(xybin.ix, xybin.iy, value);
0235   }
0236 
0237 #ifdef debug_TkHistoMap
0238   LogTrace("TkHistoMap") << "[TkHistoMap::setbincontent]  setBinContent detid " << detid.rawId() << " Layer " << layer
0239                          << " value " << value << " ix,iy " << xybin.ix << " " << xybin.iy << " " << xybin.x << " "
0240                          << xybin.y << " " << tkHistoMap_[layer]->getTProfile2D()->GetName() << " bin "
0241                          << tkHistoMap_[layer]->getTProfile2D()->GetBin(xybin.ix, xybin.iy);
0242 
0243   LogTrace("TkHistoMap") << "[TkHistoMap::setbincontent] "
0244                          << tkHistoMap_[layer]->getTProfile2D()->GetBinContent(xybin.ix, xybin.iy);
0245   for (size_t ii = 0; ii < 4; ii++)
0246     for (size_t jj = 0; jj < 11; jj++) {
0247       LogTrace("TkHistoMap") << "[TkHistoMap::setbincontent] " << ii << " " << jj << " "
0248                              << tkHistoMap_[layer]->getTProfile2D()->GetBinContent(ii, jj);
0249     }
0250 #endif
0251 }
0252 
0253 void TkHistoMap::add(DetId detid, float value) {
0254 #ifdef debug_TkHistoMap
0255   LogTrace("TkHistoMap") << "[TkHistoMap::add]";
0256 #endif
0257   int16_t layer = tkdetmap_->findLayer(detid, cached_detid, cached_layer, cached_XYbin);
0258   if (layer == TkLayerMap::INVALID) {
0259     edm::LogError("TkHistoMap") << " could not add for detid " << detid.rawId() << ", as the layer is invalid";
0260     return;
0261   }
0262   TkLayerMap::XYbin xybin = tkdetmap_->getXY(detid, cached_detid, cached_layer, cached_XYbin);
0263   if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TPROFILE2D)
0264     setBinContent(detid,
0265                   tkHistoMap_[layer]->getTProfile2D()->GetBinContent(
0266                       tkHistoMap_[layer]->getTProfile2D()->GetBin(xybin.ix, xybin.iy)) +
0267                       value);
0268   else if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TH2F)
0269     setBinContent(
0270         detid,
0271         tkHistoMap_[layer]->getTH2F()->GetBinContent(tkHistoMap_[layer]->getTH2F()->GetBin(xybin.ix, xybin.iy)) +
0272             value);
0273 }
0274 
0275 float TkHistoMap::getValue(DetId detid) {
0276   int16_t layer = tkdetmap_->findLayer(detid, cached_detid, cached_layer, cached_XYbin);
0277   if (layer == TkLayerMap::INVALID) {
0278     edm::LogError("TkHistoMap") << " could not getValue for detid " << detid.rawId() << ", as the layer is invalid";
0279     return -99999.f;
0280   }
0281 
0282   TkLayerMap::XYbin xybin = tkdetmap_->getXY(detid, cached_detid, cached_layer, cached_XYbin);
0283 
0284   if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TH2F)
0285     return tkHistoMap_[layer]->getTH2F()->GetBinContent(tkHistoMap_[layer]->getTH2F()->GetBin(xybin.ix, xybin.iy));
0286   else
0287     return tkHistoMap_[layer]->getTProfile2D()->GetBinContent(
0288         tkHistoMap_[layer]->getTProfile2D()->GetBin(xybin.ix, xybin.iy));
0289 }
0290 float TkHistoMap::getEntries(DetId detid) {
0291   int16_t layer = tkdetmap_->findLayer(detid, cached_detid, cached_layer, cached_XYbin);
0292   if (layer == TkLayerMap::INVALID) {
0293     edm::LogError("TkHistoMap") << " could not getValue for detid " << detid.rawId() << ", as the layer is invalid";
0294     return -99999.f;
0295   }
0296 
0297   if (tkHistoMap_[layer]->kind() == MonitorElement::Kind::TH2F) {
0298     return 1;
0299   } else {
0300     TkLayerMap::XYbin xybin = tkdetmap_->getXY(detid, cached_detid, cached_layer, cached_XYbin);
0301     return tkHistoMap_[layer]->getTProfile2D()->GetBinEntries(
0302         tkHistoMap_[layer]->getTProfile2D()->GetBin(xybin.ix, xybin.iy));
0303   }
0304 }
0305 
0306 void TkHistoMap::dumpInTkMap(TrackerMap* tkmap, bool dumpEntries) {
0307   for (int layer = 1; layer < HistoNumber; ++layer) {
0308     // std::vector<uint32_t> dets;
0309     // tkdetmap_->getDetsForLayer(layer,dets);
0310     std::vector<DetId> dets = tkdetmap_->getDetsForLayer(layer);
0311     for (size_t i = 0; i < dets.size(); ++i) {
0312       if (dets[i] > 0) {
0313         if (getEntries(dets[i]) > 0) {
0314           tkmap->fill(dets[i], dumpEntries ? getEntries(dets[i]) : getValue(dets[i]));
0315         }
0316       }
0317     }
0318   }
0319 }
0320 
0321 #include "TCanvas.h"
0322 #include "TFile.h"
0323 void TkHistoMap::saveAsCanvas(const std::string& filename, const std::string& options, const std::string& mode) {
0324   //  TCanvas C(MapName_,MapName_,200,10,900,700);
0325   TCanvas* CTIB =
0326       new TCanvas(std::string("Canvas_" + MapName_ + "TIB").c_str(), std::string("Canvas_" + MapName_ + "TIB").c_str());
0327   TCanvas* CTOB =
0328       new TCanvas(std::string("Canvas_" + MapName_ + "TOB").c_str(), std::string("Canvas_" + MapName_ + "TOB").c_str());
0329   TCanvas* CTIDP = new TCanvas(std::string("Canvas_" + MapName_ + "TIDP").c_str(),
0330                                std::string("Canvas_" + MapName_ + "TIDP").c_str());
0331   TCanvas* CTIDM = new TCanvas(std::string("Canvas_" + MapName_ + "TIDM").c_str(),
0332                                std::string("Canvas_" + MapName_ + "TIDM").c_str());
0333   TCanvas* CTECP = new TCanvas(std::string("Canvas_" + MapName_ + "TECP").c_str(),
0334                                std::string("Canvas_" + MapName_ + "TECP").c_str());
0335   TCanvas* CTECM = new TCanvas(std::string("Canvas_" + MapName_ + "TECM").c_str(),
0336                                std::string("Canvas_" + MapName_ + "TECM").c_str());
0337   CTIB->Divide(2, 2);
0338   CTOB->Divide(2, 3);
0339   CTIDP->Divide(1, 3);
0340   CTIDM->Divide(1, 3);
0341   CTECP->Divide(3, 3);
0342   CTECM->Divide(3, 3);
0343 
0344   int i;
0345   i = 0;
0346   CTIB->cd(++i);
0347   tkHistoMap_[TkLayerMap::TIB_L1]->getTProfile2D()->Draw(options.c_str());
0348   CTIB->cd(++i);
0349   tkHistoMap_[TkLayerMap::TIB_L2]->getTProfile2D()->Draw(options.c_str());
0350   CTIB->cd(++i);
0351   tkHistoMap_[TkLayerMap::TIB_L3]->getTProfile2D()->Draw(options.c_str());
0352   CTIB->cd(++i);
0353   tkHistoMap_[TkLayerMap::TIB_L4]->getTProfile2D()->Draw(options.c_str());
0354 
0355   i = 0;
0356   CTIDP->cd(++i);
0357   tkHistoMap_[TkLayerMap::TIDP_D1]->getTProfile2D()->Draw(options.c_str());
0358   CTIDP->cd(++i);
0359   tkHistoMap_[TkLayerMap::TIDP_D2]->getTProfile2D()->Draw(options.c_str());
0360   CTIDP->cd(++i);
0361   tkHistoMap_[TkLayerMap::TIDP_D3]->getTProfile2D()->Draw(options.c_str());
0362 
0363   i = 0;
0364   CTIDM->cd(++i);
0365   tkHistoMap_[TkLayerMap::TIDM_D1]->getTProfile2D()->Draw(options.c_str());
0366   CTIDM->cd(++i);
0367   tkHistoMap_[TkLayerMap::TIDM_D2]->getTProfile2D()->Draw(options.c_str());
0368   CTIDM->cd(++i);
0369   tkHistoMap_[TkLayerMap::TIDM_D3]->getTProfile2D()->Draw(options.c_str());
0370 
0371   i = 0;
0372   CTOB->cd(++i);
0373   tkHistoMap_[TkLayerMap::TOB_L1]->getTProfile2D()->Draw(options.c_str());
0374   CTOB->cd(++i);
0375   tkHistoMap_[TkLayerMap::TOB_L2]->getTProfile2D()->Draw(options.c_str());
0376   CTOB->cd(++i);
0377   tkHistoMap_[TkLayerMap::TOB_L3]->getTProfile2D()->Draw(options.c_str());
0378   CTOB->cd(++i);
0379   tkHistoMap_[TkLayerMap::TOB_L4]->getTProfile2D()->Draw(options.c_str());
0380   CTOB->cd(++i);
0381   tkHistoMap_[TkLayerMap::TOB_L5]->getTProfile2D()->Draw(options.c_str());
0382   CTOB->cd(++i);
0383   tkHistoMap_[TkLayerMap::TOB_L6]->getTProfile2D()->Draw(options.c_str());
0384 
0385   i = 0;
0386   CTECP->cd(++i);
0387   tkHistoMap_[TkLayerMap::TECP_W1]->getTProfile2D()->Draw(options.c_str());
0388   CTECP->cd(++i);
0389   tkHistoMap_[TkLayerMap::TECP_W2]->getTProfile2D()->Draw(options.c_str());
0390   CTECP->cd(++i);
0391   tkHistoMap_[TkLayerMap::TECP_W3]->getTProfile2D()->Draw(options.c_str());
0392   CTECP->cd(++i);
0393   tkHistoMap_[TkLayerMap::TECP_W4]->getTProfile2D()->Draw(options.c_str());
0394   CTECP->cd(++i);
0395   tkHistoMap_[TkLayerMap::TECP_W5]->getTProfile2D()->Draw(options.c_str());
0396   CTECP->cd(++i);
0397   tkHistoMap_[TkLayerMap::TECP_W6]->getTProfile2D()->Draw(options.c_str());
0398   CTECP->cd(++i);
0399   tkHistoMap_[TkLayerMap::TECP_W7]->getTProfile2D()->Draw(options.c_str());
0400   CTECP->cd(++i);
0401   tkHistoMap_[TkLayerMap::TECP_W8]->getTProfile2D()->Draw(options.c_str());
0402   CTECP->cd(++i);
0403   tkHistoMap_[TkLayerMap::TECP_W9]->getTProfile2D()->Draw(options.c_str());
0404 
0405   i = 0;
0406   CTECM->cd(++i);
0407   tkHistoMap_[TkLayerMap::TECM_W1]->getTProfile2D()->Draw(options.c_str());
0408   CTECM->cd(++i);
0409   tkHistoMap_[TkLayerMap::TECM_W2]->getTProfile2D()->Draw(options.c_str());
0410   CTECM->cd(++i);
0411   tkHistoMap_[TkLayerMap::TECM_W3]->getTProfile2D()->Draw(options.c_str());
0412   CTECM->cd(++i);
0413   tkHistoMap_[TkLayerMap::TECM_W4]->getTProfile2D()->Draw(options.c_str());
0414   CTECM->cd(++i);
0415   tkHistoMap_[TkLayerMap::TECM_W5]->getTProfile2D()->Draw(options.c_str());
0416   CTECM->cd(++i);
0417   tkHistoMap_[TkLayerMap::TECM_W6]->getTProfile2D()->Draw(options.c_str());
0418   CTECM->cd(++i);
0419   tkHistoMap_[TkLayerMap::TECM_W7]->getTProfile2D()->Draw(options.c_str());
0420   CTECM->cd(++i);
0421   tkHistoMap_[TkLayerMap::TECM_W8]->getTProfile2D()->Draw(options.c_str());
0422   CTECM->cd(++i);
0423   tkHistoMap_[TkLayerMap::TECM_W9]->getTProfile2D()->Draw(options.c_str());
0424 
0425   TFile* f = new TFile(filename.c_str(), mode.c_str());
0426   CTIB->Write();
0427   CTIDP->Write();
0428   CTIDM->Write();
0429   CTOB->Write();
0430   CTECP->Write();
0431   CTECM->Write();
0432   f->Close();
0433   delete f;
0434 }