splitter_code.h
1 #include "splitter.h"
2 #include "data.h"
3 
4 
5 template<unsigned int Nunmod, class Unmod, unsigned int Nsplit, class Split>
7  Log<Reco> odinlog(c_label(),"process");
8 
9 
10  // create new view of input data
12 
13  TinyVector<int,Nsplit> splitshape;
14  for(int i=0; i<int(Nsplit); i++) splitshape(i)=indata.extent(i);
15 
16  TinyVector<int,Nunmod> outshape;
17  for(int i=0; i<int(Nunmod); i++) outshape(i)=indata.extent(Nsplit+i);
18 
19  ODINLOG(odinlog,normalDebug) << "indata.shape()/outshape/splitshape=" << indata.shape() << "/" << outshape << "/" << splitshape << STD_endl;
20 
21  // Splitted output data with same (padded) shape as input data
22  TinyVector<int,Nsplit+Nunmod> outshape_padded=1;
23  for(unsigned int i=0; i<Nunmod; i++) outshape_padded(Nsplit+i)=outshape(i);
24 
25 
26  // create domains for retrieving input data from the correct position
27  // initialize unmodified part with outshape
28  TinyVector<int,Nsplit+Nunmod> lowin=0;
29  TinyVector<int,Nsplit+Nunmod> uppin=outshape_padded-1;
30 
31  TinyVector<int,Nsplit+Nunmod> lowout=0;
32  TinyVector<int,Nsplit+Nunmod> uppout=outshape_padded-1;
33 
34  // output domain, the same for each dataset
35  RectDomain<Nsplit+Nunmod> outdomain(lowout,uppout);
36 
37  ComplexData<Nsplit+Nunmod> outdata_padded(outshape_padded);
38  ComplexData<Nunmod> outdata(outshape);
39 
40 
41  for(int isplit=0; isplit<product(splitshape); isplit++) {
42 
43  // create Nsplit-dim index from linear index
44  TinyVector<int,Nsplit> splitindex=index2extent(splitshape, isplit);
45 
46  // set input inidices
47  for(unsigned int i=0; i<Nsplit; i++) lowin(i)=uppin(i)=splitindex(i);
48 
49  // copy data
50  RectDomain<Nsplit+Nunmod> indomain(lowin,uppin);
51  outdata_padded(outdomain)=indata(indomain);
52 
53  outdata_padded.convert_to(outdata); // bring to output shape
54 
55  // set data and index and feed data into rest of pipeline
56  RecoData rdout; // separate data object since indata is just a reference
57  rdout.copy_meta(rd); // Use all meta data from indata
58  Split::modify(RecoIndex::separate, rdout.coord());
59  Split::set_index(splitindex, rdout.coord());
60  rdout.data(Rank<Nunmod>()).reference(outdata);
61  if(!execute_next_step(rdout,controller)) return false;
62 
63  }
64 
65  return true;
66 }
chansplit, repsplit: Split data in one or more dimensions
Definition: splitter.h:35
Definition: tjlog.h:218
RecoCoord & coord()
RecoData & copy_meta(const RecoData &rd)
ComplexData< 1 > & data(Rank< 1 >) const
Definition: odinreco/data.h:91