CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AlignmentPrescaler Class Reference

#include <AlignmentPrescaler.h>

Inheritance diagram for AlignmentPrescaler:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AlignmentPrescaler (const edm::ParameterSet &iConfig)
 
void beginJob ()
 
void endJob ()
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 ~AlignmentPrescaler ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

int layerFromId (const DetId &id, const TrackerTopology *tTopo) const
 

Private Attributes

unsigned int detid_
 
TFile * fpresc_
 
float hitPrescFactor_
 
TRandom3 * myrand_
 
float overlapPrescFactor_
 
std::string prescfilename_
 
std::string presctreename_
 
edm::InputTag src_
 
edm::InputTag srcQualityMap_
 
int totnhitspxl_
 
TTree * tpresc_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 23 of file AlignmentPrescaler.h.

Constructor & Destructor Documentation

AlignmentPrescaler::AlignmentPrescaler ( const edm::ParameterSet iConfig)

Definition at line 28 of file AlignmentPrescaler.cc.

28  :
29  src_(iConfig.getParameter<edm::InputTag>("src")),
30  srcQualityMap_(iConfig.getParameter<edm::InputTag>("assomap")),
31  prescfilename_(iConfig.getParameter<std::string>("PrescFileName")),
32  presctreename_(iConfig.getParameter<std::string>("PrescTreeName"))
33 {
34  // issue the produce<>
35  produces<AliClusterValueMap>();
36  produces<AliTrackTakenClusterValueMap>();
37 
38 }
T getParameter(std::string const &) const
edm::InputTag srcQualityMap_
std::string prescfilename_
std::string presctreename_
AlignmentPrescaler::~AlignmentPrescaler ( )

Definition at line 40 of file AlignmentPrescaler.cc.

40  {
41  //
42 }

Member Function Documentation

void AlignmentPrescaler::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 44 of file AlignmentPrescaler.cc.

References gather_cfg::cout, detid_, fpresc_, hitPrescFactor_, myrand_, overlapPrescFactor_, prescfilename_, presctreename_, and tpresc_.

44  {
45  //
46  std::cout<<"in AlignmentPrescaler::beginJob"<<std::flush;
47  fpresc_=new TFile(prescfilename_.c_str(),"READ");
48  tpresc_=(TTree*)fpresc_->Get(presctreename_.c_str());
49  tpresc_->BuildIndex("DetId");
50  tpresc_->SetBranchStatus("*",0);
51  tpresc_->SetBranchStatus("DetId",1);
52  tpresc_->SetBranchStatus("PrescaleFactor",1);
53  tpresc_->SetBranchStatus("PrescaleFactorOverlap",1);
54  cout<<" Branches activated "<<std::flush;
55  detid_=0;
56  hitPrescFactor_=99.0;
58 
59  tpresc_->SetBranchAddress("DetId",&detid_);
60  tpresc_->SetBranchAddress("PrescaleFactor",&hitPrescFactor_);
61  tpresc_->SetBranchAddress("PrescaleFactorOverlap",&overlapPrescFactor_);
62  cout<<" addressed "<<std::flush;
63  myrand_=new TRandom3();
64  // myrand_->SetSeed();
65  cout<<" ok "<<std::endl;
66 
67 }
std::string prescfilename_
std::string presctreename_
void AlignmentPrescaler::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 69 of file AlignmentPrescaler.cc.

References fpresc_, myrand_, and tpresc_.

Referenced by o2olib.O2ORunMgr::executeJob().

69  {
70 
71  delete tpresc_;
72  fpresc_->Close();
73  delete fpresc_;
74  delete myrand_;
75 }
int AlignmentPrescaler::layerFromId ( const DetId id,
const TrackerTopology tTopo 
) const
private

Definition at line 242 of file AlignmentPrescaler.cc.

References DEFINE_FWK_MODULE, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), StripSubdetector::TEC, TrackerTopology::tecWheel(), StripSubdetector::TIB, TrackerTopology::tibLayer(), StripSubdetector::TID, TrackerTopology::tidSide(), TrackerTopology::tidWheel(), StripSubdetector::TOB, and TrackerTopology::tobLayer().

