Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LoadCalDetFilterChannels.cxx

Go to the documentation of this file.
00001 #include "CalDetDST/LoadCalDetFilterChannels.h"
00002 #include "CalDetDST/ChannelsToFilter.h"
00003 
00004 #include <iostream>
00005 
00006 #include "Validity/VldContext.h"
00007 #include "Validity/VldRange.h"
00008 #include "Plex/PlexHandle.h"
00009 #include "Plex/PlexStripEndId.h"
00010 #include "DatabaseInterface/DbiCascader.h"
00011 #include "DatabaseInterface/DbiTableProxyRegistry.h"
00012 #include "DatabaseInterface/DbiWriter.h"
00013 #include "DatabaseInterface/DbiResultPtr.h"
00014 #include "DatabaseInterface/DbiValidityRec.h"
00015 #include "Conventions/StripEnd.h"
00016 
00017 void MakeFilterChannelList(const VldTimeStamp& vts, const VldTimeStamp& vte,
00018                            const vector<RawChannelId>& v, 
00019                            bool createtemp,  
00020                            Detector::Detector_t det,
00021                            int sim)
00022 {
00023    if(createtemp){
00024 //  Ask the singleton DbiTableProxyRegistry for the DbiCascader.
00025       DbiCascader& cascader 
00026          = DbiTableProxyRegistry::Instance().GetCascader();
00027       
00028 //  Define the table.
00029       string tableDescr = "(SeqNo int, Encoded BIGINT UNSIGNED)";
00030       
00031 //  Ask the cascader to find a database that will accept it.
00032       Int_t dbNoTemp = cascader.CreateTemporaryTable("CHANNELSTOFILTER",
00033                                                      tableDescr);
00034       
00035       if ( dbNoTemp < 0 ) {
00036          std::cout << "No database to will accept temporary tables." 
00037                    << std::endl;
00038          return;
00039       }
00040    }
00041    
00042    VldRange vr(det,sim,vts,vte,"MakeFilterChannelList");
00043    VldTimeStamp now;
00044    Dbi::Task task=0;
00045    int aggno=-1; 
00046    DbiWriter<ChannelsToFilter> writer(vr,aggno,task,now); 
00047    for(unsigned int i=0; i<v.size(); i++){
00048       ChannelsToFilter chan(v[i]);
00049       writer<<chan;
00050    }
00051    if(!writer.Close()){
00052       std::cout<<"\nMakeFilterChannelList(): "
00053           <<"Output error writing data!"<<std::endl;
00054    }
00055 
00056 }
00057 
00058 
00059 void FilterChannelsT1102(bool createtemp){
00060 
00061    // construct, by hand, the list of bad strip ends
00062    // use a plexhandle to convert to rawchannelid
00063    // fill a vector with the rcids and call makefilterchannellist
00064 
00065    const Detector::Detector_t det = Detector::kCalDet;
00066 //   const int sim = (SimFlag::kData|SimFlag::kMC);
00067    const VldTimeStamp start(2002, 9, 16, 0, 0, 0);
00068    const VldTimeStamp end(2002, 10, 4, 0, 0, 0);
00069 
00070 
00071    const VldTimeStamp midrun(2002, 9, 24, 0,0,0);
00072    const VldContext vc(Detector::kCalDet,SimFlag::kData, midrun);
00073    PlexHandle ph(vc);
00074    
00075    vector<RawChannelId> v;
00076    
00077    // a complete loss 
00078    v.push_back(
00079       ph.GetRawChannelId(PlexStripEndId(det,38,10,StripEnd::kPositive)) );
00080 
00081    // the pedestal problem
00082    v.push_back(
00083       ph.GetRawChannelId(PlexStripEndId(det,20,4,StripEnd::kPositive)) );
00084 
00085    v.push_back(
00086       ph.GetRawChannelId(PlexStripEndId(det,40,4,StripEnd::kPositive)) );
00087 
00088    v.push_back(
00089       ph.GetRawChannelId(PlexStripEndId(det,21,19,StripEnd::kNegative)) );
00090 
00091    v.push_back(
00092       ph.GetRawChannelId(PlexStripEndId(det,41,19,StripEnd::kNegative)) );
00093 
00094    MakeFilterChannelList(start,end,v,createtemp);
00095    
00096 
00097 }
00098 
00099 void FilterChannelsT702(bool createtemp){
00100 
00101    // construct, by hand, the list of bad strip ends
00102    // use a plexhandle to convert to rawchannelid
00103    // fill a vector with the rcids and call makefilterchannellist
00104 
00105    const Detector::Detector_t det = Detector::kCalDet;
00106 //   const int sim = (SimFlag::kData|SimFlag::kMC);
00107    const VldTimeStamp start(2002, 10, 4, 0, 0, 1);
00108    const VldTimeStamp end(2002, 10, 17, 0, 0, 1);
00109 
00110 
00111    const VldTimeStamp midrun(2002, 10, 10, 0,0,0);
00112    const VldContext vc(Detector::kCalDet,SimFlag::kData, midrun);
00113    PlexHandle ph(vc);
00114    
00115    vector<RawChannelId> v;
00116    
00117    // a complete loss 
00118    v.push_back(
00119       ph.GetRawChannelId(PlexStripEndId(det,38,10,StripEnd::kPositive)) );
00120 
00121    // the pedestal problem
00122    v.push_back(
00123       ph.GetRawChannelId(PlexStripEndId(det,20,4,StripEnd::kPositive)) );
00124 
00125    v.push_back(
00126       ph.GetRawChannelId(PlexStripEndId(det,40,4,StripEnd::kPositive)) );
00127 
00128    v.push_back(
00129       ph.GetRawChannelId(PlexStripEndId(det,21,19,StripEnd::kNegative)) );
00130 
00131    v.push_back(
00132       ph.GetRawChannelId(PlexStripEndId(det,41,19,StripEnd::kNegative)) );
00133 
00134    MakeFilterChannelList(start,end,v,createtemp);
00135 
00136 }
00137 
00138 void DumpFilterChannels(const VldContext& vc){
00139    PlexHandle ph(vc);
00140    DbiResultPtr<ChannelsToFilter> rptr(vc);   
00141    std::cout<<"List of Channels: "<<std::endl;
00142    for(unsigned int i=0; i<rptr.GetNumRows(); i++){
00143       const ChannelsToFilter* ctof = rptr.GetRow(i);
00144       std::cout<<(*ctof)<<std::endl;
00145       std::cout<<ph.GetSEIdAltL(ctof->GetRawChannelId())<<std::endl;
00146    }
00147    
00148 }

Generated on Mon Feb 15 11:06:53 2010 for loon by  doxygen 1.3.9.1