243 {
244  if ( uint32_t(id.subdetId())==PixelSubdetector::PixelBarrel ) {
245 
246  return tTopo->pxbLayer(id);
247  }
248  else if ( uint32_t(id.subdetId())==PixelSubdetector::PixelEndcap ) {
249 
250  return tTopo->pxfDisk(id) + (3*(tTopo->pxfSide(id)-1));
251  }
252  else if ( id.subdetId()==StripSubdetector::TIB ) {
253 
254  return tTopo->tibLayer(id);
255  }
256  else if ( id.subdetId()==StripSubdetector::TOB ) {
257 
258  return tTopo->tobLayer(id);
259  }
260  else if ( id.subdetId()==StripSubdetector::TEC ) {
261 
262  return tTopo->tecWheel(id) + (9*(tTopo->pxfSide(id)-1));
263  }
264  else if ( id.subdetId()==StripSubdetector::TID ) {
265 
266  return tTopo->tidWheel(id) + (3*(tTopo->tidSide(id)-1));
267  }
268  return -1;
269 
270 }//end layerfromId
unsigned int tibLayer(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tidSide(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
unsigned int pxfSide(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
void AlignmentPrescaler::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Definition at line 77 of file AlignmentPrescaler.cc.

References SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), SiPixelRecHit::cluster(), gather_cfg::cout, objects.autophobj::float, TrackingRecHit::geographicalId(), edm::Event::getByLabel(), hitPrescFactor_, TrackingRecHit::isValid(), eostools::move(), myrand_, overlapPrescFactor_, edm::Event::put(), DetId::rawId(), findQualityFiles::rr, src_, srcQualityMap_, DetId::subdetId(), tpresc_, and gather_cfg::Tracks.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

77  {
78  // std::cout<<"\n\n#################\n### Starting the AlignmentPrescaler::produce ; Event: "<<iEvent.id().run() <<", "<<iEvent.id().event()<<std::endl;
80  iEvent.getByLabel(src_, Tracks);
81 
82  //take HitAssomap
84  iEvent.getByLabel(srcQualityMap_, hMap);
85  AliClusterValueMap InValMap=*hMap;
86 
87  //prepare the output of the ValueMap flagging tracks
88  std::vector<int> trackflags(Tracks->size(),0);
89 
90 
91  //int npxlhits=0;
92 
93  //loop on tracks
94  for(std::vector<reco::Track>::const_iterator ittrk = Tracks->begin(), edtrk = Tracks->end(); ittrk != edtrk; ++ittrk){
95  //loop on tracking rechits
96  // std::cout << "Loop on hits of track #" << (ittrk - Tracks->begin()) << std::endl;
97  int nhit=0;
98  int ntakenhits=0;
99  bool firstTakenHit=false;
100 
101  for (trackingRecHit_iterator ith = ittrk->recHitsBegin(), edh = ittrk->recHitsEnd(); ith != edh; ++ith) {
102  const TrackingRecHit *hit = *ith; // ith is an iterator on edm::Ref to rechit
103  if(! hit->isValid()){
104  nhit++;
105  continue;
106  }
107  uint32_t tmpdetid = hit->geographicalId().rawId();
108  tpresc_->GetEntryWithIndex(tmpdetid);
109 
110 
111  //-------------
112  //decide whether to take this hit or not
113  bool takeit=false;
114  int subdetId=hit->geographicalId().subdetId();
115 
116 
117  //check first if the cluster is also in the overlap asso map
118  bool isOverlapHit=false;
119  // bool first=true;
120  //ugly...
121  const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
122  const SiStripRecHit1D* stripHit1D = dynamic_cast<const SiStripRecHit1D*>(hit);
123  const SiStripRecHit2D* stripHit2D = dynamic_cast<const SiStripRecHit2D*>(hit);
124 
125  AlignmentClusterFlag tmpflag(hit->geographicalId());
126  int stripType=0;
127  if(subdetId>2){// SST case
128  const std::type_info &type = typeid(*hit);
129  if (type == typeid(SiStripRecHit1D)) stripType=1;
130  else if (type == typeid(SiStripRecHit2D)) stripType=2;
131  else stripType=3;
132 
133  if(stripType==1) {
134  // const SiStripRecHit1D* stripHit1D = dynamic_cast<const SiStripRecHit1D*>(hit);
135 
136  if(stripHit1D!=0){
137  SiStripRecHit1D::ClusterRef stripclust(stripHit1D->cluster());
138  tmpflag=InValMap[stripclust];
139  tmpflag.SetDetId(hit->geographicalId());
140  if(tmpflag.isOverlap())isOverlapHit=true;
141  // std::cout<<"~*~*~* Prescale (1D) for module "<<tmpflag.detId().rawId()<<"("<<InValMap[stripclust].detId().rawId() <<") is "<<hitPrescFactor_<<std::flush;
142  // if(tmpflag.isOverlap())cout<<" (it is Overlap)"<<endl;
143  // else cout<<endl;
144 
145  }//end if striphit1D!=0
146  }
147  else if (stripType==2) {
148  //const SiStripRecHit2D* stripHit2D = dynamic_cast<const SiStripRecHit2D*>(hit);
149  if(stripHit2D!=0){
150  SiStripRecHit2D::ClusterRef stripclust(stripHit2D->cluster());
151  tmpflag=InValMap[stripclust];
152  tmpflag.SetDetId(hit->geographicalId());
153  if(tmpflag.isOverlap())isOverlapHit=true;
154  // std::cout<<"~*~*~* Prescale (2D) for module "<<tmpflag.detId().rawId()<<"("<<InValMap[stripclust].detId().rawId() <<") is "<<hitPrescFactor_<<std::flush;
155  // if(tmpflag.isOverlap())cout<<" (it is Overlap)"<<endl;
156  // else cout<<endl;
157 
158  }//end if striphit2D!=0
159  }
160  }//end if is a strip hit
161  else{
162  // const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
163  if(pixelhit!=0){
164  //npxlhits++;
165  SiPixelClusterRefNew pixclust(pixelhit->cluster());
166  tmpflag=InValMap[pixclust];
167  tmpflag.SetDetId(hit->geographicalId());
168  if(tmpflag.isOverlap())isOverlapHit=true;
169  }
170  }//end else is a pixel hit
171  // tmpflag.SetDetId(hit->geographicalId());
172 
173  if( isOverlapHit ){
174  //cout<<" DetId="<<tmpdetid<<" is Overlap! "<<flush;
175  takeit=(float(myrand_->Rndm())<=overlapPrescFactor_);
176  }
177  if( !takeit ){
178  float rr=float(myrand_->Rndm());
179  takeit=(rr<=hitPrescFactor_);
180  }
181  if(takeit){//HIT TAKEN !
182  //cout<<" DetId="<<tmpdetid<<" taken!"<<flush;
183  tmpflag.SetTakenFlag();
184 
185  if(subdetId>2){
186  if(stripType==1){
187  SiStripRecHit1D::ClusterRef stripclust(stripHit1D->cluster());
188  InValMap[stripclust]=tmpflag;//.SetTakenFlag();
189  }
190  else if(stripType==2){
191  SiStripRecHit1D::ClusterRef stripclust(stripHit2D->cluster());
192  InValMap[stripclust]=tmpflag;//.SetTakenFlag();
193  }
194  else std::cout<<"Unknown type of strip hit"<<std::endl;
195  }
196  else{
197  SiPixelClusterRefNew pixclust(pixelhit->cluster());
198  InValMap[pixclust]=tmpflag;//.SetTakenFlag();
199  }
200 
201  if(!firstTakenHit){
202  firstTakenHit=true;
203  //std::cout<<"Index of the track iterator is "<< ittrk-Tracks->begin() <<endl;
204 
205  }
206  ntakenhits++;
207  }//end if take this hit
208  //cout<<endl;
209 
210  nhit++;
211  //cout<<endl;
212  }//end loop on RecHits
213  trackflags[ittrk-Tracks->begin()]=ntakenhits;
214 
215  }//end loop on tracks
216 
217 
218 
219  // totnhitspxl_+=ntakenhits;
220  //cout<<"AlignmentPrescaler::produce says that in this event "<<ntakenhits<<" pixel clusters were taken (out of "<<npxlhits<<" total pixel hits."<<endl;
221 
222 
223 
224  //save the asso map, tracks...
225  // prepare output
226  auto OutVM = std::make_unique<AliClusterValueMap>();
227  *OutVM=InValMap;
228 
229  iEvent.put(std::move(OutVM));
230 
231 
232  auto trkVM = std::make_unique<AliTrackTakenClusterValueMap>();
233  AliTrackTakenClusterValueMap::Filler trkmapfiller(*trkVM);
234  trkmapfiller.insert(Tracks,trackflags.begin(),trackflags.end() );
235  trkmapfiller.fill();
236  iEvent.put(std::move(trkVM));
237 
238 
239 }//end produce
ClusterRef cluster() const
type
Definition: HCALResponse.h:21
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::InputTag srcQualityMap_
ClusterRef cluster() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
bool isValid() const
DetId geographicalId() const
def move(src, dest)
Definition: eostools.py:510
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Our base class.
Definition: SiPixelRecHit.h:23

Member Data Documentation

unsigned int AlignmentPrescaler::detid_
private

Definition at line 46 of file AlignmentPrescaler.h.

Referenced by beginJob().

TFile* AlignmentPrescaler::fpresc_
private

Definition at line 39 of file AlignmentPrescaler.h.

Referenced by beginJob(), and endJob().

float AlignmentPrescaler::hitPrescFactor_
private

Definition at line 47 of file AlignmentPrescaler.h.

Referenced by beginJob(), and produce().

TRandom3* AlignmentPrescaler::myrand_
private

Definition at line 41 of file AlignmentPrescaler.h.

Referenced by beginJob(), endJob(), and produce().

float AlignmentPrescaler::overlapPrescFactor_
private

Definition at line 47 of file AlignmentPrescaler.h.

Referenced by beginJob(), and produce().

std::string AlignmentPrescaler::prescfilename_
private

Definition at line 36 of file AlignmentPrescaler.h.

Referenced by beginJob().

std::string AlignmentPrescaler::presctreename_
private

Definition at line 37 of file AlignmentPrescaler.h.

Referenced by beginJob().

edm::InputTag AlignmentPrescaler::src_
private

Definition at line 33 of file AlignmentPrescaler.h.

Referenced by produce().

edm::InputTag AlignmentPrescaler::srcQualityMap_
private

Definition at line 34 of file AlignmentPrescaler.h.

Referenced by produce().

int AlignmentPrescaler::totnhitspxl_
private

Definition at line 48 of file AlignmentPrescaler.h.

TTree* AlignmentPrescaler::tpresc_
private

Definition at line 40 of file AlignmentPrescaler.h.

Referenced by beginJob(), endJob(), and produce().